{% extends "base.html" %}
{% load url from future %}
{% load pagelet_tags %}

{% block title %}{{ page.title }}{% endblock %}

{% block meta %}
    {% if page.meta_keywords %}
    <meta name="keywords" content="{{ page.meta_keywords }}">
    {% endif %}
    {% if page.meta_robots %}
    <meta name="robots" content="{{ page.meta_robots }}">
    {% endif %}
    {% if page.description %}
    <meta name="description" content="{{ page.description|striptags|truncatewords:35 }}">
    {% endif %}
{% endblock %}

{% block content %}
    <div id='page-{{ page.pk }}' class='page {{ page.slug }}'>
        <div class='page-title'>{{ page.title }}</div>

        {% render_content_area page 'main' %}

        <div id='page-attachments'>
        {% ifnotequal page.attachments.count 0 %}
            <h2>Attachments</h2>
            <ul>
                {% for attachment in page.attachments.all %}
                    <li>
                        <a href='{{ attachment.file.url }}'>{{ attachment }}</a>
                        <span class='file-size'>({{ attachment.file.size|filesizeformat }})</span>
                        {% if perms.pagelets.delete_pageattachment %}
                            (<a href='{% url "remove_attachment" page.slug attachment.pk %}?next={{ request.get_full_path }}'>Delete</a>)
                        {% endif %}
                    </li>
                {% endfor %}
                {% if perms.pagelets.add_pageattachment %}
                    <li><a href='{% url "add_attachment" page.slug %}'>Add additional attachment...</a></li>
                {% endif %}
            </ul>
        {% else %}
            {% if perms.pagelets.add_pageattachment %}
                <p><a href='{% url "add_attachment" page.slug %}'>Add attachment...</a></p>
            {% endif %}
        {% endifnotequal %}
        </div>
    </div>
{% endblock %}
