home » zplus/dokk.org.git
ID: 7337c3f62f5c33aff6c231e55309dfe9a524d688
79 lines — 2K — View raw


{% extends "templates/base.tpl" %}

{% set data = query("""
    PREFIX library: <dokk:vocab:library:>
    PREFIX license: <dokk:vocab:license:>

    CONSTRUCT {
        ?item library:title ?title ;
              library:author ?author ;
              license:licensed_under ?license .

        ?license license:id ?license_id ;
                 license:name ?license_name .
    }
    WHERE {
        ?item
            library:title ?title ;
            library:author ?author ;
            license:licensed_under ?license .

        FILTER (?item = <dokk:""" + item_id + """>)

        OPTIONAL {
        ?license license:id ?license_id_optional ;
                 license:name ?license_name_optional .
        }

        BIND(COALESCE(?license_id_optional, SUBSTR(STR(?license), 14)) AS ?license_id)
        BIND(COALESCE(?license_name_optional, SUBSTR(STR(?license), 14)) AS ?license_name)
    }
    """,
    {
        "@context": {
            "library": "dokk:vocab:library:",
            "license": "dokk:vocab:license:",
            "library:author": { "@container": "@set" },
            "license:licensed_under": { "@container": "@set" }
        },
        "library:title": {}
    }
    )["@graph"][0]
%}

{% block title %}{{ data['library:title'] }}{% endblock %}

{% block body %}

<div class="library_item">
    <div class="header">
        <a href="/library">DOKK Library</a>
    </div>

    <object type="application/pdf" data="https://blob.dokk.org/pdf/{{ item_id }}.pdf"></object>

    <div class="info">
        <h1>{{ data["library:title"] }}</h1>

        <p>
            <b>Authors</b>
            {% for author in data["library:author"]|sort() %}
                {{ author }}
            {% endfor%}
        </p>

        <p>
            <b>License</b>
            {% for license in data["license:licensed_under"]|sort(attribute="license:id") %}
                <a href="{{ url('license', id=license['license:id']) }}">{{ license['license:id'] }}</a>
            {% endfor%}
        </p>
    </div>

    <details open>
        <summary>Plaintext</summary>
        <pre>{{ plaintext }}</pre>
    </details>
</div>

{% endblock %}