summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/koszko_org_website/app.py51
-rw-r--r--src/koszko_org_website/templates/en/koszko.html.jinja6
-rw-r--r--src/koszko_org_website/templates/koszko.html.jinja11
-rw-r--r--src/koszko_org_website/templates/pl/koszko.html.jinja6
4 files changed, 74 insertions, 0 deletions
diff --git a/src/koszko_org_website/app.py b/src/koszko_org_website/app.py
index e3e6339..84be22a 100644
--- a/src/koszko_org_website/app.py
+++ b/src/koszko_org_website/app.py
@@ -5,6 +5,7 @@
# Copyright (C) 2021, 2022 Wojtek Kosior
import gettext
+import re
import dataclasses as dc
import typing as t
@@ -38,6 +39,55 @@ def raise_exception(msg) -> t.NoReturn:
raise Exception(msg)
+post_titles_pl = {
+ 'gospel-despite-no-enthusiasm': 'Dobra Nowina pomimo zniechęcenia'
+}
+
+post_titles_en = {
+ 'gospel-despite-no-enthusiasm': 'Gospel despite lack of enthusiasm'
+}
+
+post_titles = {'en': post_titles_en, 'pl': post_titles_pl}
+
+@dc.dataclass(frozen=True)
+class PostData:
+ date: str
+ page_path: str
+ title: str
+
+ def __lt__(self, other: 'PostData') -> bool:
+ return (other.date, self.page_path) < (self.date, other.page_path)
+
+post_filename_re = re.compile(
+ r'''
+ ^
+ (?P<date>20[0-9][0-9]-[0-1][0-9]-[0-3][0-9])
+ -
+ (?P<post_identifier>.*)
+ \.html\.jinja
+ $
+ ''',
+ re.VERBOSE
+)
+
+def get_posts(lang: str) -> t.Sequence[PostData]:
+ lang_dir = here / 'templates' / lang
+ posts_data = []
+
+ for template_path in (lang_dir / 'posts').glob('20*'):
+ filename_match = post_filename_re.match(template_path.name)
+ assert filename_match is not None
+
+ date = filename_match.group('date')
+ post_identifier = filename_match.group('post_identifier')
+ page_path = f'posts/{date}-{post_identifier}.html'
+ title = post_titles[lang][post_identifier]
+
+ posts_data.append(PostData(date=date, page_path=page_path, title=title))
+
+ return sorted(posts_data)
+
+
@dc.dataclass(init=False)
class Website(flask.Flask):
def __init__(self) -> None:
@@ -56,6 +106,7 @@ class Website(flask.Flask):
}
self.jinja_env.globals['raise'] = raise_exception
+ self.jinja_env.globals['get_posts'] = get_posts
def koszko_install_translations(self, locale: str) -> None:
translations = gettext.translation(
diff --git a/src/koszko_org_website/templates/en/koszko.html.jinja b/src/koszko_org_website/templates/en/koszko.html.jinja
index ecf94dc..b6ce215 100644
--- a/src/koszko_org_website/templates/en/koszko.html.jinja
+++ b/src/koszko_org_website/templates/en/koszko.html.jinja
@@ -153,4 +153,10 @@ Copyright (C) 2021,2022 Wojtek Kosior <koszko@koszko.org>
{{ request_table() }}
{% endcall %}
+
+ {% call section('posts') %}
+ {{ header(2, 'Posts') }}
+
+ {{ posts() }}
+ {% endcall %}
{% endblock %}
diff --git a/src/koszko_org_website/templates/koszko.html.jinja b/src/koszko_org_website/templates/koszko.html.jinja
index 4253329..14b5bd5 100644
--- a/src/koszko_org_website/templates/koszko.html.jinja
+++ b/src/koszko_org_website/templates/koszko.html.jinja
@@ -64,3 +64,14 @@ Copyright (C) 2021,2022 Wojtek Kosior <koszko@koszko.org>
</tbody>
</table>
{% endmacro %}
+
+{% macro posts() %}
+ {% call unordered_list() %}
+ {% for post_data in get_posts(lang_short) %}
+ {% call list_entry() %}
+ {{ link(same_lang_url(post_data.page_path), post_data.title) }}
+ {{ italic('(' ~ post_data.date ~ ')') }}
+ {% endcall %}
+ {% endfor %}
+ {% endcall %}
+{% endmacro %}
diff --git a/src/koszko_org_website/templates/pl/koszko.html.jinja b/src/koszko_org_website/templates/pl/koszko.html.jinja
index 7828c4a..6dae783 100644
--- a/src/koszko_org_website/templates/pl/koszko.html.jinja
+++ b/src/koszko_org_website/templates/pl/koszko.html.jinja
@@ -159,4 +159,10 @@ Copyright (C) 2021,2022 Wojtek Kosior <koszko@koszko.org>
{{ request_table() }}
{% endcall %}
+
+ {% call section('posts') %}
+ {{ header(2, 'Posty') }}
+
+ {{ posts() }}
+ {% endcall %}
{% endblock %}
arget. (doc-pot-update): Also update cookbook pot file. (doc-po-update): Also update cookbook po files. 2019-06-14build: Remove 'gnu/packages/bootstrap' and its binaries.Ludovic Courtès * gnu/local.mk (bootstrapdir, bootstrap_i686_linuxdir) (bootstrap_armhf_linuxdir, bootstrap_aarch64_linuxdir) (bootstrap_mips64el_linuxdir, dist_bootstrap_i686_linux_DATA) (dist_bootstrap_armhf_linux_DATA, dist_bootstrap_aarch64_linux_DATA) (dist_bootstrap_mips64el_linux_DATA): Remove. (set-bootstrap-executable-permissions): Remove target. * Makefile.am (install-data-hook): Remove dependency on 'set-bootstrap-executable-permissions'. * gnu/packages/bootstrap: Remove directory. * tests/search-paths.scm ("evaluate-search-paths, separator is #f"): Adjust to match .../aux-files/linux-libre. 2019-04-26bootstrap: Break automake dependency on generated files.Miguel Ángel Arruga Vivas * bootstrap: Generate stub files for the manual translations whose generated files are not included in the VCS. * doc/contributing.de.texi: Remove file. * doc/contributing.es.texi: Remove file. * doc/contributing.fr.texi: Remove file. * doc/contributing.zh_CN.texi: Remove file. * doc/guix.de.texi: Remove file. * doc/guix.es.texi: Remove file. * doc/guix.fr.texi: Remove file. * doc/guix.zh_CN.texi: Remove file. * .gitignore: Add them. Signed-off-by: Julien Lepiller <julien@lepiller.eu> 2018-11-20.gitignore: Re-add 'authenticate' script.Marius Bakke This is a follow-up to commit 0fe1fba4af41f267c4bb2c006fb37f42422ab703. * .gitignore: s/guix-authenticate/authenticate/