{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "kbforums/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
{% from "includes/common_macros.html" import content_editor %}
{# L10n: {t} is the title of the thread. {d} is the name of the document. #}
{% set title = _('Edit a post | {t} | {d} Discussion | Knowledge Base')|f(t=thread.title, d=document.title) %}
{% set crumbs = [(url('wiki.category', document.category), document.get_category_display()),
                 (document.get_absolute_url(), document.title),
                 (url('wiki.discuss.threads', document.slug), _('Discuss')),
                 (url('wiki.discuss.posts', document.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('wiki.discuss.edit_post', document.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('wiki.discuss.posts', document.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 "kbforums/includes/post.html" %}
        </li>
      </ol>
    </div>
  {% endif %}
</article>
{% endblock %}
