Files
danbooru/app/views/comments/_index_by_comment.html.erb
evazion 1b30b71a07 posts: refactor post previews to use ViewComponent.
Refactor the post preview html to use the ViewComponent framework. This
lets us encapsulate all the HTML, CSS, and helper methods for a UI
component in a single place.

See https://viewcomponent.org.
2021-01-14 21:17:57 -06:00

19 lines
921 B
Plaintext

<div id="p-index-by-comment" class="comments-for-post">
<div class="list-of-comments list-of-messages">
<% @comments.each do |comment| %>
<% if CurrentUser.is_moderator? || (params[:search] && params[:search][:is_deleted] =~ /t/) || !comment.is_deleted? %>
<%= tag.div id: "post_#{comment.post.id}", **PostPreviewComponent.new(post: comment.post).article_attrs("post") do %>
<div class="preview">
<% if policy(comment.post).visible? %>
<%= link_to(image_tag(comment.post.preview_file_url), post_path(comment.post)) %>
<% end %>
</div>
<%= render partial: "comments/partials/show/comment", collection: [comment], locals: { context: :index_by_comment, dtext_data: DText.preprocess(@comments.map(&:body)), moderation_reports: [] } %>
<% end %>
<% end %>
<% end %>
</div>
</div>
<%= numbered_paginator(@comments) %>