aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/blog/settings_controller.rb2
-rw-r--r--app/controllers/blog_posts_controller.rb6
-rw-r--r--app/models/blog_comment.rb38
-rw-r--r--app/models/blog_post.rb6
-rw-r--r--app/views/admin/blog/categories/_category.html.erb6
-rw-r--r--app/views/admin/blog/categories/_form.html.erb12
-rw-r--r--app/views/admin/blog/comments/_comment.html.erb4
-rw-r--r--app/views/admin/blog/posts/_form.html.erb10
-rw-r--r--app/views/admin/blog/posts/_post.html.erb4
-rw-r--r--app/views/blog_posts/show.html.erb14
10 files changed, 77 insertions, 25 deletions
diff --git a/app/controllers/admin/blog/settings_controller.rb b/app/controllers/admin/blog/settings_controller.rb
index 541fa36..cc9261b 100644
--- a/app/controllers/admin/blog/settings_controller.rb
+++ b/app/controllers/admin/blog/settings_controller.rb
@@ -16,7 +16,7 @@ class Admin::Blog::SettingsController < Admin::BaseController
end
def moderation
- enabled = BlogComment::Moderation.toggle
+ enabled = BlogComment::Moderation.toggle!
unless request.xhr?
redirect_back_or_default(admin_blog_posts_path)
else
diff --git a/app/controllers/blog_posts_controller.rb b/app/controllers/blog_posts_controller.rb
index 9f476bd..73b9dfa 100644
--- a/app/controllers/blog_posts_controller.rb
+++ b/app/controllers/blog_posts_controller.rb
@@ -21,10 +21,10 @@ class BlogPostsController < ApplicationController
def comment
if (@blog_comment = @blog_post.comments.create(params[:blog_comment])).valid?
if BlogComment::Moderation.enabled?
- flash[:notice] = t('.comments.thank_you_moderated')
- redirect_back_or_default blog_post_url(params[:id])
+ flash[:notice] = t('blog_posts.show.comments.thank_you_moderated')
+ redirect_to blog_post_url(params[:id])
else
- flash[:notice] = t('.comments.thank_you')
+ flash[:notice] = t('blog_posts.show.comments.thank_you')
redirect_to blog_post_url(params[:id],
:anchor => "comment-#{@blog_comment.to_param}")
end
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index 4c7be77..201f75c 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -14,9 +14,15 @@ class BlogComment < ActiveRecord::Base
validates_format_of :email,
:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
- named_scope :unmoderated, :conditions => {:state => nil}
- named_scope :approved, :conditions => {:state => 'approved'}
- named_scope :rejected, :conditions => {:state => 'rejected'}
+ if Rails.version < '3.0.0'
+ named_scope :unmoderated, :conditions => {:state => nil}
+ named_scope :approved, :conditions => {:state => 'approved'}
+ named_scope :rejected, :conditions => {:state => 'rejected'}
+ else
+ scope :unmoderated, :conditions => {:state => nil}
+ scope :approved, :conditions => {:state => 'approved'}
+ scope :rejected, :conditions => {:state => 'rejected'}
+ end
def approve!
self.update_attribute(:state, 'approved')
@@ -48,14 +54,18 @@ class BlogComment < ActiveRecord::Base
class << self
def enabled?
RefinerySetting.find_or_set(:comment_moderation, true, {
- :scoping => :blog
+ :scoping => :blog,
+ :restricted => false,
+ :callback_proc_as_string => nil
})
end
- def toggle
+ def toggle!
RefinerySetting[:comment_moderation] = {
:value => !self.enabled?,
- :scoping => :blog
+ :scoping => :blog,
+ :restricted => false,
+ :callback_proc_as_string => nil
}
end
end
@@ -64,17 +74,21 @@ class BlogComment < ActiveRecord::Base
module Notification
class << self
def recipients
- RefinerySetting.find_or_set(
- :comment_notification_recipients,
- (Role[:refinery].users.first.email rescue ''),
- {:scoping => :blog}
- )
+ RefinerySetting.find_or_set(:comment_notification_recipients,
+ (Role[:refinery].users.first.email rescue ''),
+ {
+ :scoping => :blog,
+ :restricted => false,
+ :callback_proc_as_string => nil
+ })
end
def recipients=(emails)
RefinerySetting[:comment_notification_recipients] = {
:value => emails,
- :scoping => :blog
+ :scoping => :blog,
+ :restricted => false,
+ :callback_proc_as_string => nil
}
end
end
diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb
index abd64d1..ad31778 100644
--- a/app/models/blog_post.rb
+++ b/app/models/blog_post.rb
@@ -12,7 +12,11 @@ class BlogPost < ActiveRecord::Base
default_scope :order => "created_at DESC"
- named_scope :live, :conditions => {:draft => false}
+ if Rails.version < '3.0.0'
+ named_scope :live, :conditions => {:draft => false}
+ else
+ scope :live, :conditions => {:draft => false}
+ end
def category_ids=(ids)
self.categories = ids.reject{|id| id.blank?}.collect {|c_id|
diff --git a/app/views/admin/blog/categories/_category.html.erb b/app/views/admin/blog/categories/_category.html.erb
index 20c5c35..7997d68 100644
--- a/app/views/admin/blog/categories/_category.html.erb
+++ b/app/views/admin/blog/categories/_category.html.erb
@@ -4,11 +4,13 @@
<span class="preview">&nbsp;</span>
</span>
<span class='actions'>
- <%= link_to refinery_icon_tag("application_edit.png"),
+ <%= link_to refinery_icon_tag("application_edit.png"),
edit_admin_blog_category_path(category, :dialog => true, :height => 325),
:title => t('.edit') %>
<%= link_to refinery_icon_tag("delete.png"), admin_blog_category_path(category),
:class => "cancel confirm-delete",
- :title => t('.delete') %>
+ :title => t('.delete'),
+ :'data-method' => 'delete',
+ :'data-confirm' => t('shared.admin.delete.message', :title => category.title) %>
</span>
</li>
diff --git a/app/views/admin/blog/categories/_form.html.erb b/app/views/admin/blog/categories/_form.html.erb
index 0c5b9c4..247f31b 100644
--- a/app/views/admin/blog/categories/_form.html.erb
+++ b/app/views/admin/blog/categories/_form.html.erb
@@ -1,6 +1,14 @@
<% form_for [:admin, @blog_category] do |f| -%>
- <%= f.error_messages %>
-
+ <% if Rails.version < '3.0.0'%>
+ <%= f.error_messages %>
+ <% else %>
+ <%= render :partial => "/shared/admin/error_messages",
+ :locals => {
+ :object => f.object,
+ :include_object_name => true
+ } %>
+ <% end %>
+
<div class='field'>
<%= f.label :title -%>
<%= f.text_field :title, :class => 'larger widest' -%>
diff --git a/app/views/admin/blog/comments/_comment.html.erb b/app/views/admin/blog/comments/_comment.html.erb
index 3435c75..52a8167 100644
--- a/app/views/admin/blog/comments/_comment.html.erb
+++ b/app/views/admin/blog/comments/_comment.html.erb
@@ -11,10 +11,10 @@
<%= 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),
+ rejected_admin_blog_comment_path(comment, :return_to => request.path.split('/').last.gsub(/^comments$/, 'index')),
: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),
+ approved_admin_blog_comment_path(comment, :return_to => request.path.split('/').last.gsub(/^comments$/, 'index')),
:title => t('.approve') unless comment.approved? %>
</span>
</li>
diff --git a/app/views/admin/blog/posts/_form.html.erb b/app/views/admin/blog/posts/_form.html.erb
index f6f332f..bf964e9 100644
--- a/app/views/admin/blog/posts/_form.html.erb
+++ b/app/views/admin/blog/posts/_form.html.erb
@@ -1,5 +1,13 @@
<% form_for [:admin, @blog_post] do |f| -%>
- <%= f.error_messages %>
+ <% if Rails.version < '3.0.0'%>
+ <%= f.error_messages %>
+ <% else %>
+ <%= render :partial => "/shared/admin/error_messages",
+ :locals => {
+ :object => f.object,
+ :include_object_name => true
+ } %>
+ <% end %>
<div class='field'>
<%= f.label :title -%>
diff --git a/app/views/admin/blog/posts/_post.html.erb b/app/views/admin/blog/posts/_post.html.erb
index 3e15543..a768279 100644
--- a/app/views/admin/blog/posts/_post.html.erb
+++ b/app/views/admin/blog/posts/_post.html.erb
@@ -11,6 +11,8 @@
:title => t('.edit') %>
<%= link_to refinery_icon_tag("delete.png"), admin_blog_post_path(post),
:class => "cancel confirm-delete",
- :title => t('.delete') %>
+ :title => t('.delete'),
+ :'data-method' => 'delete',
+ :'data-confirm' => t('shared.admin.delete.message', :title => post.title) %>
</span>
</li>
diff --git a/app/views/blog_posts/show.html.erb b/app/views/blog_posts/show.html.erb
index 57b2f92..9e3cf4d 100644
--- a/app/views/blog_posts/show.html.erb
+++ b/app/views/blog_posts/show.html.erb
@@ -35,7 +35,21 @@
<% if BlogPost.comments_allowed? %>
<hr />
+ <% flash.each do |key, value| %>
+ <div id='flash' class="flash flash_<%= key %>">
+ <%= value %>
+ </div>
+ <% end %>
<% form_for [:blog_post, @blog_comment] do |f| %>
+ <% if Rails.version < '3.0.0'%>
+ <%= f.error_messages %>
+ <% else %>
+ <%= render :partial => "/shared/admin/error_messages",
+ :locals => {
+ :object => f.object,
+ :include_object_name => true
+ } %>
+ <% end %>
<div class='field'>
<%= f.label :name %>
<%= f.text_field :name %>