Noosfero/noosfero

View on GitHub
app/views/cms/_view_items.html.erb

Summary

Maintainability
Test Coverage
<% @articles.partition { |article| article.is_a? Folder }.flatten.each do |article| article = FilePresenter.for article %>
  <tr title="<%= article.title%>" class="<%= article.is_a?(Folder) ? "folder" : article.type == nil ? "" : article.type.downcase %>">
    <td class="article-name">
      <%= link_to_article(article) %>
    </td>
    <td>
      <%= content_tag :span, font_awesome(:home) if profile.home_page == article %>
    </td>
    <td class="last-modified">
      <%= time_ago_in_words(article.updated_at) %>
    </td>
    <td>
      <%= article.size ? number_to_human_size(article.size, precision: 2) : '<span style="font-weight: 700;">-</span>'.html_safe %>
    </td>
    <td>
      <%= link_to font_awesome(:ellipsis), '#!', class: 'menu-toggle', id: 'article-options' %>
      <ul class="noosfero-dropdown-menu">
        <% if !remove_content_button(:edit, article) %>
          <li>
            <%= link_to font_awesome(:edit, _('Edit')), { action: 'edit', id: article.id } %>
          </li>
        <% end %>

        <% if user.can_change_homepage? && !remove_content_button(:home, article) && !article.is_a?(FilePresenter) %>
          <li>
            <% if profile.home_page != article %>
            <%= link_to font_awesome(:home, _('Use as homepage')), set_home_page_cms_index_path(profile.identifier, id: article), method: :post %>
            <% else %>
              <%= link_to font_awesome(:undo, _('Reset homepage')),  set_home_page_cms_index_path(profile.identifier, id: nil), method: :post %>
            <% end %>
          </li>
        <% end %>
        <li>
          <%= link_to font_awesome(:globe, _('Public view')), article.view_url %>
        </li>
        <% unless remove_content_button(:spread, article) %>
          <li>
            <%= link_to font_awesome(:spread, _('Spread')), { action: 'publish', id: article.id}, { modal: true } %>
          </li>
        <% end %>

        <% if !remove_content_button(:delete, article) %>
          <li>
            <%= link_to font_awesome('trash', _('Delete')), { action: 'destroy', id: article.id }, method: :post, 'data-confirm' => delete_article_message(article) %>
          </li>
        <% end %>
      </ul>
    </td>
  </tr>
<% end %>