summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2016-11-15 14:00:53 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2016-11-15 14:08:53 +0100
commit05dcd9f533711e42d80e85a06716c140c8b1f3e2 (patch)
tree3fab5d77e02398a75f3dc7b9908047985cdbafd9 /scripts
parent46bad35efce8817fd9fae0450e416f820ff742ce (diff)
downloadkyblo-05dcd9f533711e42d80e85a06716c140c8b1f3e2.tar.xz
Merge build_entry and build_index
No need to special-case this anymore with unpublished pages. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build.py46
1 files changed, 13 insertions, 33 deletions
diff --git a/scripts/build.py b/scripts/build.py
index 2b6055d..560f503 100755
--- a/scripts/build.py
+++ b/scripts/build.py
@@ -8,36 +8,19 @@ from jinja2 import Environment, FileSystemLoader
from utils.reST import reST_to_html
-def build_entry(jenv, entry, older=None, newer=None):
- entry_template = jenv.get_template('entry.html')
-
- source_file = 'entries/{}.rst'.format(entry['file'])
- with open(source_file, 'r') as f:
- source = f.read()
-
- rendered_source = reST_to_html(source)
-
- rendered = entry_template.render(entry=entry,
- older=older,
- newer=newer,
- content=rendered_source)
- with open('out/{}.html'.format(entry['file']), 'w+') as f:
- f.write(rendered)
-
-
-def build_index(jenv, entry, older=None):
- index_template = jenv.get_template('index.html')
-
+def build_entry(jenv, fname, entry, older=None, newer=None):
+ template = jenv.get_template('entry.html')
source_file = 'entries/{}.rst'.format(entry['file'])
with open(source_file, 'r') as f:
source = f.read()
rendered_source = reST_to_html(source)
- rendered = index_template.render(entry=entry,
- older=older,
- content=rendered_source)
- with open('out/index.html', 'w+') as f:
+ rendered = template.render(entry=entry,
+ older=older,
+ newer=newer,
+ content=rendered_source)
+ with open('out/{}.html'.format(fname), 'w+') as f:
f.write(rendered)
@@ -78,16 +61,13 @@ if __name__ == '__main__':
published, unpublished = split_entries(entries)
for entry in unpublished:
- build_entry(jenv, entry)
+ build_entry(jenv, entry['file'], entry)
for index, entry in enumerate(published):
- older = published[index:index-1]
- newer = published[index:index+1]
- build_entry(jenv, entry, older, newer)
-
- if len(published) > 1:
- build_index(jenv, published[-1], published[-2])
- else:
- build_index(jenv, published[-1], None)
+ older = published[index-1:index]
+ newer = published[index+1:index+2]
+ build_entry(jenv, entry['file'], entry, older, newer)
+
+ build_entry(jenv, 'index', published[-1], older=published[-2:-1])
build_archive(jenv, published)