diff options
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | Gemfile.lock | 4 | ||||
-rw-r--r-- | app/controllers/blog_posts_controller.rb | 7 | ||||
-rw-r--r-- | app/models/blog_comment.rb | 8 | ||||
-rw-r--r-- | app/models/blog_post.rb | 8 | ||||
-rw-r--r-- | app/views/admin/blog/comments/_comment.html.erb | 17 | ||||
-rw-r--r-- | app/views/admin/blog/comments/_sortable_list.html.erb | 7 | ||||
-rw-r--r-- | app/views/blog_posts/_categories.html.erb | 0 | ||||
-rw-r--r-- | app/views/blog_posts/_comments.html.erb | 0 | ||||
-rw-r--r-- | app/views/blog_posts/show.html.erb | 47 | ||||
-rw-r--r-- | config/locales/en.yml | 4 | ||||
-rw-r--r-- | generators/refinery_blog/refinery_blog_generator.rb | 3 | ||||
-rw-r--r-- | lib/gemspec.rb | 2 | ||||
-rw-r--r-- | lib/refinerycms-blog.rb | 2 | ||||
-rw-r--r-- | refinerycms-blog.gemspec | 10 |
15 files changed, 85 insertions, 36 deletions
@@ -1 +1 @@ -gem 'filters_spam', '~> 0.1'
\ No newline at end of file +gem 'filters_spam', '~> 0.2'
\ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 4fe5eb7..62d287d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,9 @@ GEM specs: - filters_spam (0.1) + filters_spam (0.2) PLATFORMS ruby DEPENDENCIES - filters_spam (~> 0.1) + filters_spam (~> 0.2) diff --git a/app/controllers/blog_posts_controller.rb b/app/controllers/blog_posts_controller.rb index caaa336..9f476bd 100644 --- a/app/controllers/blog_posts_controller.rb +++ b/app/controllers/blog_posts_controller.rb @@ -19,12 +19,13 @@ class BlogPostsController < ApplicationController end def comment - if (@blog_comment = BlogComment.create(params[:blog_comment])).valid? + if (@blog_comment = @blog_post.comments.create(params[:blog_comment])).valid? if BlogComment::Moderation.enabled? - flash[:notice] = t('.thank_you_moderated') + flash[:notice] = t('.comments.thank_you_moderated') redirect_back_or_default blog_post_url(params[:id]) else - redirect_to blog_post_url(params[:id], + flash[:notice] = t('.comments.thank_you') + redirect_to blog_post_url(params[:id], :anchor => "comment-#{@blog_comment.to_param}") end else diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index cc890fa..c115aef 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -2,7 +2,7 @@ class BlogComment < ActiveRecord::Base filters_spam :author_field => :name, :email_field => :email, - :message_field => :message + :message_field => :body belongs_to :post, :class_name => 'BlogPost' @@ -18,6 +18,12 @@ class BlogComment < ActiveRecord::Base named_scope :approved, :conditions => {:state => 'approved'} named_scope :rejected, :conditions => {:state => 'rejected'} + before_create do |comment| + unless BlogComment::Moderation.enabled? + comment.state = comment.spam? ? 'rejected' : 'approved' + end + end + module Moderation class << self def enabled? diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb index 237385f..abd64d1 100644 --- a/app/models/blog_post.rb +++ b/app/models/blog_post.rb @@ -20,4 +20,12 @@ class BlogPost < ActiveRecord::Base }.compact end + class << self + def comments_allowed? + RefinerySetting.find_or_set(:comments_allowed, true, { + :scoping => :blog + }) + end + end + end diff --git a/app/views/admin/blog/comments/_comment.html.erb b/app/views/admin/blog/comments/_comment.html.erb new file mode 100644 index 0000000..e03605a --- /dev/null +++ b/app/views/admin/blog/comments/_comment.html.erb @@ -0,0 +1,17 @@ +<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(comment) -%>"> + <span class='title'> + <%=h comment.name %> + <span class="preview"> - <%= truncate(comment.message, :length => 75) %></span> + </span> + <span class='actions'> + <%= link_to refinery_icon_tag("application_go.png"), blog_post_url(comment.post, + :anchor => "comment-#{comment.to_param}"), + :title => t('.view_live'), + :target => "_blank" %> + <%= link_to refinery_icon_tag("application_edit.png"), edit_admin_blog_comment_path(comment), + :title => t('.edit') %> + <%= link_to refinery_icon_tag("delete.png"), admin_blog_comment_path(comment), + :class => "cancel confirm-delete", + :title => t('.delete') %> + </span> +</li> diff --git a/app/views/admin/blog/comments/_sortable_list.html.erb b/app/views/admin/blog/comments/_sortable_list.html.erb new file mode 100644 index 0000000..e141dee --- /dev/null +++ b/app/views/admin/blog/comments/_sortable_list.html.erb @@ -0,0 +1,7 @@ +<ul id='sortable_list'> + <%= render :partial => 'comment', :collection => @blog_comments %> +</ul> +<%= render :partial => "/shared/admin/sortable_list", + :locals => { + :continue_reordering => (defined?(continue_reordering) ? continue_reordering : true) + } %> diff --git a/app/views/blog_posts/_categories.html.erb b/app/views/blog_posts/_categories.html.erb new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/views/blog_posts/_categories.html.erb diff --git a/app/views/blog_posts/_comments.html.erb b/app/views/blog_posts/_comments.html.erb new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/views/blog_posts/_comments.html.erb diff --git a/app/views/blog_posts/show.html.erb b/app/views/blog_posts/show.html.erb index cf51e0c..6fea210 100644 --- a/app/views/blog_posts/show.html.erb +++ b/app/views/blog_posts/show.html.erb @@ -3,9 +3,8 @@ <% content_for :body_content_left do %> <%= @blog_post.body %> - <hr /> - <% if (categories = @blog_post.categories).any? %> + <hr /> <div class='post_categories'> <span class='filed_in'><%= t('.filed_in') %></span> <ul> @@ -18,9 +17,9 @@ </div> <% end %> - <hr /> <% if (comments = @blog_post.comments.approved).any? %> - <h2><%= t('.comments') %></h2> + <hr /> + <h2><%= t('.comments.title') %></h2> <% comments.each do |comment| %> <div class='blog_comment_message'> <p> @@ -28,29 +27,31 @@ </p> </div> <p class='blog_comment_author'> - <%= t('.comment_by', :who => comment.name) %> - <%= ", #{time_ago_in_words(comment.created_at)}".html_safe %> + <%= t('.comments.by', :who => comment.name) %> + <%= t('.comments.time_ago', :time => time_ago_in_words(comment.created_at)) %> </p> <% end %> - <hr /> <% end %> - <% form_for [:blog_post, @blog_comment] do |f| %> - <div class='field'> - <%= f.label :name %> - <%= f.text_field :name %> - </div> - <div class='field'> - <%= f.label :email %> - <%= f.text_field :email %> - </div> - <div class='field message_field'> - <%= f.label :message %> - <%= f.text_area :message, :rows => 6 %> - </div> - <div class='field form-actions'> - <%= f.submit t('.submit') %> - </div> + <% if BlogPost.comments_allowed? %> + <hr /> + <% form_for [:blog_post, @blog_comment] do |f| %> + <div class='field'> + <%= f.label :name %> + <%= f.text_field :name %> + </div> + <div class='field'> + <%= f.label :email %> + <%= f.text_field :email %> + </div> + <div class='field message_field'> + <%= f.label :message %> + <%= f.text_area :message, :rows => 6 %> + </div> + <div class='field form-actions'> + <%= f.submit t('.submit') %> + </div> + <% end %> <% end %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index c6d75e6..1c00495 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -55,6 +55,10 @@ en: index: read_more: Read more show: + comments: + title: Comments + by: Posted by {{who}} + time_ago: '{{time}} ago' other: Other Blog Posts filed_in: Filed in created_at_title: Publishing Date diff --git a/generators/refinery_blog/refinery_blog_generator.rb b/generators/refinery_blog/refinery_blog_generator.rb index 524868b..2bf39d8 100644 --- a/generators/refinery_blog/refinery_blog_generator.rb +++ b/generators/refinery_blog/refinery_blog_generator.rb @@ -43,11 +43,12 @@ class RefineryBlogGenerator < Rails::Generator::NamedBase },{ :table_name => 'blog_comments', :attributes => [ + Rails::Generator::GeneratedAttribute.new('blog_post_id', 'integer'), + Rails::Generator::GeneratedAttribute.new('spam', 'boolean'), Rails::Generator::GeneratedAttribute.new('name', 'string'), Rails::Generator::GeneratedAttribute.new('email', 'string'), Rails::Generator::GeneratedAttribute.new('body', 'text'), Rails::Generator::GeneratedAttribute.new('state', 'string'), - Rails::Generator::GeneratedAttribute.new('blog_post_id', 'integer') ], :id => true },{ :table_name => 'blog_categories', diff --git a/lib/gemspec.rb b/lib/gemspec.rb index ad1eff2..7589b25 100644 --- a/lib/gemspec.rb +++ b/lib/gemspec.rb @@ -18,7 +18,7 @@ Gem::Specification.new do |s| s.authors = %w(Resolve\\ Digital Neoteric\\ Design) s.require_paths = %w(lib) s.add_dependency 'refinerycms', '~> 0.9.7.13' - s.add_dependency 'filters_spam', '~> 0.1' + s.add_dependency 'filters_spam', '~> 0.2' s.files = %w( #{files.join("\n ")} diff --git a/lib/refinerycms-blog.rb b/lib/refinerycms-blog.rb index c322faf..4027d70 100644 --- a/lib/refinerycms-blog.rb +++ b/lib/refinerycms-blog.rb @@ -22,7 +22,7 @@ module Refinery class << self def version - %q{0.9.8.0.rc1} + %q{0.9.8.0.rc2} end end end diff --git a/refinerycms-blog.gemspec b/refinerycms-blog.gemspec index b185f93..2c2f712 100644 --- a/refinerycms-blog.gemspec +++ b/refinerycms-blog.gemspec @@ -1,15 +1,15 @@ Gem::Specification.new do |s| s.name = %q{refinerycms-blog} - s.version = %q{0.9.8.0.rc1} + s.version = %q{0.9.8.0.rc2} s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.} - s.date = %q{2010-08-28} + s.date = %q{2010-08-30} s.summary = %q{Ruby on Rails blogging engine for RefineryCMS.} s.email = %q{info@refinerycms.com} s.homepage = %q{http://refinerycms.com} s.authors = %w(Resolve\ Digital Neoteric\ Design) s.require_paths = %w(lib) s.add_dependency 'refinerycms', '~> 0.9.7.13' - s.add_dependency 'filters_spam', '~> 0.1' + s.add_dependency 'filters_spam', '~> 0.2' s.files = %w( app @@ -38,6 +38,8 @@ Gem::Specification.new do |s| app/views/admin/blog/categories/index.html.erb app/views/admin/blog/categories/new.html.erb app/views/admin/blog/comments + app/views/admin/blog/comments/_comment.html.erb + app/views/admin/blog/comments/_sortable_list.html.erb app/views/admin/blog/comments/index.html.erb app/views/admin/blog/posts app/views/admin/blog/posts/_form.html.erb @@ -49,6 +51,8 @@ Gem::Specification.new do |s| app/views/admin/blog/settings app/views/admin/blog/settings/notification_recipients.html.erb app/views/blog_posts + app/views/blog_posts/_categories.html.erb + app/views/blog_posts/_comments.html.erb app/views/blog_posts/_side_bar.html.erb app/views/blog_posts/index.html.erb app/views/blog_posts/show.html.erb |