aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/admin/blog/settings_controller.rb16
-rw-r--r--app/models/blog_comment.rb9
-rw-r--r--app/views/admin/blog/_submenu.html.erb4
-rw-r--r--config/locales/en.yml1
-rw-r--r--config/locales/es.yml1
-rw-r--r--config/locales/fr.yml5
-rw-r--r--config/locales/it.yml1
-rw-r--r--config/locales/pt-BR.yml1
-rw-r--r--config/locales/ru.yml1
-rw-r--r--config/routes.rb1
-rw-r--r--refinerycms-blog.gemspec2
-rw-r--r--spec/models/blog_posts_spec.rb15
12 files changed, 43 insertions, 14 deletions
diff --git a/app/controllers/admin/blog/settings_controller.rb b/app/controllers/admin/blog/settings_controller.rb
index cc9261b..a805d9c 100644
--- a/app/controllers/admin/blog/settings_controller.rb
+++ b/app/controllers/admin/blog/settings_controller.rb
@@ -10,7 +10,8 @@ class Admin::Blog::SettingsController < Admin::BaseController
unless request.xhr? or from_dialog?
redirect_back_or_default(admin_blog_posts_path)
else
- render :text => "<script type='text/javascript'>parent.window.location = '#{admin_blog_posts_path}';</script>"
+ render :text => "<script type='text/javascript'>parent.window.location = '#{admin_blog_posts_path}';</script>",
+ :layout => false
end
end
end
@@ -20,7 +21,18 @@ class Admin::Blog::SettingsController < Admin::BaseController
unless request.xhr?
redirect_back_or_default(admin_blog_posts_path)
else
- render :json => {:enabled => enabled}
+ render :json => {:enabled => enabled},
+ :layout => false
+ end
+ end
+
+ def comments
+ enabled = BlogComment.toggle!
+ unless request.xhr?
+ redirect_back_or_default(admin_blog_posts_path)
+ else
+ render :json => {:enabled => enabled},
+ :layout => false
end
end
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index 015b96d..13aceb1 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -13,7 +13,7 @@ class BlogComment < ActiveRecord::Base
alias_attribute :message, :body
validates :name, :message, :presence => true
- validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
+ validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
scope :unmoderated, :conditions => {:state => nil}
scope :approved, :conditions => {:state => 'approved'}
@@ -39,6 +39,13 @@ class BlogComment < ActiveRecord::Base
self.state.nil?
end
+ def self.toggle!
+ currently = RefinerySetting.find_or_set(:comments_allowed, true, {
+ :scoping => 'blog'
+ })
+ RefinerySetting.set(:comments_allowed, {:value => !currently, :scoping => 'blog'})
+ end
+
before_create do |comment|
unless BlogComment::Moderation.enabled?
comment.state = comment.ham? ? 'approved' : 'rejected'
diff --git a/app/views/admin/blog/_submenu.html.erb b/app/views/admin/blog/_submenu.html.erb
index f6f1c55..b93e30d 100644
--- a/app/views/admin/blog/_submenu.html.erb
+++ b/app/views/admin/blog/_submenu.html.erb
@@ -73,6 +73,10 @@
:class => 'settings_icon' %>
</li>
<li>
+ <%= link_to t('.settings.comments'), comments_admin_blog_settings_url,
+ :class => "#{BlogPost.comments_allowed? ? 'success' : 'failure'}_icon" %>
+ </li>
+ <li>
<%= link_to t('.settings.moderation'), moderation_admin_blog_settings_url,
:class => "#{BlogComment::Moderation.enabled? ? 'success' : 'failure'}_icon" %>
</li>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 21a1459..6585d5b 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -74,6 +74,7 @@ en:
title: Settings
moderation: Moderation
update_notified: Update who gets notified
+ comments: Comments
blog:
comment_mailer:
notification:
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 10b533c..cd1c616 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -71,6 +71,7 @@ es:
title: Configuración
moderation: Moderación
update_notified: ¿Quién recibe las notificaciones?
+ comments: Comentarios
blog:
comment_mailer:
notification:
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index c09f25f..b012054 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -22,7 +22,7 @@ fr:
no_items_yet: 'Il n''y aucun %{type} de commentaires.'
show:
comment: Commenter
- blog_post: Article
+ blog_post: Article
from: Écrit par
date: Écrit le
message: Commentaire
@@ -57,7 +57,7 @@ fr:
manage: Gérer
new: Créer une nouvelle catégorie
comments:
- title: Commentaires
+ title: Commentaires
title_with_count: 'Commentaires (%{new_count} nouveau(x))'
new: Nouveau
unmoderated: Nouveau
@@ -71,6 +71,7 @@ fr:
title: Paramêtres
moderation: Modération
update_notified: Mettre à jour les personnes à notifier
+ comments: Commentaires
blog:
comment_mailer:
notification:
diff --git a/config/locales/it.yml b/config/locales/it.yml
index e0c9c79..e68a331 100644
--- a/config/locales/it.yml
+++ b/config/locales/it.yml
@@ -71,6 +71,7 @@ it:
title: Impostazioni
moderation: Moderazione
update_notified: Aggiornare destinatario notifica
+ comments: Commenti
blog:
shared:
categories:
diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml
index deeeb3a..1d856bb 100644
--- a/config/locales/pt-BR.yml
+++ b/config/locales/pt-BR.yml
@@ -71,6 +71,7 @@ pt-BR:
title: Configurações
moderation: Moderação
update_notified: Quem receberá a notificação?
+ comments: Comentários
blog:
comment_mailer:
notification:
diff --git a/config/locales/ru.yml b/config/locales/ru.yml
index 493b895..98b22fc 100644
--- a/config/locales/ru.yml
+++ b/config/locales/ru.yml
@@ -71,6 +71,7 @@ ru:
title: Настройки
moderation: Модерирование
update_notified: Настроить уведомления
+ comments: Комментарии
blog:
comment_mailer:
notification:
diff --git a/config/routes.rb b/config/routes.rb
index 73d4a11..e37987a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -34,6 +34,7 @@ Refinery::Application.routes.draw do
post :notification_recipients
get :moderation
+ get :comments
end
end
end
diff --git a/refinerycms-blog.gemspec b/refinerycms-blog.gemspec
index 393ffee..549802a 100644
--- a/refinerycms-blog.gemspec
+++ b/refinerycms-blog.gemspec
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
s.name = %q{refinerycms-blog}
s.version = %q{1.2}
s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.}
- s.date = %q{2011-02-17}
+ s.date = %q{2011-02-21}
s.summary = %q{Ruby on Rails blogging engine for RefineryCMS.}
s.email = %q{info@refinerycms.com}
s.homepage = %q{http://refinerycms.com}
diff --git a/spec/models/blog_posts_spec.rb b/spec/models/blog_posts_spec.rb
index f15cd64..9a58e3f 100644
--- a/spec/models/blog_posts_spec.rb
+++ b/spec/models/blog_posts_spec.rb
@@ -94,14 +94,14 @@ describe BlogPost do
BlogPost.previous(blog_post2).should == [blog_post1]
end
end
-
+
describe "uncategorized scope" do
it "returns uncategorized posts if they exist" do
uncategorized_blog_post = Factory(:post)
categorized_blog_post = Factory(:post)
-
+
categorized_blog_post.categories << Factory(:blog_category)
-
+
BlogPost.uncategorized.should include uncategorized_blog_post
BlogPost.uncategorized.should_not include categorized_blog_post
end
@@ -162,10 +162,9 @@ describe BlogPost do
BlogPost.comments_allowed?.should be_true
end
- # TODO: fix this test
- # it "returns false if comments_allowed setting is set to false" do
- # RefinerySetting.set(:comments_allowed, false)
- # BlogPost.comments_allowed?.should be_false
- # end
+ it "returns false if comments_allowed setting is set to false" do
+ RefinerySetting.set(:comments_allowed, {:scoping => 'blog', :value => false})
+ BlogPost.comments_allowed?.should be_false
+ end
end
end