Skip to content
Snippets Groups Projects
Commit ee8659b3 authored by moogdo49's avatar moogdo49
Browse files

geändert: api.py

	geändert:               templates/index.html
	templates/filter.html
parent 80df282e
Branches
Tags 0.2.3
No related merge requests found
...@@ -108,6 +108,55 @@ def search(): ...@@ -108,6 +108,55 @@ def search():
return render_template('index.html', objects = merke, searchBool = True, text = text) return render_template('index.html', objects = merke, searchBool = True, text = text)
@app.route('/filter', methods=['GET'])
def filter():
merke = []
merkeLetter = []
actorQuery = session.query("declare namespace lido=\"http://www.lido-schema.org\"; for $x in distinct-values(/root/object/descriptiveMetadata/actor/text()) order by $x return $x")
for a,actor in actorQuery.iter():
anfang = actor[0]
if (len(merkeLetter) == 0):
merkeLetter.append({"name" : anfang})
elif anfang != merkeLetter[len(merkeLetter)-1]["name"]:
merkeLetter.append({"name" : anfang})
merke.append({"anfang" : anfang, "name" : actor})
return render_template('filter.html', letters = merkeLetter, objects = merke, filter = True, text = '')
@app.route('/filter/actor/<path:kunstler>', methods=['GET'])
def filterActor(kunstler):
text = kunstler
merke = []
urlQuery = session.query("declare namespace lido=\"http://www.lido-schema.org\"; for $x in (/root/object[descriptiveMetadata/actor[contains(text(),'" + kunstler + "')]]/bildLink/text()) return $x")
actorQuery = session.query("declare namespace lido=\"http://www.lido-schema.org\"; for $x in (/root/object[descriptiveMetadata/actor[contains(text(),'" + kunstler + "')]]/descriptiveMetadata/actor/text()) return $x")
titleQuery = session.query("declare namespace lido=\"http://www.lido-schema.org\"; for $x in (/root/object[descriptiveMetadata/actor[contains(text(),'" + kunstler + "')]]/descriptiveMetadata/objectIdentificationWrap/title/text()) return $x")
urlList = []
actorList = []
titleList = []
for a,url in urlQuery.iter():
urlList.append(url)
for b,actor in actorQuery.iter():
actorList.append(actor)
for c,title in titleQuery.iter():
titleList.append(title)
for i in range(0, len(urlList)):
url = urlList[i]
actor = actorList[i]
title = titleList[i]
eintrag = {"url" : url, "actor" : actor, "title" : title}
merke.append(eintrag)
urlQuery.close()
actorQuery.close()
titleQuery.close()
return render_template('index.html', objects = merke, searchBool = True, text = text)
if __name__ == "__main__": if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True) app.run(host="0.0.0.0", port=5000, debug=True)
\ No newline at end of file
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<div class="menue"> <div class="menue">
<ul id="navibereich"> <ul id="navibereich">
<li><a href="https://www.wikidata.org/wiki/Wikidata:Main_Page">WikiData</a></li> <li><a href="https://www.wikidata.org/wiki/Wikidata:Main_Page">WikiData</a></li>
<li><a href="">Filter</a></li> <li><a href="{{ url_for('filter') }}">Filter</a></li>
</ul> </ul>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment