refinerycms-blog 1.0.rc15 → 1.0.rc16

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,18 @@ class Blog::PostsController < BlogController
17
17
 
18
18
  def comment
19
19
  if (@blog_comment = @blog_post.comments.create(params[:blog_comment])).valid?
20
+ if BlogComment::Moderation.enabled? or @blog_comment.ham?
21
+ begin
22
+ if Rails.version < '3.0.0'
23
+ Blog::CommentMailer.deliver_notification(@blog_comment, request)
24
+ else
25
+ Blog::CommentMailer.notification(@blog_comment, request).deliver
26
+ end
27
+ rescue
28
+ logger.warn "There was an error delivering a blog comment notification.\n#{$!}\n"
29
+ end
30
+ end
31
+
20
32
  if BlogComment::Moderation.enabled?
21
33
  flash[:notice] = t('blog.posts.comments.thank_you_moderated')
22
34
  redirect_to blog_post_url(params[:id])
@@ -0,0 +1,11 @@
1
+ class Blog::CommentMailer < ActionMailer::Base
2
+
3
+ def notification(comment, request)
4
+ subject BlogComment::Notification.subject
5
+ recipients BlogComment::Notification.recipients
6
+ from "\"#{RefinerySetting[:site_name]}\" <no-reply@#{request.domain(RefinerySetting.find_or_set(:tld_length, 1))}>"
7
+ sent_on Time.now
8
+ @comment = comment
9
+ end
10
+
11
+ end
@@ -0,0 +1 @@
1
+ require File.expand_path('../../../mailers/blog/comment_mailer', __FILE__)
@@ -46,7 +46,7 @@ class BlogComment < ActiveRecord::Base
46
46
 
47
47
  before_create do |comment|
48
48
  unless BlogComment::Moderation.enabled?
49
- comment.state = comment.spam? ? 'rejected' : 'approved'
49
+ comment.state = comment.ham? ? 'approved' : 'rejected'
50
50
  end
51
51
  end
52
52
 
@@ -55,8 +55,7 @@ class BlogComment < ActiveRecord::Base
55
55
  def enabled?
56
56
  RefinerySetting.find_or_set(:comment_moderation, true, {
57
57
  :scoping => :blog,
58
- :restricted => false,
59
- :callback_proc_as_string => nil
58
+ :restricted => false
60
59
  })
61
60
  end
62
61
 
@@ -64,8 +63,7 @@ class BlogComment < ActiveRecord::Base
64
63
  RefinerySetting[:comment_moderation] = {
65
64
  :value => !self.enabled?,
66
65
  :scoping => :blog,
67
- :restricted => false,
68
- :callback_proc_as_string => nil
66
+ :restricted => false
69
67
  }
70
68
  end
71
69
  end
@@ -74,21 +72,33 @@ class BlogComment < ActiveRecord::Base
74
72
  module Notification
75
73
  class << self
76
74
  def recipients
77
- RefinerySetting.find_or_set(:comment_notification_recipients,
78
- (Role[:refinery].users.first.email rescue ''),
79
- {
80
- :scoping => :blog,
81
- :restricted => false,
82
- :callback_proc_as_string => nil
83
- })
75
+ RefinerySetting.find_or_set(:comment_notification_recipients, (Role[:refinery].users.first.email rescue ''),
76
+ {
77
+ :scoping => :blog,
78
+ :restricted => false
79
+ })
84
80
  end
85
81
 
86
82
  def recipients=(emails)
87
83
  RefinerySetting[:comment_notification_recipients] = {
88
84
  :value => emails,
89
85
  :scoping => :blog,
90
- :restricted => false,
91
- :callback_proc_as_string => nil
86
+ :restricted => false
87
+ }
88
+ end
89
+
90
+ def subject
91
+ RefinerySetting.find_or_set(:comment_notification_subject, "New inquiry from your website", {
92
+ :scoping => :blog,
93
+ :restricted => false
94
+ })
95
+ end
96
+
97
+ def subject=(subject_line)
98
+ RefinerySetting[:comment_notification_subject] = {
99
+ :value => subject_line,
100
+ :scoping => :blog,
101
+ :restricted => false
92
102
  }
