refinerycms-blog 2.0.5 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/.travis.yml +3 -9
  4. data/Gemfile +10 -11
  5. data/app/assets/images/refinery/blog/icons/add.png +0 -0
  6. data/app/assets/stylesheets/refinery/blog/backend.css.scss +25 -25
  7. data/app/assets/stylesheets/refinery/blog/frontend.css.scss +87 -76
  8. data/app/controllers/refinery/blog/admin/comments_controller.rb +19 -19
  9. data/app/controllers/refinery/blog/admin/posts_controller.rb +9 -4
  10. data/app/controllers/refinery/blog/categories_controller.rb +1 -1
  11. data/app/controllers/refinery/blog/posts_controller.rb +12 -11
  12. data/app/helpers/refinery/blog/controller_helper.rb +7 -7
  13. data/app/helpers/refinery/blog/posts_helper.rb +5 -0
  14. data/app/models/refinery/blog/categorization.rb +12 -0
  15. data/app/models/refinery/blog/category.rb +14 -4
  16. data/app/models/refinery/blog/comment.rb +0 -9
  17. data/app/models/refinery/blog/post.rb +55 -13
  18. data/app/views/refinery/blog/admin/_submenu.html.erb +1 -4
  19. data/app/views/refinery/blog/admin/categories/_category.html.erb +11 -3
  20. data/app/views/refinery/blog/admin/categories/_form.html.erb +10 -11
  21. data/app/views/refinery/blog/admin/categories/_sortable_list.html.erb +2 -4
  22. data/app/views/refinery/blog/admin/categories/edit.html.erb +1 -1
  23. data/app/views/refinery/blog/admin/categories/index.html.erb +9 -15
  24. data/app/views/refinery/blog/admin/categories/new.html.erb +1 -1
  25. data/app/views/refinery/blog/admin/comments/_comment.html.erb +4 -2
  26. data/app/views/refinery/blog/admin/comments/_sortable_list.html.erb +2 -4
  27. data/app/views/refinery/blog/admin/comments/index.html.erb +14 -23
  28. data/app/views/refinery/blog/admin/comments/show.html.erb +6 -4
  29. data/app/views/refinery/blog/admin/posts/_form.html.erb +18 -26
  30. data/app/views/refinery/blog/admin/posts/_post.html.erb +14 -1
  31. data/app/views/refinery/blog/admin/posts/_sortable_list.html.erb +2 -4
  32. data/app/views/refinery/blog/admin/posts/edit.html.erb +1 -1
  33. data/app/views/refinery/blog/admin/posts/index.html.erb +9 -15
  34. data/app/views/refinery/blog/admin/posts/new.html.erb +1 -1
  35. data/app/views/refinery/blog/admin/posts/uncategorized.html.erb +2 -2
  36. data/app/views/refinery/blog/admin/settings/notification_recipients.html.erb +5 -7
  37. data/app/views/refinery/blog/categories/show.html.erb +2 -2
  38. data/app/views/refinery/blog/comment_mailer/notification.html.erb +5 -0
  39. data/app/views/refinery/blog/posts/_comment.html.erb +1 -1
  40. data/app/views/refinery/blog/posts/_comments.html.erb +28 -31
  41. data/app/views/refinery/blog/posts/_post.html.erb +3 -3
  42. data/app/views/refinery/blog/posts/archive.html.erb +6 -5
  43. data/app/views/refinery/blog/posts/index.html.erb +3 -3
  44. data/app/views/refinery/blog/posts/show.html.erb +4 -6
  45. data/app/views/refinery/blog/posts/tagged.html.erb +4 -4
  46. data/app/views/refinery/blog/shared/_body_content_right.html.erb +6 -6
  47. data/app/views/refinery/blog/shared/_post.html.erb +11 -13
  48. data/app/views/refinery/blog/shared/_rss_feed.html.erb +2 -0
  49. data/config/initializers/url_validator.rb +15 -11
  50. data/config/locales/bg.yml +2 -4
  51. data/config/locales/cs.yml +6 -8
  52. data/config/locales/de.yml +27 -8
  53. data/config/locales/en.yml +9 -6
  54. data/config/locales/es.yml +2 -4
  55. data/config/locales/fr.yml +23 -7
  56. data/config/locales/it.yml +2 -4
  57. data/config/locales/ja.yml +16 -5
  58. data/config/locales/nb.yml +0 -2
  59. data/config/locales/nl.yml +21 -7
  60. data/config/locales/pl.yml +3 -5
  61. data/config/locales/pt-BR.yml +38 -7
  62. data/config/locales/ru.yml +35 -2
  63. data/config/locales/sk.yml +4 -6
  64. data/config/locales/sv.yml +2 -4
  65. data/config/locales/zh-CN.yml +2 -4
  66. data/config/routes.rb +3 -3
  67. data/db/migrate/20110803223522_create_blog_structure.rb +15 -14
  68. data/db/migrate/20110803223523_add_user_id_to_blog_posts.rb +2 -2
  69. data/db/migrate/20110803223526_add_cached_slugs.rb +2 -2
  70. data/db/migrate/20110803223527_add_custom_url_field_to_blog_posts.rb +1 -1
  71. data/db/migrate/20110803223528_add_custom_teaser_field_to_blog_posts.rb +1 -1
  72. data/db/migrate/20110803223529_add_primary_key_to_categorizations.rb +4 -4
  73. data/db/migrate/20120530102901_create_blog_translations.rb +17 -0
  74. data/db/migrate/20120531113632_delete_cached_slugs.rb +6 -0
  75. data/db/migrate/20120601151114_create_category_translations.rb +14 -0
  76. data/db/seeds.rb +2 -2
  77. data/lib/generators/refinery/blog/templates/config/initializers/refinery/blog.rb.erb +3 -0
  78. data/lib/refinery/blog.rb +1 -0
  79. data/lib/refinery/blog/configuration.rb +23 -0
  80. data/readme.md +3 -3
  81. data/refinerycms-blog.gemspec +8 -14
  82. data/spec/controllers/refinery/blog/admin/comments_controller_spec.rb +84 -0
  83. data/spec/controllers/refinery/blog/posts_controller_spec.rb +0 -2
  84. data/spec/factories/blog_posts.rb +2 -2
  85. data/spec/features/refinery/blog/admin/categories_spec.rb +119 -0
  86. data/spec/{requests → features}/refinery/blog/admin/comments_spec.rb +9 -9
  87. data/spec/{requests → features}/refinery/blog/admin/menu_spec.rb +2 -2
  88. data/spec/features/refinery/blog/admin/posts_spec.rb +338 -0
  89. data/spec/features/refinery/blog/categories_spec.rb +28 -0
  90. data/spec/{requests → features}/refinery/blog/posts_spec.rb +62 -42
  91. data/spec/helpers/refinery/blog/controller_helper_spec.rb +27 -0
  92. data/spec/helpers/refinery/blog/posts_helper_spec.rb +12 -0
  93. data/spec/models/refinery/blog/category_spec.rb +10 -2
  94. data/spec/models/refinery/blog/post_spec.rb +21 -17
  95. data/spec/spec_helper.rb +20 -46
  96. metadata +41 -38
  97. data/Guardfile +0 -20
  98. data/app/assets/images/refinerycms-blog/.gitkeep +0 -0
  99. data/app/assets/javascripts/refinerycms-blog/.gitkeep +0 -0
  100. data/app/assets/stylesheets/refinerycms-blog/.gitkeep +0 -0
  101. data/app/models/refinery/categorization.rb +0 -10
  102. data/app/views/refinery/blog/admin/comments/approve.html.erb +0 -0
  103. data/lib/refinery/blog/version.rb +0 -17
  104. data/spec/requests/refinery/blog/admin/categories_spec.rb +0 -20
  105. data/spec/requests/refinery/blog/admin/posts_spec.rb +0 -175
  106. data/spec/requests/refinery/blog/categories_spec.rb +0 -24
