diff --git a/app.py b/app.py index ad971da..9ad73bb 100755 --- a/app.py +++ b/app.py @@ -451,7 +451,28 @@ def manpages_page(distro_name, distro_number, package, page): 'html': html, }) -@bottle.get('/mimi_and_eunice', name='mimi_and_eunice') +@bottle.get('/comics', name='comics') +def comics(): + """ + Comics index. + """ + + data = query(""" + PREFIX comics: + + SELECT DISTINCT ?id ?title + WHERE { + ?id a comics:ComicStrip ; + comics:title ?title + } + ORDER BY ?id + """) + + pages = data['results']['bindings'] + + return template('comics/index.html', pages=pages) + +@bottle.get('/comics/mimi_and_eunice', name='mimi_and_eunice') def mimi_and_eunice(): """ Mimi&Eunice index. @@ -469,9 +490,9 @@ def mimi_and_eunice(): ORDER BY ?number """) - return template('mimi_and_eunice/index.html', data=data) + return template('comics/mimi_and_eunice/index.html', data=data) -@bottle.get('/mimi_and_eunice/', name='mimi_and_eunice_strip') +@bottle.get('/comics/mimi_and_eunice/', name='mimi_and_eunice_strip') def mimi_and_eunice_strip(number): """ """ @@ -505,7 +526,64 @@ def mimi_and_eunice_strip(number): 'blob:at': {} }) - return template('mimi_and_eunice/strip.html', data=data['@graph'][0]) + return template('comics/mimi_and_eunice/strip.html', data=data['@graph'][0]) + +@bottle.get('/comics/xkcd', name='xkcd') +def xkcd(): + """ + XKCD index. + """ + + data = query(f""" + PREFIX comics: + + SELECT ?id ?number ?title + WHERE {{ + ?id comics:series ; + comics:number ?number ; + comics:title ?title + }} + ORDER BY ?number + """) + + data = data['results']['bindings'] + + return template('comics/xkcd/index.html', data=data) + +@bottle.get('/comics/xkcd/', name='xkcd_strip') +def xkcd_strip(number): + """ + """ + + iri = '' + + data = query(f''' + prefix blob: + prefix license: + prefix comics: + + DESCRIBE {iri} ?license ?blob + WHERE + {{ + {iri} a comics:ComicStripPanel ; + comics:license ?license; + blob:at ?blob + }} + ''', + { + '@context': { + 'blob': 'dokk:vocab:blob:', + 'license': 'dokk:vocab:license:', + 'comics': 'dokk:vocab:comicstrip:', + 'comics:tag': { '@container': '@set' }, + 'comics:transcript': { '@container': '@set' } + }, + '@type': 'comics:ComicStripPanel', + 'comics:license': {}, + 'blob:at': {} + }) + + return template('comics/xkcd/strip.html', data=data['@graph'][0]) @bottle.get('/articles', name='articles') def articles(): diff --git a/templates/comics/index.html b/templates/comics/index.html new file mode 100644 index 0000000..307b952 --- /dev/null +++ b/templates/comics/index.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} + +{% block title %}Comics{% endblock %} + +{% block body %} + +
+ +
+ DOKK / + comics +
+ + {% for page in pages %} +

+ {{ page['title']['value'] }} +

+ {% endfor %} +
+ +{% endblock %} diff --git a/templates/mimi_and_eunice/index.html b/templates/comics/mimi_and_eunice/index.html similarity index 100% rename from templates/mimi_and_eunice/index.html rename to templates/comics/mimi_and_eunice/index.html diff --git a/templates/mimi_and_eunice/strip.html b/templates/comics/mimi_and_eunice/strip.html similarity index 96% rename from templates/mimi_and_eunice/strip.html rename to templates/comics/mimi_and_eunice/strip.html index c162f56..184f505 100644 --- a/templates/mimi_and_eunice/strip.html +++ b/templates/comics/mimi_and_eunice/strip.html @@ -11,7 +11,7 @@ Published: {{ data['comics:published'] }}

- Liense: + License: {{ data['comics:license']['license:id'] }}

diff --git a/templates/comics/xkcd/index.html b/templates/comics/xkcd/index.html new file mode 100644 index 0000000..7a83aa7 --- /dev/null +++ b/templates/comics/xkcd/index.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} + +{% block title %}XKCD{% endblock %} + +{% block body %} + +

+{% for comic_strip in data %} +

+ {{ comic_strip['number']['value'] }} - + {{ comic_strip['title']['value'] }} +

+{% endfor %} +
+ +{% endblock %} diff --git a/templates/comics/xkcd/strip.html b/templates/comics/xkcd/strip.html new file mode 100644 index 0000000..4ca77b5 --- /dev/null +++ b/templates/comics/xkcd/strip.html @@ -0,0 +1,22 @@ +{% extends "base.html" %} + +{% block title %}XKCD {{ data['comics:number']['@value'] }}: {{ data['comics:title'] }}{% endblock %} + +{% block body %} + +
+

{{ data['comics:title'] }}

+ +

+ Published: {{ data['comics:published'] }} +

+

+ License: + {{ data['comics:license']['license:id'] }} +

+ + + +
+ +{% endblock %} diff --git a/templates/index.html b/templates/index.html index 83bc128..f0bc8d6 100644 --- a/templates/index.html +++ b/templates/index.html @@ -12,7 +12,7 @@

- Library

- Licenses

- Man pages

-

- Mimi & Eunice comic strips

+

- Comics