aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/admin/blog/comments_controller.rb22
-rw-r--r--app/models/blog_comment.rb22
-rw-r--r--app/views/admin/blog/comments/_comment.html.erb23
-rw-r--r--app/views/admin/blog/comments/index.html.erb2
-rw-r--r--app/views/admin/blog/comments/show.html.erb61
-rw-r--r--app/views/blog_posts/show.html.erb2
-rw-r--r--config/locales/en.yml18
-rw-r--r--config/routes.rb6
-rw-r--r--refinerycms-blog.gemspec3
9 files changed, 140 insertions, 19 deletions
diff --git a/app/controllers/admin/blog/comments_controller.rb b/app/controllers/admin/blog/comments_controller.rb
index 33b3463..709d86d 100644
--- a/app/controllers/admin/blog/comments_controller.rb
+++ b/app/controllers/admin/blog/comments_controller.rb
@@ -10,13 +10,27 @@ class Admin::Blog::CommentsController < Admin::BaseController
end
def approved
- @blog_comments = BlogComment.approved
- render :action => 'index'
+ unless params[:id].present?
+ @blog_comments = BlogComment.approved
+ render :action => 'index'
+ else
+ @blog_comment = BlogComment.find(params[:id])
+ @blog_comment.approve!
+ flash[:notice] = t('admin.blog.comments.approved', :author => @blog_comment.name)
+ redirect_to :action => params[:return_to] || 'index'
+ end
end
def rejected
- @blog_comments = BlogComment.rejected
- render :action => 'index'
+ unless params[:id].present?
+ @blog_comments = BlogComment.rejected
+ render :action => 'index'
+ else
+ @blog_comment = BlogComment.find(params[:id])
+ @blog_comment.reject!
+ flash[:notice] = t('admin.blog.comments.rejected', :author => @blog_comment.name)
+ redirect_to :action => params[:return_to] || 'index'
+ end
end
end
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index c115aef..4c7be77 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -4,7 +4,7 @@ class BlogComment < ActiveRecord::Base
:email_field => :email,
:message_field => :body
- belongs_to :post, :class_name => 'BlogPost'
+ belongs_to :post, :class_name => 'BlogPost', :foreign_key => 'blog_post_id'
acts_as_indexed :fields => [:name, :email, :message]
@@ -18,6 +18,26 @@ class BlogComment < ActiveRecord::Base
named_scope :approved, :conditions => {:state => 'approved'}
named_scope :rejected, :conditions => {:state => 'rejected'}
+ def approve!
+ self.update_attribute(:state, 'approved')
+ end
+
+ def reject!
+ self.update_attribute(:state, 'rejected')
+ end
+
+ def rejected?
+ self.state == 'rejected'
+ end
+
+ def approved?
+ self.state == 'approved'
+ end
+
+ def unmoderated?
+ self.state.nil?
+ end
+
before_create do |comment|
unless BlogComment::Moderation.enabled?
comment.state = comment.spam? ? 'rejected' : 'approved'
diff --git a/app/views/admin/blog/comments/_comment.html.erb b/app/views/admin/blog/comments/_comment.html.erb
index e03605a..3435c75 100644
--- a/app/views/admin/blog/comments/_comment.html.erb
+++ b/app/views/admin/blog/comments/_comment.html.erb
@@ -1,17 +1,20 @@
-<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(comment) -%>">
+<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= "comment-#{comment.to_param}" -%>">
<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') %>
+ <%= link_to refinery_icon_tag("application_go.png"),
+ blog_post_url(comment.post, :anchor => "comment-#{comment.to_param}"),
+ :title => t('.view_live'),
+ :target => "_blank" unless comment.unmoderated? %>
+ <%= link_to refinery_icon_tag('zoom.png'), admin_blog_comment_path(comment),
+ :title => t('.read') %>
+ <%= link_to refinery_icon_tag("cross.png"),
+ rejected_admin_blog_comment_path(comment, :return_to => request.path.split('/').last),
+ :title => t('.reject') unless comment.rejected? %>
+ <%= link_to refinery_icon_tag("tick.png"),
+ approved_admin_blog_comment_path(comment, :return_to => request.path.split('/').last),
+ :title => t('.approve') unless comment.approved? %>
</span>
</li>
diff --git a/app/views/admin/blog/comments/index.html.erb b/app/views/admin/blog/comments/index.html.erb
index 940ba47..c1596a6 100644
--- a/app/views/admin/blog/comments/index.html.erb
+++ b/app/views/admin/blog/comments/index.html.erb
@@ -28,7 +28,7 @@
<% else %>
<h3>
<%= t('.no_items_yet',
- :type => (t("admin.blog.submenu.comments.#{action_name}").downcase unless action_name == 'index')) %>
+ :type => t("admin.blog.submenu.comments.#{action_name.gsub('index', 'new')}").downcase) %>
</h3>
<% end %>
<% end %>
diff --git a/app/views/admin/blog/comments/show.html.erb b/app/views/admin/blog/comments/show.html.erb
new file mode 100644
index 0000000..8ed5191
--- /dev/null
+++ b/app/views/admin/blog/comments/show.html.erb
@@ -0,0 +1,61 @@
+<div id='actions'>
+ <h2><%= t('.details')%></h2>
+ <p>
+ <strong><%= t('.age') %>:</strong> <%= time_ago_in_words(@blog_comment.created_at) %>
+ </p>
+ <h2><%= t('.actions') %></h2>
+ <ul>
+ <li>
+ <%= link_to t('.back'), {:action => 'index'}, :class => "back_icon" %>
+ </li>
+ <li>
+ <%= link_to t('.reject'), rejected_admin_blog_comment_path(@blog_comment, :return_to => 'rejected'),
+ :class => 'comment_cross_icon' unless @blog_comment.rejected? %>
+ </li>
+ <li>
+ <%= link_to t('.approve'), approved_admin_blog_comment_path(@blog_comment, :return_to => 'approved'),
+ :class => 'comment_tick_icon' unless @blog_comment.approved? %>
+ </li>
+ </ul>
+</div>
+<div id='records'>
+ <h2><%= t('.comment') %></h2>
+ <table id='inquiry'>
+ <tr>
+ <td>
+ <strong><%= t('.blog_post') %></strong>
+ </td>
+ <td>
+ <%= link_to @blog_comment.post.title,
+ blog_post_url(@blog_comment.post, :anchor => "comment-#{@blog_comment.to_param}"),
+ :target => '_blank' %>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <strong><%= t('.from') %></strong>
+ </td>
+ <td>
+ <%= @blog_comment.name %> [<%= mail_to @blog_comment.email, @blog_comment.email, {:title => t('.click_to_email')} %>]
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <strong><%= t('.date') %></strong>
+ </td>
+ <td>
+ <%= l(Date.parse(@blog_comment.created_at.to_s), :format => :long) %>
+ </td>
+ </tr>
+ <tr>
+ <td valign='top'>
+ <strong><%= t('.message') %></strong>
+ </td>
+ <td>
+ <p style='margin-top: 0px'>
+ <%= @blog_comment.message.gsub("\r\n\r\n", "\r\n").gsub("\r\n", "</p><p>") %>
+ </p>
+ </td>
+ </tr>
+ </table>
+</div> \ No newline at end of file
diff --git a/app/views/blog_posts/show.html.erb b/app/views/blog_posts/show.html.erb
index 6fea210..57b2f92 100644
--- a/app/views/blog_posts/show.html.erb
+++ b/app/views/blog_posts/show.html.erb
@@ -21,7 +21,7 @@
<hr />
<h2><%= t('.comments.title') %></h2>
<% comments.each do |comment| %>
- <div class='blog_comment_message'>
+ <div class='blog_comment_message' id='<%= "comment-#{comment.to_param}" %>'>
<p>
<%= comment.message.to_s.gsub("\r\n\r\n", "</p><p>").gsub("\r\n", "<br/>") %>
</p>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 1c00495..f137f30 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -11,8 +11,22 @@ en:
index:
no_items_yet: There are no categories yet. Click "{{create}}" to add your first category.
comments:
+ approved: The comment from '{{author}}' has been approved.
+ rejected: The comment from '{{author}}' has been rejected.
index:
- no_items_yet: There are no {{type}} comments yet.
+ no_items_yet: There are no {{type}} comments.
+ show:
+ comment: Comment
+ blog_post: Blog Post
+ from: Posted by
+ date: Posted at
+ message: Comment
+ details: Details
+ age: Age
+ actions: Actions
+ back: Back to all comments
+ reject: Reject this comment
+ approve: Approve this comment
posts:
form:
advanced_options: Advanced Options
@@ -59,6 +73,8 @@ en:
title: Comments
by: Posted by {{who}}
time_ago: '{{time}} ago'
+ thank_you: 'Thank you for commenting.'
+ thank_you_moderated: 'Thank you for commenting. Your message has been placed in the moderation queue and will appear shortly.'
other: Other Blog Posts
filed_in: Filed in
created_at_title: Publishing Date
diff --git a/config/routes.rb b/config/routes.rb
index fabb925..ce4a2ef 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -8,11 +8,17 @@ if Rails.version < '3.0.0'
map.namespace(:admin, :path_prefix => 'refinery') do |admin|
admin.namespace :blog do |blog|
blog.resources :posts
+
blog.resources :categories
+
blog.resources :comments, :collection => {
:approved => :get,
:rejected => :get
+ }, :member => {
+ :approved => :get,
+ :rejected => :get
}
+
blog.resources :settings, :collection => {
:notification_recipients => [:get, :post],
:moderation => :get
diff --git a/refinerycms-blog.gemspec b/refinerycms-blog.gemspec
index 2c2f712..5b3c9a4 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{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-30}
+ s.date = %q{2010-09-02}
s.summary = %q{Ruby on Rails blogging engine for RefineryCMS.}
s.email = %q{info@refinerycms.com}
s.homepage = %q{http://refinerycms.com}
@@ -41,6 +41,7 @@ Gem::Specification.new do |s|
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/comments/show.html.erb
app/views/admin/blog/posts
app/views/admin/blog/posts/_form.html.erb
app/views/admin/blog/posts/_post.html.erb