Browse Source

last changes

master
jules 4 years ago
parent
commit
c20d80a59d
  1. 23
      daapinterface.py
  2. 41
      templates/artwork.html

23
daapinterface.py

@ -217,7 +217,6 @@ def artwork():
''') ''')
sparql.setReturnFormat(JSON) sparql.setReturnFormat(JSON)
artworkintro = sparql.query().convert() artworkintro = sparql.query().convert()
# print(artworkintro)
# Image(s) # Image(s)
# query for later # query for later
@ -252,7 +251,6 @@ def artwork():
sparql.setReturnFormat(JSON) sparql.setReturnFormat(JSON)
artworkimages = sparql.query().convert() artworkimages = sparql.query().convert()
# print(artworkimages)
# Links and downloads # Links and downloads
sparql.setQuery(''' sparql.setQuery('''
@ -267,7 +265,6 @@ def artwork():
}''') }''')
sparql.setReturnFormat(JSON) sparql.setReturnFormat(JSON)
artworklinksanddownloads = sparql.query().convert() artworklinksanddownloads = sparql.query().convert()
print(artworklinksanddownloads)
# Other digital artefacts # Other digital artefacts
sparql.setQuery(''' sparql.setQuery('''
@ -276,19 +273,21 @@ def artwork():
{ {
{ {
SELECT ?ImageFile WHERE { SELECT ?ImageFile WHERE {
VALUES ?work {wd:Q57} VALUES ?work {wd:'''+artwork_id+'''}
OPTIONAL {?work p:P35 ?statement. OPTIONAL {?work p:P35 ?statement.
?statement ps:P35 ?ImageFile; ?statement ps:P35 ?ImageFile;
pq:P16 wd:Q85.} pq:P16 wd:Q85.}
}} }}
{ {
SELECT ?AudioFile WHERE { SELECT ?AudioFile WHERE {
VALUES ?work {wd:'''+artwork_id+'''}
OPTIONAL {?work p:P35 ?statement. OPTIONAL {?work p:P35 ?statement.
?statement ps:P35 ?AudioFile; ?statement ps:P35 ?AudioFile;
pq:P16 wd:Q28.} pq:P16 wd:Q28.}
}} }}
{ {
SELECT ?VideoFile WHERE { SELECT ?VideoFile WHERE {
VALUES ?work {wd:'''+artwork_id+'''}
OPTIONAL {?work p:P35 ?statement. OPTIONAL {?work p:P35 ?statement.
?statement ps:P35 ?VideoFile; ?statement ps:P35 ?VideoFile;
pq:P16 wd:Q27.} pq:P16 wd:Q27.}
@ -298,7 +297,7 @@ def artwork():
''') ''')
sparql.setReturnFormat(JSON) sparql.setReturnFormat(JSON)
artworkartefacts = sparql.query().convert() artworkartefacts = sparql.query().convert()
# print(artworkartefacts) print(artworkartefacts)
# Distributor Links # Distributor Links
@ -335,7 +334,6 @@ def artwork():
''') ''')
sparql.setReturnFormat(JSON) sparql.setReturnFormat(JSON)
artworkcontributors = sparql.query().convert() artworkcontributors = sparql.query().convert()
# print(artworkcontributors)
# date # date
sparql.setQuery(''' sparql.setQuery('''
@ -352,7 +350,6 @@ def artwork():
''') ''')
sparql.setReturnFormat(JSON) sparql.setReturnFormat(JSON)
artworkdate = sparql.query().convert() artworkdate = sparql.query().convert()
# print(artworkdate)
# publishers # publishers
sparql.setQuery(''' sparql.setQuery('''
@ -373,8 +370,6 @@ def artwork():
''') ''')
sparql.setReturnFormat(JSON) sparql.setReturnFormat(JSON)
artworkpublisher = sparql.query().convert() artworkpublisher = sparql.query().convert()
# print(artworkpublisher)
#####right middle #####right middle
# description + id to be changed # description + id to be changed
@ -395,16 +390,10 @@ def artwork():
artworkdescriptiondata = sparql.query().convert() artworkdescriptiondata = sparql.query().convert()
# get the description text or say there isn't any
# artworkdescriptiontext = []
for x in artworkdescriptiondata['results']['bindings']: for x in artworkdescriptiondata['results']['bindings']:
if "accessURLdescriptionPage" in x: if "accessURLdescriptionPage" in x:
# print("url for description present")
# print(x["accessURLdescriptionPage"]["value"])
accessURLdescriptionUrl = x["accessURLdescriptionPage"]["value"] accessURLdescriptionUrl = x["accessURLdescriptionPage"]["value"]
desc_url = re.search(r':Q(.*)', accessURLdescriptionUrl, re.DOTALL) desc_url = re.search(r':Q(.*)', accessURLdescriptionUrl, re.DOTALL)
# print(desc_url.group(1))
desc_id=desc_url.group(1) desc_id=desc_url.group(1)
# # get the description content from wiki # # get the description content from wiki
artworkdescriptioncontenturl = "https://daap.bannerrepeater.org/w/index.php?title=Description:Q"+desc_id+"&action=render" artworkdescriptioncontenturl = "https://daap.bannerrepeater.org/w/index.php?title=Description:Q"+desc_id+"&action=render"
@ -444,8 +433,6 @@ def artwork():
# get the text from the url # get the text from the url
for x in artworkexhibitiondata['results']['bindings']: for x in artworkexhibitiondata['results']['bindings']:
if "accessURLexhibitionHisPage" in x: if "accessURLexhibitionHisPage" in x:
# print("url for description present")
# print(x["accessURLexhibitionHisPage"]["value"])
accessURLexhibitionHisPage = x["accessURLexhibitionHisPage"]["value"] accessURLexhibitionHisPage = x["accessURLexhibitionHisPage"]["value"]
desc_url = re.search(r':Q(.*)', accessURLexhibitionHisPage, re.DOTALL) desc_url = re.search(r':Q(.*)', accessURLexhibitionHisPage, re.DOTALL)
# print(desc_url.group(1)) # print(desc_url.group(1))
@ -467,7 +454,6 @@ def artwork():
# artworkexhibitiontext=Markup(text) # artworkexhibitiontext=Markup(text)
x['text']=text x['text']=text
# print(artworkexhibitiondata)
############## bottom ############## bottom
@ -519,7 +505,6 @@ def artwork():
''') ''')
sparql.setReturnFormat(JSON) sparql.setReturnFormat(JSON)
artworklists = sparql.query().convert() artworklists = sparql.query().convert()
# print(artworklists)
return render_template('artwork.html', artwork_id=artwork_id, artworkintro=artworkintro, artworkimages=artworkimages, artworklinksanddownloads=artworklinksanddownloads, artworkartefacts=artworkartefacts, artworkdistributorlinks=artworkdistributorlinks, artworkcontributors=artworkcontributors, artworkdate=artworkdate, artworkpublisher=artworkpublisher, artworkdescriptiondata=artworkdescriptiondata, artworkexhibitiondata=artworkexhibitiondata, artworklists=artworklists, copiesincollection=copiesincollection, relatedworks=relatedworks) return render_template('artwork.html', artwork_id=artwork_id, artworkintro=artworkintro, artworkimages=artworkimages, artworklinksanddownloads=artworklinksanddownloads, artworkartefacts=artworkartefacts, artworkdistributorlinks=artworkdistributorlinks, artworkcontributors=artworkcontributors, artworkdate=artworkdate, artworkpublisher=artworkpublisher, artworkdescriptiondata=artworkdescriptiondata, artworkexhibitiondata=artworkexhibitiondata, artworklists=artworklists, copiesincollection=copiesincollection, relatedworks=relatedworks)

41
templates/artwork.html

@ -63,6 +63,10 @@
{% for x in artworklinksanddownloads['results']['bindings'] %} {% for x in artworklinksanddownloads['results']['bindings'] %}
<p class="label-item">DOWNLOADS AND LINKS</p> <p class="label-item">DOWNLOADS AND LINKS</p>
{% if ('DownloadDigitalFacsimile' not in x) and ('DigitalFacsimileExternalLink' not in x) and ('DigitalFacsimileExternalLink2' not in x) %}
<p>information not available</p>
{% endif %}
{% if 'DownloadDigitalFacsimile' in x %} {% if 'DownloadDigitalFacsimile' in x %}
<div> <div>
<a target="_blank" href="{{ x['DownloadDigitalFacsimile']['value'] }}"><img src="{{ url_for('static', filename='/imgs/Icons/icn_download.svg') }}"></a> <a target="_blank" href="{{ x['DownloadDigitalFacsimile']['value'] }}"><img src="{{ url_for('static', filename='/imgs/Icons/icn_download.svg') }}"></a>
@ -92,10 +96,14 @@
<!-- OTHER DIGITAL ARTEFACTS --> <!-- OTHER DIGITAL ARTEFACTS -->
<div> <div>
{% if artworkartefacts['results']['bindings']==[] %} {% if artworkartefacts['results']['bindings']==[] %}
<p>information not available</p>
{% else %}
<p class="label-item">OTHER DIGTAL ARTEFACTS</p> <p class="label-item">OTHER DIGTAL ARTEFACTS</p>
<!-- video images audio --> <!-- video images audio -->
{% for x in artworkartefacts['results']['bindings'] %} {% for x in artworkartefacts['results']['bindings'] %}
{{ x }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</div> </div>
@ -106,11 +114,16 @@
{% else %} {% else %}
<p class="label-item">DISTRIBUTOR LINKS</p> <p class="label-item">DISTRIBUTOR LINKS</p>
{% for x in artworkdistributorlinks['results']['bindings'] %} {% for x in artworkdistributorlinks['results']['bindings'] %}
{% if 'distributorLinks' not in x %}
<p>information not available</p>
{% endif %}
{% if 'distributorLinks' in x %} {% if 'distributorLinks' in x %}
<div> <div>
<img src="{{ url_for('static', filename='/imgs/Icons/icn_external_link.svg') }}"> <img src="{{ url_for('static', filename='/imgs/Icons/icn_external_link.svg') }}">
<a target="_blank" href="{{ x['distributorLinks']['value'] }}">{{ x['distributorLinks']['value'] }}</a> <a target="_blank" href="{{ x['distributorLinks']['value'] }}">{{ x['distributorLinks']['value'] }}</a>
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</p> </p>
@ -124,9 +137,15 @@
<!-- RIGHT COLUMN --> <!-- RIGHT COLUMN -->
<div class="artwork-rightcolumn"> <div class="artwork-rightcolumn">
<!-- RIGHT TOP --> <!-- RIGHT TOP -->
<!-- contributors --> <!-- contributors -->
<div class="artwork-rightcolumn-top-contributors"> <div class="artwork-rightcolumn-top-contributors">
<p class="label-item">CONTRIBUTORS</p> <p class="label-item">CONTRIBUTORS</p>
<!-- check if info not available -->
{% if artworkcontributors['results']['bindings']==[] %}
<div>information not available</div>
{% else %}
<!-- else loop through available data -->
{% for x in artworkcontributors['results']['bindings'] %} {% for x in artworkcontributors['results']['bindings'] %}
<!-- name surname --> <!-- name surname -->
<div class="metadata-link"> <div class="metadata-link">
@ -137,17 +156,22 @@
<p>{{ x['role']['value'] }}</p> <p>{{ x['role']['value'] }}</p>
</div> </div>
{% endfor %} {% endfor %}
{% endif %}
</div> </div>
<!-- date --> <!-- date -->
<div class="artwork-rightcolumn-top-date"> <div class="artwork-rightcolumn-top-date">
<p class="label-item">DATE</p> <p class="label-item">DATE</p>
<!-- loops through dates --> <!-- check if info not available -->
{% if artworkdate['results']['bindings']==[] %}
<div>information not available</div>
{% else %}
<!-- else loops through available dates -->
{% for x in artworkdate['results']['bindings'] %} {% for x in artworkdate['results']['bindings'] %}
<!-- date --> <!-- date -->
{% if 'date' in x %} {% if 'date' in x %}
<div class="label-item-date-artwork">{{ x['date']['value'] | replace("T00:00:00Z", "") }}</div> <div class="label-item-date-artwork">{{ x['date']['value'] | replace("T00:00:00Z", "") }}</div>
{% else %}
but <div>information not available</div>
{% endif %} {% endif %}
<!-- extra info if available --> <!-- extra info if available -->
@ -155,18 +179,21 @@
<div>Source: {{ x['sourceLabel']['value'] }}</div> <div>Source: {{ x['sourceLabel']['value'] }}</div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %}
<!-- publishers removed div .artwork-rightcolumn-top-publishers--> <!-- publishers removed div .artwork-rightcolumn-top-publishers-->
<p class="label-item">PUBLISHERS</p> <p class="label-item">PUBLISHERS</p>
<!-- loop through publishers --> <!-- loop through publishers -->
{% if artworkpublisher['results']['bindings']==[] %}
<span>information not available</span>
{% else %}
{% for x in artworkpublisher['results']['bindings'] %} {% for x in artworkpublisher['results']['bindings'] %}
<!-- name, surname --> <!-- name, surname -->
<div class="metadata-link artwork-rightcolumn-top-publishers-item"> <div class="metadata-link artwork-rightcolumn-top-publishers-item">
{% if 'publishersLabel' in x %} {% if 'publishersLabel' in x %}
<a href='/organisation?id={{ x["publishers"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'><span>{{ x['publishersLabel']['value'] }}</span></a> <a href='/organisation?id={{ x["publishers"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'><span>{{ x['publishersLabel']['value'] }}</span></a>
{% else %}
<span>information not available</span>
{% endif %} {% endif %}
<!-- role --> <!-- role -->
{% if 'role' in x %} {% if 'role' in x %}
@ -174,6 +201,8 @@
{% endif %} {% endif %}
<div> <div>
{% endfor %} {% endfor %}
{% endif %}
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save