Browse Source

support + copy to frontend + queries desc and exhib

master
jules 3 years ago
parent
commit
12102370f8
  1. 54
      daapinterface.py
  2. 5
      templates/artwork.html
  3. 4
      templates/copy.html
  4. 10
      templates/item.html
  5. 2
      templates/layout.html

54
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="<p>Information not available</p>"
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():

5
templates/artwork.html

@ -288,10 +288,15 @@
<!-- right ride with author etc LATER-->
<div class="text-date-author">
{% if "authordescriptionPageLabel" in x %}
<!-- IF VARIABLE NOT EMPTY ADD AUTHOR -->
{% if x['authordescriptionPageLabel']['value'] |length %}
<p class="label-item">AUTHOR</p>
<p>{{ x['authordescriptionPageLabel']['value'] }}</p>
{% endif %}
{% endif %}
<!-- if there is an author name then add here otherwise info non available -->

4
templates/copy.html

@ -101,7 +101,7 @@
{% else %}
{% for x in copyof['results']['bindings'] %}
<div class="metadata-link">
<a target="_blank" href="{{ x['work']['value'] }}">
<a href="/artwork?id={{ x['work']['value'] | replace('http://daap.bannerrepeater.org/entity/', '') }}">
<span>{{ x['workLabel']['value'] }}</span>
</a>
@ -117,7 +117,7 @@
{% else %}
{% for x in copycollection['results']['bindings'] %}
<div class="metadata-link">
<a target="_blank" href="{{ x['collection']['value'] }}">
<a href="/item?id={{ x['collection']['value'] | replace('http://daap.bannerrepeater.org/entity/', '') }}">
<span>{{ x['collectionLabel']['value'] }}</span>
</a>

10
templates/item.html

@ -175,7 +175,9 @@
{% else %}
<!-- else loop through available data -->
{% for x in orglocation['results']['bindings'] %}
<span>{{ x['locationLabel']['value'] }}</span>
<span>{{ x['locationLabel']['value'] }}
{{ ", " if not loop.last else "" }}
</span>
{% endfor %}
{% endif %}
<!-- end location -->
@ -188,7 +190,11 @@
{% else %}
<!-- else loop through available data -->
{% for x in orgcountry['results']['bindings'] %}
<span>{{ x['countryLabel']['value'] }}</span>
<span>{{ x['countryLabel']['value'] }}
{% if not loop.last %}
,
{% endif %}
</span>
{% endfor %}
{% endif %}
<!-- end country -->

2
templates/layout.html

@ -66,7 +66,7 @@
<div id="nav-tutorials"><a href="{{ url_for('tutorials') }}">Tutorials</a></div>
<div id="nav-upload"><a href="{{ url_for('upload') }}">Upload</a></div>
<div id="nav-login"><a href="https://daap.bannerrepeater.org/w/index.php?title=Special:UserLogin&returnto=Main+Page">Log in</a></div>
<a id="nav-heart" href="https://daap.network/support">
<a id="nav-heart" href="{{ url_for('support') }}">
<img
src="css/Icons/heart-solid.svg"
alt="heart icon and link to donation page"

Loading…
Cancel
Save