From dfb7cf69944ffa8c816d917a8f0e8b8041d62159 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 29 Sep 2018 14:24:17 -0500 Subject: [PATCH] comments: add standalone new comment form. Add standalone /comments/new page to allow commenting if javascript is disabled. --- app/controllers/comments_controller.rb | 2 +- app/views/comments/new.html.erb | 13 +++++++++++++ app/views/comments/partials/index/_list.html.erb | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 app/views/comments/new.html.erb diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 5714fcbab..ad8767907 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -106,6 +106,6 @@ private permitted_params += %i[is_deleted] if context == :update permitted_params += %i[is_sticky] if CurrentUser.is_moderator? - params.require(:comment).permit(permitted_params) + params.fetch(:comment, {}).permit(permitted_params) end end diff --git a/app/views/comments/new.html.erb b/app/views/comments/new.html.erb new file mode 100644 index 000000000..25082c265 --- /dev/null +++ b/app/views/comments/new.html.erb @@ -0,0 +1,13 @@ +
+
+

New Comment

+ + <%= render "comments/form", comment: @comment %> +
+
+ +<%= render "secondary_links" %> + +<% content_for(:page_title) do %> + New Comment - <%= Danbooru.config.app_name %> +<% end %> diff --git a/app/views/comments/partials/index/_list.html.erb b/app/views/comments/partials/index/_list.html.erb index 5c3d7193f..20d1d299e 100644 --- a/app/views/comments/partials/index/_list.html.erb +++ b/app/views/comments/partials/index/_list.html.erb @@ -27,7 +27,7 @@ <% if CurrentUser.is_member? %>
-

<%= link_to "Post comment", new_comment_path, :class => "expand-comment-response" %>

+

<%= link_to "Post comment", new_comment_path(comment: { post_id: post.id }), :class => "expand-comment-response" %>

<%= render "comments/form", comment: post.comments.new, hidden: true %>
<% end %>