{% extends this_string_will_be_replaced %}

{% load i18n %}
{% load static %}

<!-- load custom template tags -->
{% load unicms_carousels %}
{% load unicms_contexts %}
{% load unicms_menus %}
{% load unicms_templates %}
{% load unicms_pages %}
{% load unicms_publications %}

<!-- SEO  -->
{% block page_title %}{{ publication_context.publication.title }}{% endblock page_title %}
{% block page_meta_description %}{{ publication_context.publication.subheading }}{% endblock page_meta_description %}
{% block page_meta_keywords %}{% for tag in publication_context.publication.tags.all %}{{ tag }},{% endfor %}{% endblock page_meta_keywords %}

{% block container %}
{% breadcrumbs webpath=webpath leaf=handler %}

<div class="container">
    <div class="col-12 py-5 bd-content">
        {% block centered_container %}
<!--
        <p><img src="{{ publication_context.publication.image_url }}" width="100%"></p>
-->
        <div class="row">

            <div class="col-12 mb-4">
                <div class="pt-2 pb-3 pl-3 background-yellow">
                    <h2 class="m-0 p-0">
                        <span style="font-weight: 500">unical</span>
                        <span class="super-bold">world</span>
                    </h2>
                </div>
            </div>

            <div class="col-12 mb-5">
                <p style="font-size: 2rem">
                {% for category in publication_context.publication.categories %}
                    <span class="badge badge-grey-unical square-corners">
                        <a href="{% call obj=publication_context method='get_url_list' category_name=cat %}?category_name={{ category }}">{{ category }}</a>
                    </span>
                {% endfor %}
                </p>
            </div>

            <div class="col-12 col-lg-8">

                <p class="text-muted">
                    <svg class="icon icon-xs">
                        <use xlink:href="{% static 'svg/sprite.svg' %}#it-clock"></use>
                    </svg> {% trans "Published" %} {{ publication_context.publication.created }}
                </p>
                <h1 class="mb-4">{{ publication_context.publication.title }}</h1>
                <p class="bigger-font">{{ publication_context.publication.subheading }}</p>
                {% if publication_context.publication.presentation_image %}
                <div class="img-wrapper pb-3">
                    <img src="{{ publication_context.publication.image_url }}"
                         title="img title"
                         alt="imagealt"
                         style="width: 100%">
                </div>
                {% endif %}

                <div>
                    {{ publication_context.publication.html_content|safe }}
                </div>

                {% if publication_context.publication.tags.all %}
                <h4>{% trans "tags" %}</h4>
                <p style="font-size: 1.2rem">
                {% for tag in publication_context.publication.tags.all %}
                    <span class="badge badge-grey-unical square-corners">{{ tag.name }}</span>
                {% endfor %}
                </p>
                {% endif %}

                {% if publication_context.publication.get_attachments %}
                <hr>
                <br>
                <h4>{% trans "attachments" %}</h4>

                <!-- ATTACHMENTS -->
                <ul class="upload-file-list">

                    {% for item in publication_context.publication.get_attachments %}
                    <li class="upload-file success">
                      <a href="{{ item.file.url }}" >
                      <span  style="color: #000;">
                        <svg class="icon icon-secondary" aria-hidden="true"><use xlink:href="{% static '/svg/sprite.svg' %}#it-file"></use></svg>
                        <span class="sr-only">{% trans "Allegato" %}:</span> {{ item.name }}
                        <span class="text-muted small"> &nbsp; {{ item.file_type }} ({{ item.file_size_kb }} KB)</span>
                      </span>
                      </a>
                    </li>
                    {% endfor %}
                </ul>
              <!-- END ATTACHMENTS -->

            {% endif %}


                {% if publication_context.publication.related_galleries %}
                <hr>

                <br>
                <h4>{% trans "photo gallery" %}</h4>


                    {% for gallery in publication_context.publication.related_galleries %}

                        {% include "carousel_media_gallery.html" with media_items=gallery.collection.get_items %}

                        {% include "grid_media_gallery.html" with media_items=gallery.collection.get_items %}

                    {% endfor %}
                {% endif %}

            <!-- END PUBLICATION BODY -->
            </div>

            <div class="col-12 col-lg-3 offset-lg-1">

                <h5 class="card-title">{% trans "Published in" %}</h5>
                <ul class="pl-0" style="list-style: none">
                {% for pub_context in publication_context.publication.related_contexts %}
                    <li class="mb-3">
                        <a href="{{ pub_context.webpath.get_full_path }}">{{ pub_context.webpath.name }}</a>
                    </li>
                {% endfor %}
                </ul>

                {% if publication_context.publication.related_publications %}
                <h5 class="card-title">{% trans "Related pages" %}</h5>
                <ul class="pl-0" style="list-style: none">
                {% for related_pub in publication_context.publication.related_publications %}
                    <li class="mb-3">
                        <a href="{{ related_pub.first_available_url }}">{{ related_pub.related }}</a>
                        <br>
                        <svg class="icon icon-xs">
                            <use xlink:href="{% static 'svg/sprite.svg' %}#it-clock"></use>
                        </svg> <small class="text-muted">{{ related_pub.related.created|date:"d M Y" }}</small>
                    </li>
                {% endfor %}
                </ul>
                {% endif %}

                {% if publication_context.publication.related_links %}
                    <h5 class="card-title">{% trans "Links" %}</h5>
                    <ul class="pl-0" style="list-style: none">
                    {% for link in publication_context.publication.related_links %}
                        <li class="mb-3">
                            <a href="{{ link.url }}">
                                <svg class="icon icon-xs">
                                    <use xlink:href="{% static 'svg/sprite.svg' %}#it-link"></use>
                                </svg>
                                {{ link.name }}</a>
                        </li>
                    {% endfor %}
                    </ul>
                {% endif %}

                {% if publication_context.publication.available_in_languages %}
                    <h5 class="card-title">{% trans "Available in languages" %}</h5>
                    <ul class="pl-0" style="list-style: none">
                    {% for lang,language in publication_context.publication.available_in_languages %}
                        <li class="mb-3">
                            <p>{{ language }}</p>
                        </li>
                    {% endfor %}
                    </ul>
                {% endif %}

            </div>

        </div>

        {% endblock %}
    </div>
</div>
{% endblock container %}
