{% extends "base.html" %}

{% block title %}
    Diario: Pagina {{ page }}
{% endblock %}

{% block content %}
    <div class="diarioview">
        {% if page > 1 %}
            <a class="previous-page" href="{{ url_for("diarioview.diarioview_page", page=(page - 1)) }}">Pagina precedente</a>
        {% endif %}
        {% for entry in entries %}
            <blockquote id="diario-{{ entry.diario_id }}" class="diario{% if entry.spoiler %} diario-spoiler{% endif %}">
                <div class="diario-content">
                    {% if entry.media_url %}
                        <a href="{{ entry.media_url }}" class="no-icon diario-img"><img src="{{ entry.media_url }}" alt="Caricamento immagine fallito"></a>
                    {% endif %}
                    {% if entry.text %}
                        "<span class="diario-text">{{ entry.text }}</span>"
                    {% endif %}
                </div>
                {% if entry.quoted %}
                    <div class="diario-quote">
                        —
                        {% if entry.quoted_account %}
                            <a href="{{ url_for("profile.profile_by_username", username=entry.quoted_account.username) }}" class="diario-quoted">{{ entry.quoted }}</a>
                        {% else %}
                            <span class="diario-quoted">{{ entry.quoted }}</span>
                        {% endif %}
                        {% if entry.context %}
                            , <span class="diario-context">{{ entry.context }}</span>
                        {% endif %}
                    </div>
                {% endif %}
                {% if entry.creator %}
                    <div class="diario-created">Salvato da <a href="{{ url_for("profile.profile_by_username", username=entry.creator.username) }}" class="diario-creator">{{ entry.creator.username }}</a></div>
                {% endif %}
                <time class="diario-timestamp" datetime="{{ entry.timestamp.isoformat() }}">{{ entry.timestamp.strftime("%d %b %Y %H:%M:%S") }}</time>
                <span class="diario-id">#{{ entry.diario_id }}</span>
            </blockquote>
        {% endfor %}
        {% if entries|length == 1000 %}
            <a class="next-page" href="{{ url_for("diarioview.diarioview_page", page=(page + 1)) }}">Pagina successiva</a>
        {% endif %}
    </div>
{% endblock %}
