aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/blog/posts_controller.rb12
-rw-r--r--app/mailers/blog/comment_mailer.rb11
-rw-r--r--app/models/blog/comment_mailer.rb1
-rw-r--r--app/models/blog_comment.rb38
-rw-r--r--app/views/blog/comment_mailer/notification.html.erb17
-rw-r--r--config/locales/en.yml11
-rw-r--r--lib/refinerycms-blog.rb2
-rw-r--r--readme.md2
-rw-r--r--refinerycms-blog.gemspec11
9 files changed, 87 insertions, 18 deletions
diff --git a/app/controllers/blog/posts_controller.rb b/app/controllers/blog/posts_controller.rb
index ee707ed..1d8a0b5 100644
--- a/app/controllers/blog/posts_controller.rb
+++ b/app/controllers/blog/posts_controller.rb
@@ -17,6 +17,18 @@ class Blog::PostsController < BlogController
def comment
if (@blog_comment = @blog_post.comments.create(params[:blog_comment])).valid?
+ if BlogComment::Moderation.enabled? or @blog_comment.ham?
+ begin
+ if Rails.version < '3.0.0'
+ Blog::CommentMailer.deliver_notification(@blog_comment, request)
+ else
+ Blog::CommentMailer.notification(@blog_comment, request).deliver
+ end
+ rescue
+ logger.warn "There was an error delivering a blog comment notification.\n#{$!}\n"
+ end
+ end
+
if BlogComment::Moderation.enabled?
flash[:notice] = t('blog.posts.comments.thank_you_moderated')
redirect_to blog_post_url(params[:id])
diff --git a/app/mailers/blog/comment_mailer.rb b/app/mailers/blog/comment_mailer.rb
new file mode 100644
index 0000000..3e4c76d
--- /dev/null
+++ b/app/mailers/blog/comment_mailer.rb
@@ -0,0 +1,11 @@
+class Blog::CommentMailer < ActionMailer::Base
+
+ def notification(comment, request)
+ subject BlogComment::Notification.subject
+ recipients BlogComment::Notification.recipients
+ from "\"#{RefinerySetting[:site_name]}\" <no-reply@#{request.domain(RefinerySetting.find_or_set(:tld_length, 1))}>"
+ sent_on Time.now
+ @comment = comment
+ end
+
+end
diff --git a/app/models/blog/comment_mailer.rb b/app/models/blog/comment_mailer.rb
new file mode 100644
index 0000000..dac526d
--- /dev/null
+++ b/app/models/blog/comment_mailer.rb
@@ -0,0 +1 @@
+require File.expand_path('../../../mailers/blog/comment_mailer', __FILE__) \ No newline at end of file
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index 201f75c..b888e35 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -46,7 +46,7 @@ class BlogComment < ActiveRecord::Base
before_create do |comment|
unless BlogComment::Moderation.enabled?
- comment.state = comment.spam? ? 'rejected' : 'approved'
+ comment.state = comment.ham? ? 'approved' : 'rejected'
end
end
@@ -55,8 +55,7 @@ class BlogComment < ActiveRecord::Base
def enabled?
RefinerySetting.find_or_set(:comment_moderation, true, {
:scoping => :blog,
- :restricted => false,
- :callback_proc_as_string => nil
+ :restricted => false
})
end
@@ -64,8 +63,7 @@ class BlogComment < ActiveRecord::Base
RefinerySetting[:comment_moderation] = {
:value => !self.enabled?,
:scoping => :blog,
- :restricted => false,
- :callback_proc_as_string => nil
+ :restricted => false
}
end
end
@@ -74,21 +72,33 @@ 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,
- :restricted => false,
- :callback_proc_as_string => nil
- })
+ RefinerySetting.find_or_set(:comment_notification_recipients, (Role[:refinery].users.first.email rescue ''),
+ {
+ :scoping => :blog,
+ :restricted => false
+ })
end
def recipients=(emails)
RefinerySetting[:comment_notification_recipients] = {
:value => emails,
:scoping => :blog,
- :restricted => false,
- :callback_proc_as_string => nil
+ :restricted => false
+ }
+ end
+
+ def subject
+ RefinerySetting.find_or_set(:comment_notification_subject, "New inquiry from your website", {
+ :scoping => :blog,
+ :restricted => false
+ })
+ end
+
+ def subject=(subject_line)
+ RefinerySetting[:comment_notification_subject] = {
+ :value => subject_line,
+ :scoping => :blog,
+ :restricted => false
}
end
end
diff --git a/app/views/blog/comment_mailer/notification.html.erb b/app/views/blog/comment_mailer/notification.html.erb
new file mode 100644
index 0000000..b75020d
--- /dev/null
+++ b/app/views/blog/comment_mailer/notification.html.erb
@@ -0,0 +1,17 @@
+<%= t('.greeting') %>,
+
+<%= t('.you_recieved_new_comment') %>
+
+<%= t('.comment_starts') %>
+
+<%= t('.from') %>: <%= @comment.name %>
+<%= t('.email') %>: <%= @comment.email %>
+<%= t('.message') %>:
+<%= @comment.body %>
+
+<%= t('.comment_ends') %>
+
+<%= t('.closing_line') %>,
+<%= RefinerySetting[:site_name] %>
+
+<%= t('.ps') %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index f4a6659..d12605c 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -72,6 +72,17 @@ en:
moderation: Moderation
update_notified: Update who gets notified
blog:
+ comment_mailer:
+ notification:
+ greeting: Hi there
+ you_recieved_new_comment: You just received a new comment on your website.
+ comment_starts: --- comment starts ---
+ comment_ends: --- comment ends ---
+ from: From
+ email: Email
+ message: Message
+ closing_line: Kind Regards
+ ps: P.S. All your comments are stored in the "Blog" section of Refinery under the "Comments" submenu should you ever want to view it later there.
shared:
categories:
title: Categories
diff --git a/lib/refinerycms-blog.rb b/lib/refinerycms-blog.rb
index 427fcfa..cc59376 100644
--- a/lib/refinerycms-blog.rb
+++ b/lib/refinerycms-blog.rb
@@ -42,7 +42,7 @@ module Refinery
class << self
def version
- %q{1.0.rc15}
+ %q{1.0.rc16}
end
end
end
diff --git a/readme.md b/readme.md
index e53a939..d3f2114 100644
--- a/readme.md
+++ b/readme.md
@@ -11,7 +11,7 @@ Options:
Open up your ``Gemfile`` and add at the bottom this line
- gem 'refinerycms-blog', '~> 1.0.rc15'
+ gem 'refinerycms-blog', '~> 1.0.rc16'
Now run ``bundle install``
diff --git a/refinerycms-blog.gemspec b/refinerycms-blog.gemspec
index 2cfb9c6..27c304f 100644
--- a/refinerycms-blog.gemspec
+++ b/refinerycms-blog.gemspec
@@ -1,8 +1,8 @@
Gem::Specification.new do |s|
s.name = %q{refinerycms-blog}
- s.version = %q{1.0.rc15}
+ s.version = %q{1.0.rc16}
s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.}
- s.date = %q{2010-11-12}
+ s.date = %q{2010-11-15}
s.summary = %q{Ruby on Rails blogging engine for RefineryCMS.}
s.email = %q{info@refinerycms.com}
s.homepage = %q{http://refinerycms.com}
@@ -24,7 +24,12 @@ Gem::Specification.new do |s|
app/controllers/blog/categories_controller.rb
app/controllers/blog/posts_controller.rb
app/controllers/blog_controller.rb
+ app/mailers
+ app/mailers/blog
+ app/mailers/blog/comment_mailer.rb
app/models
+ app/models/blog
+ app/models/blog/comment_mailer.rb
app/models/blog_category.rb
app/models/blog_comment.rb
app/models/blog_post.rb
@@ -56,6 +61,8 @@ Gem::Specification.new do |s|
app/views/blog
app/views/blog/categories
app/views/blog/categories/show.html.erb
+ app/views/blog/comment_mailer
+ app/views/blog/comment_mailer/notification.html.erb
app/views/blog/posts
app/views/blog/posts/_comment.html.erb
app/views/blog/posts/index.html.erb