Browse Source

cover artwork pages

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

23
daapinterface.py

@ -220,8 +220,24 @@ def artwork():
# print(artworkintro)
# Image(s)
# query for later
# 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".}
# }
# ''')
# temp fix query
sparql.setQuery('''
SELECT ?image ?depictsLabel ?licenseLabel
SELECT ?image ?depictsLabel ?licenseLabel
WHERE
{
VALUES ?work {wd:'''+artwork_id+'''}
@ -230,9 +246,10 @@ def artwork():
?statement2 ps:P30 ?image;
pq:P54 ?depicts;
pq:P56 ?license.}
FILTER(?depicts != wd:Q1897)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en".}
}
''')
}''')
sparql.setReturnFormat(JSON)
artworkimages = sparql.query().convert()
print(artworkimages)

8
templates/artwork.html

@ -45,12 +45,8 @@
{% if artworkimages['results']['bindings']==[] %}
<img class="artwork-about-imgs" src="{{ url_for('static', filename='/imgs/Icons/placeholder_no-image2.png') }}">
{% else %}
{% for x in artworkimages['results']['bindings'] %}
{% if loop.index <= 1 %}
{% if "image" in x %}
<img class="artwork-about-imgs" src='{{ x["image"]["value"] | replace("wiki/File:","wiki/Special:Redirect/file/") }}'>
{% endif %}
{% endif %}
{% for x in artworkimages["results"]["bindings"] %}
<img class="artwork-about-imgs" src='{{ x["image"]["value"] | replace("wiki/File:","wiki/Special:Redirect/file/") }}'>
{% endfor %}
{% endif %}
</div>

Loading…
Cancel
Save