<div class="stream-item">
  <div class="row">
    <div class="col s12">
        <span class="right">
          <%= render partial: 'content_page_shares/action_dropdown', locals: { share: share, content: content } %>
        </span>
      <%= link_to share.user, class: "#{User.text_color}" do %>
        <%= image_tag share.user.image_url(size=20), class: 'left circle avatar' %>
        <%= share.user.display_name %>
      <% end %>
      <% if share.user == content.user %>
        added a <%= share.secondary_content_page.class.name.downcase %> to their
      <% else %>
        got accepted into the
      <% end %>
      <%= link_to content.title, content, class: "#{content.class.text_color} text-darken-1" %>
      Collection!
      <span class="right">
        <%= link_to [share.user, share], class: 'grey-text' do %>
          <%= time_ago_in_words share.created_at %> ago
        <% end %>
      </span>
    </div>
  </div>

  <div class="main-container hoverable card row clearfix">
    <div class="col s12 m6 l6">
      <div class="card-image">
        <% if share.user == content.user %>
          <%= link_to [share.user, share] do %>
            <%= image_tag secondary_content.first_public_image %>
          <% end %>
        <% else %>
          <%= link_to [share.user, share] do %>
            <%= image_tag content.first_public_image %>
          <% end %>
        <% end %>
        <span class="card-title">
          <% if share.user_id == content.user_id %>
            <%# if this is a share for adding content you own to your own collection, show the content instead of the collection %>
            <%= link_to secondary_content do %>
              <i class="material-icons tiny <%= secondary_content.class.text_color %>"><%= secondary_content.class.icon %></i>
              <span class="white-text bordered-text"><%= secondary_content.name %></i>
            <% end %>

          <% else %>
            <%= link_to content do %>
              <i class="material-icons tiny <%= content.class.text_color %>"><%= content.class.icon %></i>
              <span class="white-text bordered-text"><%= content.title %></i>
            <% end %>
          <% end %>
        </span>
      </div>
    </div>

    <div class="col s12 m6 l6">
      <div class="card-content discussion-container">
        <div class="metadata">
          <%= link_to share.user, class: "#{User.text_color}" do %>
            <%= image_tag share.user.image_url(size=20), class: 'left circle avatar' %>
            <%= share.user.display_name %>
          <% end %>
          <span class="helper-text">
            <% if secondary_content.user_id == share.user_id %>
              added
              <%= link_to secondary_content.name, secondary_content, class: "#{secondary_content.class.text_color}" %>
              to a Collection!

              <br /><br />
              <%= link_to content, class: "btn #{PageCollection.color} hoverable left white-text clearfix", style: 'width: 100%' do %>
                <i class="material-icons left"><%= PageCollection.icon %></i>
                <span class="left"><%= content.name %></span>
                <i class="material-icons right">arrow_right</i>
              <% end %>
              <div class="clearfix"></div>

            <% else %>
              submitted
              <%= link_to secondary_content.name, secondary_content, class: "#{secondary_content.class.text_color}" %>
              to
              <%= link_to content.title, content, class: "#{content.class.text_color} text-lighten-2" %>
              and got <span class="orange-text">accepted</span>!
            <% end %>
          </span>
        </div>
        <% if share.message.present? %>
          <blockquote class="original-comment">
            <%= simple_format share.message %>
          </blockquote>
        <% end %>

        <% if user_signed_in? %>
          <%= render partial: 'share_comments/form', locals: { share: share } %>
        <% else %>
          <div class='center'>
            <%= link_to new_user_registration_path do %>
              To leave a comment, sign up for a free Notebook.ai account.
            <% end %>
          </div>
        <% end %>
        <br />
        
        <div class="uppercase grey-text center"><%= pluralize share.share_comments.count, 'comment' %></div>
        <div class="row">
          <% share.share_comments.each do |comment| %>
            <%= render partial: 'share_comments/show', locals: { comment: comment, share: share } %>
          <% end %>
        </div>

        <% if share.share_comments.count > 10 && user_signed_in? %>
          <%= render partial: 'share_comments/form', locals: { share: share } %>
        <% end %>
      </div>
    </div>
  </div>
</div>