<!DOCTYPE html5>
<html>
<head>
    {% import "photo_card.html" as photo_card %}
    {% import "header.html" as header %}
    <title>Album {{album.title}}</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/common.css">

<style>
p
{
    word-break: break-word;
}
#content_body
{
    /* overriding common.css here */
    display: block;
}
</style>
</head>


<body>
{{header.make_header(session=session)}}
<div id="content_body">
    <h2>{{album.title}}</h2>
    <p>{{album.description}}</p>
    {% set parent=album.parent() %}
    {% if parent %}
    <h3>Parent: <a href="/album/{{parent.id}}">{{parent.id + " " + parent.title}}</a></h3>
    {% else %}
    <h3>Parent: <a href="/albums">Albums</a></h3>
    {% endif %}
    {% set sub_albums = album.children() %}
    {% if sub_albums %}
    <h3>Sub-albums</h3>
    <ul>
        {% for sub_album in sub_albums|sort(attribute='title') %}
        <li><a href="/album/{{sub_album.id}}">
            {% if sub_album.title %}
            {{sub_album.title}}
            {% else %}
            {{sub_album.id}}
            {% endif %}</a>
        </li>
        {% endfor %}
    </ul>
    {% endif %}
    {% set photos = album.photos() %}
    <span>
        Download:
        {% if photos %}
            <a href="/album/{{album.id}}.zip?recursive=no">
                These files ({{album.sum_bytes(recurse=False, string=True)}})
            </a>
        {% endif %}
        {% if sub_albums %}
            <a href="/album/{{album.id}}.zip?recursive=yes">
                Include children ({{album.sum_bytes(recurse=True, string=True)}})
            </a>
        {% endif %}
    </span>
    {% if photos %}
    <h3>Photos</h3>
    <ul>
        {% for photo in photos %}
        {{photo_card.create_photo_card(photo, view=view)}}
        {% endfor %}
    </ul>
    {% endif %}
</div>
</body>


<script type="text/javascript">
function submit_tag(callback)
{
    add_photo_tag('{{album.id}}', add_tag_box.value, callback);
    add_tag_box.value = "";
}
</script>
</html>