{% 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 ({{ publication_count }})
                </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 ({{ book_count }})
                    </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 ({{ periodical_count }})
                    </a>
                </li>
            {% endif %}
        </ul>
    {% endif %}

    {% if reading_list|length > 0 %}

        {% for reading in reading_list %}
            {% ifchanged reading.end_date|date:"m" %}
                {% if not forloop.first %}
                    </ul>
                {% endif %}
                <h2>{{ reading.end_date|date:"F"}}</h2>
                <ul>
            {% endifchanged %}
            <li class="mb-2">
                {% include 'spectator_reading/includes/publication.html' with publication=reading.publication show_readings='none' 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 %}
