{% extends "base/base.html" %}
{% import "widgets/editor.html" as widget_editor %}
{% import "widgets/thread.html" as widget_thread %}
{% import "widgets/user.html" as widget_user %}
{% import "widgets/pagination.html" as widget_pagination with context %}

{% block title %}
<a href='/forum'>Forum de Planète Casio</a> » <a href="{{ url_for('forum_page', f=t.forum) }}">{{ t.forum.name }}</a> » <h1>{{ t.title }}</h1>
{% endblock %}

{% block content %}
<section>
    <h1>{{ t.title }}</h1>
    {{ widget_thread.thread([t.thread.top_comment], None) }}

    {{ widget_pagination.paginate(comments, 'forum_topic', t, {'f': t.forum}) }}

    {{ widget_thread.thread(comments.items, t.thread.top_comment) }}

    {{ widget_pagination.paginate(comments, 'forum_topic', t, {'f': t.forum}) }}

    {% if outdated %}
    <div class="bg-warn">
        Ce topic est sans activité depuis {{ outdated }} jours, êtes-vous sûr de vouloir y poster ?
    </div>
    {% endif %}

    {% if current_user.is_authenticated or V5Config.ENABLE_GUEST_POST %}
    <div class=form>
        <h3>Commenter le sujet</h3>
        <form action="" method="post" enctype="multipart/form-data">
            {{ form.hidden_tag() }}

            {% if form.pseudo %}
                {{ form.pseudo.label }}
                {{ form.pseudo }}
                {% for error in form.pseudo.errors %}
                <span class="msgerror">{{ error }}</span>
                {% endfor %}
            {% endif %}

            {{ widget_editor.text_editor(form.message, label=False) }}

            {{ form.attachments }}
            {% for error in form.attachments.errors %}
            <span class="msgerror">{{ error }}</span>
            {% endfor %}

            <div>{{ form.submit(class_='bg-ok') }}</div>
        </form>
    {% endif %}
    </div>
</section>
{% endblock %}
