<!-- this partial requires collection; @challenges_count, @works_count, @bookmarks_count must be set -->
<li class="<% if collection.user_is_owner?(current_user) %>own <% end %>collection picture blurb group" role="article">
  <% logged_in = (logged_in_as_admin? || logged_in?) ? "logged-in" : "logged-out" %>
  <% # remember to update collection_sweeper if you change this key %>
  <% cache("collection-blurb-#{logged_in}-#{collection.id}-v4", expires_in: ArchiveConfig.MINUTES_UNTIL_COLLECTION_BLURBS_EXPIRE.minutes, skip_digest: true) do %>
    <div class="header module group">
      <h4 class="heading">
        <%= link_to collection.title, collection_path(collection) %>
        <span class="name">(<%= collection.name %>)</span>
        <%= ts('by') %>
        <%= collection.all_owners.map {|owner| link_to(owner.byline, owner.user)}.join(", ").html_safe %>
      </h4>
      <!--collections header iconised header image-->
      <div class="icon">
        <%= collection_icon_display(collection) %>
      </div>
      <p class="datetime"><%= set_format_for_date(collection.updated_at) %></p>
      <% if collection.all_moderators.length > 0%>
        <h6 class="landmark heading"><%= ts("Mods") %></h6>
        <ul class="mods commas">
          <%= collection.all_moderators.map {|mod| content_tag(:li, link_to(mod.byline, mod.user))}.join("\n").html_safe %>
        </ul>
      <% end %>
    </div>

    <!--summary/descriptions-->
    <h6 class="landmark heading"><%= ts("Summary") %></h6>
    <blockquote class="userstuff summary">
      <%=raw strip_images(sanitize_field(collection, :description)) || "&nbsp;".html_safe %>

      <% if collection.challenge && collection.challenge.signup_open %>
        <p><%= ts("Sign-ups close at:") %> <%= time_in_zone(collection.challenge.signups_close_at, (collection.challenge.time_zone || Time.zone.name)) %></p>
      <% end %>
    </blockquote>

    <p class="type">
      (<%= collection.closed? ? ts("Closed") : ts("Open") %>, <%= collection.moderated? ? ts("Moderated") : ts("Unmoderated") %><%= collection.unrevealed? ? ts(", Unrevealed") : "" %><%= collection.anonymous? ? ts(", Anonymous") : "" %><%= collection.gift_exchange? ? ts(", Gift Exchange Challenge") : "" %><%= collection.prompt_meme? ? ts(", Prompt Meme Challenge") : "" %>)
    </p>

    <!--stats-->
    <dl class="stats">
      <% if (@challenges_count = collection.children.count) > 0 %>
        <dt><%= ts("Challenges/Subcollections:") %></dt>
        <dd><%= link_to(@challenges_count, collection_collections_path(collection)) %></dd>
      <% end %>
      <% if (@works_count = SearchCounts.work_count_for_collection(collection)) > 0 %>
        <dt><%= ts("Fandoms:") %></dt>
        <dd><%= link_to(SearchCounts.fandom_count_for_collection(collection), collection_fandoms_path(collection)) %></dd>
      <% end %>
      <% if collection.challenge? && collection.prompt_meme? %>
        <dt><%= ts("Prompts:") %></dt>
        <dd><%= link_to(collection.prompts.count.to_s, collection_requests_path(collection)) %></dd>
      <% end %>
      <dt><%= ts("Works:") %></dt>
      <dd><%= link_to(@works_count, collection_works_path(collection)) %></dd>
      <% if (@bookmarks_count = SearchCounts.bookmarkable_count_for_collection(collection)) > 0 %>
        <dt><%= ts("Bookmarked Items:") %></dt>
        <dd><%= link_to(@bookmarks_count, collection_bookmarks_path(collection)) %></dd>
      <% end %>
    </dl>

  <% end %><!-- end cache -->

  <% if collection.user_is_owner?(current_user) || (collection.challenge && collection.challenge.signup_open && logged_in?) || (collection.moderated? && logged_in?) %>
    <h6 class="landmark heading"><%= ts("User Actions") %></h6>
    <ul class="actions" role="menu">
      <% if collection.user_is_owner?(current_user) %>
        <li><%= link_to ts("Edit"), edit_collection_path(collection) %></li>
      <% end %>
      <% if collection.challenge && collection.challenge.signup_open && logged_in? %>
        <%= render "challenge/#{challenge_class_name(collection)}/challenge_navigation_user", :collection => collection %>
      <% end %>
      <% if !collection.user_is_owner?(current_user) && collection.moderated? && !(collection.challenge && collection.challenge.signup_open) %>
        <li>
          <% if (participant = collection.get_participants_for_user(current_user).first) %>
            <%= link_to ts("Leave"), collection_participant_path(collection, participant),
              data: {confirm: ts('Are you certain you want to leave this collection?')},
              :method => :delete %></li>
          <% else %>
                        <%= link_to ts("Join"), join_collection_participants_path(collection) %> <% end %>
        </li>
      <% end %>
    </ul>
  <% end %>
</li>
<!--end single blurb-->
