{% extends 'entity/page.html.j2' %}
{% set file = file | default(entity) %}
{% set page_title = file.label | localize %}
{% block page_content %}
    {% if file.media_type and file.media_type.type == 'image' %}
        <div class="featured image">
            <a href="{{ file | file | static_url }}">
                <img src="{{ file | filter_image_resize_cover((1500, 1500)) | static_url }}"{% if file.description %} alt="{{ file.description | localize }}"{% endif %}>
            </a>
        </div>
    {% endif %}
    {% if file.copyright_notice is not none %}
        <div class="has-copyright-notice">
            <h2>{% trans %}Copyright{% endtrans %}</h2>
            <p>
                {% if file.copyright_notice.url is not none %}
                    <a href="{{ file.copyright_notice.url | localize }}">
                {% endif %}
                {{ file.copyright_notice.summary | localize | html_lang }}
                {% if file.copyright_notice.url is not none %}
                    </a>
                {% endif %}
            </p>
        </div>
    {% endif %}
    {% if file.license is not none %}
        <div class="has-license">
            <h2>{% trans %}License{% endtrans %}</h2>
            <p>
                {% if file.license.url is not none %}
                    <a href="{{ file.license.url | localize }}">
                {% endif %}
                {{ file.license.summary | localize | html_lang }}
                {% if file.license.url is not none %}
                    </a>
                {% endif %}
            </p>
        </div>
    {% endif %}
    {% with notes = file.notes %}
        {% include 'section-notes.html.j2' %}
    {% endwith %}
    {% set referees = file.referees | map(attribute='referee') | select('public') | list %}
    {% if referees | length > 0 %}
        <section id="appearances">
            <h2>
                {% trans %}Appearances{% endtrans %}
                {% with url = page_resource | localized_url ~ '#appearances'%}
                    {% include 'permalink.html.j2' %}
                {% endwith %}
            </h2>
            <ul class="entities">
                {% for entity in referees %}
                    <li class="{{ loop.cycle('odd', 'even') }}">
                        {% include ['entity/label--' + entity.plugin_id() + '.html.j2', 'entity/label.html.j2'] %}
                        {% include ['entity/meta--' + entity.plugin_id() + '.html.j2', 'entity/meta.html.j2'] ignore missing %}
                    </li>
                {% endfor %}
            </ul>
        </section>
    {% endif %}
    {% set citations = file.citations | list %}
    {% if citations | length  > 0 %}
        {# These are the citations for the file itself. This assumes no other citations are tracked on the page and #}
        {# rendered by base.html.j2. #}
        <section id="references">
            <h2>
                {% trans %}References{% endtrans %}
                {% with url = page_resource | localized_url ~ '#references'%}
                    {% include 'permalink.html.j2' %}
                {% endwith %}
            </h2>
            <ul>
            {% for citation in citations %}
                <li>{% include 'entity/label--citation.html.j2' %}</li>
            {% endfor %}
            </ul>
        </section>
    {% endif %}
{% endblock %}
