hackety_sling 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aec087cce60257c2b6cc60afb89f13352d3ea48f20693eb14b0b12491043b470
4
- data.tar.gz: bb2a69d945aa6e170a1071829d4d52829f4049a29e51afb4a912748801c5d6ed
3
+ metadata.gz: f305500207b2425bd681b8ca00f10b688499fae9c1653f693791c4ddb6184794
4
+ data.tar.gz: aca3fb0911b69d4bdb05800e4a22627f525d34b0831487eb0332621d920eb130
5
5
  SHA512:
6
- metadata.gz: 514777edf3e1caf49c0f725302f105680500ad73cd9f5dd9fc81e4949e888bdf7d5157f162514cd88013d933842ff0d856e3af13a43e9489b0e3285a1f7200f7
7
- data.tar.gz: 5ae35ee18b30eb7d6a496d1dbc50fa1d1d2883b2838a09516d3d8c9cb09ebe224eba47e3b02ec4b5dddd01247b523a2a765106ecf1853a84242b60dec0c10f6e
6
+ metadata.gz: 3c983fab72aae9b0c0da3684f30a15047d3b20a2e1a74dd903531e16ee8cf82802cb31f8db30df11c9a2034b69fdcc97ddab58ba364d729a24d4450862c8e44c
7
+ data.tar.gz: e6386197eb2b274e9e2a005ac1584b5bd6e6d9895ef5af82fe4187d2a4e5c74fec5d05fa5102f22996381d95eb999bdf553f4d2471a72fd4009fb3c391814470
@@ -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")
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module HacketySling
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  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(:date => :desc).limit(limit).all
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(:date => :desc).all
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(:date => :desc)
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(:date => :desc).where(selector_hash).all
50
- erb :posts
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(:href => blog_url)
58
- f.links << Atom::Link.new(:rel => 'self', :href => request.url)
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(:name => author)
65
+ f.authors << Atom::Person.new(name: author)
62
66
  f.id = blog_url
63
- Post.order_by(:date => :desc).limit(10).all.each do |post|
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(:href => blog_url + post.permalink)
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'
@@ -17,22 +17,23 @@ describe TestApp do
17
17
  end
18
18
 
19
19
  before do
20
- @post_titles = Sinatra::HacketySling::Post.order_by(:title => :asc).all.map(&:title)
20
+ @post_titles = Sinatra::HacketySling::Post.order_by(title: :asc).all.map(&:title)
21
21
  end
22
22
 
23
23
  describe 'when requesting the index path' do
24
24
  it 'displays the 2 most current posts by default' do
25
+ app.set :hackety_sling_posts_on_index, 2
25
26
  get '/'
26
27
  assert last_response.ok?
27
- assert_equal ['Test post 4', 'Test post 3'], post_titles
28
+ assert_equal ['Test post 5', 'Test post 4'], post_titles
28
29
  end
29
30
 
30
31
  it 'the number of posts is configurable' do
31
32
  app.set :hackety_sling_posts_on_index, 3
32
33
  get '/'
33
- app.set :hackety_sling_posts_on_index, 2 # set back to original value
34
34
  assert last_response.ok?
35
- assert_equal ['Test post 4', 'Test post 3', 'Test post 2'], post_titles
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
36
37
  end
37
38
  end
38
39
 
@@ -40,32 +41,37 @@ describe TestApp do
40
41
  it 'shows all posts of one year' do
41
42
  get '/2010/'
42
43
  assert last_response.ok?
43
- assert_equal ['Test post 3', 'Test post 2', 'Test post 1'], post_titles
44
+ assert_equal ['Test post 4', 'Test post 2', 'Test post 3', 'Test post 1'], post_titles
44
45
  end
45
46
 
46
47
  it 'shows all posts of one month' do
47
- get '/2010/11/'
48
+ get '/2010/08/'
48
49
  assert last_response.ok?
49
- assert_equal ['Test post 3'], post_titles
50
+ assert_equal ['Test post 2', 'Test post 3', 'Test post 1'], post_titles
50
51
  end
51
52
 
52
53
  it 'shows all posts of one day' do
53
54
  get '/2010/08/10/'
54
55
  assert last_response.ok?
55
- 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
56
62
  end
57
63
  end
58
64
 
59
65
  describe 'when requesting a certain blog post' do
60
66
  it 'shows the blog post' do
61
- get '/2010/11/13/test-post-3/'
67
+ get '/2010/11/13/test-post-4/'
62
68
  assert last_response.ok?
63
- assert_equal ['Test post 3'], post_titles
69
+ assert_equal ['Test post 4'], post_titles
64
70
  end
65
71
 
66
72
  it 'redirects to the url with date if only the slug was given' do
67
- get '/test-post-2/'
68
- assert_redirected_to '/2010/08/10/test-post-2/', 301
73
+ get '/test-post-1/'
74
+ assert_redirected_to '/2010/08/09/test-post-1/', 301
69
75
  end
70
76
  end
71
77
 
@@ -81,7 +87,7 @@ describe TestApp do
81
87
  it 'shows all posts with a certain author' do
82
88
  get '/author/ralph/'
83
89
  assert last_response.ok?
84
- assert_equal ['Test post 3'], post_titles
90
+ assert_equal ['Test post 4'], post_titles
85
91
  end
86
92
  end
87
93
 
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: Test post 3
3
+ tags: [lol]
4
+ title_photo: 4894724000
5
+ ---
6
+
7
+ photo. 4894724000
@@ -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 3
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ralph von der Heyden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-05 00:00:00.000000000 Z
11
+ date: 2023-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: document_mapper
@@ -115,14 +115,16 @@ files:
115
115
  - test/test_app.rb
116
116
  - test/test_posts/2010-08-09-test-post-1.textile
117
117
  - test/test_posts/2010-08-10-test-post-2.textile
118
- - test/test_posts/2010-11-13-test-post-3.textile
119
- - test/test_posts/2011-02-28-test-post-4.textile
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
120
121
  - views/index.erb
121
122
  - views/post.erb
122
123
  - views/post_list.erb
123
124
  - views/posts.erb
124
125
  homepage: http://rvdh.de
125
- licenses: []
126
+ licenses:
127
+ - MIT
126
128
  metadata: {}
127
129
  post_install_message:
128
130
  rdoc_options: []
@@ -139,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
141
  - !ruby/object:Gem::Version
140
142
  version: '0'
141
143
  requirements: []
142
- rubygems_version: 3.3.26
144
+ rubygems_version: 3.4.6
143
145
  signing_key:
144
146
  specification_version: 4
145
147
  summary: A simple blog engine based on Sinatra and document_mapper
@@ -149,5 +151,6 @@ test_files:
149
151
  - test/test_app.rb
150
152
  - test/test_posts/2010-08-09-test-post-1.textile
151
153
  - test/test_posts/2010-08-10-test-post-2.textile
152
- - test/test_posts/2010-11-13-test-post-3.textile
153
- - test/test_posts/2011-02-28-test-post-4.textile
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