publiclab/plots2

View on GitHub
app/views/notes/_coauthored_notes.html.erb

Summary

Maintainability
Test Coverage
<% notes = notes || @coauthored # accept local if present, default to instance %>
<div id="notes">
    <div class="row">
    <% notes.each_with_index do |node,i| %>
      <div class="<% if @widget %>col-xs-3 col-sm-3 col-md-3 <% end %><%= node.tagnames_as_classes %> col-lg-3 clearfix node note node-nid-<%= node.id %> note-nid-<%= node.id %><% if node.status == 4 %> moderated<% end %>" style="overflow:hidden; text-align:center">

        <% if node.main_image %>
          <a class="img" <% if @widget %>target="_blank"<% end %> href="<%= node.path %>"><img src="<%= node.main_image.path(:default) %>" style="width:100%;" /></a>
        <% end %>

        <% if node.status == 4 %>
          <p class="alert alert-warning moderated">
            <% if logged_in_as(['admin','moderator']) %>
              <%= translation('notes._notes.moderate_first_time_post') %> <br class="d-none d-lg-inline"/>
              <a class="btn btn-outline-secondary btn-sm" href="/moderate/publish/<%= node.id %>"><%= translation('notes._notes.approve') %></a>
              <a class="btn btn-outline-secondary btn-sm" href="/moderate/spam/<%= node.id %>"><%= translation('notes._notes.spam') %></a>
            <% else %>
              <%= raw translation('notes._notes.pending_approval', :url1 => '/wiki/moderation') %>
            <% end %>
          </p>
        <% end %>

        <h3><a <% if @widget %>target="_blank"<% end %> href="<%= node.path %>"><%= (node.type == 'note') ? node.title : node.latest.title %></a></h3>

        <p class="meta"><small>
          <% if node.type == 'note' %>
            by <a <% if @widget %>target="_blank"<% end %> href="/profile/<%= node.author.name %>"><%= node.author.name %></a>
            <%= distance_of_time_in_words(node.created_at, Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' }) %>
            | <a <% if @widget %>target="_blank"<% end %> href="<%= node.path %>#comments"><i style="color:#888;" class="fa fa-comment-o"></i> <%= node.comments.size %></a>
          <% else %>
            <%= translation('notes._notes.last_edit_by') %> <a <% if @widget %>target="_blank"<% end %> href="/profile/<%= node.latest.author.name %>"><%= node.latest.author.name %></a>
        <%= distance_of_time_in_words(Time.at(node.latest.timestamp), Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' }) %>
          <% end %>
          | <i class="fa fa-eye"></i> <%= number_with_delimiter(node.views) %> <span class="d-none d-lg-inline"><%= translation('notes._notes.views') %></span>
          | <i style="<% if node.likes > 0 %>color:#db4;<% else %>color:#888;<% end %>" class="fa fa-star-o"></i> <%= node.likes %>
        </small></p>

        <div class="content">
          <% if @compact.nil? %>
            <% if params[:action].to_s.include?("methods") %>
              <p><small>
                <a <% if @widget %>target="_blank"<% end %> href="<%= node.path %>#Activity+grid"><i class="fa fa-flask" style="color:#3da56a;"></i> <%= Node.activities(node.power_tag('activities')).count %> activities</a> &nbsp;
                <!-- <p><i class="fa fa-users" style="color:blue"></i> contributors</p> -->
                <a <% if @widget %>target="_blank"<% end %> href="<%= node.path %>#Upgrade+grid"><i class="fa fa-level-up" style="color:#db3a1e;"></i> <%= Node.upgrades(node.power_tag('upgrades')).count %> upgrades</a>
              </small></p>
            <% else %>
              <p><%= raw strip_tags(sanitize(RDiscount.new(node.body_preview).to_html)) if node.body %></p>
            <% end %>
            <p>
              <% if logged_in_as(['admin','moderator']) %><a class="btn btn-outline-secondary" href="/moderate/spam/<%= node.id %>"><i class="fa fa-ban"></i> <%= translation('notes._notes.spam') %></a><% end %>
              <a style="float: right; margin-left: 1px;" class="btn btn-outline-secondary" href="<%= node.path %>"><%= translation('notes._notes.read_more') %></a>
            </p>
          <% end %>
          <% if params[:mod] %>
            <a class="btn btn-outline-secondary" href="#"><i class="fa fa-ban-circle"></i> <%= translation('notes._notes.spam') %></a>
          <% end %>
          <hr style="display:none;" class="bottom" />
        </div>

      </div>
      <% unless @widget %><hr class="d-lg-none" /><% end %>
    <% if ((i+1)/4.0).to_i == ((i+1)/4.0) %>
    </div>
    <% unless @widget %><hr class="d-lg-none grid" /><% end %>
    <div class="row">
    <% end %>
    <% end %>
    </div>
</div>
<% if @pagy %>
  <%== pagy_bootstrap_nav @pagy %>
<% else %>
  <%= will_paginate notes, renderer: WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated %>
<% end %>