@@ -1,7 +1,7 @@
1
1
  class AddUserIdToBlogPosts < ActiveRecord::Migration
2
2
 
3
3
  def change
4
- add_column Refinery::Blog::Post.table_name, :user_id, :integer
4
+ add_column :refinery_blog_posts, :user_id, :integer
5
5
  end
6
6
 
7
- end
7
+ end
@@ -1,6 +1,6 @@
1
1
  class AddCachedSlugs < ActiveRecord::Migration
2
2
  def change
3
- add_column Refinery::Blog::Category.table_name, :cached_slug, :string
4
- add_column Refinery::Blog::Post.table_name, :cached_slug, :string
3
+ add_column :refinery_blog_categories, :cached_slug, :string
4
+ add_column :refinery_blog_posts, :cached_slug, :string
5
5
  end
6
6
  end
@@ -1,5 +1,5 @@
1
1
  class AddCustomUrlFieldToBlogPosts < ActiveRecord::Migration
2
2
  def change
3
- add_column Refinery::Blog::Post.table_name, :custom_url, :string
3
+ add_column :refinery_blog_posts, :custom_url, :string
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  class AddCustomTeaserFieldToBlogPosts < ActiveRecord::Migration
2
2
  def change
3
- add_column Refinery::Blog::Post.table_name, :custom_teaser, :text
3
+ add_column :refinery_blog_posts, :custom_teaser, :text
4
4
  end
