Comments are now moderated automatically unless moderation is enabled and show up below posts.
This commit is contained in:
parent
21dca99ddf
commit
4d1e364085
15 changed files with 85 additions and 36 deletions
2
Gemfile
2
Gemfile
|
@ -1 +1 @@
|
|||
gem 'filters_spam', '~> 0.1'
|
||||
gem 'filters_spam', '~> 0.2'
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
|
17
app/views/admin/blog/comments/_comment.html.erb
Normal file
17
app/views/admin/blog/comments/_comment.html.erb
Normal file
|
@ -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>
|
7
app/views/admin/blog/comments/_sortable_list.html.erb
Normal file
7
app/views/admin/blog/comments/_sortable_list.html.erb
Normal file
|
@ -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)
|
||||
} %>
|
0
app/views/blog_posts/_categories.html.erb
Normal file
0
app/views/blog_posts/_categories.html.erb
Normal file
0
app/views/blog_posts/_comments.html.erb
Normal file
0
app/views/blog_posts/_comments.html.erb
Normal file
|
@ -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 %>
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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 ")}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue