Factor out FontAwesome icons into a set of helpers. This is so that it's easier to keep track of which icons we're using and easier to change icons globally.
125 lines
5.1 KiB
Plaintext
125 lines
5.1 KiB
Plaintext
<a name="comment-<%= comment.id %>"></a>
|
|
<article id="comment_<%= comment.id %>" class="comment message"
|
|
data-id="<%= comment.id %>"
|
|
data-post-id="<%= comment.post_id %>"
|
|
data-creator-id="<%= comment.creator_id unless redact_deleted? %>"
|
|
data-updater-id="<%= comment.updater_id unless redact_deleted? %>"
|
|
data-score="<%= comment.score %>"
|
|
data-do-not-bump-post="<%= comment.do_not_bump_post? %>"
|
|
data-is-deleted="<%= comment.is_deleted? %>"
|
|
data-is-sticky="<%= comment.is_sticky? %>"
|
|
data-is-dimmed="<%= dimmed? %>"
|
|
data-is-thresholded="<%= thresholded? %>"
|
|
data-is-reported="<%= reported? %>"
|
|
data-is-upvoted="<%= upvoted? %>"
|
|
data-is-downvoted="<%= downvoted? %>">
|
|
|
|
<div class="author">
|
|
<div class="author-name">
|
|
<% if redact_deleted? %>
|
|
[deleted]
|
|
<% else %>
|
|
<%= link_to_user comment.creator %>
|
|
<% if comment.is_deleted? %>
|
|
(deleted)
|
|
<% end %>
|
|
<% end %>
|
|
</div>
|
|
<%= link_to time_ago_in_words_tagged(comment.created_at), post_path(comment.post, anchor: "comment_#{comment.id}"), class: "message-timestamp" %>
|
|
</div>
|
|
|
|
<div class="content">
|
|
<% if thresholded? %>
|
|
<%= link_to "[hidden]", "javascript:void(0)", class: "unhide-comment-link" %>
|
|
<% end %>
|
|
|
|
<%= tag.div class: "body prose", style: ("display: none;" if thresholded?) do %>
|
|
<% if redact_deleted? %>
|
|
<p>[deleted]</p>
|
|
<% else %>
|
|
<%= format_text(comment.body, data: dtext_data) %>
|
|
<% end %>
|
|
|
|
<%= render "application/update_notice", record: comment %>
|
|
<% end %>
|
|
|
|
<menu>
|
|
<% if votable? %>
|
|
<li class="comment-votes">
|
|
<% if current_user.is_anonymous? %>
|
|
<%= link_to "🡹", login_path(url: request.fullpath), class: "comment-upvote-link" %>
|
|
<% elsif upvoted? %>
|
|
<%= link_to "🡹", comment_comment_votes_path(comment_id: comment.id), class: "comment-upvote-link comment-unvote-link", method: :delete, remote: true %>
|
|
<% else %>
|
|
<%= link_to "🡹", comment_comment_votes_path(comment_id: comment.id, score: "1"), class: "comment-upvote-link", method: :post, remote: true %>
|
|
<% end %>
|
|
|
|
<span class="comment-score"><%= comment.score %></span>
|
|
|
|
<% if current_user.is_anonymous? %>
|
|
<%= link_to "🡻", login_path(url: request.fullpath), class: "comment-downvote-link" %>
|
|
<% elsif downvoted? %>
|
|
<%= link_to "🡻", comment_comment_votes_path(comment_id: comment.id), class: "comment-downvote-link comment-unvote-link", method: :delete, remote: true %>
|
|
<% else %>
|
|
<%= link_to "🡻", comment_comment_votes_path(comment_id: comment.id, score: "-1"), class: "comment-downvote-link", method: :post, remote: true %>
|
|
<% end %>
|
|
</li>
|
|
<% end %>
|
|
|
|
<% if policy(comment).reply? %>
|
|
<li class="comment-reply">
|
|
<% if current_user.is_anonymous? %>
|
|
<%= link_to "Reply", login_path(url: request.fullpath) %>
|
|
<% elsif context == :index_by_comment %>
|
|
<%= link_to "Reply", new_comment_path(id: comment, comment: { post_id: comment.post_id }) %>
|
|
<% else %>
|
|
<%= link_to "Reply", new_comment_path(id: comment, comment: { post_id: comment.post_id }), remote: true %>
|
|
<% end %>
|
|
</li>
|
|
<% end %>
|
|
|
|
<% if reported? %>
|
|
<li class="moderation-report-notice">
|
|
Reported (<%= link_to pluralize(comment.moderation_reports.length, "report"), moderation_reports_path(search: { model_type: "Comment", model_id: comment.id }) %>)
|
|
</li>
|
|
<% end %>
|
|
|
|
<% if policy(comment).update? || policy(comment).reportable? %>
|
|
<%= render PopupMenuComponent.new do |menu| %>
|
|
<% if policy(comment).update? %>
|
|
<%= menu.item do %>
|
|
<%= link_to edit_comment_path(comment.id), id: "edit_comment_link_#{comment.id}", class: "edit_comment_link" do %>
|
|
<%= edit_icon %> Edit
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<%= menu.item do %>
|
|
<% if comment.is_deleted? %>
|
|
<%= link_to undelete_comment_path(comment.id), method: :post, remote: true do %>
|
|
<%= undelete_icon %> Undelete
|
|
<% end %>
|
|
<% else %>
|
|
<%= link_to comment_path(comment.id), "data-confirm": "Are you sure you want to delete this comment?", method: :delete, remote: true do %>
|
|
<%= delete_icon %> Delete
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<% if policy(comment).reportable? %>
|
|
<%= menu.item do %>
|
|
<%= link_to new_moderation_report_path(moderation_report: { model_type: "Comment", model_id: comment.id }), remote: true do %>
|
|
<%= flag_icon %> Report
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
</menu>
|
|
|
|
<% if policy(comment).update? %>
|
|
<%= render "comments/form", comment: comment, hidden: true %>
|
|
<% end %>
|
|
</div>
|
|
</article>
|