diff --git a/.gitignore b/.gitignore
index d237c6a..8a8dde4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.static/settings.json
venv/
+++/*.jpg
+++/*.jpeg
@@ -7,3 +8,4 @@ venv/
+++/533201N0032129W_from_the_Sea_poster.png
+++/key.asc
+++/index.html
+.DS_Store
diff --git a/.static/settings.template.json b/.static/settings.template.json
new file mode 100644
index 0000000..8f2a8e2
--- /dev/null
+++ b/.static/settings.template.json
@@ -0,0 +1,5 @@
+{
+ "inputdir": "<>",
+ "outputdir": "<>",
+ "style": "<>"
+}
\ No newline at end of file
diff --git a/gen.py b/gen.py
index 2d3785e..daec81e 100644
--- a/gen.py
+++ b/gen.py
@@ -1,31 +1,13 @@
#!/usr/bin/env python
-import sys, os, string, markdown, argparse, shutil, json, glob, re
-from distutils import dir_util as dirutil
+import argparse, json, sys, markdown, shutil, json, re, pathlib, shutil
-arg_parser = argparse.ArgumentParser(description='Generates html file accroding to directory content');
-
-input_dir = '../content/';
-output_dir = '../deploy/';
-
-def parse_args():
- global input_dir, output_dir, clean
- arg_parser.add_argument('--input', help='input directory');
- arg_parser.add_argument('--output', help='output directory');
- arg_parser.add_argument('--clean', help='cleans the output directory');
- args = arg_parser.parse_args();
- if args.input and os.path.isdir(args.input):
- input_dir = args.input;
- if args.output and os.path.isdir(args.output):
- output_dir = args.output;
+input_dir = None
+output_dir = None
+style = None
+codebase = pathlib.Path(__file__).parent.absolute()
def translate_index_header(txt, dirname):
- try:
- table = open(os.path.join('.', '
'), 'r+');
- except:
- print('error opening file. aborting...');
- sys.exit(0);
-
href = None
sections = txt.count('- - -');
if sections == 0:
@@ -43,7 +25,12 @@ def translate_index_header(txt, dirname):
# revise this - perhaps with a better
link_md = link_md.replace('data/', dirname + '/');
- out = table.read().replace('[[text_md]]', text_md);
+
+ table = codebase / "templates/"
+ with table.open(encoding="utf-8") as fp:
+ out = fp.read()
+
+ out = out.replace('[[text_md]]', text_md);
out = out.replace('[[link_md]]', link_md);
if href:
href = href.replace('data/', dirname + '/');
@@ -53,45 +40,49 @@ def translate_index_header(txt, dirname):
def escape_date(dirname):
return re.sub('^20\d{2}?.', '', dirname)
-def emit_img(file, data_dir):
- return '
'
+def emit_img(file: pathlib.Path, data_dir: pathlib.Path):
-def emit_video_mp4(file, data_dir):
- return '