From 46afde26d6abbe40f8e933e891c9884de9585e3e Mon Sep 17 00:00:00 2001 From: Augusto Gunsch Date: Fri, 14 Jan 2022 21:32:43 -0300 Subject: [PATCH] Improve styling --- .gitignore | 4 ++-- generate.py | 27 ++++++++++++++++------- index.html | 7 ++++-- templates/{base.html => dir.html} | 8 ++++++- templates/file.html | 19 ++++++++++++++++ templates/stylesheet.css | 36 ++++++++++++++++++++++++++++++- 6 files changed, 87 insertions(+), 14 deletions(-) rename templates/{base.html => dir.html} (50%) create mode 100644 templates/file.html 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 = '' with open(outroot + '/index.html', 'w') as f: - f.write(render_template(title=outroot, + pretty_outroot = outroot.replace('_', ' ') + + f.write(render_template(dir_template, + title=pretty_outroot, + path=pretty_outroot, content=index_html)) diff --git a/index.html b/index.html index e25da1f..acf9a28 100644 --- a/index.html +++ b/index.html @@ -2,10 +2,13 @@ + Cabinet -

Cabinet file manager

- Explore +
+

Cabinet file manager

+ Explore +
diff --git a/templates/base.html b/templates/dir.html similarity index 50% rename from templates/base.html rename to templates/dir.html index 73b7559..faf901a 100644 --- a/templates/base.html +++ b/templates/dir.html @@ -6,7 +6,13 @@ ${title} - Back +
+

Cabinet file manager

+ ← Back + ${path} +
+
${content} +
diff --git a/templates/file.html b/templates/file.html new file mode 100644 index 0000000..fc21adf --- /dev/null +++ b/templates/file.html @@ -0,0 +1,19 @@ + + + + + + ${title} + + +
+

Cabinet file manager

+ ← Back + ${path} +
+
+

${title}

+ ${content} +

+ + diff --git a/templates/stylesheet.css b/templates/stylesheet.css index 1bd70a2..4d1dcdf 100644 --- a/templates/stylesheet.css +++ b/templates/stylesheet.css @@ -1,3 +1,37 @@ body { - background-color: yellow + background-color: black; + color: white; + margin: 0; +} + +header { + background-color: #232323; + padding: 1em; +} + +a { + text-decoration: none; + color: #3b7fdd; +} + +#back { + background-color: #3b7fdd; + color: black; + padding: .4em; + border-radius: 3px; +} + +#path { + margin-left: 1em; +} + +#cabinet { + margin-top: 0; +} + +main { + margin: 2em; + width: 60%; + margin-left: 20%; + text-align: justify; }