sudara/alonetone

View on GitHub
app/views/shared/_comment.html.erb

Summary

Maintainability
Test Coverage
<% if should_display_track_with_comment? %>
  <%= render(partial: 'assets/asset', layout: 'assets/normal_playback',
    locals: { asset: comment.commentable }) if comment.commentable_type == "Asset" %>
<% end %>

<%= div_for comment do %>
  <div class="comment_user">
    <%= user_image_link(comment.commenter, variant: :small_avatar) %>
    </div>

    <div class="comment_right">
        <div class="comment_user_text">
            <%= comment.commenter ? (link_to comment.commenter.name, user_home_path(comment.commenter)) : 'Guest' %>
            <% if logged_in? %>
        <span class="comment_ip">
            (<%= comment.remote_ip %>)
        </span>
        <% end %>
        said <%= local_time_ago(comment.created_at) %>
        </div>

        <div class="comment_body">
            <p>
                <%= strip_tags(comment.body) %>
            </p>
        <% if comment.private %>
            <div class="private_message">private message</div>
        <% end %>

        <% if authorized_for_comment(comment) -%>
            <div class="comment_controls">
                    <% if comment.is_spam? %>
                        <%= link_to 'un-spam', unspam_admin_comment_path(comment),  data: { turbo_method: :put, turbo_confirm: 'This will make the comment public. Are you sure?'} %>
                    <% else %>
                        <%= link_to 'mark as spam', spam_admin_comment_path(comment),  data: { turbo_method: :put, turbo_confirm: 'Are you sure you want to mark this as SPAM? This will make it harder for the user who posted this comment to post again'}%>
                    <% end %>
                <%= link_to 'delete', comment_path(comment), data: { turbo_method: :delete, turbo_confirm: 'Are you sure you want to delete this comment?'} %>
            </div>
            <% end %>
        </div>
    </div>

    <div class="clear">
    </div>
<% end if comment && (!comment.private? || authorized_for_comment(comment))%>