diff options
Diffstat (limited to 'make_site.py')
-rwxr-xr-x | make_site.py | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/make_site.py b/make_site.py index c4a17e21..d335f979 100755 --- a/make_site.py +++ b/make_site.py | |||
@@ -18,29 +18,50 @@ | |||
18 | # is thus to be invoked via the Makefile. | 18 | # is thus to be invoked via the Makefile. |
19 | 19 | ||
20 | import jinja2 | 20 | import jinja2 |
21 | import os | 21 | import sys |
22 | from pathlib import Path, PurePath | ||
22 | from inc.site import gen_site | 23 | from inc.site import gen_site |
23 | from inc.fileproc import copy_files | 24 | from inc.fileproc import copy_files |
24 | 25 | ||
25 | env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(__file__),"inc"), | 26 | env = jinja2.Environment(loader=jinja2.FileSystemLoader(str(PurePath(__file__).parent)), |
26 | extensions=["jinja2.ext.i18n"], | 27 | extensions=["jinja2.ext.i18n"], |
27 | lstrip_blocks=True, | 28 | lstrip_blocks=True, |
28 | trim_blocks=True, | 29 | trim_blocks=True, |
29 | undefined=jinja2.StrictUndefined, | 30 | undefined=jinja2.StrictUndefined, |
30 | autoescape=False) | 31 | autoescape=False) |
31 | 32 | ||
33 | if len(sys.argv) >= 2 and sys.argv[1] == "-vv": | ||
34 | DEBUG=1 | ||
35 | elif len(sys.argv) >= 2 and sys.argv[1] == "-vvv": | ||
36 | DEBUG=2 | ||
37 | elif len(sys.argv) >= 2 and sys.argv[1] == "-vvvv": | ||
38 | DEBUG=3 | ||
39 | else: | ||
40 | DEBUG=0 | ||
41 | |||
32 | def main(): | 42 | def main(): |
33 | # rm_rf("rendered") | 43 | # rm_rf("rendered") |
34 | x = gen_site() | 44 | x = gen_site(DEBUG) |
35 | conf = x.load_config("www.yml") | 45 | conf = x.load_config("www.yml") |
36 | print("generating news abstracts...") | ||
37 | x.gen_abstract(conf, "newsposts", "abstract", "page", 1000) | 46 | x.gen_abstract(conf, "newsposts", "abstract", "page", 1000) |
38 | print("generating html from jinja2 templates...") | 47 | if DEBUG: |
48 | print("generating html from jinja2 templates...") | ||
39 | x.run("template", conf, env) | 49 | x.run("template", conf, env) |
40 | print("generating html from jinja2 news templates...") | 50 | if DEBUG: |
51 | print(Path.cwd()) | ||
52 | _ = Path("rendered") | ||
53 | for child in _.iterdir(): | ||
54 | print(child) | ||
55 | if DEBUG: | ||
56 | print(Path.cwd()) | ||
57 | print("generating html from jinja2 news templates...") | ||
41 | x.run("news", conf, env) | 58 | x.run("news", conf, env) |
42 | #for lang in conf["langs_full"]: | 59 | #for lang in conf["langs_full"]: |
43 | # copy_files("static", conf, lang, "staticfiles", "rendered") | 60 | # copy_files("static", conf, lang, "staticfiles", "rendered") |
61 | if DEBUG: | ||
62 | print("copying directories...") | ||
63 | x.copy_trees("static") | ||
64 | x.copy_trees("dist") | ||
44 | # print("generating rss...") | 65 | # print("generating rss...") |
45 | # x.generate_rss() | 66 | # x.generate_rss() |
46 | # print("generating sitemap...") | 67 | # print("generating sitemap...") |