{# vim: set ts=2 et sts=2 sw=2: #}
{% macro document_tabs(document, parent, user, active, settings) -%}
  {% if not parent %}
    {% set parent = document %}
  {% endif %}
  <nav id="doc-tabs">
    <ul>
      <li{% if active == 'article' %} class="active"{% endif %}>
        {% if active == 'article' or not document %}
          <span>{{ _('Article') }}</span>
        {% else %}
          <a href="{{ url('wiki.document', document.slug) }}">{{ _('Article') }}</a>
        {% endif %}
      </li>
      {% if document %}
        <li{% if active == 'discussion' %} class="active"{% endif %}>
          {% if active == 'discussion' %}
            <span>{{ _('Discussion') }}</span>
          {% else %}
            <a href="{{ url('wiki.discuss.threads', document.slug) }}">{{ _('Discussion') }}</a>
          {% endif %}
        </li>
      {% endif %}
      {% if user.is_authenticated() and document %}
        {% if document.allows_revision_by(user) or document.allows_editing_by(user) %}
          <li class="edit{% if active == 'edit' %} active{% endif %}">
            {% if active == 'edit' %}
              <span>{{ _('Edit Article') }}</span>
            {% else %}
              <a href="{{ url('wiki.edit_document', document.slug) }}">{{ _('Edit Article') }}</a>
            {% endif %}
          </li>
        {% endif %}
        {% if document.is_localizable %}
          <li{% if active == 'localize' %} class="active"{% endif %}>
            {% if active == 'localize' %}
              <span>{{ _('Translate Article') }}</span>
            {% else %}
              <a href="{{ url('wiki.select_locale', document.slug) }}">{{ _('Translate Article') }}</a>
            {% endif %}
          </li>
        {% endif %}
        <li{% if active == 'history' %} class="active"{% endif %}>
          <a href="{% if document %}{{ url('wiki.document_revisions', document.slug) }}{% else %}{{ url('wiki.document_revisions', parent.slug, locale=settings.WIKI_DEFAULT_LANGUAGE) }}{% endif %}">{{ _('Show History') }}</a>
        </li>
      {% endif %}
    </ul>
  </nav>
{%- endmacro %}

{% macro document_notifications(document, user) -%}
  {% if user.is_authenticated() %}
    <div id="doc-watch">
      {% if document.is_watched_by(user) %}
        <form action="{{ url('wiki.document_unwatch', document.slug) }}" method="post">
          {{ csrf() }}
          <input type="submit" class="submit" value="{{ _('Unsubscribe from edit notifications') }}" />
        </form>
      {% else %}
        <form action="{{ url('wiki.document_watch', document.slug) }}" method="post">
          {{ csrf() }}
          <input type="submit" class="submit" value="{{ _('Subscribe to edit notifications') }}" />
        </form>
      {% endif %}
    </div>
  {% endif %}
{%- endmacro %}
