publiclab/plots2

View on GitHub
app/views/comments/_comments.html.erb

Summary

Maintainability
Test Coverage
<% if comments.count() > 0 %>
  <table class="table">
      <tr>
        <th class="d-lg-none"></th>
        <th><%= translation('users.list.Author') %></th>
        <th><i data-toggle="tooltip" title="Commenting method" class="fa fa-envelope"></i></th>
        <th><%= translation('users.list.comment') %></th>
        <th><%= translation('users.list.last_activity') %></th>

        <% if logged_in_as(['admin', 'moderator']) %>
        <th><%= translation('users.list.moderation') %></th>
        <% else %>
        <th><%= translation('users.list.moderation') %></th>
        <% end %>
      </tr>

    <% comments.each do |comment| %>
     <tr id="c<%= comment.cid %>">
        <td>
          <a href="/profile/<%= comment.author.username %>"> <%=raw strip_tags(sanitize(RDiscount.new(comment.author.username).to_html)).truncate(150) %></a>
        </td>
       <td>
         <% if comment.comment_via == 1 %>
           <i data-toggle="tooltip" title="This comment was posted by email." class="fa fa-envelope"></i>
         <% end %>
       </td>
       <td>
        "<%= raw strip_tags(sanitize(RDiscount.new(comment.comment).to_html)).truncate(150) %>" |
        <% if comment.parent %>
          <a href="<%= comment.parent.path %>#c<%= comment.cid %>"><%= translation('home._comments.read_more') %> &raquo;</a>
        <% end %>
        </td>
      <td><%= distance_of_time_in_words(comment.created_at, Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' }) %></td>
      <td>
        <% if comment.status == 4 && current_user &. can_moderate? %>
        <%= translation('comments._comments.status') %> <%= comment.status_value %>
              <a class="btn btn-outline-secondary btn-sm" href="/admin/publish_comment/<%= comment.id %>"><%= translation('dashboard.moderate.approve') %></a>
              <a class="btn btn-outline-secondary btn-sm" href="/admin/mark_comment_spam/<%= comment.id %>"><%= translation('dashboard.moderate.spam') %></a>
        <% elsif current_user &. can_moderate? %>
        <%= translation('comments._comments.status') %> <%= comment.status_value  %>
            <a rel="tooltip" title="Mark as spam" class="btn btn-sm btn-outline-secondary btn-flag-spam-<%= comment.id %>" data-confirm="Are you sure? The user will no longer be able to log in or publish, and their content will be hidden except comments." href="/admin/mark_comment_spam/<%= comment.id %>">
              <i class="fa fa-ban"></i>
            </a>
        <% else %>
            <a rel="tooltip" title="Flag as spam" class="btn btn-sm btn-outline-secondary btn-flag-spam-<%= comment.id %>" href="/moderate/flag_comment/<%= comment.id %>" data-toggle="tooltip" data-placement="top" title="Flag this Comment">
              <i class="fa fa-flag"></i>
            </a>
        <% end %>
      </td>
    </tr>
    <% end %>
  </table>
<% else %>
<p><%= translation('comments._comments.no_comments') %></p>
<% end %>
<% if @pagy %> <%= raw pagy_bootstrap_nav @pagy %> <% else %> <%= will_paginate comments, renderer: WillPaginate::ActionView::BootstrapLinkRenderer %> <% end %>