From cf9958da7c7a8d8522937d7c4706c7ab2fc5fd73 Mon Sep 17 00:00:00 2001 From: ng0 Date: Mon, 2 Sep 2019 10:54:27 +0000 Subject: Adjust repository layout (resolves #5596), add sitemap.xml generator. --- template.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'template.py') diff --git a/template.py b/template.py index a055a33e..d7be569f 100755 --- a/template.py +++ b/template.py @@ -1,4 +1,6 @@ #!/usr/bin/env python3 +# coding: utf-8 +# # This file is in the public domain. # # This script runs the jinja2 templating engine on an input template-file @@ -34,7 +36,7 @@ langs_full = {"en": "English", "ru": "Ру́сский язы́к", "pt": "Português"} -for in_file in glob.glob("*.j2"): +for in_file in glob.glob("template/*.j2"): name, ext = re.match(r"(.*)\.([^.]+)$", in_file.rstrip(".j2")).groups() tmpl = env.get_template(in_file) @@ -42,7 +44,7 @@ for in_file in glob.glob("*.j2"): """ Return URL for the current page in another locale. """ - return "../" + other_locale + "/" + in_file.rstrip(".j2") + return "../" + other_locale + "/" + in_file.replace('template/', '').rstrip(".j2") def url_localized(filename): return "../" + locale + "/" + filename @@ -70,7 +72,6 @@ for in_file in glob.glob("*.j2"): env.install_gettext_translations(tr, newstyle=True) - content = tmpl.render( docshost="docs.taler.net", lang=locale, @@ -80,7 +81,7 @@ for in_file in glob.glob("*.j2"): url_localized=url_localized, svg_localized=svg_localized, filename=name + "." + ext) - out_name = "./" + locale + "/" + in_file.rstrip(".j2") - os.makedirs("./" + locale, exist_ok=True) - with codecs.open(out_name, "w", "utf-8") as f: + out_name = "./rendered/" + locale + "/" + in_file.replace('template/', '').rstrip(".j2") + os.makedirs("./rendered/" + locale, exist_ok=True) + with codecs.open(out_name, "w", encoding='utf-8') as f: f.write(content) -- cgit v1.2.3