The name `safe_html_with_links` was confusing and could make you think it takes care of making the HTML safe. So I've renamed it in a way that makes it a bit more intuitive that it expects its input to be already sanitized. I've changed `text_with_links` as well so now the two method names complement each other.
141 lines
6.3 KiB
Plaintext
141 lines
6.3 KiB
Plaintext
<% comment_flags ||= @comment_flags %>
|
|
<% valuation = local_assigns.fetch(:valuation, false) %>
|
|
<% allow_votes = local_assigns.fetch(:allow_votes, true) %>
|
|
<% allow_actions = local_assigns.fetch(:allow_actions, true) %>
|
|
<% allow_comments = local_assigns.fetch(:allow_comments, true) %>
|
|
<% admin_layout = local_assigns.fetch(:admin_layout, false) %>
|
|
<% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (comment_flags[comment.id] if comment_flags), (admin_layout if admin_layout)] do %>
|
|
<ul id="<%= dom_id(comment) %>" class="comment no-bullet small-12">
|
|
<li class="comment-body">
|
|
<% if comment.hidden? || comment.user.hidden? %>
|
|
<% if comment.children.size > 0 %>
|
|
<div class="callout secondary">
|
|
<p><%= t("comments.comment.deleted") %></p>
|
|
</div>
|
|
<% end %>
|
|
<% else %>
|
|
<% if comment.as_administrator? %>
|
|
<%= image_tag("avatar_admin.png", size: 32, class: "admin-avatar float-left") %>
|
|
<% elsif comment.as_moderator? %>
|
|
<%= image_tag("avatar_moderator.png", size: 32, class: "moderator-avatar float-left") %>
|
|
<% else %>
|
|
<% if comment.user.hidden? || comment.user.erased? %>
|
|
<span class="icon-deleted user-deleted"></span>
|
|
<% elsif comment.user.organization? %>
|
|
<%= image_tag("avatar_collective.png", size: 32, class: "avatar float-left") %>
|
|
<% else %>
|
|
<%= avatar_image(comment.user, seed: comment.user_id, size: 32, class: "float-left") %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<div class="comment-info">
|
|
|
|
<% if comment.as_administrator? %>
|
|
<span class="user-name">
|
|
<%= t("comments.comment.admin") %>
|
|
<% if admin_layout %>
|
|
<%= Administrator.find(comment.administrator_id).description_or_name %>
|
|
<% else %>
|
|
#<%= comment.administrator_id %>
|
|
<% end %>
|
|
</span>
|
|
<% elsif comment.as_moderator? %>
|
|
<span class="user-name"><%= t("comments.comment.moderator") %> #<%= comment.moderator_id %></span>
|
|
<% else %>
|
|
|
|
<% if comment.user.hidden? || comment.user.erased? %>
|
|
<span class="user-name"><%= t("comments.comment.user_deleted") %></span>
|
|
<% else %>
|
|
<span class="user-name"><%= link_to comment.user.name, user_path(comment.user) %></span>
|
|
<% if comment.user.display_official_position_badge? %>
|
|
•
|
|
<span class="label round level-<%= comment.user.official_level %>">
|
|
<%= comment.user.official_position %>
|
|
</span>
|
|
<% end %>
|
|
<% end %>
|
|
<% if comment.user.verified_organization? %>
|
|
•
|
|
<span class="label round is-association">
|
|
<%= t("shared.collective") %>
|
|
</span>
|
|
<% end %>
|
|
<% if comment.user_id == comment.commentable.author_id %>
|
|
•
|
|
<span class="label round is-author">
|
|
<%= t("comments.comment.author") %>
|
|
</span>
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
•
|
|
<span>
|
|
<%= link_to comment_path(comment) do %>
|
|
<%= l comment.created_at.to_datetime, format: :datetime %>
|
|
<% end %>
|
|
</span>
|
|
</div>
|
|
|
|
<div class="comment-user
|
|
<%= user_level_class comment %>
|
|
<%= comment_author_class comment, comment.commentable.author_id %>">
|
|
<%= simple_format sanitize_and_auto_link(comment.body), {}, sanitize: false %>
|
|
</div>
|
|
|
|
<div id="<%= dom_id(comment) %>_reply" class="reply">
|
|
<% if allow_votes %>
|
|
<div id="<%= dom_id(comment) %>_votes" class="comment-votes float-right">
|
|
<%= render "comments/votes", comment: comment %>
|
|
</div>
|
|
<% end %>
|
|
|
|
<% if comment.children.size > 0 %>
|
|
<%= link_to "", class: "js-toggle-children relative", data: { "id": "#{dom_id(comment)}" } do %>
|
|
<span class="show-for-sr js-child-toggle" style="display: none;"><%= t("shared.show") %></span>
|
|
<span class="show-for-sr js-child-toggle"><%= t("shared.hide") %></span>
|
|
<span id="<%= dom_id(comment) %>_children_arrow" class="icon-arrow-down"></span>
|
|
<span class="js-child-toggle" style="display: none;"><%= t("comments.comment.responses_show", count: comment.children.size) %></span>
|
|
<span class="js-child-toggle"><%= t("comments.comment.responses_collapse", count: comment.children.size) %></span>
|
|
<% end %>
|
|
<% else %>
|
|
<%= t("comments.comment.responses", count: 0) %>
|
|
<% end %>
|
|
|
|
<% if user_signed_in? && !comments_closed_for_commentable?(comment.commentable) && !require_verified_resident_for_commentable?(comment.commentable, current_user) %>
|
|
<span class="divider"> | </span>
|
|
<%= link_to(comment_link_text(comment), "",
|
|
class: "js-add-comment-link", data: { "id": dom_id(comment) }) %>
|
|
|
|
<% if allow_actions %>
|
|
<%= render "comments/actions", { comment: comment } %>
|
|
<% end %>
|
|
|
|
<% if allow_comments %>
|
|
<%= render "comments/form", { commentable: comment.commentable,
|
|
parent_id: comment.id,
|
|
toggeable: true,
|
|
valuation: valuation } %>
|
|
<% end %>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
</li>
|
|
<% unless child_comments_of(comment).empty? %>
|
|
<li>
|
|
<ul id="<%= dom_id(comment) %>_children" class="no-bullet comment-children">
|
|
<% child_comments_of(comment).each do |child| %>
|
|
<li>
|
|
<%= render "comments/comment", { comment: child,
|
|
valuation: valuation,
|
|
allow_votes: allow_votes,
|
|
allow_actions: allow_actions,
|
|
allow_comments: allow_comments } %>
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
<% end %>
|