Show more than just paintings during browse
This commit is contained in:
parent
036a4be5ed
commit
75257632ba
18
app.py
18
app.py
|
@ -47,6 +47,8 @@ find_more_props = {
|
|||
'P2348': 'time period',
|
||||
'P361': 'part of',
|
||||
'P608': 'exhibition history',
|
||||
'P180': 'depicts',
|
||||
'P31': 'instance of',
|
||||
|
||||
# possible future props
|
||||
# 'P571': 'inception',
|
||||
|
@ -55,6 +57,17 @@ find_more_props = {
|
|||
# 'P123': 'publisher', (only 1)
|
||||
}
|
||||
|
||||
isa_list = [
|
||||
'Q60520', # sketchbook
|
||||
'Q93184', # drawing
|
||||
'Q3305213', # painting
|
||||
'Q15123870', # lithograph
|
||||
'Q18761202', # watercolor painting
|
||||
'Q79218', # triptych
|
||||
'Q2647254', # study
|
||||
'Q46686' # reredos
|
||||
]
|
||||
|
||||
@app.teardown_appcontext
|
||||
def shutdown_session(exception=None):
|
||||
database.session.remove()
|
||||
|
@ -550,6 +563,7 @@ def get_facets(params):
|
|||
|
||||
q = render_template('query/facet.sparql',
|
||||
params=params,
|
||||
isa_list=isa_list,
|
||||
properties=properties)
|
||||
|
||||
bindings = wdqs.run_query_with_cache(q, flat + '_facets')
|
||||
|
@ -575,7 +589,9 @@ def get_artwork_params():
|
|||
|
||||
def filter_artwork(params):
|
||||
flat = '_'.join(f'{pid}={qid}' for pid, qid in params)
|
||||
q = render_template('query/find_more.sparql', params=params)
|
||||
q = render_template('query/find_more.sparql',
|
||||
params=params,
|
||||
isa_list=isa_list)
|
||||
bindings = wdqs.run_query_with_cache(q, flat)
|
||||
|
||||
return bindings
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
select ?property ?object ?objectLabel (count(*) as ?count) {
|
||||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
|
||||
?item wdt:P31 wd:Q3305213 .
|
||||
VALUES ?isa { {% for isa in isa_list %} wd:{{ isa }} {% endfor %} }
|
||||
?item wdt:P31 ?isa .
|
||||
?item wdt:P18 ?image .
|
||||
{% for pid, qid in params %}
|
||||
?item wdt:{{pid}} wd:{{qid}} .
|
||||
{% endfor %}
|
||||
values ?property { {% for pid in properties %} wdt:{{pid}}{% endfor %} }
|
||||
?item ?property ?object .
|
||||
FILTER NOT EXISTS { ?item wdt:P180 ?depicts }
|
||||
} group by ?property ?propertyLabel ?object ?objectLabel
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
select ?item ?itemLabel ?image ?artist ?artistLabel ?title ?titleLang ?time ?timeprecision {
|
||||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
|
||||
?item wdt:P31 wd:Q3305213 .
|
||||
VALUES ?isa { {% for isa in isa_list %} wd:{{ isa }} {% endfor %} }
|
||||
|
||||
?item wdt:P31 ?isa .
|
||||
{% for pid, qid in params %}
|
||||
?item wdt:{{pid}} wd:{{qid}} .
|
||||
{% endfor %}
|
||||
|
@ -15,5 +17,4 @@ select ?item ?itemLabel ?image ?artist ?artistLabel ?title ?titleLang ?time ?tim
|
|||
BIND(LANG(?title) as ?titleLang)
|
||||
}
|
||||
OPTIONAL { ?item wdt:P170 ?artist }
|
||||
FILTER NOT EXISTS { ?item wdt:P180 ?depicts }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue