home » zplus/dokk.org.git
ID: d9429d22001161a7839d3fed06ceea67a6f6fe13
77 lines — 2K — View raw


<?xml version="1.0" encoding="UTF-8"?>

{% 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(NOT EXISTS { ?item library:type ?item_type })

        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': {}
    })
%}

<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:dc="http://purl.org/dc/terms/"
      xmlns:opds="http://opds-spec.org/2010/catalog">

    <link rel="start" href="/library/opds.xml" type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
    <link rel="self" href="/library/opds/others.xml" type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>

    <id>urn:uuid:98d6aff1-0df9-4229-8c6e-2ab0ebece9e1</id>
    <title>DOKK Library Other Materials</title>
    <updated>{{ now() }}</updated>
    <author>
        <name>DOKK</name>
        <uri>https://dokk.org</uri>
    </author>

    {% for item in data["@graph"]|sort(attribute="library:title") %}
    <entry>
        <title>{{ item['library:title'] }}</title>

        {% for author in item["library:author"]|sort() %}
            <author>
                <name>{{ author }}</name>
            </author>
        {% endfor%}

        {% for license in item["library:license"]|sort(attribute="license:id") %}
            <rights>{{ license['license:id'] }}</rights>
        {% endfor%}

        <updated></updated>

        <dc:language></dc:language>
        <dc:identifier></dc:identifier>
        <link rel="http://opds-spec.org/acquisition" href="https://blob.dokk.org/pdf/{{ item['@id'][8:] }}.pdf" type="application/pdf" />
    </entry>
    {% endfor %}
</feed>