diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/comments_controller.rb | 2 | ||||
-rw-r--r-- | app/mailers/comment_mailer.rb | 6 | ||||
-rw-r--r-- | app/views/comment_mailer/new_pending_comment_email.html.haml | 22 | ||||
-rw-r--r-- | app/views/comment_mailer/new_pending_comment_email.text.erb | 19 |
4 files changed, 49 insertions, 0 deletions
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index c66365b..a444dba 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb | |||
@@ -46,6 +46,8 @@ class CommentsController < ApplicationController | |||
46 | 46 | ||
47 | if @comment.status == :published | 47 | if @comment.status == :published |
48 | CommentMailer.with(comment: @comment).new_comment_email.deliver_later | 48 | CommentMailer.with(comment: @comment).new_comment_email.deliver_later |
49 | else | ||
50 | CommentMailer.with(comment: @comment).new_pending_comment_email.deliver_later | ||
49 | end | 51 | end |
50 | else | 52 | else |
51 | flash.alert = "Error posting comment." | 53 | flash.alert = "Error posting comment." |
diff --git a/app/mailers/comment_mailer.rb b/app/mailers/comment_mailer.rb index 363875a..e72b17d 100644 --- a/app/mailers/comment_mailer.rb +++ b/app/mailers/comment_mailer.rb | |||
@@ -4,4 +4,10 @@ class CommentMailer < ApplicationMailer | |||
4 | @admin = User.first # this is weird | 4 | @admin = User.first # this is weird |
5 | mail(to: @admin.email, subject: "[Four Island] Comment on #{@comment.blog.title}") | 5 | mail(to: @admin.email, subject: "[Four Island] Comment on #{@comment.blog.title}") |
6 | end | 6 | end |
7 | |||
8 | def new_pending_comment_email | ||
9 | @comment = params[:comment] | ||
10 | @admin = User.first # this is weird | ||
11 | mail(to: @admin.email, subject: "[Four Island] Pending comment on #{@comment.blog.title}") | ||
12 | end | ||
7 | end | 13 | end |
diff --git a/app/views/comment_mailer/new_pending_comment_email.html.haml b/app/views/comment_mailer/new_pending_comment_email.html.haml new file mode 100644 index 0000000..d3f7dca --- /dev/null +++ b/app/views/comment_mailer/new_pending_comment_email.html.haml | |||
@@ -0,0 +1,22 @@ | |||
1 | %p | ||
2 | A new comment has been posted on | ||
3 | = link_to @comment.blog.title, @comment.blog | ||
4 | that is pending moderation. | ||
5 | %p The details of the user that posted it: | ||
6 | %ul | ||
7 | %li | ||
8 | Name: | ||
9 | = @comment.username | ||
10 | %li | ||
11 | Email: | ||
12 | = @comment.email | ||
13 | - unless @comment.website.empty? | ||
14 | %li | ||
15 | Website: | ||
16 | = @comment.website | ||
17 | %p Here is the comment: | ||
18 | %blockquote= @comment.body | ||
19 | %p | ||
20 | Posted: | ||
21 | = @comment.created_at.strftime("%B #{@comment.created_at.day.ordinalize}, %Y at %-I:%M:%S%P") | ||
22 | %p= link_to "Go to the admin panel", pending_admin_comments_url | ||
diff --git a/app/views/comment_mailer/new_pending_comment_email.text.erb b/app/views/comment_mailer/new_pending_comment_email.text.erb new file mode 100644 index 0000000..787d6b8 --- /dev/null +++ b/app/views/comment_mailer/new_pending_comment_email.text.erb | |||
@@ -0,0 +1,19 @@ | |||
1 | A comment has been posted on <%= @comment.blog.title %> that is pending moderation. | ||
2 | |||
3 | The details of the user that posted it: | ||
4 | |||
5 | * Name: <%= @comment.username %> | ||
6 | * Email: <%= @comment.email %> | ||
7 | <% unless @comment.website.empty? %>* Website: <%= @comment.website %> | ||
8 | <% end %> | ||
9 | Here is the comment: | ||
10 | |||
11 | --- | ||
12 | |||
13 | <%= @comment.body %> | ||
14 | |||
15 | --- | ||
16 | |||
17 | Posted: <%= @comment.created_at.strftime("%B #{@comment.created_at.day.ordinalize}, %Y at %-I:%M:%S%P") %> | ||
18 | |||
19 | Go to the admin panel: <%= pending_admin_comments_url %> | ||