refinerycms-blog 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/blog/posts_controller.rb +14 -1
- data/app/models/blog_post.rb +15 -9
- data/app/models/categorization.rb +2 -0
- data/app/views/admin/blog/posts/_form.html.erb +8 -1
- data/app/views/blog/posts/_post.html.erb +2 -4
- data/app/views/blog/posts/archive.html.erb +1 -2
- data/app/views/blog/posts/index.html.erb +1 -0
- data/app/views/blog/posts/show.html.erb +1 -0
- data/app/views/blog/posts/tagged.html.erb +22 -0
- data/app/views/blog/shared/_post.html.erb +7 -3
- data/app/views/blog/shared/_tags.html.erb +8 -0
- data/changelog.md +6 -1
- data/config/locales/cs.yml +128 -0
- data/config/locales/en.yml +5 -0
- data/config/locales/nb.yml +7 -0
- data/config/locales/nl.yml +120 -10
- data/config/locales/pt-BR.yml +3 -0
- data/config/locales/sk.yml +128 -0
- data/config/locales/zh-CN.yml +128 -0
- data/config/routes.rb +2 -1
- data/db/migrate/3_acts_as_taggable_on_migration.rb +28 -0
- data/db/migrate/4_create_seo_meta_for_blog.rb +25 -0
- data/db/seeds/refinerycms_blog.rb +18 -14
- data/features/authors.feature +4 -4
- data/features/support/factories/blog_categories.rb +2 -1
- data/features/support/factories/blog_comments.rb +2 -4
- data/features/support/factories/blog_posts.rb +3 -0
- data/features/support/step_definitions/tags_steps.rb +11 -0
- data/features/tags.feature +26 -0
- data/lib/gemspec.rb +12 -6
- data/lib/refinery/blog/version.rb +17 -0
- data/lib/refinerycms-blog.rb +10 -9
- data/readme.md +1 -1
- data/spec/models/blog_category_spec.rb +41 -0
- data/spec/models/{blog_comments_spec.rb → blog_comment_spec.rb} +0 -0
- data/spec/models/blog_post_spec.rb +187 -0
- metadata +53 -10
- data/spec/models/blog_categories_spec.rb +0 -41
- data/spec/models/blog_posts_spec.rb +0 -176
data/lib/gemspec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require File.expand_path('../
|
3
|
-
version = ::Refinery::Blog.
|
2
|
+
require File.expand_path('../refinery/blog/version', __FILE__)
|
3
|
+
version = ::Refinery::Blog::Version.to_s
|
4
4
|
raise "Could not get version so gemspec can not be built" if version.nil?
|
5
5
|
files = Dir.glob("**/*").flatten.reject do |file|
|
6
6
|
file =~ /\.gem(spec)?$/
|
@@ -14,12 +14,18 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.date = %q{#{Time.now.strftime('%Y-%m-%d')}}
|
15
15
|
s.summary = %q{Ruby on Rails blogging engine for RefineryCMS.}
|
16
16
|
s.email = %q{info@refinerycms.com}
|
17
|
-
s.homepage = %q{http://refinerycms.com}
|
18
|
-
s.authors =
|
17
|
+
s.homepage = %q{http://refinerycms.com/blog}
|
18
|
+
s.authors = ['Resolve Digital', 'Neoteric Design']
|
19
19
|
s.require_paths = %w(lib)
|
20
20
|
|
21
|
-
|
22
|
-
s.add_dependency '
|
21
|
+
# Runtime dependencies
|
22
|
+
s.add_dependency 'refinerycms-core', '~> 0.9.9.22'
|
23
|
+
s.add_dependency 'filters_spam', '~> 0.2'
|
24
|
+
s.add_dependency 'acts-as-taggable-on'
|
25
|
+
s.add_dependency 'seo_meta', '~> 1.1.0'
|
26
|
+
|
27
|
+
# Development dependencies
|
28
|
+
s.add_development_dependency 'factory_girl'
|
23
29
|
|
24
30
|
s.files = %w(
|
25
31
|
#{files.join("\n ")}
|
data/lib/refinerycms-blog.rb
CHANGED
@@ -3,6 +3,13 @@ require 'filters_spam'
|
|
3
3
|
module Refinery
|
4
4
|
module Blog
|
5
5
|
|
6
|
+
autoload :Version, File.expand_path('../refinery/blog/version', __FILE__)
|
7
|
+
class << self
|
8
|
+
def version
|
9
|
+
::Refinery::Blog::Version.to_s
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
6
13
|
class Engine < Rails::Engine
|
7
14
|
initializer 'blog serves assets' do |app|
|
8
15
|
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
@@ -21,25 +28,19 @@ module Refinery
|
|
21
28
|
# refinery 0.9.8 had a bug that we later found through using this engine.
|
22
29
|
# the bug was that the plugin urls were not :controller => '/admin/whatever'
|
23
30
|
if Refinery.version == '0.9.8'
|
24
|
-
::Refinery::Plugin.class_eval
|
31
|
+
::Refinery::Plugin.class_eval do
|
25
32
|
alias_method :old_url, :url
|
26
33
|
|
27
34
|
def url
|
28
35
|
if (plugin_url = self.old_url).is_a?(Hash) and plugin_url[:controller] =~ %r{^admin}
|
29
|
-
plugin_url[:controller] = "
|
36
|
+
plugin_url[:controller] = "/#{plugin_url[:controller]}"
|
30
37
|
end
|
31
38
|
|
32
39
|
plugin_url
|
33
40
|
end
|
34
|
-
|
41
|
+
end
|
35
42
|
end
|
36
43
|
end
|
37
44
|
end if defined?(Rails::Engine)
|
38
|
-
|
39
|
-
class << self
|
40
|
-
def version
|
41
|
-
%q{1.3.2}
|
42
|
-
end
|
43
|
-
end
|
44
45
|
end
|
45
46
|
end
|
data/readme.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Simple blog engine for [Refinery CMS](http://refinerycms.com). It supports posts, categories and comments.
|
4
4
|
|
5
|
-
|
5
|
+
This version of `refinerycms-blog` supports Rails 3.0.x. To use Rails 2.3.x use the [refinerycms-blog "Rails 2.3.x stable branch"](http://github.com/resolve/refinerycms-blog/tree/rails2-stable).
|
6
6
|
|
7
7
|
Options:
|
8
8
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory}
|
3
|
+
|
4
|
+
describe BlogCategory do
|
5
|
+
before(:each) do
|
6
|
+
@blog_category = Factory(:blog_category)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "validations" do
|
10
|
+
it "requires title" do
|
11
|
+
Factory.build(:blog_category, :title => "").should_not be_valid
|
12
|
+
end
|
13
|
+
|
14
|
+
it "won't allow duplicate titles" do
|
15
|
+
Factory.build(:blog_category, :title => @blog_category.title).should_not be_valid
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "blog posts association" do
|
20
|
+
it "has a posts attribute" do
|
21
|
+
@blog_category.should respond_to(:posts)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns posts by published_at date in descending order" do
|
25
|
+
first_post = @blog_category.posts.create!({ :title => "Breaking News: Joe Sak is hot stuff you guys!!", :body => "True story.", :published_at => Time.now.yesterday })
|
26
|
+
latest_post = @blog_category.posts.create!({ :title => "parndt is p. okay", :body => "For a kiwi.", :published_at => Time.now })
|
27
|
+
|
28
|
+
@blog_category.posts.first.should == latest_post
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#post_count" do
|
34
|
+
it "returns post count in category" do
|
35
|
+
2.times do
|
36
|
+
@blog_category.posts << Factory(:post)
|
37
|
+
end
|
38
|
+
@blog_category.post_count.should == 2
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
File without changes
|
@@ -0,0 +1,187 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory}
|
3
|
+
|
4
|
+
describe BlogPost do
|
5
|
+
let(:blog_post ) { Factory :post }
|
6
|
+
|
7
|
+
describe "validations" do
|
8
|
+
it "requires title" do
|
9
|
+
Factory.build(:post, :title => "").should_not be_valid
|
10
|
+
end
|
11
|
+
|
12
|
+
it "won't allow duplicate titles" do
|
13
|
+
Factory.build(:post, :title => blog_post.title).should_not be_valid
|
14
|
+
end
|
15
|
+
|
16
|
+
it "requires body" do
|
17
|
+
Factory.build(:post, :body => nil).should_not be_valid
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "comments association" do
|
22
|
+
|
23
|
+
it "have a comments attribute" do
|
24
|
+
blog_post.should respond_to(:comments)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "destroys associated comments" do
|
28
|
+
Factory(:blog_comment, :blog_post_id => blog_post.id)
|
29
|
+
blog_post.destroy
|
30
|
+
BlogComment.find_by_blog_post_id(blog_post.id).should == nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "categories association" do
|
35
|
+
it "have categories attribute" do
|
36
|
+
blog_post.should respond_to(:categories)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "tags" do
|
41
|
+
it "acts as taggable" do
|
42
|
+
blog_post.should respond_to(:tag_list)
|
43
|
+
|
44
|
+
#the factory has default tags, including 'chicago'
|
45
|
+
blog_post.tag_list.should include("chicago")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "authors" do
|
50
|
+
it "are authored" do
|
51
|
+
BlogPost.instance_methods.map(&:to_sym).should include(:author)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "by_archive scope" do
|
56
|
+
before do
|
57
|
+
@blog_post1 = Factory(:post, :published_at => Date.new(2011, 3, 11))
|
58
|
+
@blog_post2 = Factory(:post, :published_at => Date.new(2011, 3, 12))
|
59
|
+
|
60
|
+
#2 months before
|
61
|
+
Factory(:post, :published_at => Date.new(2011, 1, 10))
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns all posts from specified month" do
|
65
|
+
#check for this month
|
66
|
+
date = "03/2011"
|
67
|
+
BlogPost.by_archive(Time.parse(date)).count.should == 2
|
68
|
+
BlogPost.by_archive(Time.parse(date)).should == [@blog_post2, @blog_post1]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "all_previous scope" do
|
73
|
+
before do
|
74
|
+
@blog_post1 = Factory(:post, :published_at => Time.now - 2.months)
|
75
|
+
@blog_post2 = Factory(:post, :published_at => Time.now - 1.month)
|
76
|
+
Factory :post, :published_at => Time.now
|
77
|
+
end
|
78
|
+
|
79
|
+
it "returns all posts from previous months" do
|
80
|
+
BlogPost.all_previous.count.should == 2
|
81
|
+
BlogPost.all_previous.should == [@blog_post2, @blog_post1]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "live scope" do
|
86
|
+
before do
|
87
|
+
@blog_post1 = Factory(:post, :published_at => Time.now.advance(:minutes => -2))
|
88
|
+
@blog_post2 = Factory(:post, :published_at => Time.now.advance(:minutes => -1))
|
89
|
+
Factory(:post, :draft => true)
|
90
|
+
Factory(:post, :published_at => Time.now + 1.minute)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "returns all posts which aren't in draft and pub date isn't in future" do
|
94
|
+
BlogPost.live.count.should == 2
|
95
|
+
BlogPost.live.should == [@blog_post2, @blog_post1]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "uncategorized scope" do
|
100
|
+
before do
|
101
|
+
@uncategorized_blog_post = Factory(:post)
|
102
|
+
@categorized_blog_post = Factory(:post)
|
103
|
+
|
104
|
+
@categorized_blog_post.categories << Factory(:blog_category)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "returns uncategorized posts if they exist" do
|
108
|
+
BlogPost.uncategorized.should include @uncategorized_blog_post
|
109
|
+
BlogPost.uncategorized.should_not include @categorized_blog_post
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "#live?" do
|
114
|
+
it "returns true if post is not in draft and it's published" do
|
115
|
+
Factory(:post).live?.should be_true
|
116
|
+
end
|
117
|
+
|
118
|
+
it "returns false if post is in draft" do
|
119
|
+
Factory(:post, :draft => true).live?.should be_false
|
120
|
+
end
|
121
|
+
|
122
|
+
it "returns false if post pub date is in future" do
|
123
|
+
Factory(:post, :published_at => Time.now.advance(:minutes => 1)).live?.should be_false
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "#next" do
|
128
|
+
before do
|
129
|
+
Factory(:post, :published_at => Time.now.advance(:minutes => -1))
|
130
|
+
@blog_post = Factory(:post)
|
131
|
+
end
|
132
|
+
|
133
|
+
it "returns next article when called on current article" do
|
134
|
+
BlogPost.last.next.should == @blog_post
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "#prev" do
|
139
|
+
before do
|
140
|
+
Factory(:post)
|
141
|
+
@blog_post = Factory(:post, :published_at => Time.now.advance(:minutes => -1))
|
142
|
+
end
|
143
|
+
|
144
|
+
it "returns previous article when called on current article" do
|
145
|
+
BlogPost.first.prev.should == @blog_post
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "#category_ids=" do
|
150
|
+
before do
|
151
|
+
@cat1 = Factory(:blog_category, :id => 1)
|
152
|
+
@cat2 = Factory(:blog_category, :id => 2)
|
153
|
+
@cat3 = Factory(:blog_category, :id => 3)
|
154
|
+
blog_post.category_ids = [1,2,"","",3]
|
155
|
+
end
|
156
|
+
|
157
|
+
it "rejects blank category ids" do
|
158
|
+
blog_post.categories.count.should == 3
|
159
|
+
end
|
160
|
+
|
161
|
+
it "returns array of categories based on given ids" do
|
162
|
+
blog_post.categories.should == [@cat1, @cat2, @cat3]
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe ".comments_allowed?" do
|
167
|
+
context "with RefinerySetting comments_allowed set to true" do
|
168
|
+
before do
|
169
|
+
RefinerySetting.set(:comments_allowed, { :scoping => 'blog', :value => true })
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should be true" do
|
173
|
+
BlogPost.comments_allowed?.should be_true
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
context "with RefinerySetting comments_allowed set to true" do
|
178
|
+
before do
|
179
|
+
RefinerySetting.set(:comments_allowed, { :scoping => 'blog', :value => false })
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should be false" do
|
183
|
+
BlogPost.comments_allowed?.should be_false
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: refinerycms-blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.4.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Resolve Digital
|
@@ -11,18 +11,18 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-
|
14
|
+
date: 2011-05-26 00:00:00 +12:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
|
-
name: refinerycms
|
18
|
+
name: refinerycms-core
|
19
19
|
prerelease: false
|
20
20
|
requirement: &id001 !ruby/object:Gem::Requirement
|
21
21
|
none: false
|
22
22
|
requirements:
|
23
|
-
- -
|
23
|
+
- - ~>
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: 0.9.
|
25
|
+
version: 0.9.9.22
|
26
26
|
type: :runtime
|
27
27
|
version_requirements: *id001
|
28
28
|
- !ruby/object:Gem::Dependency
|
@@ -36,6 +36,39 @@ dependencies:
|
|
36
36
|
version: "0.2"
|
37
37
|
type: :runtime
|
38
38
|
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: acts-as-taggable-on
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id003
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: seo_meta
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.1.0
|
59
|
+
type: :runtime
|
60
|
+
version_requirements: *id004
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: factory_girl
|
63
|
+
prerelease: false
|
64
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
type: :development
|
71
|
+
version_requirements: *id005
|
39
72
|
description: A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.
|
40
73
|
email: info@refinerycms.com
|
41
74
|
executables: []
|
@@ -89,11 +122,14 @@ files:
|
|
89
122
|
- app/views/blog/posts/index.html.erb
|
90
123
|
- app/views/blog/posts/index.rss.builder
|
91
124
|
- app/views/blog/posts/show.html.erb
|
125
|
+
- app/views/blog/posts/tagged.html.erb
|
92
126
|
- app/views/blog/shared/_categories.html.erb
|
93
127
|
- app/views/blog/shared/_post.html.erb
|
94
128
|
- app/views/blog/shared/_posts.html.erb
|
95
129
|
- app/views/blog/shared/_rss_feed.html.erb
|
130
|
+
- app/views/blog/shared/_tags.html.erb
|
96
131
|
- changelog.md
|
132
|
+
- config/locales/cs.yml
|
97
133
|
- config/locales/de.yml
|
98
134
|
- config/locales/en.yml
|
99
135
|
- config/locales/es.yml
|
@@ -104,9 +140,13 @@ files:
|
|
104
140
|
- config/locales/pl.yml
|
105
141
|
- config/locales/pt-BR.yml
|
106
142
|
- config/locales/ru.yml
|
143
|
+
- config/locales/sk.yml
|
144
|
+
- config/locales/zh-CN.yml
|
107
145
|
- config/routes.rb
|
108
146
|
- db/migrate/1_create_blog_structure.rb
|
109
147
|
- db/migrate/2_add_user_id_to_blog_posts.rb
|
148
|
+
- db/migrate/3_acts_as_taggable_on_migration.rb
|
149
|
+
- db/migrate/4_create_seo_meta_for_blog.rb
|
110
150
|
- db/seeds/refinerycms_blog.rb
|
111
151
|
- features/authors.feature
|
112
152
|
- features/support/factories/blog_categories.rb
|
@@ -114,8 +154,11 @@ files:
|
|
114
154
|
- features/support/factories/blog_posts.rb
|
115
155
|
- features/support/paths.rb
|
116
156
|
- features/support/step_definitions/authors_steps.rb
|
157
|
+
- features/support/step_definitions/tags_steps.rb
|
158
|
+
- features/tags.feature
|
117
159
|
- lib/gemspec.rb
|
118
160
|
- lib/generators/refinerycms_blog_generator.rb
|
161
|
+
- lib/refinery/blog/version.rb
|
119
162
|
- lib/refinerycms-blog.rb
|
120
163
|
- public/images/refinerycms-blog/icons/cog.png
|
121
164
|
- public/images/refinerycms-blog/icons/comment.png
|
@@ -136,11 +179,11 @@ files:
|
|
136
179
|
- public/stylesheets/refinery/refinerycms-blog.css
|
137
180
|
- public/stylesheets/refinerycms-blog.css
|
138
181
|
- readme.md
|
139
|
-
- spec/models/
|
140
|
-
- spec/models/
|
141
|
-
- spec/models/
|
182
|
+
- spec/models/blog_category_spec.rb
|
183
|
+
- spec/models/blog_comment_spec.rb
|
184
|
+
- spec/models/blog_post_spec.rb
|
142
185
|
has_rdoc: true
|
143
|
-
homepage: http://refinerycms.com
|
186
|
+
homepage: http://refinerycms.com/blog
|
144
187
|
licenses: []
|
145
188
|
|
146
189
|
post_install_message:
|
@@ -163,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
206
|
requirements: []
|
164
207
|
|
165
208
|
rubyforge_project:
|
166
|
-
rubygems_version: 1.6.
|
209
|
+
rubygems_version: 1.6.2
|
167
210
|
signing_key:
|
168
211
|
specification_version: 3
|
169
212
|
summary: Ruby on Rails blogging engine for RefineryCMS.
|