JoBCB 4 years ago
parent
commit
d2e3dae763
  1. 62
      daapinterface.py
  2. 101
      templates/artwork.html
  3. 9
      templates/browsethearchive.html

62
daapinterface.py

@ -195,34 +195,50 @@ def zinesindex():
def artwork():
artwork_id = request.args.get('id')
# copies in collection
sparql.setQuery('''
SELECT ?work ?workLabel ?workDescription ?propLabel ?b ?bLabel ?creators ?creatorsLabel ?creatorRoles ?creatorRolesLabel ?image ?depicts ?depictsLabel ?license ?licenseLabel
SELECT ?copiesCollections ?copiesCollectionsLabel ?collection ?collectionLabel ?image
WHERE
{
VALUES ?work {wd:'''+artwork_id+'''}
?work ?a ?b.
OPTIONAL { ?work wdt:P9 ?creators. }
OPTIONAL { ?work p:P9 ?statement1.
?statement1 ps:P9 ?creators;
pq:P49 ?creatorRoles. }
OPTIONAL { ?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". }
?prop wikibase:directClaim ?a .
} ''')
VALUES ?work {wd:'''+artwork_id+'''}
?work wdt:P43 ?copiesCollections.
?copiesCollections wdt:P47 ?collection.
OPTIONAL { ?collection wdt:P30 ?image. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
} ''')
sparql.setReturnFormat(JSON)
artwork = sparql.query().convert()
print(artwork)
copiesincollection = sparql.query().convert()
print(copiesincollection)
# related works
sparql.setQuery('''
SELECT ?relatedWorks ?relatedWorksLabel ?image ?daterelatedWorks
WHERE {
{
SELECT ?relatedWorks ?relatedWorksLabel (SAMPLE(?daterelatedWorks) AS ?daterelatedWorks)
WHERE
{ VALUES ?work {wd:'''+artwork_id+'''}
?work wdt:P44 ?relatedWorks.
OPTIONAL {?relatedWorks wdt:P13 ?daterelatedWorks.}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?relatedWorks ?relatedWorksLabel
ORDER BY ?relatedWorksLabel
}
OPTIONAL {?relatedWorks wdt:P30 ?image.}
} ''')
sparql.setReturnFormat(JSON)
relatedworks = sparql.query().convert()
print(relatedworks)
# artwork_url = "https://daap.bannerrepeater.org/wiki/Item:Q92"
# artwork_title = "the human printer"
# artwork_description = "short description"
return render_template('artwork.html', copiesincollection=copiesincollection, relatedworks=relatedworks)
artwork_url = "https://daap.bannerrepeater.org/wiki/Item:Q92"
artwork_title = "the human printer"
artwork_description = "short description"
return render_template('artwork.html', artwork_title=artwork_title, artwork_description=artwork_description, artwork=artwork, artwork_id=artwork_id)
######################### PERSON
@app.route("/person", methods=['GET'])

101
templates/artwork.html

@ -1,35 +1,90 @@
{% extends "layout.html" %}
{% block content %}
<!-- <div id="artwork-description">
<div id="artwork-page-title">ARTWORK</div>
<div id="artwork-title">WHATEVER</div>
<div id="artwork-short-description"></div>
</div>
<div id="artwork-content">
<div id="artwork-content-menu">
<div id="artwork-content-menu-about">About this work</div>
<div id="artwork-content-menu-record">Detailed record</div>
<div id="artwork-content-menu-relationships">Relationships</div>
<div id="artwork-content-menu-lists">Lists</div>
<div>
<!-- Artwork title and navigation -->
<div></div>
<!-- The content in 3 divs displayed or not (detailed revord is out)-->
<div>
<!-- about -->
<div></div>
<!-- relationships -->
<div></div>
<!-- lists -->
<div></div>
</div>
<div id="artwork-content-infos">
<!-- copies in collections -->
<div>
<div>Copies in collections</div>
<!-- all the copies if any -->
{% for x in copiesincollection['results']['bindings'] %}
<div class="artwork-copiesincollection">
<!-- img -->
<div class="artwork-copiesincollection-img-div">
{% if "image" in x %}
<!-- <a href='/artwork?id={{ x["???"]["copiesCollections"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'> -->
<img class="artwork-copiesincollection-imgs" src='{{ x["image"]["value"] | replace("wiki/File:","wiki/Special:Redirect/file/") }}'>
<!-- </a> -->
<br>
{% else %}
<!-- <a href='/artwork?id={{ x["copiesCollections"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'> -->
<img class="artwork-copiesincollection-imgs" src="{{ url_for('static', filename='/imgs/Icons/placeholder_no-image2.png') }}">
<!-- </a> -->
<br>
{% endif %}
</div>
<!-- title/name of collection -->
<div class="artwork-copiesincollection-title-div">
{{ x["collectionLabel"]["value"]}}
</div>
</div>
{% endfor %}
</div>
</div>
-->
<div id="container-backend-data-button">
<!-- Related works -->
<div>
<div>Related works</div>
<!-- all the works if any-->
{% for x in relatedworks['results']['bindings'] %}
<div class="artwork-relatedworks">
<!-- image -->
<div class="artwork-relatedworks-img-div">
{% if "image" in x %}
<a href='/artwork?id={{ x["relatedWorks"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'>
<img class="artwork-relatedworks-imgs" src='{{ x["image"]["value"] | replace("wiki/File:","wiki/Special:Redirect/file/") }}'>
</a>
<br>
{% else %}
<a href='/artwork?id={{ x["relatedWorks"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'>
<img class="artwork-relatedworks-imgs" src="{{ url_for('static', filename='/imgs/Icons/placeholder_no-image2.png') }}">
</a>
<br>
{% endif %}
</div>
<!-- title -->
<div class="artwork-relatedworks-tile">
{{ x["relatedWorksLabel"]["value"]}}
</div>
<!-- year -->
<div class="artwork-relatedworks-date">
{% if "daterelatedWorks" in x %}
{{ x["daterelatedWorks"]["value"] | replace("T00:00:00Z", "") }}
{% endif %}
</div>
</div>
{% endfor %}
</div>
<a target="_blank" href="https://daap.bannerrepeater.org/wiki/Item:{{ artwork_id }}">
<div class="bluebutton" id="backend-data-button">
<span>Go to backend to see live data</span>
</div>
</a>
</div>
<img class="artwork-mockuppage" src="{{ url_for('static', filename='/imgs/Pages/mockup_page_artwork-min.jpg') }}">
{% endblock content %}

9
templates/browsethearchive.html

@ -10,26 +10,27 @@
<div class="browsethearchive-items">
<div class="browsethearchive-items-top">
{% if "image" in x %}
<a href='/artwork?id={{ x["work"]["value"] | replace("http://wikibase.svc/entity/", "") }}'>
<a href='/artwork?id={{ x["work"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'>
<img class="browsethearchive-imgs" src='{{ x["image"]["value"] | replace("wiki/File:","wiki/Special:Redirect/file/") }}'>
</a> <br>
{% else %}
<a href='/artwork?id={{ x["work"]["value"] | replace("http://wikibase.svc/entity/", "") }}'>
<a href='/artwork?id={{ x["work"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'>
<img class="browsethearchive-imgs" src="{{ url_for('static', filename='/imgs/Icons/placeholder_no-image2.png') }}"><br>
</a>
{% endif %}
</div>
<div class="browsethearchive-items-bottom">
<a class="title" href='/artwork?id={{ x["work"]["value"] | replace("http://wikibase.svc/entity/", "") }}'>
<a class="title" href='/artwork?id={{ x["work"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'>
{{ x["workLabel"]["value"]}}
</a> <br>
<span class="date">
{% if "date" in x %}
{{ x["date"]["value"] | replace("T00:00:00Z", "") }}
{% endif %}
</span>
{% endif %}
</div>
</div>

Loading…
Cancel
Save