diff --git a/daapinterface.py b/daapinterface.py index dce6be7..d9de650 100644 --- a/daapinterface.py +++ b/daapinterface.py @@ -35,23 +35,6 @@ sparql3 = SPARQLWrapper("https://query.daap.bannerrepeater.org/proxy/wdqs/bigdat # # # # # # # # # # # # # # # # # # # # # # # # @app.route("/") def home(): - # this doesn't show any results yet because I just added the data and I guess the query builder needs to be reloaded again, but the query code should work correctly. - # sparql.setQuery(''' - # SELECT ?work ?workLabel ?image ?date ?dateadded - # WHERE { - # SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } - # ?work wdt:P1 wd:Q1; - # wdt:P87 ?dateadded. - # OPTIONAL { ?work wdt:P30 ?image. } - # OPTIONAL { ?work wdt:P13 ?date. } - # FILTER(?work != wd:Q57) - # } - # ORDER BY (?dateadded) - # LIMIT 24 - # ''') - # sparql.setReturnFormat(JSON) - # results = sparql.query().convert() - # return render_template('home.html', results=results) sparql.setQuery(''' SELECT ?work ?workLabel ?image ?date WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } @@ -66,6 +49,7 @@ ORDER BY (?workLabel) ''') sparql.setReturnFormat(JSON) results = sparql.query().convert() + ImagesBanner = [] # print(results) for publication in results["results"]["bindings"]: publication_title = publication["workLabel"]["value"] @@ -75,7 +59,9 @@ ORDER BY (?workLabel) publication_date = publication["date"]["value"] if "image" in publication: publication_image = publication["image"]["value"] - return render_template('home.html', results=results) + ImagesBanner.append(publication_image) + ImagesBanner = ImagesBanner[-3:] + return render_template('home.html', results=results, ImagesBanner=ImagesBanner) @app.route("/browsethearchive") diff --git a/templates/home.html b/templates/home.html index 6572078..940ff15 100644 --- a/templates/home.html +++ b/templates/home.html @@ -1,14 +1,41 @@ {% extends "layout.html" %} {% block content %} -
+ + + + +
+ + + {% set count = namespace(value=0) %} + {% for img in ImagesBanner %} + + {% set count.value = count.value + 1 %} + {% endfor %} + + + +
+ + +
RECENTLY ADDED WORKS
+ {% for x in results['results']['bindings']%} +
{% if "image" in x %} @@ -36,6 +63,7 @@
{% endfor %} +