NatLibFi/Skosmos

View on GitHub
src/view/vocab-info.inc.twig

Summary

Maintainability
Test Coverage
<div class="col-md-8" id="main-content">
  <div class="main-content-section px-5 py-4">
    <h1 class="pt-3 pb-5">{{ "Vocabulary information" | trans }}</h1>

    {% set vocabInfo = vocab.info(request.contentLang) %}
    {% if not vocabInfo %}
    <div class="alert alert-danger" role="alert">
        {{ "Error: Failed to retrieve vocabulary information!" | trans }}
    </div>
    {% else %}

    {% for key, values in vocabInfo %}
    <div class="row property g-0">
      <div class="col-sm-4 px-0 property-label"><h2>{{ key | trans }}</h2></div>
      <div class="col-sm-8 align-self-center property-value">
        <ul class="align-bottom">
          {% for val in values %}
          <li>
            {% if val.get('skosmos:vocab') %}
            <a href="{{ val.uri | link_url(val.get('skosmos:vocab').value,request.lang,'page',request.contentLang) }}">{{ val.get('skosmos:label') }}</a>
            {% elseif val.label %}
            <a href="{{ val.uri }}">
              {% if val.label(request.contentLang) %}{{ val.label(request.contentLang) }}
              {% else %}{{ val.label }}
              {% endif %}
            </a>
            {% elseif val matches '|^(https?://)|' %}<a href="{{ val }}">{{ val }}</a>
            {% elseif val matches '|<\\w*\\b[^>]*>|' %}{{ val|raw|nl2br }}
            {% else %}{{ val|nl2br }}
            {% endif %}
          </li>
          {% endfor %}
        </ul>
      </div>
    </div>
    {% endfor %}

    {% endif %}

    {% if vocab.config.showStatistics %}
    <div class="vocab-statistics">
      <div id="resource-counts"></div>
      <div id="term-counts"></div>
    </div>
    {% endif %}

    {% if vocab.config.dataURLs %}
    <div class="row g-0 py-3">
      <div class="col-sm-12 px-0 property-label" id="download-links">
        <h2><i class="fa-solid fa-download"></i> {{ "Download this vocabulary:" | trans }}</h2>
        <ul class="d-inline">
        {% if 'application/rdf+xml' in vocab.config.dataURLs|keys %}
          <li><a class="me-3" href="rest/v1/{{ request.vocabid }}/data?format=application/rdf%2Bxml">RDF/XML</a></li>
        {% endif %}
        {% if 'text/turtle' in vocab.config.dataURLs|keys %}
          <li><a class="me-3" href="rest/v1/{{ request.vocabid }}/data?format=text/turtle">TURTLE</a></li>
        {% endif %}
        {% if 'application/ld+json' in vocab.config.dataURLs|keys %}
          <li><a class="me-3" href="rest/v1/{{ request.vocabid }}/data?format=application%2Fld%2Bjson">JSON-LD</a></li>
        {% endif %}
        {% if 'application/marcxml+xml' in vocab.config.dataURLs|keys %}
            {% if vocab.config.dataURLs['application/marcxml+xml'] is iterable %}
                {% for key, values in vocab.config.dataURLs['application/marcxml+xml'] %}
                    <li><a class="me-3" href="rest/v1/{{ request.vocabid }}/data?format=application/marcxml%2Bxml&lang={{key}}">MARCXML/{{ key | lang_name(request.lang) }}</a></li>
                {% endfor %}
            {% else %}
                <li><a href="rest/v1/{{ request.vocabid }}/data?format=application/marcxml%2Bxml">MARCXML</a></li>
            {% endif %}
        {% endif %}
        </ul>
      </div>
    </div>
    {% endif %}
  </div>
  <!-- appendix / concept mapping properties -->
  <div id="concept-mappings">
  </div>
</div>