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.
- data/app/controllers/blog/posts_controller.rb +12 -0
- data/app/mailers/blog/comment_mailer.rb +11 -0
- data/app/models/blog/comment_mailer.rb +1 -0
- data/app/models/blog_comment.rb +24 -14
- data/app/views/blog/comment_mailer/notification.html.erb +17 -0
- data/config/locales/en.yml +11 -0
- data/lib/refinerycms-blog.rb +1 -1
- data/public/stylesheets/refinery/refinerycms-blog.css +5 -1
- data/readme.md +1 -1
- metadata +7 -4
@@ -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__)
|
data/app/models/blog_comment.rb
CHANGED
@@ -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.
|
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
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
-
|
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') %>
|
data/config/locales/en.yml
CHANGED
@@ -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
|
data/lib/refinerycms-blog.rb
CHANGED
data/readme.md
CHANGED
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: -
|
4
|
+
hash: -398340063
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
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-
|
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
|