From c59961093b8ad9f866206a9a026860e08113302a Mon Sep 17 00:00:00 2001 From: subnixr Date: Sat, 21 Jul 2018 02:25:50 +0200 Subject: [PATCH] add rss --- src/ciclostile/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ciclostile/__init__.py b/src/ciclostile/__init__.py index 9094c75..4af2b03 100644 --- a/src/ciclostile/__init__.py +++ b/src/ciclostile/__init__.py @@ -52,12 +52,14 @@ def compile_all(root_path): template_files = [f for f in os.listdir(template_path) if f.endswith('.html')] + rss_file = 'templates/rss.xml' for md_fname in md_files: full_path = os.path.join(md_path, md_fname) name, _ = os.path.splitext(md_fname) data['pages'][name] = parse_file(full_path) + data['pages'][name]['link'] = f"/{name}.html" for file_name in template_files: full_path = os.path.join(template_path, file_name) @@ -76,9 +78,18 @@ def compile_all(root_path): with open(out_path, 'w') as f: f.write(out) + # index with open(templates['index']) as fh: index_template = jinja2.Template(fh.read()) out = index_template.render(**data) out_path = os.path.join(target_path, 'index.html') with open(out_path, "w") as f: f.write(out) + + # rss + with open(rss_file) as fh: + rss_template = jinja2.Template(fh.read()) + out = rss_template.render(**data) + out_path = os.path.join(target_path, 'rss.xml') + with open(out_path, "w") as f: + f.write(out)