master
subnixr 2018-07-21 02:25:50 +02:00
parent 18c77e71f2
commit c59961093b
1 changed files with 11 additions and 0 deletions

View File

@ -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)