From 72ba26819ef7a620d74fc5414d155f9f25b0d040 Mon Sep 17 00:00:00 2001 From: jules Date: Sun, 15 Nov 2020 19:00:03 +0100 Subject: [PATCH] mockups person and org --- daapinterface.py | 112 +++++++++++++++++++++++++++++++++++- templates/organisation.html | 18 ++++++ templates/person.html | 2 +- 3 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 templates/organisation.html diff --git a/daapinterface.py b/daapinterface.py index 1054894..3bf8620 100644 --- a/daapinterface.py +++ b/daapinterface.py @@ -226,12 +226,13 @@ def artwork(): artworkimages = sparql.query().convert() # print(artworkimages) +######### Right top # contributors sparql.setQuery(''' SELECT DISTINCT ?creators ?creatorsLabel (group_concat(?creatorRolesLabel; separator="; ") as ?role) WHERE { - VALUES ?work {wd:Q118} + VALUES ?work {wd:'''+artwork_id+'''} ?work wdt:P9 ?creators. OPTIONAL { ?work p:P9 ?statement1. ?statement1 ps:P9 ?creators; @@ -286,6 +287,95 @@ def artwork(): print(artworkpublisher) +#####right middle +# description + id to be changed + sparql.setQuery(''' + SELECT ?accessURLdescriptionPage ?authordescriptionPage ?authordescriptionPageLabel ?datedescriptionPage ?sourcedescriptionPage ?sourcedescriptionPageLabel + WHERE + { + VALUES ?work {wd:'''+artwork_id+'''} + ?work wdt:P65 ?descriptionPage. + OPTIONAL { ?descriptionPage wdt:P4 ?accessURLdescriptionPage. } + OPTIONAL { ?descriptionPage wdt:P9 ?authordescriptionPage. } + OPTIONAL { ?descriptionPage wdt:P13 ?datedescriptionPage. } + OPTIONAL { ?descriptionPage wdt:P50 ?sourcedescriptionPage. } + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } + } + ''') + sparql.setReturnFormat(JSON) + artworkdescriptiondata = sparql.query().convert() + # print("hello") + # print(artworkdescriptiondata) + # print("bye") + + dictionary = artworkdescriptiondata + # print(type(dictionary)) + + # get the description text or say there isn't any + # artworkdescriptiontext = None + + # for x in dictionary['results']['bindings']: + # if "accessURLdescriptionPage" in x: + # print("url for description present") + # # get the description content from wiki + # artworkdescriptioncontenturl = "https://daap.bannerrepeater.org/w/index.php?title=Description:"+artwork_id+"&action=render" + # # Make a GET request to fetch the raw HTML content + # html_content = requests.get(artworkdescriptioncontenturl).text + # # Parse the html content + # soup = BeautifulSoup(html_content, "lxml") + # # print(soup.prettify()) # print the parsed data of html + # # text=soup.find("div" , {"class" : "mw-parser-output"}) + # text=soup.find_all("p") + # artworkdescriptiontext=Markup(text) + # else: + # print("url for description absent") + # text="

Information not available

" + # artworkdescriptiontext=Markup(text) + + artworkdescriptioncontenturl = "https://daap.bannerrepeater.org/w/index.php?title=Description:Q427&action=render" + # Make a GET request to fetch the raw HTML content + html_content = requests.get(artworkdescriptioncontenturl).text + # Parse the html content + soup = BeautifulSoup(html_content, "lxml") + # print(soup.prettify()) # print the parsed data of html + # text=soup.find("div" , {"class" : "mw-parser-output"}) + text=soup.find_all("p") + artworkdescriptiontext=Markup(text) + + print(artworkdescriptiontext) + +############ right bottom LATER +# exhibitions + id to be changed + sparql.setQuery(''' + SELECT ?accessURLexhibitionHisPage ?authorexhibitionHisPageLabel ?dateexhibitionHisPage ?sourceexhibitionHisPage + WHERE + { + VALUES ?work {wd:Q57} + ?work wdt:P66 ?exhibitionHisPage. + OPTIONAL { ?exhibitionHisPage wdt:P4 ?accessURLexhibitionHisPage. } + OPTIONAL { ?exhibitionHisPage wdt:P9 ?authorexhibitionHisPage. } + OPTIONAL { ?exhibitionHisPage wdt:P13 ?dateexhibitionHisPage. } + OPTIONAL { ?exhibitionHisPage wdt:P50 ?sourceexhibitionHisPage. } + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } + } + ''') + sparql.setReturnFormat(JSON) + artworkexhibitiondata = sparql.query().convert() + + # description content from wiki + artworkexhibitioncontenturl = "https://daap.bannerrepeater.org/w/index.php?title=History:"+artwork_id+"&action=render" + # Make a GET request to fetch the raw HTML content + html_content = requests.get(artworkexhibitioncontenturl).text + # Parse the html content + soup = BeautifulSoup(html_content, "lxml") + # print(soup.prettify()) # print the parsed data of html + + # text=soup.find("div" , {"class" : "mw-parser-output"}) + text=soup.find_all("p") + artworkexhibitiontext=Markup(text) + # print(artworkexhibitiontext) + +############## bottom # copies in collection sparql.setQuery(''' SELECT ?copiesCollections ?copiesCollectionsLabel ?collection ?collectionLabel ?image @@ -323,7 +413,10 @@ def artwork(): # print(relatedworks) - return render_template('artwork.html', artworkintro=artworkintro, artworkimages=artworkimages, artworkcontributors=artworkcontributors, artworkdate=artworkdate, artworkpublisher=artworkpublisher, copiesincollection=copiesincollection, relatedworks=relatedworks) + return render_template('artwork.html', artworkintro=artworkintro, artworkimages=artworkimages, artworkcontributors=artworkcontributors, artworkdate=artworkdate, artworkpublisher=artworkpublisher, artworkdescriptiondata=artworkdescriptiondata, artworkdescriptiontext=artworkdescriptiontext, copiesincollection=copiesincollection, relatedworks=relatedworks) + + + @@ -385,6 +478,12 @@ def person(): return render_template("person.html", person_id=person_id, person_creatorof=person_creatorof, person_publisherof=person_publisherof, person_details=person_details) +######################### ORGANISATION +@app.route("/organisation", methods=['GET']) +def organisation(): + org_id = request.args.get('id') + return render_template("organisation.html") + ######################### # PAGES FROM WIKI @@ -425,6 +524,15 @@ def about(): ######################### TUTORIAL @app.route("/tutorials") def tutorials(): + url="https://daap.bannerrepeater.org/w/index.php?title=Tutorials&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('tutorials.html') diff --git a/templates/organisation.html b/templates/organisation.html new file mode 100644 index 0000000..5d19d25 --- /dev/null +++ b/templates/organisation.html @@ -0,0 +1,18 @@ +{% extends "layout.html" %} +{% block content %} + + + +
+ + +
+Go to backend to see live data +
+
+ +
+ + + +{% endblock content %} \ No newline at end of file diff --git a/templates/person.html b/templates/person.html index 1f68c19..d9ac89d 100644 --- a/templates/person.html +++ b/templates/person.html @@ -13,6 +13,6 @@ - + {% endblock content %} \ No newline at end of file