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


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

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

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

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

        FILTER (?item = <dokk:library:""" + 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:library:",
            "license": "dokk:license:",
            "library:author": { "@container": "@set" },
            "library:license": { "@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["library:license"]|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 %}