<% pages.each do |page| %>
  <% content = page.content %>
  <% next unless (current_user || User.new).can_read?(content) %>
  <div class="hoverable card horizontal">
    <div class="card-image">
      <%= link_to content do %>
        <%= image_tag content.first_public_image %>
      <% end %>
    </div>
    <div class="card-stacked">
      <div class="card-content">
        <div class="card-title">
          <%= link_to content.name, content %>

          <% if user_signed_in? && current_user == @page_collection.user %>
            <a class='dropdown-trigger right' href='#' data-target='dropdown-<%= page.id %>'>
              <i class="material-icons">more_vert</i>
            </a>
            <ul id='dropdown-<%= page.id %>' class='dropdown-content'>
              <li>
                <%= link_to 'All pages from this user', page_collection_submissions_by_user_path(page_collection_id: @page_collection.id, user_id: page.user_id) %>
              </li>
              <li class="divider"></li>
              <li>
                <%= link_to 'Remove from collection', page_collection_submission_path(page), method: :delete %>
              </li>
            </ul>
          <% end %>
        </div>
        <% if page.explanation? %>
          <div>
            <%= simple_format page.explanation %>
          </div>
        <% end %>
        <ul>
          <li class="help-text">
            Submitted by 
            <%= link_to content.user, class: "#{User.text_color}" do %>
              <%= image_tag content.user.image_url(size=20), class: 'left circle', style: 'margin-right: 8px;' %>
              <%= content.user.display_name %>
            <% end %>
          </li>
        </ul>
      </div>
    </div>
  </div>

<% end %>