#!/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 # using the specified locale for gettext translations, and outputs # the resulting (HTML) ouptut-file. # # Note that the gettext files need to be prepared first. This script # is thus to be invoked via the Makefile. import jinja2 import sys from pathlib import Path, PurePath # Make sure the current directory is in the search path when trying # to import i18nfix. sys.path.insert(0, ".") sys.path.insert(0, "inc/") from inc.site import gen_site from inc.fileproc import copy_files env = jinja2.Environment(loader=jinja2.FileSystemLoader(str(PurePath(__file__).parent)), extensions=["jinja2.ext.i18n"], lstrip_blocks=True, trim_blocks=True, undefined=jinja2.StrictUndefined, autoescape=False) env.newstyle_gettext = True def main(): x = gen_site(0) conf = x.load_config("www.yml") x.gen_abstract(conf, "newsposts", "abstract", "page", 1000) x.gen_newspost_content(conf, "newsposts", "content", "page", "en") x.gen_rss("inc", conf, env) x.run("template", conf, env) x.copy_trees("static") x.copy_trees("dist") if __name__ == "__main__": main()