{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "forums/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
{% from "includes/common_macros.html" import content_editor %}
{# L10n: {f} if the name of the forum, {t} if the name of the thread. #}
{% set title = _('Edit a post | {t} | {f} | Forums')|f(t=thread.title,f=forum.name) %}
{% set crumbs = [(url('forums.forums'), _('Forums')),
                 (url('forums.threads', forum.slug), forum.name),
                 (url('forums.posts', forum.slug, thread.id), thread.title),
                 (None, _('Edit a post'))] %}

{% block content %}
<article id="edit-post" class="main">
  <h1>{{ _('Edit a post') }}</h1>

  <form action="{{ url('forums.edit_post', forum.slug, thread.id, post.id) }}" method="post" class="edit-post">
    {{ csrf() }}
    {{ errorlist(form) }}

    <div class="form-widget{% if form.content.errors %} invalid{% endif %}">
      {{ form.content.label_tag()|safe }}
      {{ content_editor(form.content) }}
    </div>

    <div class="form-widget submit">
      <input type="submit" name="preview" value="{{ _('Preview') }}" />
      <input type="submit" value="{{ _('Update post') }}" />
      <a href="{{ url('forums.posts', forum.slug, thread.id) }}">{{ _('Cancel') }}</a>
    </div>
  </form>

  {% if post_preview %}
    <div id="post-preview">
      <h3>{{ _('Post Preview:') }}</h3>
      <ol class="posts">
        <li>
          {% set post = post_preview %}
          {% include "forums/includes/post.html" %}
        </li>
      </ol>
    </div>
  {% endif %}
</article>
{% endblock %}
