{% load sorl_thumbnail %}
{% load i18n %}

<article class="l-books__item book-container-activator" data-pop="-{{ book.popularity.count }}" data-longpress="hover">
  <figure class="l-books__item__img book-container book-container-{{ book.pk }}" data-book="{{ book.pk }}">
    <a href="{{ book.get_absolute_url }}">
      {% if book.is_picture %}
        {% if book.image_file %}
          {% thumbnail book.image_file "170x240" crop="center" as im %}
          <img src="{{ im.url }}"
               srcset="{{ im.url }} 1x, {{ im.url|resolution:"2x" }} 2x"
               width="{{ im.x }}" height="{{ im.y }}" />
          {% endthumbnail %}
        {% endif %}
      {% else %}
        {% if book.cover_clean %}
          <img src="{{ book.cover_clean.url }}" alt="{{ book.title }}">
        {% endif %}
      {% endif %}
    </a>

    <div class="set-tools">
      <div class="sets"></div>
      <form method="post" action="{% url 'social_add_set_tag' %}" class="add-set-tag">
        {% csrf_token %} {# this needs to be copied in with JS #}
        <input type="hidden" name="book" value="{{ book.id }}">
        <input name="name" placeholder="{% trans 'nazwa półki' %}" />
        <button type="submit"></button>
      </form>
    </div>

  </figure>
  <div class="l-books__item__actions">
    {% if book.is_book %}
      <span class="icon icon-book-alt" title="{% trans 'książka' %}"></span>
    {% endif %}
    {% if book.has_audio %}
      <span class="icon icon-audio" title="{% trans 'audiobook' %}"></span>
    {% endif %}
    {% if book.is_picture %}
      <span class="icon icon-picture" title="{% trans 'obraz' %}"></span>
    {% endif %}
    <a href="{{ book.get_absolute_url }}" class="icon icon-like" data-book="{{ book.pk }}" data-book-slug="{{ book.slug }}"></a>
  </div>
  <h3 class="s">
    {% for author in book.authors %}
      <a href="{{ author.get_absolute_url }}">{{ author }}</a>{% if not forloop.last %}, {% endif %}
    {% endfor %}
  </h3>
  <h2 class="s"><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></h2>
  <span class="other-info s">
    {% for kind in book.kinds %}{{ kind }} {% endfor %}
    {% for genre in book.genres %}{{ genre }} {% endfor %}
    {% for epoch in book.epochs %}{{ epoch }} {% endfor %}
  </span>
</article>
