aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2010-08-10 16:17:03 +1200
committerPhilip Arndt <parndt@gmail.com>2010-08-10 16:17:03 +1200
commita6b6a0da3477719e0109ad6175b16f04d37b2550 (patch)
tree3adf9305d598bb8764b24f30abb827dc6b64949e
parent2e2b8bc9ba728091a58b93af6d72a34d9707cba7 (diff)
downloadrefinerycms-blog-a6b6a0da3477719e0109ad6175b16f04d37b2550.tar.gz
refinerycms-blog-a6b6a0da3477719e0109ad6175b16f04d37b2550.tar.bz2
refinerycms-blog-a6b6a0da3477719e0109ad6175b16f04d37b2550.zip
Better settings, update notified has a form but doesn't yet work. Created script files but not using them yet.
-rw-r--r--app/controllers/admin/blog/settings_controller.rb14
-rw-r--r--app/models/blog_comment.rb20
-rw-r--r--app/views/admin/blog/_submenu.html.erb3
-rw-r--r--app/views/admin/blog/settings/notification_recipients.html.erb24
-rw-r--r--config/locales/en.yml6
-rw-r--r--config/routes.rb10
-rw-r--r--public/javascripts/refinerycms-blog.js0
-rw-r--r--public/stylesheets/refinerycms-blog.css0
8 files changed, 68 insertions, 9 deletions
diff --git a/app/controllers/admin/blog/settings_controller.rb b/app/controllers/admin/blog/settings_controller.rb
index 962e8d1..52a7e83 100644
--- a/app/controllers/admin/blog/settings_controller.rb
+++ b/app/controllers/admin/blog/settings_controller.rb
@@ -1,12 +1,20 @@
class Admin::Blog::SettingsController < Admin::BaseController
- def update_notified
+ def notification_recipients
+ @recipients = BlogComment::Notification.recipients
+ if request.post?
+ BlogComment::Notification.recipients == params[:recipients]
+ end
end
def moderation
- BlogComment::Moderation.toggle
- redirect_back_or_default(admin_blog_posts_path)
+ enabled = BlogComment::Moderation.toggle
+ unless request.xhr?
+ redirect_back_or_default(admin_blog_posts_path)
+ else
+ render :json => {:enabled => enabled}
+ end
end
end
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index aced256..04651fe 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -17,10 +17,24 @@ class BlogComment < ActiveRecord::Base
end
def toggle
- currently = self.enabled?
- RefinerySetting[:comment_moderation] = !currently
+ RefinerySetting[:comment_moderation] = !(currently = self.enabled?)
end
end
end
-end
+ module Notification
+ class << self
+ def recipients
+ RefinerySetting.find_or_set(:comment_notification_recipients, {
+ :value => (Role[:refinery].users.first.email rescue ''),
+ :scoping => :blog
+ })
+ end
+
+ def recipients=(emails)
+ RefinerySetting[:comment_notification_recipients] = emails
+ end
+ end
+ end
+
+end \ No newline at end of file
diff --git a/app/views/admin/blog/_submenu.html.erb b/app/views/admin/blog/_submenu.html.erb
index 89fe69c..e03e476 100644
--- a/app/views/admin/blog/_submenu.html.erb
+++ b/app/views/admin/blog/_submenu.html.erb
@@ -59,7 +59,8 @@
:class => "#{BlogComment::Moderation.enabled? ? 'success' : 'failure'}_icon" %>
</li>
<li>
- <%= link_to t('.settings.update_notified'), update_notified_admin_blog_settings_url(:dialog => true),
+ <%= link_to t('.settings.update_notified'),
+ notification_recipients_admin_blog_settings_url(:dialog => true, :height => 400),
:class => 'user_comment_icon' %>
</li>
</ul>
diff --git a/app/views/admin/blog/settings/notification_recipients.html.erb b/app/views/admin/blog/settings/notification_recipients.html.erb
new file mode 100644
index 0000000..ea36af1
--- /dev/null
+++ b/app/views/admin/blog/settings/notification_recipients.html.erb
@@ -0,0 +1,24 @@
+<% form_tag do %>
+
+ <div class='field'>
+ <span class='label_with_help'>
+ <%= label_tag :recipients, t('.value') %>
+ </span>
+ <%= text_field_tag :recipients, @recipients, :class => "larger widest" %>
+ </div>
+
+ <p>
+ <%= t('.hint') %>
+ </p>
+ <p>
+ <%= t('.example') %>
+ </p>
+
+ <%= render :partial => "/shared/admin/form_actions",
+ :locals => {
+ :f => nil,
+ :continue_editing => false,
+ :cancel_url => admin_blog_posts_url,
+ :hide_delete => true
+ } %>
+<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 169cd8d..6ee7b59 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -34,6 +34,12 @@ en:
title: Settings
moderation: Moderation
update_notified: Update who gets notified
+ settings:
+ notification_recipients:
+ value: Send notifications to
+ explanation: "Every time someone comments on a blog post, Refinery sends out an email to say there is a new comment."
+ hint: "When a new comment is added, Refinery will send an email notification to you."
+ example: "Enter your email address(es) like: jack@work.com, jill@office.com"
blog_posts:
show:
other: Other Blog Posts \ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 7f1bf18..2478f1b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -5,8 +5,14 @@ ActionController::Routing::Routes.draw do |map|
admin.namespace :blog do |blog|
blog.resources :posts
blog.resources :categories
- blog.resources :comments, :collection => {:approved => :get, :rejected => :get}
- blog.resources :settings, :collection => {:update_notified => [:get, :post], :moderation => :get}
+ blog.resources :comments, :collection => {
+ :approved => :get,
+ :rejected => :get
+ }
+ blog.resources :settings, :collection => {
+ :notification_recipients => [:get, :post],
+ :moderation => :get
+ }
end
end
end
diff --git a/public/javascripts/refinerycms-blog.js b/public/javascripts/refinerycms-blog.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/public/javascripts/refinerycms-blog.js
diff --git a/public/stylesheets/refinerycms-blog.css b/public/stylesheets/refinerycms-blog.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/public/stylesheets/refinerycms-blog.css