hackety_sling 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/README.md +39 -0
- data/lib/sinatra/hackety_sling/version.rb +1 -1
- data/lib/sinatra/hackety_sling.rb +5 -5
- data/test/hackety_sling_test.rb +1 -1
- data/test/post_test.rb +2 -2
- data/test/test_app.rb +1 -0
- data/views/{index.erubis → index.erb} +2 -2
- data/views/{post.erubis → post.erb} +0 -0
- data/views/{post_list.erubis → post_list.erb} +2 -2
- data/views/{posts.erubis → posts.erb} +2 -2
- metadata +27 -19
data/.travis.yml
ADDED
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Hackety Sling
|
2
|
+
|
3
|
+
[![Build Status](https://secure.travis-ci.org/ralph/hackety-sling.png)](http://travis-ci.org/ralph/hackety-sling)
|
4
|
+
|
5
|
+
Hackety Sling is a very simple blog software based on [Sinatra](http://github.com/sinatra/sinatra) and [Document Mapper](http://github.com/ralph/document_mapper). It will add the following pages to your Sinatra application:
|
6
|
+
|
7
|
+
* An index page (`/`), showing 2 posts by default
|
8
|
+
* Posts by year/month/day, e.g. `/2010/08/10/`, `/2010/08/` or `/2010/`
|
9
|
+
* Showing a single post, e.g.: `/2010/11/13/my-post/`
|
10
|
+
* Showing posts by tag, e.g.: `/tags/ruby/`
|
11
|
+
* Showing posts by author, e.g.: `/author/ralph/`
|
12
|
+
* An archive page: `/archive/`
|
13
|
+
* An atom feed: `/atom.xml`
|
14
|
+
|
15
|
+
|
16
|
+
Getting Hackety Sling to play nice with your existing Sinatra Application is easy. Just include the module and add some configuration settings, like in the example below:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
class MySuperBlog < Sinatra::Base
|
20
|
+
register Sinatra::HacketySling
|
21
|
+
|
22
|
+
set :hackety_sling_title, 'My super blog | A blog about stuff'
|
23
|
+
set :hackety_sling_author, 'Carlos Testuser'
|
24
|
+
|
25
|
+
|
26
|
+
# Optional
|
27
|
+
set :hackety_sling_posts_on_index
|
28
|
+
|
29
|
+
get '/other-sinatra-page/' do
|
30
|
+
erubis :other_sinatra_page
|
31
|
+
end
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
## Author
|
36
|
+
|
37
|
+
Written by [Ralph von der Heyden](http://www.rvdh.de). Don't hesitate to contact me if you have any further questions.
|
38
|
+
|
39
|
+
Follow me on [Twitter](http://twitter.com/ralph)
|
@@ -13,26 +13,26 @@ module Sinatra
|
|
13
13
|
app.get '/' do
|
14
14
|
limit = app.hackety_sling_posts_on_index
|
15
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
20
|
@posts = Post.order_by(:date => :asc).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
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
|
30
30
|
end
|
31
31
|
|
32
32
|
Post.all.each do |post|
|
33
33
|
app.get post.permalink do
|
34
34
|
@post = post
|
35
|
-
|
35
|
+
erb :post
|
36
36
|
end
|
37
37
|
base_name = post.file_name_without_extension.sub(/^\d{4}-\d{2}-\d{2}-/, '')
|
38
38
|
app.get "/#{base_name}/" do
|
@@ -47,7 +47,7 @@ module Sinatra
|
|
47
47
|
selector_hash[ymd[index]] = date_part.to_i unless date_part.nil?
|
48
48
|
end
|
49
49
|
@posts = Post.order_by(:date => :desc).where(selector_hash).all
|
50
|
-
|
50
|
+
erb :posts
|
51
51
|
end
|
52
52
|
|
53
53
|
app.get '/atom.xml' do
|
data/test/hackety_sling_test.rb
CHANGED
data/test/post_test.rb
CHANGED
@@ -10,10 +10,10 @@ include Sinatra::HacketySling
|
|
10
10
|
|
11
11
|
describe Post do
|
12
12
|
it 'should return the correct date permalink' do
|
13
|
-
assert_equal '/2010/08/09/', Post.first.date_permalink
|
13
|
+
assert_equal '/2010/08/09/', Post.order_by(:title => :asc).first.date_permalink
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should return the correct permalink' do
|
17
|
-
assert_equal '/2010/08/09/test-post-1/', Post.first.permalink
|
17
|
+
assert_equal '/2010/08/09/test-post-1/', Post.order_by(:title => :asc).first.permalink
|
18
18
|
end
|
19
19
|
end
|
data/test/test_app.rb
CHANGED
File without changes
|
@@ -1,3 +1,3 @@
|
|
1
|
-
|
1
|
+
<% @posts.each do |post| %>
|
2
2
|
<a href="<%= post.permalink %>"><%=post.title %></a>
|
3
|
-
|
3
|
+
<% end %>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hackety_sling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-10-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: document_mapper
|
16
|
-
requirement: &
|
16
|
+
requirement: &70301858857940 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70301858857940
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: erubis
|
27
|
-
requirement: &
|
27
|
+
requirement: &70301858857080 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70301858857080
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sinatra
|
38
|
-
requirement: &
|
38
|
+
requirement: &70301858855940 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70301858855940
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: ratom
|
49
|
-
requirement: &
|
49
|
+
requirement: &70301858854820 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70301858854820
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rack-test
|
60
|
-
requirement: &
|
60
|
+
requirement: &70301858852940 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70301858852940
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: RedCloth
|
71
|
-
requirement: &
|
71
|
+
requirement: &70301858851920 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70301858851920
|
80
80
|
description: A simple blog engine based on Sinatra and document_mapper
|
81
81
|
email:
|
82
82
|
- ralph@rvdh.de
|
@@ -85,7 +85,9 @@ extensions: []
|
|
85
85
|
extra_rdoc_files: []
|
86
86
|
files:
|
87
87
|
- .gitignore
|
88
|
+
- .travis.yml
|
88
89
|
- Gemfile
|
90
|
+
- README.md
|
89
91
|
- Rakefile
|
90
92
|
- hackety_sling.gemspec
|
91
93
|
- lib/sinatra/hackety_sling.rb
|
@@ -98,10 +100,10 @@ files:
|
|
98
100
|
- test/test_posts/2010-08-10-test-post-2.textile
|
99
101
|
- test/test_posts/2010-11-13-test-post-3.textile
|
100
102
|
- test/test_posts/2011-02-28-test-post-4.textile
|
101
|
-
- views/index.
|
102
|
-
- views/post.
|
103
|
-
- views/post_list.
|
104
|
-
- views/posts.
|
103
|
+
- views/index.erb
|
104
|
+
- views/post.erb
|
105
|
+
- views/post_list.erb
|
106
|
+
- views/posts.erb
|
105
107
|
homepage: http://rvdh.de
|
106
108
|
licenses: []
|
107
109
|
post_install_message:
|
@@ -114,15 +116,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
116
|
- - ! '>='
|
115
117
|
- !ruby/object:Gem::Version
|
116
118
|
version: '0'
|
119
|
+
segments:
|
120
|
+
- 0
|
121
|
+
hash: -4069875926690539564
|
117
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
123
|
none: false
|
119
124
|
requirements:
|
120
125
|
- - ! '>='
|
121
126
|
- !ruby/object:Gem::Version
|
122
127
|
version: '0'
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
hash: -4069875926690539564
|
123
131
|
requirements: []
|
124
132
|
rubyforge_project:
|
125
|
-
rubygems_version: 1.8.
|
133
|
+
rubygems_version: 1.8.10
|
126
134
|
signing_key:
|
127
135
|
specification_version: 3
|
128
136
|
summary: A simple blog engine based on Sinatra and document_mapper
|