{#
  Copyright (C) 2020-2023 Graz University of Technology.

  invenio-theme-iform is free software; you can redistribute it and/or
  modify it under the terms of the MIT License; see LICENSE file for more
  details.
#}

<!---Recent uploads-->
<div class="ten wide column random-records-frontpage">
    <h2>{{ _("Recent uploads") }}</h2>

    {% if not records %}
        <div class="ui centered grid">
            <p style="font-size: medium;">{{ _("There are no public records to show.") }}</p>
        </div>
    {% endif %}

    {%- for r in records %}
        {%- set creation_date = r.created | from_isodatetime -%}
        {%- set record_url = r.links.self_html %}

        <article>
            <div class="badges">
                {# Publication date/Version badge #}
                <span class="ui label blue" data-tooltip="Publication date" data-inverted="">
                    {{ r.ui.created_date_l10n_long }}
                </span>

                {# Resource type badge #}
                {% if r.ui.resource_type %}
                    <span class="ui label grey" data-tooltip="Resource type" data-inverted="">
                        {{ r.ui.resource_type.title_l10n }}
                    </span>
                {% endif %}

                <span
                    class="ui label access-status {{ r.ui.access_status.id }}"
                    data-tooltip="{{ r.ui.access_status.description_l10n }}"
                    data-inverted=""
                >
                    <i class="icon {{ r.ui.access_status.icon }}"></i>
                    {{ r.ui.access_status.title_l10n }}
                </span>
            </div>

            <h4>
                <a href="{{ record_url }}" class="no-decoration"> {{ r.metadata.title }} </a>
            </h4>

            <p>
                {%- for creator in r.metadata.creators %}
                    <span>{{ creator.person_or_org.name }}</span>
                {%- endfor %}
            </p>

            <p class="hidden-xs">
                <a href="{{ record_url }}" class="no-decoration">
                    {{ r.metadata.description | striptags | truncate(300) }}
                </a>
            </p>

            <div class="ui">
                {%- for subject in r.metadata.subjects %}
                    <span class="ui tiny label">{{ subject.subject }}</span>
                {%- endfor %}
                <div>
                    <small>
                        {#
              {% trans user=userprofile, date=creation_date | dateformat("long")%}
                Uploaded on {{date}}
              {% endtrans %}
            #}
                    </small>
                </div>
            </div>
        </article>
    {%- endfor %}

    {% if records %}
        <div class="ui centered grid">
            <a class="ui button more" href="{{ url_for('invenio_search_ui.search') }}">{{ _("More") }}</a>
        </div>
    {%- endif %}
</div>