5
5
  end
6
6
 
@@ -1,13 +1,13 @@
1
1
  class AddPrimaryKeyToCategorizations < ActiveRecord::Migration
2
2
  def up
3
- unless Refinery::Categorization.column_names.include?("id")
4
- add_column Refinery::Categorization.table_name, :id, :primary_key
3
+ unless Refinery::Blog::Categorization.column_names.include?("id")
4
+ add_column Refinery::Blog::Categorization.table_name, :id, :primary_key
5
5
  end
6
6
  end
7
7
 
8
8
  def down
9
- if Refinery::Categorization.column_names.include?("id")
10
- remove_column Refinery::Categorization.table_name, :id
9
+ if Refinery::Blog::Categorization.column_names.include?("id")
10
+ remove_column Refinery::Blog::Categorization.table_name, :id
11
11
  end
12
12
  end
13
13
  end
@@ -0,0 +1,17 @@
1
+ class CreateBlogTranslations < ActiveRecord::Migration
2
+ def up
3
+ Refinery::Blog::Post.create_translation_table!({
4
+ :body => :text,
5
+ :custom_teaser => :text,
6
+ :custom_url => :string,
7
+ :slug => :string,
8
+ :title => :string
9
+ }, {
10
+ :migrate_data => true
11
+ })
12
+ end
13
+
14
+ def down
15
+ Refinery::Blog::Post.drop_translation_table! :migrate_data => true
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ class DeleteCachedSlugs < ActiveRecord::Migration
2
+ def change
3
+ remove_column Refinery::Blog::Category.table_name, :cached_slug
4
+ remove_column Refinery::Blog::Post.table_name, :cached_slug
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ class CreateCategoryTranslations < ActiveRecord::Migration
2
+ def up
3
+ Refinery::Blog::Category.create_translation_table!({
4
+ :title => :string,
5
+ :slug => :string
6
+ }, {
7
+ :migrate_data => true
8
+ })
9
+ end
10
+
11
+ def down
12
+ Refinery::Blog::Category.drop_translation_table! :migrate_data => true
13
+ end
14
+ end
@@ -13,7 +13,7 @@ if defined?(Refinery::Page) and !Refinery::Page.exists?(:link_url => '/blog')
13
13
  :menu_match => "^/blogs?(\/|\/.+?|)$"
14
14
  )
15
15
 
16
- Refinery::Pages.default_parts.each do |default_page_part|
17
- page.parts.create(:title => default_page_part, :body => nil)
16
+ Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
17
+ page.parts.create(:title => default_page_part, :body => nil, :position => index)
18
18
  end
19
19
  end
@@ -10,4 +10,7 @@ Refinery::Blog.configure do |config|
10
10
  # config.share_this_key = <%= Refinery::Blog.share_this_key.inspect %>
