hackety_sling 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hackety_sling.gemspec +3 -1
- data/lib/sinatra/hackety_sling/version.rb +1 -1
- data/lib/sinatra/hackety_sling.rb +14 -10
- data/test/hackety_sling_test.rb +20 -16
- data/test/post_test.rb +1 -3
- data/test/test_posts/2010-08-10-test-post-3.textile +7 -0
- data/test/test_posts/{2011-02-28-test-post-4.textile → 2010-11-13-test-post-4.textile} +1 -0
- data/test/test_posts/{2010-11-13-test-post-3.textile → 2011-02-28-test-post-5.textile} +1 -2
- metadata +29 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f305500207b2425bd681b8ca00f10b688499fae9c1653f693791c4ddb6184794
|
4
|
+
data.tar.gz: aca3fb0911b69d4bdb05800e4a22627f525d34b0831487eb0332621d920eb130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c983fab72aae9b0c0da3684f30a15047d3b20a2e1a74dd903531e16ee8cf82802cb31f8db30df11c9a2034b69fdcc97ddab58ba364d729a24d4450862c8e44c
|
7
|
+
data.tar.gz: e6386197eb2b274e9e2a005ac1584b5bd6e6d9895ef5af82fe4187d2a4e5c74fec5d05fa5102f22996381d95eb999bdf553f4d2471a72fd4009fb3c391814470
|
data/hackety_sling.gemspec
CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = 'http://rvdh.de'
|
11
11
|
s.summary = %q{A simple blog engine based on Sinatra and document_mapper}
|
12
12
|
s.description = %q{A simple blog engine based on Sinatra and document_mapper}
|
13
|
+
s.license = 'MIT'
|
13
14
|
|
14
15
|
s.files = `git ls-files`.split("\n")
|
15
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -17,7 +18,8 @@ Gem::Specification.new do |s|
|
|
17
18
|
s.require_paths = ['lib']
|
18
19
|
s.add_dependency 'document_mapper'
|
19
20
|
s.add_dependency 'sinatra'
|
20
|
-
s.add_dependency 'ratom'
|
21
|
+
s.add_dependency 'ratom-nokogiri'
|
22
|
+
s.add_development_dependency 'minitest'
|
21
23
|
s.add_development_dependency 'rack-test'
|
22
24
|
s.add_development_dependency 'RedCloth'
|
23
25
|
end
|
@@ -12,18 +12,18 @@ module Sinatra
|
|
12
12
|
|
13
13
|
app.get '/' do
|
14
14
|
limit = app.hackety_sling_posts_on_index
|
15
|
-
@posts = Post.order_by(:
|
15
|
+
@posts = Post.order_by(date: :desc).limit(limit).all
|
16
16
|
erb :index
|
17
17
|
end
|
18
18
|
|
19
19
|
app.get '/archive/?' do
|
20
|
-
@posts = Post.order_by(:
|
20
|
+
@posts = Post.order_by(date: :desc).all
|
21
21
|
erb :post_list
|
22
22
|
end
|
23
23
|
|
24
24
|
%w(tags author).each do |attribute|
|
25
25
|
app.get "/#{attribute}/:value/?" do |value|
|
26
|
-
@posts = Post.order_by(:
|
26
|
+
@posts = Post.order_by(date: :desc)
|
27
27
|
@posts = @posts.where(attribute.to_sym.include => value).all
|
28
28
|
erb :posts
|
29
29
|
end
|
@@ -46,24 +46,28 @@ module Sinatra
|
|
46
46
|
params[:captures].each_with_index do |date_part, index|
|
47
47
|
selector_hash[ymd[index]] = date_part.to_i unless date_part.nil?
|
48
48
|
end
|
49
|
-
@posts = Post.order_by(:
|
50
|
-
|
49
|
+
@posts = Post.order_by(date: :desc).where(selector_hash).all
|
50
|
+
if @posts.length == 1
|
51
|
+
redirect @posts.first.permalink, 301
|
52
|
+
else
|
53
|
+
erb :posts
|
54
|
+
end
|
51
55
|
end
|
52
56
|
|
53
57
|
app.get '/atom.xml' do
|
54
58
|
feed = Atom::Feed.new do |f|
|
55
59
|
f.title = app.hackety_sling_title ||= 'HacketySling Blog'
|
56
60
|
blog_url = request.url.sub(request.fullpath, '/')
|
57
|
-
f.links << Atom::Link.new(:
|
58
|
-
f.links << Atom::Link.new(:
|
61
|
+
f.links << Atom::Link.new(href: blog_url)
|
62
|
+
f.links << Atom::Link.new(rel: 'self', href: request.url)
|
59
63
|
f.updated = Post.last.date.xmlschema + 'T00:00:00+00:00'
|
60
64
|
author = app.hackety_sling_author ||= app.hackety_sling_title
|
61
|
-
f.authors << Atom::Person.new(:
|
65
|
+
f.authors << Atom::Person.new(name: author)
|
62
66
|
f.id = blog_url
|
63
|
-
Post.order_by(:
|
67
|
+
Post.order_by(date: :desc).limit(10).all.each do |post|
|
64
68
|
f.entries << Atom::Entry.new do |e|
|
65
69
|
e.title = post.title
|
66
|
-
e.links << Atom::Link.new(:
|
70
|
+
e.links << Atom::Link.new(href: blog_url + post.permalink)
|
67
71
|
e.id = blog_url + post.permalink
|
68
72
|
e.content = Atom::Content::Html.new post.to_html
|
69
73
|
e.updated = post.date.xmlschema + 'T00:00:00+00:00'
|
data/test/hackety_sling_test.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
$:.push File.expand_path('../../lib', __FILE__)
|
2
2
|
|
3
3
|
require 'bundler/setup'
|
4
|
+
require 'minitest/autorun'
|
4
5
|
require 'sinatra/hackety_sling'
|
5
|
-
require 'minitest/spec'
|
6
|
-
require 'minitest/mock'
|
7
6
|
require 'rack/test'
|
8
|
-
MiniTest::Unit.autorun
|
9
7
|
|
10
8
|
require File.expand_path('../test_app', __FILE__)
|
11
9
|
|
@@ -19,22 +17,23 @@ describe TestApp do
|
|
19
17
|
end
|
20
18
|
|
21
19
|
before do
|
22
|
-
@post_titles = Sinatra::HacketySling::Post.order_by(:
|
20
|
+
@post_titles = Sinatra::HacketySling::Post.order_by(title: :asc).all.map(&:title)
|
23
21
|
end
|
24
22
|
|
25
23
|
describe 'when requesting the index path' do
|
26
24
|
it 'displays the 2 most current posts by default' do
|
25
|
+
app.set :hackety_sling_posts_on_index, 2
|
27
26
|
get '/'
|
28
27
|
assert last_response.ok?
|
29
|
-
assert_equal ['Test post
|
28
|
+
assert_equal ['Test post 5', 'Test post 4'], post_titles
|
30
29
|
end
|
31
30
|
|
32
31
|
it 'the number of posts is configurable' do
|
33
32
|
app.set :hackety_sling_posts_on_index, 3
|
34
33
|
get '/'
|
35
|
-
app.set :hackety_sling_posts_on_index, 2 # set back to original value
|
36
34
|
assert last_response.ok?
|
37
|
-
assert_equal ['Test post
|
35
|
+
assert_equal ['Test post 5', 'Test post 4', 'Test post 2'], post_titles
|
36
|
+
app.set :hackety_sling_posts_on_index, 2 # set back to original value
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
@@ -42,32 +41,37 @@ describe TestApp do
|
|
42
41
|
it 'shows all posts of one year' do
|
43
42
|
get '/2010/'
|
44
43
|
assert last_response.ok?
|
45
|
-
assert_equal ['Test post
|
44
|
+
assert_equal ['Test post 4', 'Test post 2', 'Test post 3', 'Test post 1'], post_titles
|
46
45
|
end
|
47
46
|
|
48
47
|
it 'shows all posts of one month' do
|
49
|
-
get '/2010/
|
48
|
+
get '/2010/08/'
|
50
49
|
assert last_response.ok?
|
51
|
-
assert_equal ['Test post 3'], post_titles
|
50
|
+
assert_equal ['Test post 2', 'Test post 3', 'Test post 1'], post_titles
|
52
51
|
end
|
53
52
|
|
54
53
|
it 'shows all posts of one day' do
|
55
54
|
get '/2010/08/10/'
|
56
55
|
assert last_response.ok?
|
57
|
-
assert_equal ['Test post 2'], post_titles
|
56
|
+
assert_equal ['Test post 2', 'Test post 3'], post_titles
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'redirects to the post permalink if it is the only post' do
|
60
|
+
get '/2010/08/09/'
|
61
|
+
assert_redirected_to '/2010/08/09/test-post-1/', 301
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
65
|
describe 'when requesting a certain blog post' do
|
62
66
|
it 'shows the blog post' do
|
63
|
-
get '/2010/11/13/test-post-
|
67
|
+
get '/2010/11/13/test-post-4/'
|
64
68
|
assert last_response.ok?
|
65
|
-
assert_equal ['Test post
|
69
|
+
assert_equal ['Test post 4'], post_titles
|
66
70
|
end
|
67
71
|
|
68
72
|
it 'redirects to the url with date if only the slug was given' do
|
69
|
-
get '/test-post-
|
70
|
-
assert_redirected_to '/2010/08/
|
73
|
+
get '/test-post-1/'
|
74
|
+
assert_redirected_to '/2010/08/09/test-post-1/', 301
|
71
75
|
end
|
72
76
|
end
|
73
77
|
|
@@ -83,7 +87,7 @@ describe TestApp do
|
|
83
87
|
it 'shows all posts with a certain author' do
|
84
88
|
get '/author/ralph/'
|
85
89
|
assert last_response.ok?
|
86
|
-
assert_equal ['Test post
|
90
|
+
assert_equal ['Test post 4'], post_titles
|
87
91
|
end
|
88
92
|
end
|
89
93
|
|
data/test/post_test.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
title: Test post 4
|
3
3
|
tags: [travel, leica, bw]
|
4
4
|
title_photo: 4735071835
|
5
|
+
author: ralph
|
5
6
|
---
|
6
7
|
|
7
8
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque commodo, erat convallis feugiat faucibus, dolor turpis faucibus sapien, eget fringilla arcu purus sit amet leo. Nulla iaculis bibendum elit, sollicitudin scelerisque arcu pulvinar ut. Nulla faucibus, eros nec lacinia placerat, dui elit pulvinar libero, ut vulputate massa lectus et augue. Nulla a mauris nulla. Suspendisse suscipit nisl volutpat augue condimentum dignissim. Pellentesque consequat fringilla dolor vitae aliquet. Aliquam non urna in urna commodo fermentum quis et mi. Proin sapien nunc, pretium nec commodo vel, aliquet vitae nisl. Cras interdum purus non nunc malesuada imperdiet. Praesent et metus risus, aliquam sollicitudin nunc. Nam at est ante. Nunc sed erat nulla, nec elementum sapien.
|
@@ -1,8 +1,7 @@
|
|
1
1
|
---
|
2
|
-
title: Test post
|
2
|
+
title: Test post 5
|
3
3
|
tags: [travel, leica, bw]
|
4
4
|
title_photo: 4735071835
|
5
|
-
author: ralph
|
6
5
|
---
|
7
6
|
|
8
7
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque commodo, erat convallis feugiat faucibus, dolor turpis faucibus sapien, eget fringilla arcu purus sit amet leo. Nulla iaculis bibendum elit, sollicitudin scelerisque arcu pulvinar ut. Nulla faucibus, eros nec lacinia placerat, dui elit pulvinar libero, ut vulputate massa lectus et augue. Nulla a mauris nulla. Suspendisse suscipit nisl volutpat augue condimentum dignissim. Pellentesque consequat fringilla dolor vitae aliquet. Aliquam non urna in urna commodo fermentum quis et mi. Proin sapien nunc, pretium nec commodo vel, aliquet vitae nisl. Cras interdum purus non nunc malesuada imperdiet. Praesent et metus risus, aliquam sollicitudin nunc. Nam at est ante. Nunc sed erat nulla, nec elementum sapien.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hackety_sling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ralph von der Heyden
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: document_mapper
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: ratom
|
42
|
+
name: ratom-nokogiri
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rack-test
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,16 +115,18 @@ files:
|
|
101
115
|
- test/test_app.rb
|
102
116
|
- test/test_posts/2010-08-09-test-post-1.textile
|
103
117
|
- test/test_posts/2010-08-10-test-post-2.textile
|
104
|
-
- test/test_posts/2010-
|
105
|
-
- test/test_posts/
|
118
|
+
- test/test_posts/2010-08-10-test-post-3.textile
|
119
|
+
- test/test_posts/2010-11-13-test-post-4.textile
|
120
|
+
- test/test_posts/2011-02-28-test-post-5.textile
|
106
121
|
- views/index.erb
|
107
122
|
- views/post.erb
|
108
123
|
- views/post_list.erb
|
109
124
|
- views/posts.erb
|
110
125
|
homepage: http://rvdh.de
|
111
|
-
licenses:
|
126
|
+
licenses:
|
127
|
+
- MIT
|
112
128
|
metadata: {}
|
113
|
-
post_install_message:
|
129
|
+
post_install_message:
|
114
130
|
rdoc_options: []
|
115
131
|
require_paths:
|
116
132
|
- lib
|
@@ -125,8 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
141
|
- !ruby/object:Gem::Version
|
126
142
|
version: '0'
|
127
143
|
requirements: []
|
128
|
-
rubygems_version: 3.
|
129
|
-
signing_key:
|
144
|
+
rubygems_version: 3.4.6
|
145
|
+
signing_key:
|
130
146
|
specification_version: 4
|
131
147
|
summary: A simple blog engine based on Sinatra and document_mapper
|
132
148
|
test_files:
|
@@ -135,5 +151,6 @@ test_files:
|
|
135
151
|
- test/test_app.rb
|
136
152
|
- test/test_posts/2010-08-09-test-post-1.textile
|
137
153
|
- test/test_posts/2010-08-10-test-post-2.textile
|
138
|
-
- test/test_posts/2010-
|
139
|
-
- test/test_posts/
|
154
|
+
- test/test_posts/2010-08-10-test-post-3.textile
|
155
|
+
- test/test_posts/2010-11-13-test-post-4.textile
|
156
|
+
- test/test_posts/2011-02-28-test-post-5.textile
|