<div class="row">
  <% pages.each do |page| %>
    <% content = page.content %>
    <% next unless (current_user || User.new).can_read?(content) %>
    <div class="col s12 m4 l3">
      <div class="hoverable card" style="min-height: 330px;">
        <div class="card-image waves-effect waves-block waves-light">
          <%= image_tag content.first_public_image, class: 'activator', style: "height: 300px;" %>
        </div>
        <div class="card-content fixed-card-content" style="border-top: 6px solid <%= content.class.hex_color %>">
          <span class="card-title activator grey-text text-darken-4">
            <%= link_to content.name, content %>
            <i class="material-icons right">more_vert</i>
          </span>
          <p>
            Submitted by 
            <%= link_to content.user, class: "#{User.text_color}" do %>
              <%= content.user.display_name %>
            <% end %>
          </p>
        </div>
        <div class="card-reveal">
          <span class="card-title grey-text text-darken-4" style="border-bottom: 4px solid <%= content.class.hex_color %>">
            <%= link_to content.name, content %>
            <i class="material-icons right">close</i>
          </span>
          <% if page.explanation? %>
            <blockquote>
              <%= simple_format page.explanation %>
            </blockquote>
          <% end %>
          <ul>
            <li>
              <%= link_to content, class: "#{content.class.text_color}" do %>
                <i class="material-icons right">arrow_right</i>
                View <%= content.name %>'s notebook page
              <% end %>
            </li>
            <li class="clearfix">
              <%= link_to page_collection_submissions_by_user_path(page_collection_id: @page_collection.id, user_id: page.user_id), class: "#{PageCollection.text_color}" do %>
                <i class="material-icons right">arrow_right</i>
                View more submissions from this user
              <% end %>
            </li>
            <li class="clearfix">
              <%= link_to page_collection_submissions_by_user_path(page_collection_id: @page_collection.id, user_id: page.user_id), class: "#{User.text_color}" do %>
                <i class="material-icons right">arrow_right</i>
                View <%= page.user.display_name %>'s profile
              <% end %>
            </li>
            <% if user_signed_in? && current_user == @page_collection.user %>
              <li>&nbsp;</li>
              <li class="divider"></li>
              <li>&nbsp;</li>
              <li><%= link_to 'Remove from collection', page_collection_submission_path(page), method: :delete, class: 'red-text', data: { confirm: "Are you sure you want to remove this page from this collection?" } %></li>
            <% end %>
          </ul>
        </div>
      </div>
    </div>
  <% end %>
</div>