11
11
 
12
12
  # config.page_url = <%= Refinery::Blog.page_url.inspect %>
13
+
14
+ # If you're grafting onto an existing app, change this to your User class
15
+ # Refinery::Blog.user_class = <%= Refinery::Blog.user_class.to_s.inspect %>
13
16
  end
@@ -2,6 +2,7 @@ require 'refinerycms-core'
2
2
  require 'refinerycms-settings'
3
3
  require 'filters_spam'
4
4
  require 'rails_autolink'
5
+ require 'friendly_id'
5
6
 
6
7
  module Refinery
7
8
  autoload :BlogGenerator, 'generators/refinery/blog/blog_generator'
@@ -11,5 +11,28 @@ module Refinery
11
11
  self.post_teaser_length = 250
12
12
  self.share_this_key = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
13
13
  self.page_url = "/blog"
14
+
15
+ # Refinery::User isn't available when this line gets hit, so we use static methods instead
16
+ @@user_class_name = nil
17
+ class << self
18
+ def user_class=(class_name)
19
+ if class_name.is_a?(Class)
20
+ raise TypeError, "You can't set user_class to be a class, e.g., User. Instead, please use a string like 'User'"
21
+ elsif class_name.is_a?(String)
22
+ @@user_class_name = class_name
23
+ else
24
+ raise TypeError, "Invalid type for user_class. Please use a string like 'User'"
25
+ end
26
+ end
27
+
28
+ def user_class
29
+ class_name = @@user_class_name || 'Refinery::User'
30
+ begin
31
+ Object.const_get(class_name)
32
+ rescue NameError
33
+ class_name.constantize
34
+ end
35
+ end
36
+ end
14
37
  end
15
38
  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
- This version of `refinerycms-blog` supports Rails 3.2.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).
5
+ This version of `refinerycms-blog` supports Rails 3.2.x. To use Rails 2.3.x use the [refinerycms-blog "Rails 2.3.x stable branch"](http://github.com/refinery/refinerycms-blog/tree/rails2-stable).
6
6
 
7
7
  Options:
8
8
 
@@ -11,14 +11,14 @@ Options:
11
11
 
12
12
  ## Requirements
13
13
 
14
- Refinery CMS version 2.0.0 or above.
14
+ Refinery CMS version 2.1.0 or above.
15
15
 
16
16
  ## Install
17
17
 
18
18
  Open up your ``Gemfile`` and add at the bottom this line:
19
19
 
20
20
  ```ruby
21
- gem 'refinerycms-blog', '~> 2.0.0'
21
+ gem 'refinerycms-blog', '~> 2.1.0'
22
22
  ```
23
23
 
24
24
  Now, run ``bundle install``
@@ -1,31 +1,25 @@
1
1
  # Encoding: UTF-8
2
- $:.push File.expand_path('../lib', __FILE__)
3
- require 'refinery/blog/version'
4
-
5
- version = Refinery::Blog::Version.to_s
6
2
 
7
3
  Gem::Specification.new do |s|
8
4
  s.name = %q{refinerycms-blog}
9
- s.version = version
5
+ s.version = %q{2.1.0}
10
6
  s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with Refinery CMS.}
11
7
  s.summary = %q{Ruby on Rails blogging engine for Refinery CMS.}
12
8
  s.email = %q{info@refinerycms.com}
