diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 9dcd753d9..32b6af649 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -81,7 +81,6 @@ private @posts = Post.where("last_comment_bumped_at IS NOT NULL").tag_match(params[:tags]).reorder("last_comment_bumped_at DESC NULLS LAST").paginate(params[:page], :limit => 5, :search_count => params[:search]) @posts.each # hack to force rails to eager load respond_with(@posts) do |format| - format.html {render :action => "index_by_post"} format.xml do render :xml => @posts.to_xml(:root => "posts") end @@ -91,10 +90,8 @@ private def index_by_comment @comments = Comment.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@comments) do |format| - format.html {render :action => "index_by_comment"} format.atom do @comments = @comments.includes(:post, :creator).load - render :action => "index" end format.xml do render :xml => @comments.to_xml(:root => "comments") diff --git a/app/views/comments/_index_by_comment.html.erb b/app/views/comments/_index_by_comment.html.erb new file mode 100644 index 000000000..6f7b13eae --- /dev/null +++ b/app/views/comments/_index_by_comment.html.erb @@ -0,0 +1,21 @@ +
+
+ <% @comments.each do |comment| %> + <% if CurrentUser.is_moderator? || !comment.is_deleted? %> +
> +
+ <% if comment.post.visible? %> + <%= link_to(image_tag(comment.post.preview_file_url), post_path(comment.post)) %> + <% end %> +
+ <%= render :partial => "comments/partials/show/comment", :collection => [comment] %> +
+
+ <% end %> + <% end %> +
+
+ +<%= numbered_paginator(@comments) %> + +<% content_for(:html_header, auto_discovery_link_tag(:atom, comments_url(:atom, search: params[:search]), title: "Comments")) %> diff --git a/app/views/comments/_index_by_post.html.erb b/app/views/comments/_index_by_post.html.erb new file mode 100644 index 000000000..53847370e --- /dev/null +++ b/app/views/comments/_index_by_post.html.erb @@ -0,0 +1,29 @@ +
+ <% if !CurrentUser.user.is_builder? %> +
+

Before commenting, read the <%= link_to "how to comment guide", wiki_pages_path(:search => {:title => "howto:comment"}) %>.

+
+ <% end %> + + <% if @posts.empty? %> + <%= render "post_sets/blank" %> + <% end %> + + <% @posts.select {|x| x.visible?}.each do |post| %> + <% if CurrentUser.is_moderator? || post.comments.undeleted.exists? %> +
> +
+ <% if post.visible? %> + <%= link_to(image_tag(post.preview_file_url), post_path(post)) %> + <% end %> +
+ <%= render "comments/partials/index/list", :post => post, :comments => post.comments.visible(CurrentUser.user).recent.reverse, :show_header => true %> +
+
+ <% end %> + <% end %> +
+ +<%= numbered_paginator(@posts) %> + +<% content_for(:html_header, auto_discovery_link_tag(:atom, comments_url(:atom, search: { do_not_bump_post: true }), title: "Comments")) %> diff --git a/app/views/comments/index.html.erb b/app/views/comments/index.html.erb new file mode 100644 index 000000000..9a07aafc5 --- /dev/null +++ b/app/views/comments/index.html.erb @@ -0,0 +1,19 @@ +
+
+

Comments

+ + <%= render "posts/partials/common/inline_blacklist" %> + + <% if params[:group_by] == "comment" %> + <%= render "index_by_comment" %> + <% else %> + <%= render "index_by_post" %> + <% end %> +
+
+ +<%= render "comments/secondary_links" %> + +<% content_for(:page_title) do %> + Comments - <%= Danbooru.config.app_name %> +<% end %> diff --git a/app/views/comments/index_by_comment.html.erb b/app/views/comments/index_by_comment.html.erb deleted file mode 100644 index 186dad6fa..000000000 --- a/app/views/comments/index_by_comment.html.erb +++ /dev/null @@ -1,35 +0,0 @@ -
-
-

Comments

- - <%= render "posts/partials/common/inline_blacklist" %> - -
-
- <% @comments.each do |comment| %> - <% if CurrentUser.is_moderator? || !comment.is_deleted? %> -
> -
- <% if comment.post.visible? %> - <%= link_to(image_tag(comment.post.preview_file_url), post_path(comment.post)) %> - <% end %> -
- <%= render :partial => "comments/partials/show/comment", :collection => [comment] %> -
-
- <% end %> - <% end %> -
-
- - <%= numbered_paginator(@comments) %> -
-
- -<%= render "comments/secondary_links" %> - -<% content_for(:page_title) do %> - Comments - <%= Danbooru.config.app_name %> -<% end %> - -<% content_for(:html_header, auto_discovery_link_tag(:atom, comments_url(:atom, search: params[:search]), title: "Comments")) %> diff --git a/app/views/comments/index_by_post.html.erb b/app/views/comments/index_by_post.html.erb deleted file mode 100644 index 3a496249b..000000000 --- a/app/views/comments/index_by_post.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -
-
-

Comments

- - <%= render "posts/partials/common/inline_blacklist" %> - - <% if !CurrentUser.user.is_builder? %> -
-

Before commenting, read the <%= link_to "how to comment guide", wiki_pages_path(:search => {:title => "howto:comment"}) %>.

-
- <% end %> - - <% if @posts.empty? %> - <%= render "post_sets/blank" %> - <% end %> - - <% @posts.select {|x| x.visible?}.each do |post| %> - <% if CurrentUser.is_moderator? || post.comments.undeleted.exists? %> -
> -
- <% if post.visible? %> - <%= link_to(image_tag(post.preview_file_url), post_path(post)) %> - <% end %> -
- <%= render "comments/partials/index/list", :post => post, :comments => post.comments.visible(CurrentUser.user).recent.reverse, :show_header => true %> -
-
- <% end %> - <% end %> - - <%= numbered_paginator(@posts) %> -
-
- -<%= render "comments/secondary_links" %> - -<% content_for(:page_title) do %> - Comments - <%= Danbooru.config.app_name %> -<% end %> - -<% content_for(:html_header, auto_discovery_link_tag(:atom, comments_url(:atom, search: { do_not_bump_post: true }), title: "Comments")) %>