|
|
@ -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 |
|
|
|