From 12102370f808ef64bb634b7166bd3f1248f15223 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 14 Jun 2021 16:13:14 +0200 Subject: [PATCH] support + copy to frontend + queries desc and exhib --- daapinterface.py | 54 ++++++++++++++++++++++++++++++++++++++---- templates/artwork.html | 5 ++++ templates/copy.html | 4 ++-- templates/item.html | 10 ++++++-- templates/layout.html | 2 +- 5 files changed, 65 insertions(+), 10 deletions(-) diff --git a/daapinterface.py b/daapinterface.py index 8544015..5d8602b 100644 --- a/daapinterface.py +++ b/daapinterface.py @@ -388,13 +388,26 @@ def artwork(): #####right middle # description + id to be changed sparql.setQuery(''' - SELECT ?accessURLdescriptionPage ?authordescriptionPage ?authordescriptionPageLabel ?datedescriptionPage ?sourcedescriptionPage ?sourcedescriptionPageLabel + SELECT ?accessURLdescriptionPage ?authordescriptionPageLabel ?datedescriptionPage ?sourcedescriptionPage WHERE { VALUES ?work {wd:'''+artwork_id+'''} ?work wdt:P65 ?descriptionPage. OPTIONAL { ?descriptionPage wdt:P4 ?accessURLdescriptionPage. } - OPTIONAL { ?descriptionPage wdt:P9 ?authordescriptionPage. } + { + SELECT DISTINCT ?descriptionPage (group_concat(?authorsdescriptionPageLabel; separator="; ") as ?authordescriptionPageLabel) + WHERE + { + VALUES ?work {wd:'''+artwork_id+'''} + ?work wdt:P65 ?descriptionPage. + OPTIONAL { ?descriptionPage wdt:P9 ?authorsdescriptionPage. } + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". + ?authorsdescriptionPage rdfs:label ?authorsdescriptionPageLabel. + ?authordescriptionPage rdfs:label ?authordescriptionPageLabel. } + } + GROUP BY ?descriptionPage + ORDER BY ?descriptionPage + } OPTIONAL { ?descriptionPage wdt:P13 ?datedescriptionPage. } OPTIONAL { ?descriptionPage wdt:P50 ?sourcedescriptionPage. } SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } @@ -403,6 +416,8 @@ def artwork(): sparql.setReturnFormat(JSON) artworkdescriptiondata = sparql.query().convert() + print(artworkdescriptiondata) + for x in artworkdescriptiondata['results']['bindings']: if "accessURLdescriptionPage" in x: @@ -426,17 +441,31 @@ def artwork(): text="

Information not available

" x["text"] = text - # print(artworkdescriptiondata) + # exhibitions + id to be changed sparql.setQuery(''' - SELECT ?accessURLexhibitionHisPage ?authorexhibitionHisPageLabel ?dateexhibitionHisPage ?sourceexhibitionHisPage + SELECT ?accessURLexhibitionHisPage ?authorexhibitionHisPageLabel ?dateexhibitionHisPage ?sourceexhibitionHisPage WHERE { VALUES ?work {wd:'''+artwork_id+'''} ?work wdt:P66 ?exhibitionHisPage. OPTIONAL { ?exhibitionHisPage wdt:P4 ?accessURLexhibitionHisPage. } - OPTIONAL { ?exhibitionHisPage wdt:P9 ?authorexhibitionHisPage. } + { SELECT DISTINCT ?exhibitionHisPage (group_concat(?authorsexhibitionHisPageLabel; separator="; ") as ?authorexhibitionHisPageLabel) + WHERE + { + VALUES ?work {wd:'''+artwork_id+'''} + + ?work wdt:P66 ?exhibitionHisPage. + OPTIONAL { ?exhibitionHisPage wdt:P9 ?authorsexhibitionHisPage. } + + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". + ?authorsexhibitionHisPage rdfs:label ?authorsexhibitionHisPageLabel. + ?authorexhibitionHisPage rdfs:label ?authorexhibitionHisPageLabel. } + } + GROUP BY ?exhibitionHisPage + ORDER BY ?exhibitionHisPage + } OPTIONAL { ?exhibitionHisPage wdt:P13 ?dateexhibitionHisPage. } OPTIONAL { ?exhibitionHisPage wdt:P50 ?sourceexhibitionHisPage. } SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } @@ -1110,6 +1139,21 @@ def searchtools(): text=Markup(text) return render_template('searchtools.html', text=text) +# #################### SUPPORT +@app.route("/support") +def support(): + url="https://daap.bannerrepeater.org/w/index.php?title=Support&action=render" + # Make a GET request to fetch the raw HTML content + html_content = requests.get(url).text + # Parse the html content + soup = BeautifulSoup(html_content, "lxml") + # print(soup.prettify()) # print the parsed data of html + + text=soup.find("html") + + text=Markup(text) + return render_template('support.html', text=text) + ######################### TUTORIAL @app.route("/tutorials") def tutorials(): diff --git a/templates/artwork.html b/templates/artwork.html index 8a62528..dd32bbe 100644 --- a/templates/artwork.html +++ b/templates/artwork.html @@ -288,10 +288,15 @@ +
{% if "authordescriptionPageLabel" in x %} + + {% if x['authordescriptionPageLabel']['value'] |length %}

AUTHOR

{{ x['authordescriptionPageLabel']['value'] }}

+ {% endif %} + {% endif %} diff --git a/templates/copy.html b/templates/copy.html index d3be2f2..24daa3d 100644 --- a/templates/copy.html +++ b/templates/copy.html @@ -101,7 +101,7 @@ {% else %} {% for x in copyof['results']['bindings'] %}