{% extends "base.html" %}

{#
    A head block must be defined in the Pelican theme's base.html prior to
    closing the HTML head tag so that the siglican stylesheets and javascript
    can be added. simply adding:
        {% block head %}{% endblock %} 
    just before the head closer is sufficient.
#}

{% block head %}
    {{ super() }}
    <link rel="stylesheet" href="{{ SIGLICAN_THEME_URL }}/css/style.min.css">
{% endblock %}

{% block content %}
    <div class="container">
      <header>
        <h1><a href="{{ SIGLICAN_ALBUM.index_url }}">{{ index_title }}</a></h1>

        {% if SIGLICAN_ALBUM.breadcrumb %}
        <h2>
          {%- for url, title in SIGLICAN_ALBUM.breadcrumb -%}
          <a href="{{ url }}">{{ title }}</a>
          {%- if not loop.last %} » {% endif -%}
          {% endfor -%}
        </h2>
        <hr>
        {% endif %}
      </header>

      <div id="main" role="main">
        {% if SIGLICAN_ALBUM.albums %}
        <div id="albums">
          <!-- <h1>Albums</h1> -->
          <ul>
            {% for alb in SIGLICAN_ALBUM.albums %}
            <li><a href="{{ alb.url }}">
              <img src="{{ alb.thumbnail }}" class="album_thumb" alt="{{ alb.name }}" title="{{ alb.name }}" /></a>
              <span class="album_title">{{ alb.title }}</span>
            </li>
            {% endfor %}
          </ul>
        </div>
        {% endif %}

        {% if SIGLICAN_ALBUM.medias %}
          {% macro img_description(media) -%}
            {%- if media.big %}<a href='{{ media.big }}'>Full size</a>{% endif %}
            {% if media.description %}<br>{{ media.description }}{% endif %}

            {%- if media.exif %}
              <br>
              {% if media.exif.iso %}ISO: {{ media.exif.iso }}, {% endif %}
              {% if media.exif.focal %}Focal: {{ media.exif.focal }}, {% endif %}
              {% if media.exif.exposure %}Exposure: {{ media.exif.exposure }}, {% endif %}
              {% if media.exif.fstop %}Fstop: {{ media.exif.fstop }}{% endif %}
              {% if media.exif.datetime %}
                <br>Date: {{ media.exif.datetime }}
              {% endif %}
            {% endif %}
          {%- endmacro %}
        <div id="gallery">
          {% for media in SIGLICAN_ALBUM.medias %}
            {% if media.type == "image" %}
              <a href="{{ media.filename }}">
                <img src="{{ media.thumbnail }}" alt="{{ media.filename }}"
                    data-title="{{ media.title if media.title else media.filename }}"
                    data-description="{{ img_description(media) }}"/>
              </a>
            {% endif %}
            {% if media.type == "video" %}
              <a href="{{ theme.url }}/img/empty.png">
                <img src="{{ media.thumbnail }}" alt="{{ media.filename }}"
                    data-title="{{ media.title if media.title else media.filename }}"
                    data-description="{{ img_description(media) }}"
                    data-layer="<video controls>
                                  <source src='{{ media.filename }}' type='video/webm' />
                                </video>" />
              </a>
            {% endif %}
          {% endfor %}
        </div>
        {% endif %}

        {% if SIGLICAN_ALBUM.zip %}
        <div id="additionnal-infos" class="row">
          <p>
            <a href="{{ album.zip }}"
               title="Download a zip archive with all images">Download ZIP</a>
          </p>
        </div>
        {% endif %}

        {% if SIGLICAN_ALBUM.description %}
        <div id="description">
          {{ SIGLICAN_ALBUM.description }}
        </div>
        {% endif %}
      </div>

      <footer>
        <p>{% if author %}&copy; {{ author }} - {% endif %}
          Generated by <a href="{{ sigal_link }}">sigal</a></p>
      </footer>
    </div>

    {% if SIGLICAN_ALBUM.medias %}
    <script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
    <script>!window.jQuery && document.write(unescape('%3Cscript src="{{ SIGLICAN_THEME_URL }}/js/jquery-1.11.1.min.js"%3E%3C/script%3E'))</script>
    <script src="{{ SIGLICAN_THEME_URL }}/js/galleria-1.3.5.min.js"></script>
    <script src="{{ SIGLICAN_THEME_URL }}/js/galleria.classic.min.js"></script>
    <script src="{{ SIGLICAN_THEME_URL }}/js/galleria.history.min.js"></script>
    <script>
    Galleria.configure({
        imageCrop: false,
        transition: "fade"
    });
    Galleria.run("#gallery");

    Galleria.ready(function() {
        this.attachKeyboard({
            right: this.next,
            left: this.prev
         });
     });

    </script>
    {% endif %}
{% endblock %}
