{% extends 'spectator_reading/base.html' %}

{% block head_page_title %}{% if publication_kind %}{{ publication_kind|title }}s{% else %}Publications{% endif %} finished in {{ year|date:"Y" }}{% endblock %}
{% block content_title %}{% if publication_kind %}{{ publication_kind|title }}s{% else %}Publications{% endif %} finished in {{ year|date:"Y" }}{% endblock %}

{% block breadcrumbs %}
  {{ block.super }}
  <li class="breadcrumb-item active">{{ year|date:"Y" }}</li>
{% endblock %}

{% block content %}
  {% include 'spectator_core/includes/pager.html' with url_name='spectator:reading:reading_year_archive' previous=previous_year next=next_year only %}

  {% if book_count > 0 or periodical_count > 0 %}
    <ul class="nav nav-tabs mb-4">
      <li class="nav-item">
        <a class="nav-link{% if publication_kind == None %} active{% endif %}" href="{% url 'spectator:reading:reading_year_archive' year=year|date:"Y" %}">
          All <small>({{ publication_count }})</small>
        </a>
      </li>
      {% if book_count > 0 %}
        <li class="nav-item">
          <a class="nav-link{% if publication_kind == 'book' %} active{% endif %}" href="{% url 'spectator:reading:reading_year_archive' year=year|date:"Y" kind='books' %}">
            Books <small>({{ book_count }})</small>
          </a>
        </li>
      {% endif %}
      {% if periodical_count > 0 %}
        <li class="nav-item">
          <a class="nav-link{% if publication_kind == 'periodical' %} active{% endif %}" href="{% url 'spectator:reading:reading_year_archive' year=year|date:"Y" kind='periodicals' %}">
            Periodicals <small>({{ periodical_count }})</small>
          </a>
        </li>
      {% endif %}
    </ul>
  {% endif %}

  {% if reading_list|length > 0 %}

    {% if show_months|default_if_none:"True" is False %}
      <ul>
    {% endif %}

    {% for reading in reading_list %}

      {% if show_months|default_if_none:"True" is True %}
        {% ifchanged reading.end_date|date:"m" %}
          {% if not forloop.first %}
            </ul>
          {% endif %}
          <h2>{{ reading.end_date|date:"F"}}</h2>
          <ul>
        {% endifchanged %}
      {% endif %}
      <li class="mb-2">
        {% include 'spectator_reading/includes/publication.html' with publication=reading.publication show_readings='none' show_thumbnail=True only %}
      </li>
    {% endfor %}
    </ul>

    {% include 'spectator_core/includes/pager.html' with url_name='spectator:reading:reading_year_archive' previous=previous_year next=next_year only %}

  {% else %}
    <p>Nothing was read in {{ year|date:"Y" }}.</p>
  {% endif %}

{% endblock content %}
