diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-12 17:44:38 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-12 17:44:38 -0400 |
commit | 17d660fd4b8516d6b446f7c41d7b076a29a242a1 (patch) | |
tree | 115e7f3c1a3aa5bdc29dfa6d0c994eb795c658f6 /app | |
parent | 835af696703484208882a70cc5dd47c5838ecf58 (diff) | |
download | thoughts-17d660fd4b8516d6b446f7c41d7b076a29a242a1.tar.gz thoughts-17d660fd4b8516d6b446f7c41d7b076a29a242a1.tar.bz2 thoughts-17d660fd4b8516d6b446f7c41d7b076a29a242a1.zip |
Added comment deleting
Also I seem to have fixed the JS errors that were preventing the fancy stuff in the admin panel from working.
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin/comments_controller.rb | 23 | ||||
-rw-r--r-- | app/helpers/admin/comments_helper.rb | 2 | ||||
-rw-r--r-- | app/views/admin/comments/index.html.haml | 23 | ||||
-rw-r--r-- | app/views/comments/_comment.html.haml | 2 | ||||
-rw-r--r-- | app/views/layouts/admin.html.haml | 2 |
5 files changed, 51 insertions, 1 deletions
diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb new file mode 100644 index 0000000..bd255ad --- /dev/null +++ b/app/controllers/admin/comments_controller.rb | |||
@@ -0,0 +1,23 @@ | |||
1 | class Admin::CommentsController < Admin::AdminController | ||
2 | before_action :set_section | ||
3 | |||
4 | def index | ||
5 | @comments = Comment.order(updated_at: :desc).paginate(page: params[:page], per_page: 20) | ||
6 | end | ||
7 | |||
8 | def destroy | ||
9 | if Comment.destroy(params[:id]) | ||
10 | flash.notice = "Comment successfully deleted." | ||
11 | else | ||
12 | flash.alert = "Could not delete comment." | ||
13 | end | ||
14 | |||
15 | redirect_to admin_comments_url | ||
16 | end | ||
17 | |||
18 | private | ||
19 | |||
20 | def set_section | ||
21 | @section = "comments" | ||
22 | end | ||
23 | end | ||
diff --git a/app/helpers/admin/comments_helper.rb b/app/helpers/admin/comments_helper.rb new file mode 100644 index 0000000..ce9444d --- /dev/null +++ b/app/helpers/admin/comments_helper.rb | |||
@@ -0,0 +1,2 @@ | |||
1 | module Admin::CommentsHelper | ||
2 | end | ||
diff --git a/app/views/admin/comments/index.html.haml b/app/views/admin/comments/index.html.haml new file mode 100644 index 0000000..7b25c05 --- /dev/null +++ b/app/views/admin/comments/index.html.haml | |||
@@ -0,0 +1,23 @@ | |||
1 | - title "Comments" | ||
2 | %table#entries | ||
3 | %tr | ||
4 | %th Text | ||
5 | %th Author | ||
6 | %th Blog post | ||
7 | %th Date published | ||
8 | %th | ||
9 | - @comments.each do |comment| | ||
10 | %tr{ class: cycle("even", "odd") } | ||
11 | %td= comment.body | ||
12 | %td | ||
13 | %ul | ||
14 | %li= comment.username | ||
15 | %li= comment.email | ||
16 | - unless comment.website.empty? | ||
17 | %li= comment.website | ||
18 | %td= link_to comment.blog.title, comment.blog | ||
19 | %td= comment.published_at.strftime("%B %d, %Y, %l:%M%P") | ||
20 | %td | ||
21 | %ul.admin-actions | ||
22 | %li= link_to "View", blog_url(comment.blog, anchor: "comment-#{comment.id}") | ||
23 | %li= link_to "Delete", admin_comment_url(comment), method: :delete, data: { confirm: "Are you sure?" } | ||
diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml index 3e10759..3ad21e9 100644 --- a/app/views/comments/_comment.html.haml +++ b/app/views/comments/_comment.html.haml | |||
@@ -1,4 +1,4 @@ | |||
1 | .blog-comment | 1 | .blog-comment{ id: "comment-#{comment.id}" } |
2 | %blockquote.bubble.rounded.bottom | 2 | %blockquote.bubble.rounded.bottom |
3 | = image_tag comment.gravatar_url, class: "comment-avatar" | 3 | = image_tag comment.gravatar_url, class: "comment-avatar" |
4 | = markdown(comment.body, { restricted: true }) | 4 | = markdown(comment.body, { restricted: true }) |
diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 1c865b0..5d75ef5 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml | |||
@@ -37,5 +37,7 @@ | |||
37 | = link_to "Games", admin_games_url, class: "major-link" | 37 | = link_to "Games", admin_games_url, class: "major-link" |
38 | %ul.minors | 38 | %ul.minors |
39 | %li.minor= link_to "New game", new_admin_game_url | 39 | %li.minor= link_to "New game", new_admin_game_url |
40 | %li{major_sidebar_attrs("comments")} | ||
41 | = link_to "Comments", admin_comments_url, class: "major-link" | ||
40 | #main | 42 | #main |
41 | = yield | 43 | = yield |