From c20d80a59db396d8d349b06a93196467ec21f4a2 Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 19 Nov 2020 14:38:05 +0100 Subject: [PATCH] last changes --- daapinterface.py | 23 ++++------------------- templates/artwork.html | 41 +++++++++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/daapinterface.py b/daapinterface.py index ba5d4e8..bf8fd84 100644 --- a/daapinterface.py +++ b/daapinterface.py @@ -217,7 +217,6 @@ def artwork(): ''') sparql.setReturnFormat(JSON) artworkintro = sparql.query().convert() - # print(artworkintro) # Image(s) # query for later @@ -252,7 +251,6 @@ def artwork(): sparql.setReturnFormat(JSON) artworkimages = sparql.query().convert() - # print(artworkimages) # Links and downloads sparql.setQuery(''' @@ -267,7 +265,6 @@ def artwork(): }''') sparql.setReturnFormat(JSON) artworklinksanddownloads = sparql.query().convert() - print(artworklinksanddownloads) # Other digital artefacts sparql.setQuery(''' @@ -276,19 +273,21 @@ def artwork(): { { SELECT ?ImageFile WHERE { - VALUES ?work {wd:Q57} + VALUES ?work {wd:'''+artwork_id+'''} OPTIONAL {?work p:P35 ?statement. ?statement ps:P35 ?ImageFile; pq:P16 wd:Q85.} }} { SELECT ?AudioFile WHERE { + VALUES ?work {wd:'''+artwork_id+'''} OPTIONAL {?work p:P35 ?statement. ?statement ps:P35 ?AudioFile; pq:P16 wd:Q28.} }} { SELECT ?VideoFile WHERE { + VALUES ?work {wd:'''+artwork_id+'''} OPTIONAL {?work p:P35 ?statement. ?statement ps:P35 ?VideoFile; pq:P16 wd:Q27.} @@ -298,7 +297,7 @@ def artwork(): ''') sparql.setReturnFormat(JSON) artworkartefacts = sparql.query().convert() - # print(artworkartefacts) + print(artworkartefacts) # Distributor Links @@ -335,7 +334,6 @@ def artwork(): ''') sparql.setReturnFormat(JSON) artworkcontributors = sparql.query().convert() - # print(artworkcontributors) # date sparql.setQuery(''' @@ -352,7 +350,6 @@ def artwork(): ''') sparql.setReturnFormat(JSON) artworkdate = sparql.query().convert() - # print(artworkdate) # publishers sparql.setQuery(''' @@ -373,8 +370,6 @@ def artwork(): ''') sparql.setReturnFormat(JSON) artworkpublisher = sparql.query().convert() - # print(artworkpublisher) - #####right middle # description + id to be changed @@ -395,16 +390,10 @@ def artwork(): artworkdescriptiondata = sparql.query().convert() - # get the description text or say there isn't any - # artworkdescriptiontext = [] - for x in artworkdescriptiondata['results']['bindings']: if "accessURLdescriptionPage" in x: - # print("url for description present") - # print(x["accessURLdescriptionPage"]["value"]) accessURLdescriptionUrl = x["accessURLdescriptionPage"]["value"] desc_url = re.search(r':Q(.*)', accessURLdescriptionUrl, re.DOTALL) - # print(desc_url.group(1)) desc_id=desc_url.group(1) # # get the description content from wiki artworkdescriptioncontenturl = "https://daap.bannerrepeater.org/w/index.php?title=Description:Q"+desc_id+"&action=render" @@ -444,8 +433,6 @@ def artwork(): # get the text from the url for x in artworkexhibitiondata['results']['bindings']: if "accessURLexhibitionHisPage" in x: - # print("url for description present") - # print(x["accessURLexhibitionHisPage"]["value"]) accessURLexhibitionHisPage = x["accessURLexhibitionHisPage"]["value"] desc_url = re.search(r':Q(.*)', accessURLexhibitionHisPage, re.DOTALL) # print(desc_url.group(1)) @@ -467,7 +454,6 @@ def artwork(): # artworkexhibitiontext=Markup(text) x['text']=text - # print(artworkexhibitiondata) ############## bottom @@ -519,7 +505,6 @@ def artwork(): ''') sparql.setReturnFormat(JSON) artworklists = sparql.query().convert() - # print(artworklists) return render_template('artwork.html', artwork_id=artwork_id, artworkintro=artworkintro, artworkimages=artworkimages, artworklinksanddownloads=artworklinksanddownloads, artworkartefacts=artworkartefacts, artworkdistributorlinks=artworkdistributorlinks, artworkcontributors=artworkcontributors, artworkdate=artworkdate, artworkpublisher=artworkpublisher, artworkdescriptiondata=artworkdescriptiondata, artworkexhibitiondata=artworkexhibitiondata, artworklists=artworklists, copiesincollection=copiesincollection, relatedworks=relatedworks) diff --git a/templates/artwork.html b/templates/artwork.html index ebeb48c..7ada940 100644 --- a/templates/artwork.html +++ b/templates/artwork.html @@ -63,6 +63,10 @@ {% for x in artworklinksanddownloads['results']['bindings'] %}

DOWNLOADS AND LINKS

+ {% if ('DownloadDigitalFacsimile' not in x) and ('DigitalFacsimileExternalLink' not in x) and ('DigitalFacsimileExternalLink2' not in x) %} +

information not available

+ {% endif %} + {% if 'DownloadDigitalFacsimile' in x %}
@@ -92,10 +96,14 @@
{% if artworkartefacts['results']['bindings']==[] %} +

information not available

+ {% else %}

OTHER DIGTAL ARTEFACTS

{% for x in artworkartefacts['results']['bindings'] %} - {{ x }} + + + {% endfor %} {% endif %}
@@ -106,11 +114,16 @@ {% else %}

DISTRIBUTOR LINKS

{% for x in artworkdistributorlinks['results']['bindings'] %} + {% if 'distributorLinks' not in x %} +

information not available

+ {% endif %} + {% if 'distributorLinks' in x %}
{{ x['distributorLinks']['value'] }}
+ {% endif %} {% endfor %}

@@ -124,9 +137,15 @@
+

CONTRIBUTORS

+ + {% if artworkcontributors['results']['bindings']==[] %} +
information not available
+ {% else %} + {% for x in artworkcontributors['results']['bindings'] %} {% endfor %} + {% endif %}
+

DATE

- + + {% if artworkdate['results']['bindings']==[] %} +
information not available
+ {% else %} + + {% for x in artworkdate['results']['bindings'] %} {% if 'date' in x %}
{{ x['date']['value'] | replace("T00:00:00Z", "") }}
- {% else %} - but
information not available
{% endif %} @@ -155,18 +179,21 @@
Source: {{ x['sourceLabel']['value'] }}
{% endif %} {% endfor %} + {% endif %}

PUBLISHERS

+ {% if artworkpublisher['results']['bindings']==[] %} + information not available + {% else %} + {% for x in artworkpublisher['results']['bindings'] %}