{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "wiki/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
{% from "includes/common_macros.html" import content_editor %}
{% set title = _('Create a New Article | Knowledge Base') %}
{% block title %}{{ page_title(title) }}{% endblock %}
{# TODO: Change KB url to landing page when we have one #}
{% set crumbs = [(None, _('New Article'))] %}
{% set classes = 'new' %}
{% block bodyclass %}new{% if is_template %} is-template{% endif %}{% endblock %}

{% block content %}
<section id="content">
  <div class="wrap">
    <div id="content-main" class="full">
    <article class="article" role="main">
    {{ errorlist(document_form) }}
    {{ errorlist(revision_form) }}
    <form id="wiki-page-edit" class="editing" method="post" action="">
      <fieldset>
      <header id="article-head">
        {{ document_form.category|safe }}

        <ul class="metadata">
          <li><label>{{_('Title:')}}</label> {{ document_form.title | safe }}</li>
          <li><label>{{_('Slug:')}}</label> {{ document_form.slug | safe }}</li>
          {% if parent_slug and not is_template %}
            <li><label>{{_('Parent:')}}</label> 
                <a href="{{ parent_path }}" class="metadataDisplay" target="_blank">{{ parent_slug }}</a></li>
          {% endif %}
          <li><label>{{_('Tags:')}}</label> {{ revision_form.tags | safe }}</li>
          {% if not is_template %}
            <li><label><abbr title="{{_('Generate table of contents')}}">{{_('TOC:')}}</abbr></label>
              {{ revision_form.show_toc | safe }}
            </li>
          {% endif %}
        </ul>
        <input type="hidden" name="parent_topic" value="{{ parent_id | safe }}" />
        <div class="hidden" id="parentSlugPrefix">{{ parent_slug | safe }}</div>

        {% include 'wiki/includes/page_buttons.html' %}

      </header>

      {{ revision_form.content|safe }}
      {% if is_template %}
        <div id="ace_content"></div>
      {% endif %}
      
      {% include 'wiki/includes/title_autosuggest_url.html' %}

      <section>
        <h4>Review needed?</h4>
        {{ revision_form.review_tags|safe }}
      </section>
      
    </fieldset>
    </form>
    
    </article>
    <div id="preview"></div>
    </div>
   </div>
</section>
{% endblock %}

{% block site_js %}
    {{ super() }}

    {% if is_template %}
      <script src="{{ MEDIA_URL }}ace/ace.js" 
        type="text/javascript" charset="utf-8"></script>
      <script src="{{ MEDIA_URL }}ace/theme-dreamweaver.js"
        type="text/javascript" charset="utf-8"></script>
      <script src="{{ MEDIA_URL }}ace/mode-javascript.js"
        type="text/javascript" charset="utf-8"></script>
    {% endif %}

{% endblock %}
