{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "base.html" %}
{% set title = _('Media Gallery') %}
{% set styles = ('wiki', 'gallery') %}
{% set scripts = ('wiki', 'gallery') %}
{% set crumbs = [(None, _('Media Gallery'))] %}

{% block content %}
  <article id="gallery-list" class="main">
    <h1>{{ _('Media Gallery') }}</h1>
    <div id="locale-filter">
      {% if user.is_authenticated() %}
        <a id="btn-upload" class="btn-upload" href="#">{{ _('Upload a New Media File') }}</a>
      {% endif %}
      <form action="" method="get">
        <label for="select-locale">{{ _('Show media for:') }}</label>
        <select id="select-locale" name="lang" class="autosubmit">
          {% for lang in settings.LANGUAGE_CHOICES %}
            <option value="{{ lang[0] }}" {% if lang[0] == request.locale %}selected="selected"{% endif %}>{{ lang[1] }} ({{ lang[0] }})</option>
          {% endfor %}
        </select>
        <noscript>
          <input type="submit" value="{{ _('Go') }}">
          {% if user.is_authenticated() %}
            <div>{{ _('You have JavaScript disabled. Please enable JavaScript to upload files.') }}</div>
          {% endif %}
        </noscript>
      </form>
    </div>
    <div id="search-filter">
      <div id="media-type-filter">
        <span>{{ _("Show:") }}</span>
        <ol>
        <li>
          {% if media_type == 'image' %}
            <span>{{ _('Images') }}</span>
          {% else %}
            <a href="{{ url('gallery.gallery', 'image') }}">{{ _('Images') }}</a>
          {% endif %}
        </li>
        <li>
          {% if media_type == 'video' %}
            <span>{{ _('Videos') }}</span>
          {% else %}
            <a href="{{ url('gallery.gallery', 'video') }}">{{ _('Videos') }}</a>
          {% endif %}
        </li>
        </ol>
      </div>
      <div id="gallery-search">
        <form action="{{ url('gallery.search', media_type=media_type) }}" method="get">
          <input type="text" name="q" required="required" />
          <input type="submit" value="{{ _('Search Gallery') }}">
        </form>
      </div>
    </div>
    {% with media_list=media %}
      {% include 'gallery/includes/media_list.html' %}
    {% endwith %}

    {% if user.is_authenticated() %}
      {% include 'gallery/includes/upload_media_form.html' %}
    {% endif %}
  </article>
{% endblock %}
