{% extends "core/base.jinja" %}
{% from 'forum/macros.jinja' import display_message, display_search_bar %}

{% block title %}
  {% if topic %}
    {% trans %}Reply{% endtrans %}
  {% else %}
    {% trans %}New topic{% endtrans %}
  {% endif %}
{% endblock %}


{% block additional_css %}
  <link rel="stylesheet" href="{{ static('forum/css/forum.scss') }}">
{% endblock %}

{% block content %}
  {% if topic %}
    {{ display_search_bar(request) }}
    <p>
      <a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
      {% for f in topic.forum.get_parent_list() %}
        > <a href="{{ f.get_absolute_url() }}">{{ f }}</a>
      {% endfor %}
      > <a href="{{ topic.forum.get_absolute_url() }}">{{ topic.forum }}</a>
      > <a href="{{ topic.get_absolute_url() }}">{{ topic }}</a>
    </p>
    <div id="forum">
      <h3>{{ topic.title }}</h3>
      <h4>{% trans %}Reply{% endtrans %}</h4>
  {% else %}
    <div id="forum">
      <h4>{% trans %}New topic{% endtrans %}</h4>
  {% endif %}
  <form action="" method="post" enctype="multipart/form-data">
    {% csrf_token %}
    {% render_honeypot_field settings.HONEYPOT_FIELD_NAME_FORUM %}
    {{ form.as_p() }}
    <p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
  </form>
  <hr>

  {% if topic %}
    {% for m in topic.messages.select_related('author__avatar_pict').order_by('-id')[:10] %}
      {{ display_message(m, user) }}
    {% endfor %}
  {% endif %}


  </div>

{% endblock %}
