{% extends "cofcms/base_aside.html" %}
{% load wagtailimages_tags cofcms_tags wagtailcore_tags static i18n %}

{% block extra_head %}
    {{ block.super }}
    <script src="{% static "vendor/jquery/jquery-3.3.1.min.js" %}"></script>
    <script src="{% static "cofcms/js/calendar.js" %}"></script>
{% endblock %}

{% block aside_title %}{% trans "Calendrier" %}{% endblock %}
{% block aside %}
    <div id="calendar-wrap">
        {% calendar %}
    </div>
{% endblock %}

{% block content %}
    <section class="intro">
        <h1>{{ page.title }}</h1>
        <div>{{ page.introduction|richtext }}</div>
    </section>

    <section class="actulist">
        {% if actus.has_previous %}
            <a class="block prev-actus" href="?page={{ actus.previous_page_number }}{% for key,value in request.GET.items %}{% ifnotequal key 'page' %}&amp;{{ key }}={{ value }}{% endifnotequal %}{% endfor %}">{% trans "Actualités plus récentes" %}</a>
        {% endif %}
        {% if actus.has_next %}
            <a class="block next-actus" href="?page={{ actus.next_page_number }}{% for key,value in request.GET.items %}{% ifnotequal key 'page' %}&amp;{{ key }}={{ value }}{% endifnotequal %}{% endfor %}">{% trans "Actualités plus anciennes" %}</a>
        {% endif %}

        {% for actu in page.actus %}
            <article class="actu">
                <div class="actu-image" {% if actu.image %}{% image actu.image fill-400x200 as img %}style="background-image:url('{{ img.url }}');"{% endif %}></div>
                <div class="actu-infos">
                    <h2><a href="{% pageurl actu %}">{{ actu.title }}</a></h2>
                    {% if actu.is_event %}
                        <p><span class="actu-dates">{{ actu|dates|capfirst }}</span><br />{{ actu.chapo }}</p>
                    {% else %}
                        {{ actu.body|richtext|truncatewords_html:15 }}
                    {% endif %}
                    <a href="{% pageurl actu %}">{% trans "Lire plus" %} &gt;</a>
                </div>
            </article>
        {% endfor %}

        {% if actus.has_previous %}
            <a class="block prev-actus" href="?page={{ actus.previous_page_number }}{% for key,value in request.GET.items %}{% ifnotequal key 'page' %}&amp;{{ key }}={{ value }}{% endifnotequal %}{% endfor %}">{% trans "Actualités plus récentes" %}</a>
        {% endif %}
        {% if actus.has_next %}
            <a class="block next-actus" href="?page={{ actus.next_page_number }}{% for key,value in request.GET.items %}{% ifnotequal key 'page' %}&amp;{{ key }}={{ value }}{% endifnotequal %}{% endfor %}">{% trans "Actualités plus anciennes" %}</a>
        {% endif %}
    </section>
{% endblock %}
