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

8
templates/artwork.html

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

Loading…
Cancel
Save