Browse Source

Lozana's css and contributors page

master
jules 4 years ago
parent
commit
d55b45be50
  1. 274
      daapinterface.py
  2. 20
      static/css/style.css
  3. 4
      templates/artwork.html
  4. 227
      templates/contributor.html

274
daapinterface.py

@ -19,6 +19,7 @@ import re
# GETTING STARTED
# # # # # # # # # # # # # # # # # # # # # # # #
app = Flask(__name__, static_url_path='', static_folder="static", template_folder="templates")
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
app.jinja_env.add_extension('jinja2.ext.loopcontrols')
@ -27,9 +28,6 @@ app.jinja_env.add_extension('jinja2.ext.loopcontrols')
# # # # # # # # # # # # # # # # # # # # # # # #
sparql = SPARQLWrapper("https://query.daap.bannerrepeater.org/proxy/wdqs/bigdata/namespace/wdq/sparql")
sparql2 = SPARQLWrapper("https://query.daap.bannerrepeater.org/proxy/wdqs/bigdata/namespace/wdq/sparql")
sparql3 = SPARQLWrapper("https://query.daap.bannerrepeater.org/proxy/wdqs/bigdata/namespace/wdq/sparql")
# # # # # # # # # # # # # # # # # # # # # # # #
# PAGES
@ -38,13 +36,33 @@ sparql3 = SPARQLWrapper("https://query.daap.bannerrepeater.org/proxy/wdqs/bigdat
def home():
sparql.setQuery('''
SELECT ?work ?workLabel ?image ?date ?dateadded WHERE {
{
SELECT ?work ?workLabel (SAMPLE(?date) AS ?date)
WHERE
{ ?work wdt:P1 wd:Q1;
wdt:P13 ?date.
FILTER(?work != wd:Q57)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?work ?workLabel
ORDER BY ?workLabel
}
{
SELECT ?work ?workLabel (SAMPLE(?image) AS ?image)
WHERE
{ ?work wdt:P1 wd:Q1;
p:P90 ?statement.
?statement ps:P90 ?image;
pq:P54 wd:Q90.
FILTER(?work != wd:Q57)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?work ?workLabel
ORDER BY ?workLabel
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?work wdt:P1 wd:Q1;
wdt:P87 ?dateadded.
?work p:P90 ?statement.
?statement ps:P90 ?image;
pq:P54 wd:Q90.
?work wdt:P13 ?date.
FILTER(?work != wd:Q57)
}
ORDER BY (?dateadded)
@ -71,15 +89,25 @@ def home():
def browsethearchive():
sparql.setQuery('''
SELECT ?work ?workLabel ?image ?date WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?work wdt:P1 wd:Q1.
OPTIONAL { ?work p:P90 ?statement.
{
SELECT ?work ?workLabel (SAMPLE(?date) AS ?date)
WHERE
{ ?work wdt:P1 wd:Q1;
wdt:P13 ?date.
FILTER(?work != wd:Q57)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?work ?workLabel
ORDER BY ?workLabel
}
?work wdt:P1 wd:Q1.
OPTIONAL {?work p:P90 ?statement.
?statement ps:P90 ?image;
pq:P54 wd:Q90.}
OPTIONAL { ?work wdt:P13 ?date. }
FILTER(?work != wd:Q57)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY (?workLabel)
ORDER BY ?workLabel
''')
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
@ -182,13 +210,14 @@ def zinesindex():
WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?work wdt:P1 wd:Q1;
wdt:P10 wd:Q71.
wdt:P16 wd:Q152.
OPTIONAL {?work p:P90 ?statement.
?statement ps:P90 ?image;
pq:P54 wd:Q90.}
OPTIONAL { ?work wdt:P13 ?date. }
FILTER(?work != wd:Q57)
}
ORDER BY ?workLabel
''')
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
@ -232,21 +261,6 @@ def artwork():
SERVICE wikibase:label { bd:serviceParam wikibase:language "en".}
}
''')
# temp fix query
# sparql.setQuery('''
# SELECT ?image ?depictsLabel ?licenseLabel
# WHERE
# {
# VALUES ?work {wd:'''+artwork_id+'''}
# ?work wdt:P90 ?image.
# OPTIONAL { ?work p:P90 ?statement2.
# ?statement2 ps:P90 ?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()
@ -473,22 +487,7 @@ def artwork():
copiesincollection = sparql.query().convert()
# 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:P90 ?image.}
# } ''')
sparql.setQuery('''
SELECT ?relatedWorks ?relatedWorksLabel ?image ?daterelatedWorks
WHERE {
@ -545,59 +544,168 @@ def artwork():
######################### PERSON - FOR NOW THIS IS A MESS
@app.route("/person", methods=['GET'])
def person():
person_id = request.args.get('id')
######################### CONTRIBUTOR : PERSON - ORGANISATION
@app.route("/contributor", methods=['GET'])
def contributor():
contributor_id = request.args.get('id')
# Intro
sparql.setQuery('''
SELECT ?item ?itemLabel ?itemDescription ?propLabel ?b ?bLabel
WHERE
SELECT ?item ?itemLabel ?itemDescription ?itemtypeLabel
{
VALUES ?item {wd:'''+person_id+'''}
?item ?a ?b.
VALUES ?item {wd:'''+contributor_id+'''}
?item wdt:P1 ?itemtype.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
?prop wikibase:directClaim ?a .
}
''')
sparql.setReturnFormat(JSON)
person_details = sparql.query().convert()
print(person_details)
contributorintro = sparql.query().convert()
print("person intro")
print(contributorintro)
print("==========")
# image
sparql.setQuery('''
SELECT ?image ?depictsLabel ?licenseLabel
WHERE
{
VALUES ?item {wd:'''+contributor_id+'''}
?item 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".}
}
''')
sparql.setReturnFormat(JSON)
contributorimage = sparql.query().convert()
print(contributorimage)
print("==========")
# biography
sparql.setQuery('''
SELECT ?work ?workLabel ?image ?date
WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?work wdt:P1 wd:Q1.
?work wdt:P9 wd:'''+person_id+'''.
OPTIONAL { ?work wdt:P90 ?image. }
OPTIONAL { ?work wdt:P13 ?date. }
FILTER(?work != wd:Q57)
}
ORDER BY (?workLabel)
SELECT ?accessURLbioPage ?authorBioPageLabel ?dateBioPage ?sourceBioPageLabel
WHERE
{
VALUES ?item {wd:'''+contributor_id+'''}
?item wdt:P67 ?bioPage.
OPTIONAL { ?bioPage wdt:P4 ?accessURLbioPage. }
OPTIONAL { ?bioPage wdt:P9 ?authorBioPage. }
OPTIONAL { ?bioPage wdt:P13 ?dateBioPage. }
OPTIONAL { ?bioPage wdt:P50 ?sourceBioPage. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
''')
sparql.setReturnFormat(JSON)
contributorbiography = sparql.query().convert()
for x in contributorbiography['results']['bindings']:
if "accessURLbioPage" in x:
accessURLbioURL = x["accessURLbioPage"]["value"]
desc_url = re.search(r':Q(.*)', accessURLbioURL, re.DOTALL)
desc_id=desc_url.group(1)
# # get the description content from wiki
contributorbiocontenturl = "https://daap.bannerrepeater.org/w/index.php?title=Biography:Q"+desc_id+"&action=render"
# # Make a GET request to fetch the raw HTML content
html_content = requests.get(contributorbiocontenturl).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
# creator of
sparql.setQuery('''
SELECT ?Works ?WorksLabel ?image ?dateWorks
WHERE {
{
SELECT ?Works ?WorksLabel (SAMPLE(?dateWorks) AS ?dateWorks)
WHERE
{
VALUES ?item {wd:'''+contributor_id+'''}
?Works wdt:P1 wd:Q1;
wdt:P9 ?item;
wdt:P13 ?dateWorks.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?Works ?WorksLabel
ORDER BY ?WorksLabel
}
{
SELECT ?Works ?WorksLabel (SAMPLE(?image) AS ?image)
WHERE
{
VALUES ?item {wd:'''+contributor_id+'''}
?Works wdt:P1 wd:Q1;
wdt:P9 ?item.
OPTIONAL {?Works wdt:P30 ?image.}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?Works ?WorksLabel
ORDER BY ?WorksLabel
}
}
''')
sparql.setReturnFormat(JSON)
person_creatorof = sparql.query().convert()
contributor_creatorof = sparql.query().convert()
print(contributor_creatorof)
print("==========")
# publisher of
sparql.setQuery('''
SELECT ?work ?workLabel ?image ?date
WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?work wdt:P1 wd:Q1.
?work wdt:P10 wd:'''+person_id+'''.
OPTIONAL { ?work wdt:P90 ?image. }
OPTIONAL { ?work wdt:P13 ?date. }
FILTER(?work != wd:Q57)
}
ORDER BY (?workLabel)
''')
SELECT ?Works ?WorksLabel ?image ?dateWorks
WHERE {
{
SELECT ?Works ?WorksLabel (SAMPLE(?dateWorks) AS ?dateWorks)
WHERE
{
VALUES ?item {wd:'''+contributor_id+'''}
?Works wdt:P1 wd:Q1;
wdt:P10 ?item;
wdt:P13 ?dateWorks.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?Works ?WorksLabel
ORDER BY ?WorksLabel
}
{
SELECT ?Works ?WorksLabel (SAMPLE(?image) AS ?image)
WHERE
{
VALUES ?item {wd:'''+contributor_id+'''}
?Works wdt:P1 wd:Q1;
wdt:P10 ?item.
OPTIONAL {?Works wdt:P30 ?image.}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?Works ?WorksLabel
ORDER BY ?WorksLabel
}
}
''')
sparql.setReturnFormat(JSON)
person_publisherof = sparql.query().convert()
contributor_publisherof = sparql.query().convert()
print(contributor_publisherof)
print("============")
person_url = ""
person_name = "the name"
person_description = "short bio"
return render_template("person.html", person_id=person_id, person_creatorof=person_creatorof, person_publisherof=person_publisherof, person_details=person_details)
contributor_url = ""
contributor_name = "the name"
contributor_description = "short bio"
return render_template("contributor.html", contributor_id=contributor_id, contributor_creatorof=contributor_creatorof, contributor_publisherof=contributor_publisherof, contributorintro=contributorintro, contributorimage=contributorimage, contributorbiography=contributorbiography)
######################### ORGANISATION

20
static/css/style.css

@ -240,7 +240,7 @@ html {
-webkit-box-sizing: inherit;
-moz-box-sizing: inherit;
box-sizing: inherit;
/*margin: 0*/
margin: 0
}
body {
@ -914,42 +914,40 @@ div#home-top-div{
/*#home-top-div img:nth-of-type(1)*/
.banner-image-0 {
animation-delay: 0s;
padding-top: 200px;
padding-top: 100px;
}
/*#home-top-div img:nth-of-type(2) */
.banner-image-1 {
animation-delay: 5s;
padding-top: 50px;
margin-top: -100px;
}
/*#home-top-div img:nth-of-type(3) */
.banner-image-2 {
animation-delay: 10s;
padding-top: 20px;
padding-top: 150px;
}
/*#home-top-div img:nth-of-type(4)*/
.banner-image-3 {
animation-delay: 15s;
padding-top: 100px;
padding-top: 50px;
}
/*#home-top-div img:nth-of-type(5) */
.banner-image-4 {
animation-delay: 20s;
padding-top: -60px;
margin-top: -150px;
}
/*#home-top-div img:nth-of-type(6)*/
.banner-image-5 {
animation-delay: 25s;
padding-top: 20px;
padding-top: 50px;
}
/*#home-top-div img:nth-of-type(7)*/
.banner-image-6{
animation-delay: 30s;
padding-top: 100px;
}
/*#home-top-div img:nth-of-type(8)*/
.banner-image-7 {
animation-delay: 35s;
padding-top: -30px;
}
/*#home-top-div img:nth-of-type(9) */
.banner-image-8 {
@ -2114,14 +2112,14 @@ div#tutorials-intro h3, div#tutorials-intro p {
}
#footer-title-others {text-align: right;}
#footer-title-contact {text-align: left; padding-bottom: 20px;}
#footer-title-contact {text-align: left; margin-bottom: 20px;}
#footer-socials {width: 100%; }
#footer-socials-links {
display: flex;
flex-direction: row;
justify-content: space-between;
width: 100%;
padding-top: 10px;
margin-top: 10px;
}
a#footer-img-wiki {

4
templates/artwork.html

@ -197,7 +197,7 @@
{% for x in artworkcontributors['results']['bindings'] %}
<!-- name surname -->
<div class="metadata-link">
<a href='/person?id={{ x["creators"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'>
<a href='/contributor?id={{ x["creators"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'>
<span>{{ x['creatorsLabel']['value'] }}</span>
</a>
<!-- role/function -->
@ -243,7 +243,7 @@
<!-- name, surname -->
<div class="metadata-link artwork-rightcolumn-top-publishers-item">
{% 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='/contributor?id={{ x["publishers"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'><span>{{ x['publishersLabel']['value'] }}</span></a>
{% endif %}
<!-- role -->
{% if 'role' in x %}

227
templates/contributor.html

@ -0,0 +1,227 @@
{% extends "layout.html" %}
{% block content %}
<!-- START OF BLOCK -->
<div>
<!-- CONTRIBUTOR TITLE AND SHORT INTRO -->
<div>
<!-- TITLE label in rectangle -->
<!-- switch label depending on label -->
{% for x in contributorintro['results']['bindings'] %}
{% if 'itemtypeLabel' in x %}
<div class="artwork-box">
<span>{{ x['itemtypeLabel']['value'] }}</span>
</div>
{% else %}
<div class="artwork-box">
<span>PERSON/ORGANISATION</span>
</div>
{% endif %}
<!-- Contributor name -->
<div class="artwork-title">
{{ x['itemLabel']['value'] }}
</div>
<!-- Contributor intro-description -->
<div class="artwork-intro">
{% if 'itemDescription' in x %}
{{ x['itemDescription']['value'] }}
{% endif %}
</div>
{% endfor %}
</div>
<!-- END TITLE SHORT INTRO -->
<!-- ########################### -->
<!-- BLOCK IMAGE/DATA AND BIO -->
<!-- ############################ -->
<div class="artwork-about">
<!-- LEFT COLUMN -->
<div class="artwork-leftcolumn">
<!-- CONTRIBUTOR IMAGES -->
<div class="my-slider">
{% if contributorimage['results']['bindings']==[] %}
<img src="{{ url_for('static', filename='/imgs/Icons/placeholder_no-image2.png') }}">
{% else %}
{% for x in contributorimage['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 CONTRIBUTOR IMAGES -->
</div>
<!-- end of left column, which has only images actually -->
<!-- RIGHT COLUMN -->
<div class="artwork-rightcolumn">
<!-- RIGHT TOP -->
<div class="artwork-rightcolumn-top">
<!-- date -->
<!-- end of date -->
</div>
<!-- end of right top -->
<!-- biography -->
<div class="des-exh-section">
<p class="label-item des">BIOGRAPHY</p>
{% if contributorbiography['results']['bindings']==[] %}
<p>information not available</p>
{% else %}
<!-- For loop -->
{% for x in contributorbiography['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 biography -->
</div>
<!-- END OF RIGHT COLUMN -->
</div>
<!-- ########################### -->
<!-- END OF BLOCK IMAGE/DATA AND BIO -->
<!-- ############################ -->
<!-- CREATOR OF -->
<div class="artwork-relatedwrapper">
<div class="Heading_C">Creator of</div>
<!-- all the works if any-->
{% for x in contributor_creatorof['results']['bindings'] %}
<div class="artwork-relatedworks">
<!-- image -->
<div class="artwork-relatedworks-img-div">
{% if "image" in x %}
<a href='/artwork?id={{ x["Works"]["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["Works"]["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">
<a href='/artwork?id={{ x["Works"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'>{{ x["WorksLabel"]["value"]}}</a>
</div>
<!-- year -->
<div class="artwork-relatedworks-date">
{% if "dateWorks" in x %}
{{ x["dateWorks"]["value"] | replace("T00:00:00Z", "") }}
{% endif %}
</div>
</div>
{% endfor %}
</div>
<!-- END CREATOR OF -->
<!-- PUBLISHER OF -->
<div class="artwork-relatedwrapper">
<div class="Heading_C">Publisher of</div>
<!-- all the works if any-->
{% for x in contributor_publisherof['results']['bindings'] %}
<div class="artwork-relatedworks">
<!-- image -->
<div class="artwork-relatedworks-img-div">
{% if "image" in x %}
<a href='/artwork?id={{ x["Works"]["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["Works"]["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">
<a href='/artwork?id={{ x["Works"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'>{{ x["WorksLabel"]["value"]}}</a>
</div>
<!-- year -->
<div class="artwork-relatedworks-date">
{% if "dateWorks" in x %}
{{ x["dateWorks"]["value"] | replace("T00:00:00Z", "") }}
{% endif %}
</div>
</div>
{% endfor %}
</div>
<!-- END PUBLISHER OF -->
</div>
<!-- END OF OVERALL BLOCK -->
<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…
Cancel
Save