13
9
  s.homepage = %q{http://refinerycms.com/blog}
14
- s.authors = ['Resolve Digital', 'Neoteric Design']
10
+ s.authors = ['Philip Arndt', 'Uģis Ozols', 'Joe Sak']
15
11
  s.require_paths = %w(lib)
16
- s.licenses = %q{MIT}
12
+ s.license = %q{MIT}
17
13
 
18
14
  s.files = `git ls-files`.split("\n")
19
15
  s.test_files = `git ls-files -- spec/*`.split("\n")
20
16
 
21
17
  # Runtime dependencies
22
- s.add_dependency 'refinerycms-core', '~> 2.0.3'
23
- s.add_dependency 'refinerycms-settings', '~> 2.0.1'
18
+ s.add_dependency 'refinerycms-core', '~> 2.1.0'
19
+ s.add_dependency 'refinerycms-settings', '~> 2.1.0'
24
20
  s.add_dependency 'filters_spam', '~> 0.2'
25
21
  s.add_dependency 'acts-as-taggable-on'
26
- s.add_dependency 'seo_meta', '~> 1.3.0'
27
- s.add_dependency 'rails_autolink'
28
-
29
- # Development dependencies
30
- s.add_development_dependency 'refinerycms-testing', '~> 2.0.0'
22
+ s.add_dependency 'seo_meta', '~> 1.4.0'
23
+ s.add_dependency 'rails_autolink', '~> 1.0.7'
24
+ s.add_dependency 'friendly_id', '~> 4.0.4'
31
25
  end
@@ -0,0 +1,84 @@
1
+ require "spec_helper"
2
+
3
+ module Refinery
4
+ module Blog
5
+ module Admin
6
+ describe CommentsController do
7
+ refinery_login_with :refinery_user
8
+
9
+ describe "#index" do
10
+ let!(:comment) { FactoryGirl.create(:blog_comment) }
11
+
12
+ it "succeeds" do
13
+ get :index
14
+ response.should be_success
15
+ response.should render_template(:index)
16
+ end
17
+
18
+ it "assigns unmoderated comments" do
19
+ get :index
20
+ assigns(:comments).first.should eq(comment)
21
+ end
22
+ end
23
+
24
+ describe "#approved" do
25
+ let!(:comment) { FactoryGirl.create(:approved_comment) }
26
+
27
+ it "succeeds" do
28
+ get :approved
29
+ response.should be_success
30
+ response.should render_template(:index)
31
+ end
32
+
33
+ it "assigns approved comments" do
34
+ get :approved
35
+ assigns(:comments).first.should eq(comment)
36
+ end
37
+ end
38
+
39
+ describe "#approve" do
40
+ let!(:comment) { FactoryGirl.create(:blog_comment) }
41
+
42
+ it "redirects on success" do
43
+ post :approve, :id => comment.id
44
+ response.should be_redirect
45
+ end
46
+
47
+ it "approves the comment" do
48
+ post :approve, :id => comment.id
49
+ Refinery::Blog::Comment.approved.count.should eq(1)
50
+ end
51
+ end
52
+
53
+ describe "#rejected" do
54
+ let!(:comment) { FactoryGirl.create(:rejected_comment) }
55
+
56
+ it "succeeds" do
57
+ get :rejected
58
+ response.should be_success
59
+ response.should render_template(:index)
60
+ end
61
+
62
+ it "assigns rejected comments" do
63
+ get :rejected
64
+ assigns(:comments).first.should eq(comment)
65
+ end
66
+ end
67
+
68
+ describe "#reject" do
69
+ let!(:comment) { FactoryGirl.create(:blog_comment) }
70
+
71
+ it "redirects on success" do
72
+ post :reject, :id => comment.id
73
+ response.should be_redirect
74
+ end
75
+
76
+ it "rejects the comment" do
77
+ post :reject, :id => comment.id
78
+ Refinery::Blog::Comment.rejected.count.should eq(1)
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -3,8 +3,6 @@ require "spec_helper"
3
3
  module Refinery
4
4
  module Blog
5
5
  describe PostsController do
6
- login_refinery_user
7
-
8
6
  before do
9
7
  FactoryGirl.create(:blog_post, :title => "blogpost_one")
10
8
  FactoryGirl.create(:blog_post, :title => "blogpost_two")
@@ -3,9 +3,9 @@ FactoryGirl.define do
3
3
  sequence(:title) { |n| "Top #{n} Shopping Centers in Chicago" }
4
4
  body "These are the top ten shopping centers in Chicago. You're going to read a long blog post about them. Come to peace with it."
5
5
  draft false
6
- tag_list "chicago, shopping, fun times"
7
6
  published_at Time.now
8
-
7
+ author { FactoryGirl.create(:refinery_user) }
8
+
9
9
  factory :blog_post_draft do
10
10
  draft true
11
11
  end
@@ -0,0 +1,119 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe "Categories admin" do
5
+ refinery_login_with :refinery_user
6
+
7
+ let(:title) { "lol" }
8
+
9
+ it "can create categories" do
10
+ visit refinery.admin_root_path
11
+
12
+ within("nav#menu") { click_link "Blog" }
13
+ within("nav.multilist") { click_link "Create new category" }
14
+
15
+ fill_in "Title", :with => title
16
+ click_button "Save"
17
+
18
+ category = Refinery::Blog::Category.first
19
+ category.title.should eq(title)
20
+ end
21
+
22
+ context "with translations" do
23
+ before do
24
+ Refinery::I18n.stub(:frontend_locales).and_return([:en, :ru])
25
+ blog_page = Globalize.with_locale(:en) { FactoryGirl.create(:page, :link_url => "/blog", :title => "Blog") }
26
+ Globalize.with_locale(:ru) do
27
+ blog_page.title = 'блог'
28
+ blog_page.save
29
+ end
30
+ end
31
+
32
+ describe "add a category with title for default locale" do
33
+ before do
34
+ Globalize.locale = :en
35
+ visit refinery.blog_admin_posts_path
36
+ click_link "Create new category"
37
+ fill_in "Title", :with => "Testing Category"
38
+ click_button "Save"
39
+ @c = Refinery::Blog::Category.find_by_title("Testing Category")
40
+ end
41
+
42
+ it "suceeds" do
43
+ page.should have_content("'#{@c.title}' was successfully added.")
44
+ Refinery::Blog::Category.count.should eq(1)
45
+ end
46
+
47
+ it "shows locale flag for category" do
48
+ click_link "Manage"
49
+ within "#category_#{@c.id}" do
50
+ page.should have_css("img[src='/assets/refinery/icons/flags/en.png']")
51
+ end
52
+ end
53
+
54
+ it "shows up in blog page for default locale" do
55
+ visit refinery.blog_root_path
56
+ within "#categories" do
57
+ page.should have_selector('li')
58
+ end
59
+ end
60
+
61
+ it "does not show up in blog page for secondary locale" do
62
+ visit refinery.blog_root_path(:locale => :ru)
63
+ page.should_not have_selector('#categories')
64
+ end
65
+
66
+ end
67
+
68
+ describe "add a category with title for secondary locale" do
69
+
70
+ let(:ru_category_title) { 'категория' }
71
+
72
+ before do
73
+ visit refinery.blog_admin_posts_path
74
+ click_link "Create new category"
75
+ within "#switch_locale_picker" do
76
+ click_link "Ru"
77
+ end
78
+ fill_in "Title", :with => ru_category_title
79
+ click_button "Save"
80
+ @c = Refinery::Blog::Category.find_by_title(ru_category_title)
81
+ end
82
+
83
+ it "suceeds" do
84
+ page.should have_content("'#{@c.title}' was successfully added.")
85
+ Refinery::Blog::Category.count.should eq(1)
86
+ end
87
+
88
+ it "shows locale flag for category" do
89
+ click_link "Manage"
90
+ within "#category_#{@c.id}" do
91
+ page.should have_css("img[src='/assets/refinery/icons/flags/ru.png']")
92
+ end
93
+ end
94
+
95
+ it "does not show locale flag for primary locale" do
96
+ click_link "Manage"
97
+ within "#category_#{@c.id}" do
98
+ page.should_not have_css("img[src='/assets/refinery/icons/flags/en.png']")
99
+ end
100
+ end
101
+
102
+ it "does not shows up in blog page for default locale" do
103
+ visit refinery.blog_root_path
104
+ page.should_not have_selector('#categories')
105
+ end
106
+
107
+ it "shows up in blog page for secondary locale" do
108
+ visit refinery.blog_root_path(:locale => :ru)
109
+ within "#categories" do
110
+ page.should have_selector('li')
111
+ end
112
+ end
113
+
114
+
115
+ end
116
+
117
+
118
+ end
119
+ end