summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2016-11-15 11:31:36 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2016-11-15 11:31:36 +0100
commit9abcf06dff2c4f0987433746ce5037eac711b31c (patch)
tree81c69d6e2164618d94955c88f56cc88d099eef17
parent956fb518ea235a62f14397c1add690f05e0a20b1 (diff)
downloadkyblo-9abcf06dff2c4f0987433746ce5037eac711b31c.tar.xz
build: Add support for unpublished entries
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
-rw-r--r--build.py45
1 files changed, 29 insertions, 16 deletions
diff --git a/build.py b/build.py
index a9b328b..60f4510 100644
--- a/build.py
+++ b/build.py
@@ -46,13 +46,23 @@ def build_archive(jenv, entries):
f.write(rendered)
-def entry_exists(entry):
- path = 'entries/{}.rst'.format(entry['file'])
- if not os.path.isfile(path):
- print('''Source file '{}' for entry '{}' does not exist. Skipping.'''
- .format(path, entry['title']))
- return False
- return True
+def split_entries(entries):
+ published = []
+ unpublished = []
+
+ for entry in entries:
+ path = 'entries/{}.rst'.format(entry['file'])
+ if not os.path.isfile(path):
+ print('''Source file '{}' for entry '{}' does not exist. Skipping.'''
+ .format(path, entry['title']))
+ continue
+
+ if entry.get('published', "True") == "True":
+ published.append(entry)
+ else:
+ unpublished.append(entry)
+
+ return (published, unpublished)
if __name__ == '__main__':
@@ -63,21 +73,24 @@ if __name__ == '__main__':
with open('entries.json') as f:
entries = json.load(f)
- entries = list(filter(entry_exists, entries))
+ published, unpublished = split_entries(entries)
+
+ for entry in unpublished:
+ build_entry(jenv, entry)
- for index, entry in enumerate(entries):
+ for index, entry in enumerate(published):
older = None
newer = None
if index > 0:
- older = entries[index-1]
- if index < len(entries) - 1:
- newer = entries[index+1]
+ older = published[index-1]
+ if index < len(published) - 1:
+ newer = published[index+1]
build_entry(jenv, entry, older, newer)
- if len(entries) > 1:
- build_index(jenv, entries[-1], entries[-2])
+ if len(published) > 1:
+ build_index(jenv, published[-1], published[-2])
else:
- build_index(jenv, entries[-1], None)
+ build_index(jenv, published[-1], None)
- build_archive(jenv, entries)
+ build_archive(jenv, published)