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

{% load unicms_contexts %}
{% load unicms_templates %}

{% settings_value "CMS_PUBLICATION_LIST_PREFIX_PATH" as page_news_suffix %}

{% if publications %}
<div class="it-carousel-wrapper it-carousel-landscape-abstract-three-cols">
    <div class="it-carousel-all owl-carousel owl-carousel-cards it-card-bg">
        {% for pub in publications %}
        <div class="card-wrapper card-space">
            <div class="card card-bg no-after">
                <div class="card-body">
                    <div class="etichetta">
                        {% for cat in pub.publication.categories %}
                            <span class="badge badge-pill badge-grey-unical my-1 py-2 px-4 mr-1">
                                <a class="no-color" href="{% call obj=pub method='get_url_list' category_name=cat %}">
                                    <b>{{ cat }}</b>
                                </a>
                            </span>
                        {% endfor %}
                    </div>
                    {% if pub.publication.image_url %}
                    <div class="img-responsive-wrapper mb-3">
                        <div class="img-responsive img-responsive-panoramic">
                            <figure class="img-wrapper">
                              <a href="{{ pub.url }}">
                                <img src="{{ pub.publication.image_url }}"
                                     title="{{ pub.publication.image_title }}"
                                     alt="{{ pub.publication.image_description }}">
                              </a>
                            </figure>
                        </div>
                    </div>
                    {% endif %}
                    <div class="category-top">
                        <span>{% trans "Published" %}: {{ pub.date_start }}</span>
                    </div>
                    <h4 class="card-title">
                        <a href="{{ pub.url }}" class="no-color">
                            {{ pub.publication.title }}
                        </a>
                    </h4>
                    {% if not pub.publication.image_url %}
                    <p class="card-text">
                        {{ pub.publication.subheading|truncatechars:135 }}
                    </p>
                    {% endif %}
                    <a href="#">
                        <svg class="icon">
                            <use xlink:href="{% static 'svg/sprite.svg' %}#it-share"></use>
                        </svg>
                    </a>
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
</div>

<p class="mt-3 ml-2">
    <a href="{{ page_news_suffix }}" class="no-color">
        <span class="text-black font-weight-bold">
            <svg class="icon mr-2">
                <use xlink:href="{% static '/svg/sprite.svg' %}#it-arrow-right-circle"></use>
            </svg>
            {% trans "Go to all news" %}
        </span>
    </a>
</p>
{% endif %}
