{% extends "wiki/article.html" %}
{% load wiki_tags i18n humanize %}

{% block pagetitle %}{% trans "Listing articles in" %} {{ article.current_revision.title }}{% endblock %}

{% block wiki_contents_tab %}

{% url 'wiki:dir' urlpath.path as self_url %}

<form class="form-search directory-toolbar">
<div class="well well-small">
  <div class="btn-group pull-left">
    {% if urlpath.parent %}
    <a href="{% url 'wiki:dir' path=urlpath.parent.path %}" class="btn">
      <span class="icon-arrow-up"></span>
      {% trans "Up one level" %}
    </a>
    {% endif %}
    <a href="{% url 'wiki:create' path=urlpath.path %}" class="btn">
      <span class="icon-plus"></span>
      {% trans "Add article" %}
    </a>
  </div>
  <div class="pull-right input-prepend">
    {{ filter_form.query.label_tag }} {{ filter_form.query }}
    {% if filter_query %}
      <div class="pull-right filter-clear">
        <a href="{{ self_url }}">{% trans "clear" %}</a>
      </div>
    {% endif %}
  </div>

  <div class="clearfix"></div>
</div>
</form>

<p>
  {% with paginator.object_list.count as cnt %}
    {% if filter_query %}
      {% blocktrans with cnt|pluralize:_("article,articles") as articles_plur and cnt|pluralize:_("matches,match") as match_plur trimmed %}
        {{ cnt }} {{ articles_plur }} in this level {{ match_plur }} your search.
      {% endblocktrans %}
    {% else %}
      {% blocktrans with cnt|pluralize:_("article,articles") as articles_plur and cnt|pluralize:_("is,are") as articles_plur_verb trimmed %}
        There {{ articles_plur_verb }} {{ cnt }} {{ articles_plur }} in this level.
      {% endblocktrans %}
    {% endif %}
  {% endwith %}
</p>

{% if directory %}
  <table class="table table-striped">
    <tr>
      <th scope="col">{% trans "Title" %}</th>
      <th scope="col">{% trans "Slug" %}</th>
      <th scope="col">{% trans "Last modified" %}</th>
    </tr>
    {% for urlpath in directory %}
      <tr>
        <td>
          <a href="{% url 'wiki:get' path=urlpath.path %}"> {{ urlpath.article.current_revision.title }} </a>
          <a href="{% url 'wiki:dir' path=urlpath.path %}" class="list-children"> › </a>
          {% if urlpath.article.current_revision.deleted %}
            <span class="icon-trash"></span>
          {% endif %}
          {% if urlpath.article.current_revision.locked %}
            <span class="icon-lock"></span>
          {% endif %}
        </td>
        <td>
          {{ urlpath.slug }}
        </td>
        <td>
          {{ urlpath.article.current_revision.created|naturaltime }}
        </td>
      </tr>
    {% endfor %}
  </table>
{% endif %}

{% include "wiki/includes/pagination.html" %}

{% endblock %}

