blogit 0.4.8 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +11 -3
- data/app/assets/javascripts/blogit/archive.js +8 -0
- data/app/assets/javascripts/blogit/index.js +1 -1
- data/app/assets/stylesheets/blogit/index.css +10 -1
- data/app/controllers/blogit/comments_controller.rb +7 -7
- data/app/controllers/blogit/posts_controller.rb +12 -10
- data/app/helpers/blogit/application_helper.rb +23 -4
- data/app/helpers/blogit/posts_helper.rb +47 -3
- data/app/models/blogit/comment.rb +2 -0
- data/app/models/blogit/post.rb +26 -8
- data/app/views/blogit/comments/_admin_links.html.erb +2 -2
- data/app/views/blogit/comments/_comment.html.erb +8 -8
- data/app/views/blogit/comments/_form.html.erb +17 -18
- data/app/views/blogit/posts/_active_record_comments.html.erb +4 -0
- data/app/views/blogit/posts/_blogger_information.html.erb +1 -1
- data/app/views/blogit/posts/_comments_count.html.erb +2 -2
- data/app/views/blogit/posts/_disqus_comments.html.erb +14 -0
- data/app/views/blogit/posts/_empty.html.erb +2 -2
- data/app/views/blogit/posts/_form.html.erb +9 -9
- data/app/views/blogit/posts/_no_comments.html.erb +0 -0
- data/app/views/blogit/posts/_post.html.erb +6 -6
- data/app/views/blogit/posts/_post_links.html.erb +1 -1
- data/app/views/blogit/posts/_share_bar.html.erb +45 -0
- data/app/views/blogit/posts/edit.html.erb +2 -2
- data/app/views/blogit/posts/index.html.erb +7 -7
- data/app/views/blogit/posts/new.html.erb +1 -1
- data/app/views/blogit/posts/show.html.erb +2 -6
- data/config/locales/en.yml +48 -0
- data/config/locales/fr.yml +61 -0
- data/lib/blogit/configuration.rb +69 -30
- data/lib/blogit/version.rb +1 -1
- data/lib/generators/templates/blogit.rb +34 -18
- data/spec/controllers/blogit/posts_controller_spec.rb +75 -75
- data/spec/dummy/app/helpers/application_helper.rb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +8 -4
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/initializers/blogit.rb +21 -12
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +155 -0
- data/spec/dummy/log/test.log +7310 -0
- data/spec/helpers/blogit/application_helper_spec.rb +63 -8
- data/spec/helpers/blogit/posts_helper_spec.rb +114 -6
- data/spec/lib/blogit/parsers/markdown_parser_spec.rb +7 -3
- data/spec/lib/configuration_spec.rb +43 -19
- data/spec/models/blogit/post_spec.rb +51 -53
- data/spec/spec_helper.rb +1 -1
- metadata +158 -36
data/lib/blogit/version.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
# These configuration options can be used to customise the behaviour of Blogit
|
2
2
|
Blogit.configure do |config|
|
3
|
-
|
4
|
-
#
|
5
|
-
# config.include_comments =
|
3
|
+
|
4
|
+
# What kind of comments do you want to add to your blog ? (:active_record, :disqus or :no)
|
5
|
+
# config.include_comments = :active_record
|
6
|
+
|
7
|
+
# When using disqus comments, what is the shortname of your forum ?
|
8
|
+
# config.disqus_shortname = ""
|
9
|
+
|
10
|
+
# Should there be a share bar on every post ?
|
11
|
+
# config.include_share_bar = false
|
12
|
+
|
13
|
+
# Twitter username used in the share bar
|
14
|
+
# config.twitter_username = ""
|
6
15
|
|
7
16
|
# The name of the controller method we'll call to return the current blogger.
|
8
17
|
# Change this if you use something other than current_user.
|
@@ -14,7 +23,7 @@ Blogit.configure do |config|
|
|
14
23
|
|
15
24
|
# Which DateTime::FORMATS format do we use to display blog and comment publish time
|
16
25
|
# config.datetime_format = :short
|
17
|
-
|
26
|
+
|
18
27
|
# Should the controllers cache the blog pages as HTML?
|
19
28
|
# config.cache_pages = false
|
20
29
|
|
@@ -24,17 +33,17 @@ Blogit.configure do |config|
|
|
24
33
|
# The name of the before filter we'll call to authenticate the current user.
|
25
34
|
# config.authentication_method = :login_required
|
26
35
|
|
27
|
-
# If set to true, the comments form will POST and DELETE to the comments
|
36
|
+
# If set to true, the comments form will POST and DELETE to the comments
|
28
37
|
# controller using AJAX calls.
|
29
38
|
# config.ajax_comments = true
|
30
39
|
|
31
40
|
# If set to true, the create, edit, update and destroy actions
|
32
|
-
# will be included. If set to false, you'll have to set these
|
41
|
+
# will be included. If set to false, you'll have to set these
|
33
42
|
# yourself elsewhere in the app.
|
34
43
|
# config.include_admin_actions = true
|
35
44
|
|
36
45
|
# If set to true, links for new posts, editing posts and deleting comments
|
37
|
-
# will be available. If set to false, you'll have to set these
|
46
|
+
# will be available. If set to false, you'll have to set these
|
38
47
|
# yourself in the templates.
|
39
48
|
# config.include_admin_links = true
|
40
49
|
|
@@ -44,25 +53,32 @@ Blogit.configure do |config|
|
|
44
53
|
# If blog content contains code, this should be highlighted using
|
45
54
|
# albino.
|
46
55
|
# config.highlight_code_syntax = true
|
47
|
-
|
56
|
+
|
48
57
|
# RSS Feed title content
|
49
58
|
# config.rss_feed_title = "A blog about ponies!"
|
50
|
-
|
59
|
+
|
51
60
|
# RSS Feed description content
|
52
61
|
# config.rss_feed_description = "Get your daily pony news here!"
|
53
|
-
|
62
|
+
|
54
63
|
# RSS Feed language
|
55
64
|
# config.rss_feed_language = "en"
|
56
|
-
|
65
|
+
|
57
66
|
# When using redcarpet as content parser, pass these options as defaults.
|
58
67
|
# @see here for more options: https://github.com/tanoku/redcarpet
|
59
68
|
config.redcarpet_options = {
|
60
|
-
hard_wrap: true,
|
61
|
-
filter_html: true,
|
62
|
-
autolink: true,
|
63
|
-
no_intraemphasis: true,
|
64
|
-
fenced_code_blocks: true,
|
69
|
+
hard_wrap: true,
|
70
|
+
filter_html: true,
|
71
|
+
autolink: true,
|
72
|
+
no_intraemphasis: true,
|
73
|
+
fenced_code_blocks: true,
|
65
74
|
gh_blockcode: true
|
66
75
|
}
|
67
|
-
|
68
|
-
|
76
|
+
|
77
|
+
# If set to true, it will be possible to call named routes of the main app
|
78
|
+
# directly, without the "main_app." prefix.
|
79
|
+
# Useful in the case where you don't want to change the main app's layout,
|
80
|
+
# but it does not expand correctly from inside blogit because some main
|
81
|
+
# app's named routes are missing.
|
82
|
+
# config.inline_main_app_named_routes = true
|
83
|
+
|
84
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe PostsController do
|
4
|
-
|
4
|
+
|
5
5
|
before do
|
6
6
|
reset_configuration
|
7
7
|
end
|
@@ -11,268 +11,268 @@ describe PostsController do
|
|
11
11
|
describe "GET 'index'" do
|
12
12
|
|
13
13
|
let(:posts) { [] }
|
14
|
-
|
14
|
+
|
15
15
|
def do_get(page=nil)
|
16
16
|
get :index, :use_route => :blogit, page: page.to_s
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "should set posts to Blogit::Post.for_index" do
|
20
20
|
Blogit::Post.expects(:for_index).returns(posts)
|
21
21
|
do_get
|
22
22
|
assigns(:posts).should == posts
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "should pass the page param to for_index" do
|
26
26
|
Blogit::Post.expects(:for_index).with("2").returns(posts)
|
27
27
|
do_get("2")
|
28
28
|
assigns(:posts).should == posts
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
describe "GET /index.xml" do
|
34
|
-
|
34
|
+
|
35
35
|
|
36
36
|
let(:posts) { [] }
|
37
|
-
|
37
|
+
|
38
38
|
def do_get(page=nil)
|
39
39
|
get :index, :use_route => :blogit, page: page.to_s, format: :xml
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
it "should load all posts in reverse date order" do
|
43
43
|
Blogit::Post.expects(:order).with('created_at DESC').returns(posts)
|
44
44
|
do_get
|
45
45
|
assigns(:posts).should == posts
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
describe "GET 'new'" do
|
51
|
-
|
51
|
+
|
52
52
|
context "when logged in" do
|
53
|
-
|
53
|
+
|
54
54
|
before do
|
55
55
|
mock_login
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def do_get
|
59
59
|
get :new, use_route: :blogit
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
it "should be successful" do
|
63
63
|
do_get
|
64
64
|
response.should be_success
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
it "should set post to a new blog post" do
|
68
68
|
do_get
|
69
69
|
assigns(:post).should be_a(Blogit::Post)
|
70
70
|
assigns(:post).should be_a_new_record
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
context "when not logged in" do
|
76
|
-
|
76
|
+
|
77
77
|
def do_get
|
78
78
|
get :new, use_route: :blogit
|
79
79
|
end
|
80
|
-
|
81
|
-
# It's not really the responsibility of the gem to manage authentication
|
80
|
+
|
81
|
+
# It's not really the responsibility of the gem to manage authentication
|
82
82
|
# so testing for specific behaviour here is not required
|
83
83
|
# at the very least though, we'd expect the status not to be 200
|
84
84
|
it "should redirect to another page" do
|
85
85
|
do_get
|
86
86
|
response.should_not be_success
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
end
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
describe "POST /create" do
|
93
|
-
|
93
|
+
|
94
94
|
context "when logged in" do
|
95
|
-
|
95
|
+
|
96
96
|
before do
|
97
97
|
mock_login
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
context "with valid params" do
|
101
|
-
|
101
|
+
|
102
102
|
let(:post_attributes) { attributes_for(:post) }
|
103
|
-
|
103
|
+
|
104
104
|
def do_post
|
105
105
|
post :create, use_route: :blogit, post: post_attributes
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
before do
|
109
109
|
@blog_posts = []
|
110
110
|
@current_blogger.expects(:blog_posts).returns(@blog_posts)
|
111
111
|
@blog_posts.expects(:new).with(post_attributes.stringify_keys).returns(blog_post)
|
112
112
|
blog_post.expects(:save).returns(true)
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
it "should redirect to the blog post page" do
|
116
116
|
do_post
|
117
117
|
response.should redirect_to(controller.posts_url)
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
end
|
121
|
-
|
121
|
+
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
end
|
125
125
|
|
126
|
-
|
126
|
+
|
127
127
|
describe "GET 'edit'" do
|
128
|
-
|
128
|
+
|
129
129
|
context "when logged in" do
|
130
|
-
|
130
|
+
|
131
131
|
before do
|
132
132
|
mock_login
|
133
133
|
@current_blogger.expects(:blog_posts).returns(@blog_posts = [])
|
134
134
|
@blog_posts.expects(:find).with("1").returns(blog_post)
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
def do_get
|
138
138
|
get :edit, :id => 1, use_route: :blogit
|
139
139
|
end
|
140
|
-
|
140
|
+
|
141
141
|
it "should find the blog post by the ID" do
|
142
142
|
do_get
|
143
143
|
assigns(:post).should eql(blog_post)
|
144
144
|
end
|
145
|
-
|
145
|
+
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
context "when not logged in" do
|
149
|
-
|
149
|
+
|
150
150
|
def do_get
|
151
151
|
get :edit, :id => 1, use_route: :blogit
|
152
152
|
end
|
153
|
-
|
154
|
-
# It's not really the responsibility of the gem to manage authentication
|
153
|
+
|
154
|
+
# It's not really the responsibility of the gem to manage authentication
|
155
155
|
# so testing for specific behaviour here is not required
|
156
156
|
# at the very least though, we'd expect the status not to be 200
|
157
157
|
it "should redirect to another pages" do
|
158
158
|
do_get
|
159
159
|
response.should_not be_success
|
160
160
|
end
|
161
|
-
|
161
|
+
|
162
162
|
end
|
163
163
|
|
164
164
|
end
|
165
|
-
|
165
|
+
|
166
166
|
describe "PUT 'update'" do
|
167
|
-
|
167
|
+
|
168
168
|
context "when logged in" do
|
169
|
-
|
169
|
+
|
170
170
|
before do
|
171
171
|
@post_attributes = { "title" => "Something new" }
|
172
172
|
mock_login
|
173
173
|
@current_blogger.expects(:blog_posts).returns(@blog_posts = [])
|
174
174
|
@blog_posts.expects(:find).with("1").returns(blog_post)
|
175
175
|
end
|
176
|
-
|
176
|
+
|
177
177
|
def do_put
|
178
178
|
put :update, id: "1", use_route: :blogit, post: @post_attributes
|
179
179
|
end
|
180
|
-
|
180
|
+
|
181
181
|
it "should update the post attributes from params" do
|
182
182
|
blog_post.expects(:update_attributes).with(@post_attributes).returns(true)
|
183
183
|
do_put
|
184
184
|
end
|
185
|
-
|
185
|
+
|
186
186
|
it "should redirect to the blog post page" do
|
187
187
|
do_put
|
188
188
|
response.should redirect_to(controller.post_url(blog_post))
|
189
189
|
end
|
190
|
-
|
190
|
+
|
191
191
|
it "should set a flash notice" do
|
192
192
|
do_put
|
193
193
|
flash[:notice].should be_present
|
194
194
|
end
|
195
195
|
end
|
196
|
-
|
196
|
+
|
197
197
|
context "when not logged in" do
|
198
|
-
|
198
|
+
|
199
199
|
before do
|
200
200
|
@post_attributes = { "title" => "Something new" }
|
201
201
|
end
|
202
|
-
|
202
|
+
|
203
203
|
def do_put
|
204
204
|
put :update, id: "1", use_route: :blogit, post: @post_attributes
|
205
205
|
end
|
206
|
-
|
207
|
-
# It's not really the responsibility of the gem to manage authentication
|
206
|
+
|
207
|
+
# It's not really the responsibility of the gem to manage authentication
|
208
208
|
# so testing for specific behaviour here is not required
|
209
209
|
# at the very least though, we'd expect the status not to be 200
|
210
210
|
it "should redirect to another page" do
|
211
211
|
do_put
|
212
212
|
response.should_not be_success
|
213
213
|
end
|
214
|
-
|
214
|
+
|
215
215
|
end
|
216
|
-
|
216
|
+
|
217
217
|
end
|
218
|
-
|
218
|
+
|
219
219
|
describe "GET 'show'" do
|
220
|
-
|
220
|
+
|
221
221
|
before do
|
222
222
|
Blogit::Post.expects(:find).with("1").returns(blog_post)
|
223
223
|
end
|
224
|
-
|
224
|
+
|
225
225
|
def do_get
|
226
226
|
get :show, :id => 1, use_route: :blogit
|
227
227
|
end
|
228
|
-
|
228
|
+
|
229
229
|
it "should find blog post by id" do
|
230
230
|
do_get
|
231
231
|
assigns(:post).should eql(blog_post)
|
232
232
|
end
|
233
233
|
|
234
234
|
end
|
235
|
-
|
235
|
+
|
236
236
|
describe "DELETE 'destroy'" do
|
237
|
-
|
237
|
+
|
238
238
|
def do_delete
|
239
239
|
delete :destroy, id: "1", use_route: :blogit
|
240
240
|
end
|
241
|
-
|
241
|
+
|
242
242
|
describe "when logged in" do
|
243
|
-
|
243
|
+
|
244
244
|
before do
|
245
245
|
mock_login
|
246
246
|
@current_blogger.expects(:blog_posts).returns(@blog_posts = [])
|
247
247
|
@blog_posts.expects(:find).with("1").returns(blog_post)
|
248
248
|
end
|
249
|
-
|
249
|
+
|
250
250
|
it "should destroy the blog post" do
|
251
251
|
blog_post.expects(:destroy)
|
252
252
|
do_delete
|
253
253
|
end
|
254
|
-
|
254
|
+
|
255
255
|
it "should redirect to the blog posts url" do
|
256
256
|
do_delete
|
257
257
|
response.should redirect_to(controller.posts_url)
|
258
258
|
end
|
259
|
-
|
259
|
+
|
260
260
|
it "should show a flash notice" do
|
261
261
|
do_delete
|
262
262
|
flash[:notice].should be_present
|
263
263
|
end
|
264
|
-
|
264
|
+
|
265
265
|
end
|
266
|
-
|
266
|
+
|
267
267
|
describe "when not logged in" do
|
268
|
-
|
268
|
+
|
269
269
|
it "should redirect to another page" do
|
270
270
|
do_delete
|
271
271
|
response.should_not be_success
|
272
272
|
end
|
273
|
-
|
273
|
+
|
274
274
|
end
|
275
|
-
|
275
|
+
|
276
276
|
end
|
277
277
|
|
278
|
-
end
|
278
|
+
end
|