diff --git a/daapinterface.py b/daapinterface.py index b2b64a3..1054894 100644 --- a/daapinterface.py +++ b/daapinterface.py @@ -195,6 +195,97 @@ def zinesindex(): def artwork(): artwork_id = request.args.get('id') +# Artwork Intro / Top of the page + sparql.setQuery(''' + SELECT ?work ?workLabel ?workDescription ?itemtypeLabel + { + VALUES ?work {wd:'''+artwork_id+'''} + ?work wdt:P1 ?itemtype. + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } + } + ''') + sparql.setReturnFormat(JSON) + artworkintro = sparql.query().convert() + # print(artworkintro) + +# Image(s) + sparql.setQuery(''' + SELECT ?image ?depictsLabel ?licenseLabel + WHERE + { + VALUES ?work {wd:'''+artwork_id+'''} + ?work wdt:P30 ?image. + OPTIONAL { ?work p:P30 ?statement2. + ?statement2 ps:P30 ?image; + pq:P54 ?depicts; + pq:P56 ?license.} + SERVICE wikibase:label { bd:serviceParam wikibase:language "en".} + } + ''') + sparql.setReturnFormat(JSON) + artworkimages = sparql.query().convert() + # print(artworkimages) + +# contributors + sparql.setQuery(''' + SELECT DISTINCT ?creators ?creatorsLabel (group_concat(?creatorRolesLabel; separator="; ") as ?role) + WHERE + { + VALUES ?work {wd:Q118} + ?work wdt:P9 ?creators. + OPTIONAL { ?work p:P9 ?statement1. + ?statement1 ps:P9 ?creators; + pq:P49 ?creatorRoles. } + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". + ?creators rdfs:label ?creatorsLabel. + ?creatorRoles rdfs:label ?creatorRolesLabel. } + } + GROUP BY ?creators ?creatorsLabel + ORDER BY ?creatorsLabel + ''') + sparql.setReturnFormat(JSON) + artworkcontributors = sparql.query().convert() + # print(artworkcontributors) + +# date + sparql.setQuery(''' + SELECT ?date ?sourceLabel + WHERE + { + VALUES ?work {wd:'''+artwork_id+'''} + ?work wdt:P13 ?date. + OPTIONAL { ?work p:P13 ?statement1. + ?statement1 ps:P13 ?date; + pq:P50 ?source. } + SERVICE wikibase:label { bd:serviceParam wikibase:language "en".} + } + ''') + sparql.setReturnFormat(JSON) + artworkdate = sparql.query().convert() + # print(artworkdate) + +# publishers + sparql.setQuery(''' + SELECT DISTINCT ?publishers ?publishersLabel (group_concat(?publishersRolesLabel; separator="; ") as ?role) + WHERE + { + VALUES ?work {wd:'''+artwork_id+'''} + ?work wdt:P10 ?publishers. + OPTIONAL { ?work p:P10 ?statement1. + ?statement1 ps:P10 ?publishers; + pq:P49 ?creatorRoles. } + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". + ?publishers rdfs:label ?publishersLabel. + ?publishersRoles rdfs:label ?publishersRolesLabel. } + } + GROUP BY ?publishers ?publishersLabel + ORDER BY ?publishersLabel + ''') + sparql.setReturnFormat(JSON) + artworkpublisher = sparql.query().convert() + print(artworkpublisher) + + # copies in collection sparql.setQuery(''' SELECT ?copiesCollections ?copiesCollectionsLabel ?collection ?collectionLabel ?image @@ -208,7 +299,7 @@ def artwork(): } ''') sparql.setReturnFormat(JSON) copiesincollection = sparql.query().convert() - print(copiesincollection) + # print(copiesincollection) # related works sparql.setQuery(''' @@ -229,18 +320,15 @@ def artwork(): } ''') sparql.setReturnFormat(JSON) relatedworks = sparql.query().convert() - print(relatedworks) + # print(relatedworks) - # artwork_url = "https://daap.bannerrepeater.org/wiki/Item:Q92" - # artwork_title = "the human printer" - # artwork_description = "short description" - return render_template('artwork.html', copiesincollection=copiesincollection, relatedworks=relatedworks) + return render_template('artwork.html', artworkintro=artworkintro, artworkimages=artworkimages, artworkcontributors=artworkcontributors, artworkdate=artworkdate, artworkpublisher=artworkpublisher, copiesincollection=copiesincollection, relatedworks=relatedworks) -######################### PERSON +######################### PERSON - FOR NOW THIS IS A MESS @app.route("/person", methods=['GET']) def person(): person_id = request.args.get('id') @@ -408,7 +496,7 @@ raw_html = response['parse']['text']['*'] document = html.document_fromstring(raw_html) first_p = document.xpath('//p')[0] intro_text = first_p.text_content() -print(intro_text) +# print(intro_text) # ALL NAME diff --git a/templates/artwork.html b/templates/artwork.html index 1e31b6f..04e19d8 100644 --- a/templates/artwork.html +++ b/templates/artwork.html @@ -4,12 +4,120 @@
-
+
+ +
+ ARTWORK +
+ +
+ {% for x in artworkintro['results']['bindings'] %} + {{ x['workLabel']['value'] }} + {% endfor %} +
+ +
+ {% for x in artworkintro['results']['bindings'] %} + {% if 'workDescription' in x %} + {{ x['workDescription']['value'] }} + {% endif %} + {% endfor %} +
+ + +
+
ABOUT THIS WORK
+
RELATIONSHIPS
+
LISTS
+
DETAILED RECORD
+
+
-
+
+ +
+ +
+ {% for x in artworkimages['results']['bindings'] %} + {% if loop.index <= 1 %} + {% if "image" in x %} + + {% else %} + + {% endif %} + {% endif %} + {% endfor %} +
+ +
+
+ +
+ +
+ +
+ CONTRIBUTORS + {% for x in artworkcontributors['results']['bindings'] %} + + + +
+ {{ x['role']['value'] }} +
+ {% endfor %} +
+ +
+ DATE + + {% for x in artworkdate['results']['bindings'] %} + + {% if 'date' in x %} +
{{ x['date']['value'] | replace("T00:00:00Z", "") }}
+ {% else %} + but
information not available
+ {% endif %} + + + {% if 'sourceLabel' in x %} +
Source: {{ x['sourceLabel']['value'] }}
+ {% endif %} + {% endfor %} +
+ +
+ PUBLISHERS + + {% for x in artworkpublisher['results']['bindings'] %} + +
+ {% if 'publishersLabel' in x %} + {{ x['publishersLabel']['value'] }} + {% else %} + information not available + {% endif %} + + {% if 'role' in x %} + {{ x['role']['value'] }} + {% endif %} +
+ {% endfor %} +
+
+ +
+ +
+
+
@@ -29,7 +137,7 @@
{% if "image" in x %} - +