copy template
This commit is contained in:
parent
3d76a038a1
commit
a1564fee94
115
daapinterface.py
115
daapinterface.py
@ -536,6 +536,121 @@ def artwork():
|
|||||||
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)
|
||||||
|
|
||||||
|
|
||||||
|
######################### COPY ITEM
|
||||||
|
@app.route("/copy", methods=['GET'])
|
||||||
|
def copy():
|
||||||
|
copy_id = request.args.get('id')
|
||||||
|
|
||||||
|
# Intro
|
||||||
|
sparql.setQuery('''
|
||||||
|
SELECT ?item ?itemLabel ?itemDescription ?itemtypeLabel
|
||||||
|
{
|
||||||
|
VALUES ?item {wd:'''+copy_id+'''}
|
||||||
|
?item wdt:P1 ?itemtype.
|
||||||
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
|
||||||
|
}
|
||||||
|
''')
|
||||||
|
sparql.setReturnFormat(JSON)
|
||||||
|
copyintro = sparql.query().convert()
|
||||||
|
|
||||||
|
# image
|
||||||
|
sparql.setQuery('''
|
||||||
|
SELECT ?image ?depictsLabel ?licenseLabel
|
||||||
|
WHERE
|
||||||
|
{
|
||||||
|
VALUES ?item {wd:'''+copy_id+'''}
|
||||||
|
?item wdt:P90 ?image.
|
||||||
|
OPTIONAL { ?work p:P90 ?statement2.
|
||||||
|
?statement2 ps:P90 ?image;
|
||||||
|
pq:P54 ?depicts;
|
||||||
|
pq:P56 ?license.}
|
||||||
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en".}
|
||||||
|
}
|
||||||
|
''')
|
||||||
|
sparql.setReturnFormat(JSON)
|
||||||
|
copyimage = sparql.query().convert()
|
||||||
|
|
||||||
|
# copy of
|
||||||
|
sparql.setQuery('''
|
||||||
|
SELECT ?work ?workLabel
|
||||||
|
WHERE
|
||||||
|
{
|
||||||
|
VALUES ?item {wd:'''+copy_id+'''}
|
||||||
|
?item wdt:P46 ?work.
|
||||||
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
|
||||||
|
}
|
||||||
|
''')
|
||||||
|
sparql.setReturnFormat(JSON)
|
||||||
|
copyof = sparql.query().convert()
|
||||||
|
|
||||||
|
# collection
|
||||||
|
sparql.setQuery('''
|
||||||
|
SELECT ?collection ?collectionLabel
|
||||||
|
WHERE
|
||||||
|
{
|
||||||
|
VALUES ?item {wd:'''+copy_id+'''}
|
||||||
|
?item wdt:P47 ?collection.
|
||||||
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
|
||||||
|
}
|
||||||
|
''')
|
||||||
|
sparql.setReturnFormat(JSON)
|
||||||
|
copycollection = sparql.query().convert()
|
||||||
|
|
||||||
|
# inventory number
|
||||||
|
sparql.setQuery('''
|
||||||
|
SELECT ?inventoryNumber
|
||||||
|
WHERE
|
||||||
|
{
|
||||||
|
VALUES ?item {wd:'''+copy_id+'''}
|
||||||
|
?item wdt:P48 ?inventoryNumber.
|
||||||
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
|
||||||
|
}
|
||||||
|
''')
|
||||||
|
sparql.setReturnFormat(JSON)
|
||||||
|
copyinventorynumber = sparql.query().convert()
|
||||||
|
|
||||||
|
|
||||||
|
# copy description
|
||||||
|
sparql.setQuery('''
|
||||||
|
SELECT ?accessURLdescriptionPage ?authordescriptionPageLabel ?datedescriptionPage ?sourcedescriptionPageLabel
|
||||||
|
WHERE
|
||||||
|
{
|
||||||
|
VALUES ?item {wd:'''+copy_id+'''}
|
||||||
|
?item wdt:P65 ?descriptionPage.
|
||||||
|
OPTIONAL { ?descriptionPage wdt:P4 ?accessURLdescriptionPage. }
|
||||||
|
OPTIONAL { ?descriptionPage wdt:P9 ?authordescriptionPage. }
|
||||||
|
OPTIONAL { ?descriptionPage wdt:P13 ?datedescriptionPage. }
|
||||||
|
OPTIONAL { ?descriptionPage wdt:P50 ?sourcedescriptionPage. }
|
||||||
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
|
||||||
|
}
|
||||||
|
''')
|
||||||
|
sparql.setReturnFormat(JSON)
|
||||||
|
copydescription = sparql.query().convert()
|
||||||
|
|
||||||
|
for x in copydescription['results']['bindings']:
|
||||||
|
if "accessURLdescriptionPage" in x:
|
||||||
|
accessURLdescURL = x["accessURLdescriptionPage"]["value"]
|
||||||
|
desc_url = re.search(r':Q(.*)', accessURLdescURL, re.DOTALL)
|
||||||
|
desc_id=desc_url.group(1)
|
||||||
|
# # get the description content from wiki
|
||||||
|
copydesccontenturl = "https://daap.bannerrepeater.org/w/index.php?title=Description:Q"+desc_id+"&action=render"
|
||||||
|
# # Make a GET request to fetch the raw HTML content
|
||||||
|
html_content = requests.get(copydesccontenturl).text
|
||||||
|
# # Parse the html content
|
||||||
|
soup = BeautifulSoup(html_content, "lxml")
|
||||||
|
# # print(soup.prettify()) # print the parsed data of html
|
||||||
|
text=soup.find("div" , {"class" : "mw-parser-output"})
|
||||||
|
# text=soup.find_all("p")
|
||||||
|
# text=Markup(text)
|
||||||
|
# artworkdescriptiontext.append(text)
|
||||||
|
x["text"] = text
|
||||||
|
else:
|
||||||
|
# print("url for description absent")
|
||||||
|
text="<p>Information not available</p>"
|
||||||
|
x["text"] = text
|
||||||
|
|
||||||
|
|
||||||
|
return render_template('copy.html', copy_id=copy_id, copyintro=copyintro, copyimage=copyimage, copyof=copyof, copycollection=copycollection, copyinventorynumber=copyinventorynumber, copydescription=copydescription)
|
||||||
|
|
||||||
|
|
||||||
######################### ITEM : COLLECTIVE - PERSON - ORGANISATION
|
######################### ITEM : COLLECTIVE - PERSON - ORGANISATION
|
||||||
|
227
templates/copy.html
Normal file
227
templates/copy.html
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<!-- COPY TITLE AND NAVIGATION -->
|
||||||
|
<div>
|
||||||
|
<!-- COPY label in rectangle -->
|
||||||
|
<div class="artwork-box">
|
||||||
|
<span>COPY ITEM</span>
|
||||||
|
</div>
|
||||||
|
<!-- Artwork title -->
|
||||||
|
<div class="artwork-title">
|
||||||
|
{% for x in copyintro['results']['bindings'] %}
|
||||||
|
{{ x['itemLabel']['value'] }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<!-- Artwork intro-description -->
|
||||||
|
<div class="artwork-intro">
|
||||||
|
{% for x in copyintro['results']['bindings'] %}
|
||||||
|
{% if 'itemDescription' in x %}
|
||||||
|
{{ x['itemDescription']['value'] }}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- NAVIGATION HERE? -->
|
||||||
|
<div class="artwork-nav">
|
||||||
|
<div class="artwork-nav-label artwork-nav-label-about active">ABOUT</div>
|
||||||
|
<!-- <div class="artwork-nav-label">RELATIONSHIPS</div> -->
|
||||||
|
<!-- <div class="artwork-nav-label">LISTS</div> -->
|
||||||
|
<div class="artwork-nav-label artwork-nav-label-record"><a class="det-record" target="_blank" href="https://daap.bannerrepeater.org/wiki/Item:{{ copy_id }}">DETAILED RECORD</a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ########################### -->
|
||||||
|
<!-- BLOCK IMAGE/DATA AND DESCRIPTION -->
|
||||||
|
<!-- ############################ -->
|
||||||
|
<div class="artwork-about">
|
||||||
|
|
||||||
|
|
||||||
|
<!-- LEFT COLUMN -->
|
||||||
|
<div class="artwork-leftcolumn">
|
||||||
|
|
||||||
|
<!-- ITEM IMAGES -->
|
||||||
|
<div class="my-slider">
|
||||||
|
{% if copyimage['results']['bindings']==[] %}
|
||||||
|
<img src="{{ url_for('static', filename='/imgs/Icons/placeholder_no-image2.png') }}">
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{% for x in copyimage['results']['bindings'] %}
|
||||||
|
<div class="item">
|
||||||
|
<!-- START GROUP IMG + LABELS -->
|
||||||
|
{% if "image" in x %}
|
||||||
|
<img src='{{ x["image"]["value"] | replace("wiki/File:","wiki/Special:Redirect/file/") }}'>
|
||||||
|
<!-- copyright and front or back -->
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if "depictsLabel" in x %}
|
||||||
|
<p>{{ x['depictsLabel']['value'] }}</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if "licenseLabel" in x %}
|
||||||
|
<p>License: {{ x['licenseLabel']['value'] }}</p>
|
||||||
|
{% endif %}
|
||||||
|
<!-- END GROUP IMG + LABELS -->
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<!-- END IMAGES -->
|
||||||
|
</div>
|
||||||
|
<!-- end of left column, which has only images actually -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- RIGHT COLUMN -->
|
||||||
|
<div class="artwork-rightcolumn">
|
||||||
|
|
||||||
|
<!-- ##################### -->
|
||||||
|
<!-- RIGHT TOP : DATA SECTION SECTION -->
|
||||||
|
<!-- ##################### -->
|
||||||
|
<div class="artwork-rightcolumn-top">
|
||||||
|
|
||||||
|
<!-- ALL DATA-->
|
||||||
|
<div class="artwork-rightcolumn-top-contributors">
|
||||||
|
|
||||||
|
<!-- copy of -->
|
||||||
|
<p class="label-item">COPY OF</p>
|
||||||
|
{% if copyof['results']['bindings']==[] %}
|
||||||
|
<div>information not available</div>
|
||||||
|
{% else %}
|
||||||
|
{% for x in copyof['results']['bindings'] %}
|
||||||
|
<div class="metadata-link">
|
||||||
|
<a target="_blank" href="{{ x['work']['value'] }}">
|
||||||
|
<span>{{ x['workLabel']['value'] }}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
<!-- end copy of -->
|
||||||
|
|
||||||
|
<!-- collection -->
|
||||||
|
<p class="label-item">COLLECTION</p>
|
||||||
|
{% if copycollection['results']['bindings']==[] %}
|
||||||
|
<div>information not available</div>
|
||||||
|
{% else %}
|
||||||
|
{% for x in copycollection['results']['bindings'] %}
|
||||||
|
<div class="metadata-link">
|
||||||
|
<a target="_blank" href="{{ x['collection']['value'] }}">
|
||||||
|
<span>{{ x['collectionLabel']['value'] }}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
<!-- end collection -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- official website -->
|
||||||
|
<p class="label-item">INVENTORY NUMBER</p>
|
||||||
|
{% if copyinventorynumber['results']['bindings']==[] %}
|
||||||
|
<div>information not available</div>
|
||||||
|
{% else %}
|
||||||
|
<!-- else loop through available data -->
|
||||||
|
{% for x in copyinventorynumber['results']['bindings'] %}
|
||||||
|
<span>#{{ x['inventoryNumber']['value'] }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
<!-- end official website -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- END PF ALL DATA -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##################### -->
|
||||||
|
<!-- RIGHT BOTTOM : BIO/DESCRIPTION SECTION -->
|
||||||
|
<!-- ##################### -->
|
||||||
|
|
||||||
|
<!-- DESCRIPTION -->
|
||||||
|
|
||||||
|
|
||||||
|
<div class="des-exh-section">
|
||||||
|
<p class="label-item des">DESCRIPTION</p>
|
||||||
|
{% if copydescription['results']['bindings']==[] %}
|
||||||
|
<p>information not available</p>
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
<!-- For loop -->
|
||||||
|
{% for x in copydescription['results']['bindings'] %}
|
||||||
|
<div class="artwork-rightcolumn-bottom">
|
||||||
|
<!-- left part with the description text already coming in a div from wiki-->
|
||||||
|
<div class="text-description">
|
||||||
|
{{ x["text"] | safe }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- END OF DESCRIPTION -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##################### -->
|
||||||
|
<!-- END OF RIGHT BOTTOM -->
|
||||||
|
<!-- ##################### -->
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- END OF RIGHT COLUMN -->
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- ########################### -->
|
||||||
|
<!-- END OF BLOCK IMAGE/DATA AND DESCRIPTION -->
|
||||||
|
<!-- ############################ -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.2/min/tiny-slider.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var slider = tns({
|
||||||
|
container: '.my-slider',
|
||||||
|
items: 1,
|
||||||
|
responsive: {
|
||||||
|
640: {
|
||||||
|
edgePadding: 20,
|
||||||
|
gutter: 20,
|
||||||
|
items: 1
|
||||||
|
},
|
||||||
|
700: {
|
||||||
|
gutter: 30
|
||||||
|
},
|
||||||
|
900: {
|
||||||
|
items: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{% endblock content %}
|
Loading…
Reference in New Issue
Block a user