From bb0728cf703d5b60e0e383b1e03426d4bd27fe71 Mon Sep 17 00:00:00 2001 From: zPlus Date: Sat, 14 Dec 2024 14:01:38 +0100 Subject: [PATCH] Update Library vocabulary. Library vocabulary in the database has changed. Update queries and HTML templates with new vocabulary. --- app.py | 28 ++++++++++++++-------------- pages/library.html | 4 ++-- pages/templates/library/item.tpl | 18 +++++++++--------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/app.py b/app.py index 71ade47..ed12e32 100755 --- a/app.py +++ b/app.py @@ -106,8 +106,7 @@ def library(): # Get a list of authors for searching authors = query(""" - PREFIX library: - PREFIX license: + PREFIX library: SELECT DISTINCT ?name WHERE { @@ -118,14 +117,15 @@ def library(): # Get a list of licenses for searching licenses = query(""" - PREFIX library: - PREFIX license: + PREFIX library: + PREFIX license: SELECT DISTINCT ?id WHERE { - [] library:license [ - license:id ?id - ] . + [] a library:Item; + license:licensed_under [ + license:id ?id + ] } ORDER BY ?id """)['results']['bindings'] @@ -147,20 +147,20 @@ def library(): query_filters += f'FILTER(?license_id IN ({query_filters_license}))' items = query(f""" - PREFIX library: - PREFIX license: + PREFIX library: + PREFIX license: CONSTRUCT {{ ?item library:title ?title; library:author ?author ; - library:license ?license . + license:licensed_under ?license . ?license license:id ?license_id ; license:name ?license_name . }} WHERE {{ ?item library:title ?title ; library:author ?author ; - library:license ?license . + license:licensed_under ?license . OPTIONAL {{ ?license license:id ?license_id_optional ; @@ -176,10 +176,10 @@ def library(): """, { '@context': { - 'library': 'dokk:library:', - 'license': 'dokk:license:', + 'library': 'dokk:vocab:library:', + 'license': 'dokk:vocab:license:', 'library:author': { '@container': '@set' }, - 'library:license': { '@container': '@set' } + 'license:licensed_under': { '@container': '@set' } }, 'library:title': {} }) diff --git a/pages/library.html b/pages/library.html index 4e8db50..60ee007 100644 --- a/pages/library.html +++ b/pages/library.html @@ -38,7 +38,7 @@ {% for item in items["@graph"]|sort(attribute="library:title") %}

@@ -50,7 +50,7 @@
License: - {% for license in item["library:license"]|sort(attribute="license:id") %} + {% for license in item["license:licensed_under"]|sort(attribute="license:id") %} {{ license['license:id'] }} {% endfor%}
diff --git a/pages/templates/library/item.tpl b/pages/templates/library/item.tpl index 5430ab9..7337c3f 100644 --- a/pages/templates/library/item.tpl +++ b/pages/templates/library/item.tpl @@ -1,13 +1,13 @@ {% extends "templates/base.tpl" %} {% set data = query(""" - PREFIX library: - PREFIX license: + PREFIX library: + PREFIX license: CONSTRUCT { ?item library:title ?title ; library:author ?author ; - library:license ?license . + license:licensed_under ?license . ?license license:id ?license_id ; license:name ?license_name . @@ -16,9 +16,9 @@ ?item library:title ?title ; library:author ?author ; - library:license ?license . + license:licensed_under ?license . - FILTER (?item = ) + FILTER (?item = ) OPTIONAL { ?license license:id ?license_id_optional ; @@ -31,10 +31,10 @@ """, { "@context": { - "library": "dokk:library:", - "license": "dokk:license:", + "library": "dokk:vocab:library:", + "license": "dokk:vocab:license:", "library:author": { "@container": "@set" }, - "library:license": { "@container": "@set" } + "license:licensed_under": { "@container": "@set" } }, "library:title": {} } @@ -64,7 +64,7 @@

License - {% for license in data["library:license"]|sort(attribute="license:id") %} + {% for license in data["license:licensed_under"]|sort(attribute="license:id") %} {{ license['license:id'] }} {% endfor%}