home » zplus/dokk.org.git
Author zPlus <zplus@peers.community> 2024-11-20 12:39:50
Committer zPlus <zplus@peers.community> 2024-11-20 12:39:50
Commit cf95e4e (patch)
Tree 2885718
Parent(s)

Move license queries from templates to controllers.


commits diff: ee4ad5c..cf95e4e
3 files changed, 29 insertions, 20 deletionsdownload


Diffstat
-rwxr-xr-x app.py 30
-rw-r--r-- pages/license.html 12
-rw-r--r-- pages/templates/license/license.tpl 7

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+29/-1 M   app.py
index 8c94ea8..ed3d417
old size: 12K - new size: 12K
@@ -229,12 +229,40 @@ def library_item(item_id):
229 229
230 230 return template('templates/library/item.tpl', item_id=item_id, plaintext=item_plaintext)
231 231
232 + @bottle.get('/license', name='license_list')
233 + def license_list():
234 + """
235 + List all licenses.
236 + """
237 +
238 + # TODO sanitize input
239 + data = query(f"""
240 + PREFIX license: <dokk:vocab:license:>
241 +
242 + SELECT *
243 + WHERE {{
244 + ?license license:id ?id ;
245 + license:name ?name .
246 + }}
247 + ORDER BY ASC(UCASE(?name))
248 + """)
249 +
250 + return template('license.html', data=data)
251 +
232 252 @bottle.get('/license/<id>', name='license')
233 253 def license(id):
234 254 """
255 + Show a single license
235 256 """
236 257
237 - return template('templates/license/license.tpl', license_id=id)
258 + # TODO sanitize input
259 + data = query(f"""
260 + PREFIX license: <dokk:vocab:license:>
261 +
262 + DESCRIBE <dokk:license:{id}>
263 + """)
264 +
265 + return template('templates/license/license.tpl', data=data)
238 266
239 267 @bottle.get('/manpages/<distribution>/<version>', name='manpages_distribution')
240 268 def manpages_distribution(distribution, version):

+0/-12 M   pages/license.html
index 01bb8dc..c1792cc
old size: 543B - new size: 336B
@@ -1,17 +1,5 @@
1 1 {% extends "templates/base.tpl" %}
2 2
3 - {% set data = query("""
4 - PREFIX license: <dokk:license:>
5 -
6 - SELECT *
7 - WHERE {
8 - ?license license:id ?id ;
9 - license:name ?name.
10 - }
11 - ORDER BY ASC(UCASE(?name))
12 - """)
13 - %}
14 -
15 3 {% block title %}Licenses{% endblock %}
16 4
17 5 {% block body %}

+0/-7 M   pages/templates/license/license.tpl
index 228e9d2..0ec6978
old size: 488B - new size: 370B
@@ -1,12 +1,5 @@
1 1 {% extends "templates/base.tpl" %}
2 2
3 - {% set data = query("""
4 - PREFIX license: <dokk:license:>
5 -
6 - DESCRIBE license:""" + license_id + """
7 - """)
8 - %}
9 -
10 3 {% block title %}{{ data['license:name'] }}{% endblock %}
11 4
12 5 {% block body %}