{% macro orcid_url(orcid) -%}
{% if not orcid.startswith("http") %}https://orcid.org/{% endif %}{{orcid | escape}}
{%- endmacro %}

{% macro link_fonts() %}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fira+Mono&family=Fira+Sans+Condensed&family=Fira+Sans:ital,wght@0,300;0,400;0,700;1,400&display=swap" rel="stylesheet">
{% endmacro %}


{% macro obsolete_alert() %}
  <div class="edition-obsolete" role="alert">
    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="#f21" class="bi bi-exclamation-triangle-fill flex-shrink-0 me-2" viewBox="0 0 16 16" role="img" aria-label="Warning:">
      <path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
    </svg>Obsolete
  </div>
{% endmacro %}


{% macro edition_band(doc) %}
    <div class="edition-band">
      {% if doc.edid %}
      <div class="edition-number">Edition&nbsp;{{ doc.edid }}</div>
      {% endif %}
      {% if doc.obsolete %}
        {{- obsolete_alert() }}
      {% endif %}
    </div>
{% endmacro %}


{% macro article_dates(doc) %}
    <dl class="article-dates">
      {% if doc.date %}
      <dt>Author date</dt>
      <dd>{{ doc.date }}</dd>
      {% endif %}
      {% if doc.archive_date %}
      <dt>Archive date</dt>
      <dd>{{ doc.archive_date }}</dd>
      {% endif %}
    </dl>
{% endmacro %}


{% macro copyright(doc) +%}
  {% set cc_license = {
      "cc0license": "CC0",
      "ccbylicense": "CC BY",
      "ccbysalicense": "CC BY-SA",
      "ccbynclicense": "CC BY-NC",
      "ccbyncsalicense": "CC BY-NC-SA",
      "ccbyndlicense": "CC BY-ND",
      "ccbyncndlicense": "CC BY-NC-ND",
  }
  %}
  {% if doc.copyright %}
  <p>{{ doc.copyright }}</p>
  {% endif %}
  {% if doc.license_ref %}
  <p>
     <a href="{{ doc.license_ref }}" rel="nofollow">
       {{ cc_license[doc.cc_license_type] }}
       License
     </a>
  </p>
  {% endif %}
  {% if doc.license_p %}
  <p>{{ doc.license_p }}</p>
  {%- endif %}
{%- endmacro %}


{% macro contributors_list(contributors, show_email=True) %}
<dl class="contributors">
  {% for contributor in contributors %}
    <dt>
      {{ (contributor['given-names'] ~ ' ' ~ contributor.surname) | escape }}
      {% if contributor.orcid %}
        <a class="orcid" href="{{ orcid_url(contributor.orcid) }}"><i class="orcid-icon"></i></a>
      {%- endif -%}
    </dt>
    {% if contributor.email and show_email %}
      <dd><a href="mailto:{{ contributor.email[0] | escape }}">{{ contributor.email | join(', ') | escape }}</a></dd>
    {% endif %}
  {% endfor %}
</dl>
{% endmacro %}
