{% extends 'pybb/base.html' %}
{% load pybb_tags i18n %}

{% block title %}{{ forum.name }}{% endblock title %}

{% block breadcrumb %}
    {% with forum as object %}
        {% include "pybb/breadcrumb.html" %}
    {% endwith %}
{% endblock %}

{% block content %}
    <h1>{{ forum.name }}</h1>
    {% if forum.headline %}
        <div class='forum-headline'>
            {{ forum.headline|safe }}
        </div>
    {% endif %}
    {% include "pybb/pagination.html" %}
    <table class='topic-list'>
        <tr class="topic-row head-row">
            <th class="topic-name">
                {% trans "Topic" %}
            </th>
            <th class="topic-post-count">
                {% trans "Posts" %}
            </th>
            <th class="topic-view-count">
                {% trans "Views" %}
            </th>
            <th class="topic-last-post">
                {% trans "Last post" %}
            </th>
        </tr>
        {% for topic in topic_list|pybb_topic_unread:user  %}
            <tr class="topic-row {% if topic.sticky %} sticky {% endif %} {% cycle "odd" "even" %} {% if topic.on_moderation %} on-moderation {% endif %}">
                <td class="topic-name{% if topic.unread %} unread {% endif %}">
                    <div class='state-indicator'></div>
                    <a href='{{ topic.get_absolute_url }}'>{{ topic.name|truncatewords:10 }}</a>
                    {% if topic.sticky %} &nbsp;[{% trans "Sticky" %}] {% endif %}
                    {% if topic.closed %} &nbsp;[{% trans "Closed" %}] {% endif %}
                    {% with topic|pybb_topic_inline_pagination as pages %}
                        {% if pages|length > 1 %}
                            <span class='mini-pagination'>
                                {% trans "pages" %}:
                                {% for page in pages %}
                                    <span class='page'>
                                    {% if page == "..." %}
                                        ...
                                    {% else %}
                                        <a href="{{ topic.get_absolute_url }}?page={{ page }}">{{ page }}</a>
                                    {% endif %}
                                    </span>
                                {% endfor %}
                            </span>
                        {% endif %}
                    {% endwith %}
                </td>
                <td class="topic-post-count">
                    {{ topic.post_count }}
                </td>
                <td class="topic-view-count">
                    {{ topic.views }}
                </td>
                <td class="topic-last-post">
                    {% if topic.updated %}
                        {{ topic.updated|date:"d.m.Y H:i" }}
                    {% endif %}
                </td>
            </tr>
        {%  endfor %}
    </table>
    {% include "pybb/pagination.html" %}

    {% if PYBB_ENABLE_ANONYMOUS_POST or not user.get_profile.is_banned %}
        <div class="controls">
            <a href="{% url pybb:add_topic forum.id %}" class='new-topic'>
                {% if PYBB_BUTTONS.new_topic %}
                    <img src="{{ STATIC_URL }}{{ PYBB_BUTTONS.new_topic }}" alt='{% trans "New topic" %}'>
                {% else %}
                    {% trans "New topic" %}
                {% endif %}
            </a>
        </div>
    {% endif %}
{% endblock content %}