diff options
author | Daniel Schadt <kingdread@gmx.de> | 2021-08-17 01:42:45 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2021-08-17 01:42:45 +0200 |
commit | 1543a13c880bf22037466109cbd77b2d0c9f21c3 (patch) | |
tree | 3a3033cff52e12d84e923ec7810b32abc6799067 /wikimini/templates/mainlinks.py | |
parent | 02f21a9ca9f9842502f8b89cf77aafc05082bcf1 (diff) | |
download | wikimini-1543a13c880bf22037466109cbd77b2d0c9f21c3.tar.gz wikimini-1543a13c880bf22037466109cbd77b2d0c9f21c3.tar.bz2 wikimini-1543a13c880bf22037466109cbd77b2d0c9f21c3.zip |
Reorganize code
Cramming everything into a single file is not necessarily good, so this
patch splits it up a bit. Furthermore, the templates are no longer
hardcoded, but managed through a registry.
This breaks the lang-ar implementation, which was a weird special case
anyway. Properly fixing it would be to include all country codes.
Diffstat (limited to 'wikimini/templates/mainlinks.py')
-rw-r--r-- | wikimini/templates/mainlinks.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/wikimini/templates/mainlinks.py b/wikimini/templates/mainlinks.py new file mode 100644 index 0000000..ffcbc5e --- /dev/null +++ b/wikimini/templates/mainlinks.py @@ -0,0 +1,15 @@ +"""Renders templates that link to further articles.""" +from . import registry + + +def tmpl_main(wikimini, obj): + """Renders the ``{{main|...}}`` template.""" + links = [ + "=> {} {}".format(wikimini.page_url(str(t.value)), t.value) + for t in obj.params + ] + return "Main articles:\n{}\n".format("\n".join(links)) + + +registry.insert("main", tmpl_main) +registry.insert("main article", tmpl_main) |