93
103
  end
94
104
  end
@@ -0,0 +1,17 @@
1
+ <%= t('.greeting') %>,
2
+
3
+ <%= t('.you_recieved_new_comment') %>
4
+
5
+ <%= t('.comment_starts') %>
6
+
7
+ <%= t('.from') %>: <%= @comment.name %>
8
+ <%= t('.email') %>: <%= @comment.email %>
9
+ <%= t('.message') %>:
10
+ <%= @comment.body %>
11
+
12
+ <%= t('.comment_ends') %>
13
+
14
+ <%= t('.closing_line') %>,
15
+ <%= RefinerySetting[:site_name] %>
16
+
17
+ <%= t('.ps') %>
@@ -72,6 +72,17 @@ en:
72
72
  moderation: Moderation
73
73
  update_notified: Update who gets notified
74
74
  blog:
75
+ comment_mailer:
76
+ notification:
77
+ greeting: Hi there
78
+ you_recieved_new_comment: You just received a new comment on your website.
79
+ comment_starts: --- comment starts ---
80
+ comment_ends: --- comment ends ---
81
+ from: From
82
+ email: Email
83
+ message: Message
84
+ closing_line: Kind Regards
85
+ 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.
75
86
  shared:
76
87
  categories:
77
88
  title: Categories
@@ -42,7 +42,7 @@ module Refinery
42
42
 
43
43
  class << self
44
44
  def version
45
- %q{1.0.rc15}
45
+ %q{1.0.rc16}
46
46
  end
47
47
  end
48
48
  end
@@ -48,4 +48,8 @@ ul.collapsible_menu li span.arrow {
48
48
  }
49
49
  ul.collapsible_menu li.closed span.arrow {
50
50
  background-image: url('/images/refinerycms-blog/icons/down.gif');
51
- }
51
+ }
52
+ ul.collapsible_menu > div {
53
+ width: 93%;
54
+ margin: 0px auto;
55
+ }
data/readme.md CHANGED
@@ -11,7 +11,7 @@ Options:
11
11
 
12
12
  Open up your ``Gemfile`` and add at the bottom this line
13
13
 
14
- gem 'refinerycms-blog', '~> 1.0.rc15'
14
+ gem 'refinerycms-blog', '~> 1.0.rc16'
15
15
 
16
16
  Now run ``bundle install``
17
17
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-blog
3
3
  version: !ruby/object:Gem::Version
4
- hash: -398340064
4
+ hash: -398340063
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - rc15
10
- version: 1.0.rc15
9
+ - rc16
10
+ version: 1.0.rc16
11
11
  platform: ruby
12
12
  authors:
13
13
  - Resolve Digital
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-12 00:00:00 +13:00
19
+ date: 2010-11-15 00:00:00 +13:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -67,6 +67,8 @@ files:
67
67
  - app/controllers/blog/categories_controller.rb
68
68
  - app/controllers/blog/posts_controller.rb
69
69
  - app/controllers/blog_controller.rb
70
+ - app/mailers/blog/comment_mailer.rb
71
+ - app/models/blog/comment_mailer.rb
70
72
  - app/models/blog_category.rb
71
73
  - app/models/blog_comment.rb
72
74
  - app/models/blog_post.rb
@@ -89,6 +91,7 @@ files:
89
91
  - app/views/admin/blog/posts/new.html.erb
90
92
  - app/views/admin/blog/settings/notification_recipients.html.erb
91
93
  - app/views/blog/categories/show.html.erb
94
+ - app/views/blog/comment_mailer/notification.html.erb
92
95
  - app/views/blog/posts/_comment.html.erb
93
96
  - app/views/blog/posts/index.html.erb
94
97
  - app/views/blog/posts/index.rss.builder