{% extends 'base.html.j2' %}
{% set page_title = place.names | negotiate_localizeds %}
{% block page_content %}
    {% include 'meta/place.html.j2' %}

    {% set places = place | walk('encloses') | select('place_resource') | list %}
    {% if place.coordinates %}
        {% set places = places + [place] %}
    {% endif %}
    {% if places | length > 0 %}
        <section id="places">
            <h2 class="js-visually-hidden">
                {% trans %}Places{% endtrans %}
                {% with url = page_resource | url ~ '#places'%}
                    {% include 'permalink.html.j2' %}
                {% endwith %}
            </h2>
            {% with place_context = place, map_hides_list = True %}
                {% include 'list-place.html.j2' %}
            {% endwith %}
        </section>
    {% endif %}

    {% if 'betty.plugin.wikipedia.Wikipedia' in plugins %}
        <section id="wikipedia">
            <h2 class="visually-hidden">
                {% trans %}Wikipedia{% endtrans %}
                {% with url = page_resource | url ~ '#wikipedia'%}
                    {% include 'permalink.html.j2' %}
                {% endwith %}
            </h2>
            {% with entity=place %}
                {% include 'wikipedia.html.j2' %}
            {% endwith %}
        </section>
    {% endif %}

    {% set events = place.events | list + place | walk('encloses') | select('place_resource') | map(attribute="events") | flatten | rejectattr('date', 'none') | selectattr('date.comparable') | list %}
    {% if events | length > 0 %}
        <section id="timeline">
            <h2>
                {% trans %}Timeline{% endtrans %}
                {% with url = page_resource | url ~ '#timeline'%}
                    {% include 'permalink.html.j2' %}
                {% endwith %}
            </h2>
            {% with events=events, place_context=place %}
                {% include 'list-event.html.j2' %}
            {% endwith %}
        </section>
    {% endif %}
{% endblock %}