summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/scripts/build.py b/scripts/build.py
index 971b8d4..4b3eddf 100755
--- a/scripts/build.py
+++ b/scripts/build.py
@@ -8,8 +8,7 @@ from jinja2 import Environment, FileSystemLoader
from utils.reST import reST_to_html
-def build_entry(jenv, fname, entry, older=None, newer=None):
- template = jenv.get_template('entry.html')
+def build_entry(template, fname, entry, older=None, newer=None):
source_file = 'entries/{}.rst'.format(entry['file'])
with open(source_file, 'r') as f:
source = f.read()
@@ -24,9 +23,8 @@ def build_entry(jenv, fname, entry, older=None, newer=None):
f.write(rendered)
-def build_archive(jenv, filename, title, entries):
- archive_template = jenv.get_template('archive.html')
- rendered = archive_template.render(title=title, entries=entries)
+def build_archive(template, filename, title, entries):
+ rendered = template.render(title=title, entries=entries)
with open('out/{}.html'.format(filename), 'w+') as f:
f.write(rendered)
@@ -57,17 +55,19 @@ if __name__ == '__main__':
jenv = Environment(loader=FileSystemLoader('templates'),
trim_blocks=True,
lstrip_blocks=True)
+ entry_tmpl = jenv.get_template('entry.html')
+ archive_tmpl = jenv.get_template('archive.html')
published, unpublished = load_metadata('metadata.json')
for entry in unpublished:
- build_entry(jenv, entry['file'], entry)
+ build_entry(entry_tmpl, entry['file'], entry)
for index, entry in enumerate(published):
older = published[index-1:index]
newer = published[index+1:index+2]
- build_entry(jenv, entry['file'], entry, older, newer)
+ build_entry(entry_tmpl, entry['file'], entry, older, newer)
- build_entry(jenv, 'index', published[-1], older=published[-2:-1])
+ build_entry(entry_tmpl, 'index', published[-1], older=published[-2:-1])
- build_archive(jenv, 'archive', 'Archive', published)
+ build_archive(archive_tmpl, 'archive', 'Archive', published)