{% extends "base.html" %}
{% load i18n %}
{% load static %}

{% block extrahead %}
<link rel="stylesheet" type="text/css" href="{% static 'css/gallery.css' %}">
{% endblock %}

{% block title %}{{ block.super }} - {{ title }}{% endblock %}

{% block content %}
<h1>{{ title }}</h1>

{% if user.is_authenticated %}
<form action="{% url 'gallery:index' %}" method="GET" class="album_filter">
{% if not perms.gallery.view %}
{% if show_public %}
<a href="?hide_public">{% trans "Hide public albums" %}</a>
{% else %}
<a href="?show_public">{% trans "Show public albums" %}</a>
{% endif %}
|
{% endif %}
<input type="text" name="q" required="required" size="20" value="{{ q }}">
<input type="submit" value="{% trans "Search" %}">
</form>
{% endif %}

<div class="album_year_list">
{% if q %}
{% blocktrans with query=q %}Results for <strong>{{ query }}</strong>{% endblocktrans %} | <a href="{% url 'gallery:index' %}">{% trans "See all albums" %}</a>
{% else %}
{% for date in date_list %}
<a href="{% url 'gallery:year' date.year %}">{{ date.year }}</a>
{% if not forloop.last %} | {% endif %}
{% endfor %}
{% endif %}
</div>

{% for album in latest %}
{% ifchanged album.date.year %}
<h2>{{ album.date.year }}</h2>
{% endifchanged %}
<h3 class="album_preview">
{{ album.display_name }}
<span class="album_count">{% blocktrans count album.photos_count as num_photos %}one photo{% plural %}{{ num_photos }} photos{% endblocktrans %}</span>
<span class="album_date">{{ album.date }}</span>
<span class="album_category">{% trans album.category %}</span>
</h3>
{% spaceless %}
<div class="photo_list">
{% for photo in album.preview %}
<a href="{{ album.get_absolute_url }}"><img src="{% url 'gallery:photo-resized' preset='thumb' pk=photo.pk %}" width="128" height="128" alt="{{ photo }}"></a>
{% empty %}
<p>{% trans "Sorry, you aren't authorized to view any photos in this album." %}</p>
{% endfor %}
</div>
{% endspaceless %}
{% empty %}
{% if q %}
<p>{% trans "Sorry, no albums match your query." %}</p>
{% else %}
<p>{% trans "Sorry, you aren't authorized to view any albums." %}</p>
{% endif %}
{% endfor %}

{% if is_paginated %}
<div class="album_page_list">
{% if page_obj.has_previous %}
<a href="{% url 'gallery:index' %}?page={{ page_obj.previous_page_number }}{% if q %}&amp;q={{ q }}{% endif %}">&larr;</a>
{% endif %}
{{ page_obj.number }} / {{ paginator.num_pages }}
{% if page_obj.has_next %}
<a href="{% url 'gallery:index' %}?page={{ page_obj.next_page_number }}{% if q %}&amp;q={{ q }}{% endif %}">&rarr;</a>
{% endif %}
</div>
{% endif %}

{% endblock %}
