aboutsummaryrefslogtreecommitdiff
path: root/build.py
diff options
context:
space:
mode:
authorBlaise Thompson <blaise@untzag.com>2021-07-05 15:42:38 -0500
committerBlaise Thompson <blaise@untzag.com>2021-07-05 15:42:38 -0500
commit92ece015bf23e0d078b8798e52d10a6cdfe7010c (patch)
tree02bad14238bfc3f4611f333dd4c6e6bf6e64f688 /build.py
parent70f88e4d34cb18ddf75f56c14e4aa2531b694952 (diff)
refactor to build using python
Diffstat (limited to 'build.py')
-rwxr-xr-xbuild.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/build.py b/build.py
new file mode 100755
index 0000000..d044287
--- /dev/null
+++ b/build.py
@@ -0,0 +1,34 @@
+import os
+import shutil
+import jinja2
+import markdown
+import pathlib
+from datetime import datetime
+from dataclasses import dataclass
+
+
+__here__ = pathlib.Path(__file__).resolve().parent
+
+
+date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+
+
+md = markdown.Markdown(extensions=['meta', "toc", "extra"])
+
+
+env = jinja2.Environment(loader = jinja2.FileSystemLoader(str(__here__ / "templates")))
+
+
+if not os.path.isdir(__here__ / "public"):
+ os.mkdir(__here__ / "public")
+
+
+template = env.get_template("index.html")
+with open(__here__ / "public" / "index.html", "w") as f:
+ f.write(template.render(date=date))
+
+
+template = env.get_template('style.css')
+for d, _, _ in os.walk(__here__ / "public", topdown=False):
+ with open(os.path.join(d, "style.css"), 'w') as f:
+ f.write(template.render())