forked from unit/ciclostile
add rss
This commit is contained in:
parent
18c77e71f2
commit
c59961093b
|
@ -52,12 +52,14 @@ def compile_all(root_path):
|
||||||
template_files = [f
|
template_files = [f
|
||||||
for f in os.listdir(template_path)
|
for f in os.listdir(template_path)
|
||||||
if f.endswith('.html')]
|
if f.endswith('.html')]
|
||||||
|
rss_file = 'templates/rss.xml'
|
||||||
|
|
||||||
for md_fname in md_files:
|
for md_fname in md_files:
|
||||||
full_path = os.path.join(md_path, md_fname)
|
full_path = os.path.join(md_path, md_fname)
|
||||||
name, _ = os.path.splitext(md_fname)
|
name, _ = os.path.splitext(md_fname)
|
||||||
|
|
||||||
data['pages'][name] = parse_file(full_path)
|
data['pages'][name] = parse_file(full_path)
|
||||||
|
data['pages'][name]['link'] = f"/{name}.html"
|
||||||
|
|
||||||
for file_name in template_files:
|
for file_name in template_files:
|
||||||
full_path = os.path.join(template_path, file_name)
|
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:
|
with open(out_path, 'w') as f:
|
||||||
f.write(out)
|
f.write(out)
|
||||||
|
|
||||||
|
# index
|
||||||
with open(templates['index']) as fh:
|
with open(templates['index']) as fh:
|
||||||
index_template = jinja2.Template(fh.read())
|
index_template = jinja2.Template(fh.read())
|
||||||
out = index_template.render(**data)
|
out = index_template.render(**data)
|
||||||
out_path = os.path.join(target_path, 'index.html')
|
out_path = os.path.join(target_path, 'index.html')
|
||||||
with open(out_path, "w") as f:
|
with open(out_path, "w") as f:
|
||||||
f.write(out)
|
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user