diff --git a/.gitignore b/.gitignore index 07c713b..695016d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ venv/ -files/ -out/ +input_files/ +Files/ diff --git a/generate.py b/generate.py index c8bff2a..bfcffa8 100755 --- a/generate.py +++ b/generate.py @@ -3,12 +3,12 @@ import os import shutil from markdown2 import markdown -input_ = 'files' -output = 'out' +input_ = 'input_files' +output = 'Files' templates = 'templates' -def render_template(**kwargs): +def render_template(template, **kwargs): expanded = template[:] for var, val in kwargs.items(): @@ -17,8 +17,11 @@ def render_template(**kwargs): return expanded -with open(templates + '/base.html', 'r') as template: - template = template.read() +with open(templates + '/file.html', 'r') as template: + file_template = template.read() + +with open(templates + '/dir.html', 'r') as template: + dir_template = template.read() for root, dirs, files in os.walk(input_, topdown=True): outroot = output + root[len(input_):] @@ -42,7 +45,11 @@ for root, dirs, files in os.walk(input_, topdown=True): with open(outfile, 'w') as f: content = markdown(content) - new_file = render_template(title=basename, + pretty_name = basename.replace('_', ' ') + + new_file = render_template(file_template, + title=pretty_name, + path=outroot.replace('_', ' ') + '/' + pretty_name, content=content) f.write(new_file) @@ -50,7 +57,7 @@ for root, dirs, files in os.walk(input_, topdown=True): index_html = '