<!--
SPDX-FileCopyrightText: 2017-present Tobias Kunze
SPDX-License-Identifier: AGPL-3.0-only WITH LicenseRef-Pretalx-AGPL-3.0-Terms
-->

{% extends "agenda/base.html" %}

{% load datetimerange %}
{% load event_tags %}
{% load html_signal %}
{% load i18n %}
{% load phrases %}
{% load rich_text %}
{% load static %}
{% load thumbnail %}

{% block title %}{{ submission.title }} ::{% endblock title %}
{% block meta_title %}{{ submission.title }}{% endblock meta_title %}
{% block social_title %}{{ submission.title }}{% endblock social_title %}
{% block meta_description %}{{ submission_description }}{% endblock meta_description %}
{% block social_description %}{{ submission_description }}{% endblock social_description %}
{% block meta_image %}
    <meta property="thumbnail" content="{{ submission.urls.social_image.full }}">
    <meta property="og:image" content="{{ submission.urls.social_image.full }}">
{% endblock meta_image %}
{% block alternate_link %}
    <link rel="alternate" type="application/json" title="{{ request.event.name }} API" href="{{ request.event.api_urls.talks.full }}{{ submission.code }}" />
{% endblock alternate_link %}

{% block agenda_custom_header %}
    <script id="pretalx-messages" data-logged-in="{% if request.user.is_anonymous %}false{% else %}true{% endif %}" src="{{ request.event.urls.schedule }}widget/messages.js"></script>
    <script defer src="{% static "agenda/js/favourite.js" %}"></script>
    <script defer src="{% static "common/js/ui/datetime-local.js" %}"></script>
{% endblock agenda_custom_header %}

{% block agenda_stylesheets %}
    <link rel="stylesheet" href="{% static "common/css/ui/tooltip.css" %}" />
    <link rel="stylesheet" href="{% static "agenda/css/talk.css" %}" />
{% endblock agenda_stylesheets %}

