aboutsummaryrefslogtreecommitdiff
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
parent70f88e4d34cb18ddf75f56c14e4aa2531b694952 (diff)
refactor to build using python
-rw-r--r--.gitignore1
-rwxr-xr-xbuild.py34
-rw-r--r--public/style.css18
-rwxr-xr-xpublicize.sh7
-rw-r--r--templates/footer.html12
-rw-r--r--templates/index.html (renamed from public/index.html)7
-rw-r--r--templates/style.css66
7 files changed, 120 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..46f5006
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+public/*
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())
diff --git a/public/style.css b/public/style.css
deleted file mode 100644
index 9cff696..0000000
--- a/public/style.css
+++ /dev/null
@@ -1,18 +0,0 @@
-a {
- text-decoration: none;
- color: #81a2be;
-}
-
-body {
- font-family: 'DejaVu Sans Mono', monospace;
- margin: 40px auto;
- min-width: 80ch;
- max-width: 80ch;
- line-height: 1.5;
- font-size: 16px;
- background-color: #1d1f21;
- color: #c5c8c6;
- padding: 0 10px;
- text-align: left;
- overflow-y: scroll;
-}
diff --git a/publicize.sh b/publicize.sh
index a5bb3d7..ebc5739 100755
--- a/publicize.sh
+++ b/publicize.sh
@@ -1 +1,6 @@
-scp -r public/* root@blaise.zone:/var/www/blaise.zone/html/
+#!/bin/bash
+cd "$(dirname "$0")"
+git pull
+python3 build.py
+cp -r ./public/* /var/www/blaise.zone/html/
+
diff --git a/templates/footer.html b/templates/footer.html
new file mode 100644
index 0000000..10419e2
--- /dev/null
+++ b/templates/footer.html
@@ -0,0 +1,12 @@
+<hr>
+
+<p style="display:inline;">
+built {{ date }}
+<div style="float:right;">
+<a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>: no copyright
+(<a href="http://git.blaise.zone/website/blog.git/">source</a>)
+</div>
+</p>
+
+</body>
+</html>
diff --git a/public/index.html b/templates/index.html
index ed1fa27..c27acac 100644
--- a/public/index.html
+++ b/templates/index.html
@@ -43,9 +43,4 @@
<a href="http://wright.tools/">WrightTools</a><br>
<a href="http://mechatronics.blaise.zone/">mechatronics</a><br>
</p>
- <hr>
- <p>
- <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>: no copyright
- </p>
-</body>
-</html>
+{% include "footer.html" %}
diff --git a/templates/style.css b/templates/style.css
new file mode 100644
index 0000000..9f19e42
--- /dev/null
+++ b/templates/style.css
@@ -0,0 +1,66 @@
+a {
+ text-decoration: none;
+ color: #81a2be;
+}
+
+body {
+ font-family: 'DejaVu Sans Mono', monospace;
+ margin: 40px auto;
+ min-width: 80ch;
+ max-width: 80ch;
+ line-height: 1.5;
+ font-size: 16px;
+ background-color: #1d1f21;
+ color: #c5c8c6;
+ padding: 0 10px;
+ text-align: left;
+ overflow-y: scroll;
+}
+
+h2 {
+ font-size: 16px;
+}
+
+pre {
+ width: 80ch;
+ padding: 15px;
+ margin-left: auto;
+ margin-right: auto;
+ overflow: auto;
+ overflow-y: hidden;
+ font-size: 15.3px;
+ background: #111314;
+ border: 1px solid #c5c8c6;
+}
+
+code {
+ background: #111314;
+ color: #de935f
+}
+
+figure {
+ width: 100%;
+ margin: 0px auto;
+ margin-bottom: 1em;
+}
+
+audio {
+ width: 100%;
+}
+
+img {
+ width: 100%;
+}
+
+table {
+ width: 100%;
+}
+
+table, th, td {
+ border: 1px solid #969896;
+ border-collapse: collapse;
+}
+
+th, td {
+ padding: 5px;
+}