{% block agenda_content %}
    <article>
        {% html_signal "pretalx.agenda.signals.html_above_session_pages" sender=request.event request=request submission=submission %}
        <h3 class="talk-title">
            <div class="heading-with-buttons">
                <span>
                    {{ submission.title }}
                    <button class="btn btn-xs btn-link d-none" id="fav-button">
                        <i class="fa fa-star-o d-none" title="{% translate "Favourite this session" %}"></i>
                        <i class="fa fa-star d-none" title="{% translate "Remove this session from your favourites" %}"></i>
                    </button>
                </span>
                <div class="buttons d-flex justify-content-end" id="talk-buttons">
                    {% if submission.state == "confirmed" and request.event.current_schedule %}
                        <a class="btn btn-outline-primary" href="{{ submission.urls.ical }}">
                            <i class="fa fa-calendar"></i> .ical
                        </a>
                    {% endif %}
                    {% if submission.does_accept_feedback and request.event|get_feature_flag:"use_feedback" and not is_html_export %}
                        <a href="{{ submission.urls.feedback }}" class="btn btn-success ml-1">
                            <i class="fa fa-comments"></i> {{ phrases.agenda.feedback }}
                        </a>
                    {% endif %}
                    {% if request.user in submission.speakers.all %}
                        <a href="{{ submission.urls.user_base }}" class="btn btn-info ml-1">
                            <i class="fa fa-edit"></i> {{ phrases.base.edit }}
                        </a>
                    {% endif %}
                </div>
            </div>
            <small class="text-muted">
                {% if scheduling_information_visible %}
                    {% if talk_slots|length == 1 %}
                        {{ talk_slots.0.start|datetimerange:talk_slots.0.end }}, {{ talk_slots.0.room.name }}
                        {% if talk_slots.0.room.description %}
                            <i class="fa fa-question-circle" data-toggle="tooltip" title="{{ talk_slots.0.room.description }}"></i>
                        {% endif %}
                    {% endif %}
                {% endif %}
                {% if request.event.is_multilingual and request.event.cfp.request_content_locale %}
                    <div class="speakers">
                        <strong>{{ phrases.base.language }}:</strong> {{ submission.get_content_locale_display }}
                    </div>
                {% endif %}
                {% if submission.do_not_record %}
                    <span class="fa-stack">
                        <i class="fa fa-video-camera fa-stack-1x"></i>
                        <i class="fa fa-ban do-not-record fa-stack-2x" aria-hidden="true" alt="{{ phrases.agenda.schedule_do_not_record }}"></i>
                    </span>
                    <em>{{ phrases.agenda.schedule.do_not_record }}</em>
                {% endif %}
            </small>
        </h3>
        <div class="talk row">
            <div class="talk-content">
                {% if recording_iframe %}{{ recording_iframe|safe }}{% endif %}
                {% if submission.image %}
                    <div class="talk-image">
                        <a href="{{ submission.image.url }}" data-lightbox>
                            <img loading="lazy"
                                 src="{{ submission.image.url }}"
                                 alt="{% translate "This session’s header image" %}">
                        </a>
                    </div>
                {% endif %}
                {% if scheduling_information_visible %}
                    {% if talk_slots|length > 1 %}
                        <ul class="talk-slots">
                            {% for talk in talk_slots %}
                                <li class="text-muted">
                                    {{ talk.start|datetimerange:talk.end }}, {{ talk.room.name }}
                                    {% if room.description %}
                                        <i class="fa fa-question-circle" data-toggle="tooltip" title="{{ room.description }}"></i>
                                    {% endif %}
                                </li>
                            {% endfor %}
                        </ul>
                        <p>
                            <i>{% phrase "phrases.schedule.timezone_hint" tz=request.event.timezone %}</i>
                        </p>
                    {% endif %}
                {% endif %}
                <section class="abstract">
                    {{ submission.abstract|rich_text }}
                </section>
                {% if submission.abstract and submission.description %}<hr />{% endif %}
                <section class="description">
                    {{ submission.description|rich_text }}
                </section>
                {% if answers or icon_answers %}
                    <hr />
                    <section class="answers">
                        {% if icon_answers %}
                            <div class="icon-group">
                                {% for answer in icon_answers %}
                                    <span class="icon-link">
                                        {% include "common/question_answer.html" with answer=answer %}
                                    </span>
                                {% endfor %}
                            </div>
                        {% endif %}
                        {% for answer in answers %}
                            <span class="question"><strong>{{ answer.question.question }}:</strong></span>
                            <span class="answer {% if answer.question.variant != "text" %}answer-strip-paragraph{% endif %}">{% include "common/question_answer.html" with answer=answer %}</span>
                        {% endfor %}
                    </section>
                {% endif %}
            </section>
            {% if submission.public_resources %}
                <section class="resources">
                    {% translate "See also:" %}
                    {% if submission.public_resources.count == 1 %}{% with resource=submission.public_resources.first %}
                        {% include "agenda/includes/submission_resource.html" %}
                    {% endwith %}{% else %}
                        <ul>
                            {% for resource in submission.public_resources %}
                                <li>{% include "agenda/includes/submission_resource.html" %}</li>
                            {% endfor %}
                        </ul>
                    {% endif %}
                </section>
            {% endif %}
            <section>
                {% html_signal "pretalx.agenda.signals.html_below_session_pages" sender=request.event request=request submission=submission %}
            </section>
        </div>
    </div>
    {% for speaker in speakers %}
        <div class="pretalx-session">
            <div class="pretalx-session-time-box avatar">
                {% if not hide_speaker_links %}<a href="{{ speaker.talk_profile.urls.public }}">{% endif %}
                <div class="avatar-wrapper">
                    {% if speaker.avatar_url and request.event.cfp.request_avatar %}
                        <img loading="lazy" src="{{ speaker.avatar|thumbnail:"default" }}" alt="{% translate "The speaker’s profile picture" %}">
                    {% else %}
                        <img loading="lazy" src="{{ request.event.urls.speakers }}avatar.svg" alt="The speaker’s profile picture">
                    {% endif %}
                </div>
                {% if not hide_speaker_links %}</a>{% endif %}
            </div>
            <div class="pretalx-session-info">
                <div class="title">
                    {% if hide_speaker_links %}
                        {{ speaker.get_display_name }}
                    {% else %}
                        <a href="{{ speaker.talk_profile.urls.public }}">{{ speaker.get_display_name }}</a>
                    {% endif %}
                </div>
                <div class="abstract">{{ speaker.talk_profile.biography|default:""|rich_text }}</div>
                {% if speaker.other_submissions and not hide_speaker_links %}
                    {% translate "This speaker also appears in:" %}
                    <ul>
                        {% for talk in speaker.other_submissions %}
                            <li>
                                <a href="{{ talk.urls.public }}">{{ talk.title }}</a>
                            </li>
                        {% endfor %}
                    </ul>
                {% endif %}
            </div>
        </div>
    {% endfor %}
    </article>
{% endblock agenda_content %}
