Compare commits
1 Commits
main
...
feature/ge
Author | SHA1 | Date |
---|---|---|
ktyl | 0c069241cd |
2
blog
2
blog
|
@ -1 +1 @@
|
||||||
Subproject commit 57cb9a24716d1094c4fc3cb491eec296d7a1dc0d
|
Subproject commit 745cedab0f6f829c9d61a0d1d31d6a8913d7e81e
|
|
@ -0,0 +1,87 @@
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
def print_usage():
|
||||||
|
print(f"usage: python {sys.argv[0]} INPUT")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
argc = len(sys.argv)
|
||||||
|
if argc < 2:
|
||||||
|
print_usage()
|
||||||
|
|
||||||
|
|
||||||
|
def error(message):
|
||||||
|
print(f"error: {message}:", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
path = sys.argv[1]
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
error(f"{path} does not exist.")
|
||||||
|
|
||||||
|
|
||||||
|
def read_metadata(path):
|
||||||
|
pattern = re.compile(r"^\+{3}\n((?:.*|\n)*)\n\+{3}")
|
||||||
|
|
||||||
|
metadata = {}
|
||||||
|
|
||||||
|
with open(path) as f:
|
||||||
|
match = re.search(pattern, f.read())
|
||||||
|
if not match:
|
||||||
|
error(f"no metadata found at start of {path}")
|
||||||
|
|
||||||
|
lines = match.group(1).split('\n')
|
||||||
|
for l in lines:
|
||||||
|
pair = [s.strip() for s in l.split('=')]
|
||||||
|
metadata[pair[0]] = pair[1]
|
||||||
|
|
||||||
|
return metadata
|
||||||
|
|
||||||
|
|
||||||
|
def strip_metadata(path):
|
||||||
|
pattern = re.compile(r"(\+{3}\n(?:.*|\n)*\n\+{3})")
|
||||||
|
|
||||||
|
with open(path) as f:
|
||||||
|
return re.sub(pattern, "", f.read()).strip()
|
||||||
|
|
||||||
|
|
||||||
|
def generate_header(metadata):
|
||||||
|
|
||||||
|
if metadata is None:
|
||||||
|
error("no metadata, can't generate header")
|
||||||
|
|
||||||
|
# TODO: is the description meta tag length-restricted?
|
||||||
|
description = metadata["description"]
|
||||||
|
keywords = metadata["keywords"]
|
||||||
|
|
||||||
|
# if "description" or "keywords" don't exist we can't do anything: crash out
|
||||||
|
if description is None or keywords is None:
|
||||||
|
error("empty metadata parameters, can't generate header")
|
||||||
|
|
||||||
|
header = """<head>
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0 minimum-scale=1" />
|
||||||
|
<meta name="description" content="{{DESCRIPTION}}" />
|
||||||
|
<meta name="keywords" content="{{KEYWORDS}}"/>
|
||||||
|
<link rel="canonical" href="https://ktyl.dev/">
|
||||||
|
<link rel="stylesheet" href="styles.css" />
|
||||||
|
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||||
|
|
||||||
|
<script src="https://kit.fontawesome.com/ad50bb2e16.js" crossorigin="anonymous"></script>
|
||||||
|
</head>"""
|
||||||
|
header = header.replace("{{DESCRIPTION}}", description)
|
||||||
|
header = header.replace("{{KEYWORDS}}", keywords)
|
||||||
|
return header
|
||||||
|
|
||||||
|
html = strip_metadata(path)
|
||||||
|
metadata = read_metadata(path)
|
||||||
|
|
||||||
|
header = generate_header(metadata)
|
||||||
|
|
||||||
|
# Inject the generated <head> element between the opening <html> and <body> elements.
|
||||||
|
pattern = r"(<html>)(?:\n|.)*(<body>)"
|
||||||
|
replacement = f"\\1\\n{header}\\n\\2"
|
||||||
|
html = re.sub(pattern, replacement, html)
|
||||||
|
|
||||||
|
print(html)
|
9
makefile
9
makefile
|
@ -1,6 +1,7 @@
|
||||||
SRC_DIR = src
|
SRC_DIR = src
|
||||||
IMG_DIR = img
|
IMG_DIR = img
|
||||||
OUT_DIR = site
|
OUT_DIR = site
|
||||||
|
TMP_DIR = tmp
|
||||||
|
|
||||||
ROOT_DIR = $(SRC_DIR)/root
|
ROOT_DIR = $(SRC_DIR)/root
|
||||||
|
|
||||||
|
@ -31,7 +32,10 @@ html: $(HTML_TARGETS) $(CSS_TARGETS) | $(OUT_DIR)
|
||||||
cp $(IMG_DIR)/*.png $(OUT_DIR)/
|
cp $(IMG_DIR)/*.png $(OUT_DIR)/
|
||||||
cp $(IMG_DIR)/*.jpg $(OUT_DIR)/
|
cp $(IMG_DIR)/*.jpg $(OUT_DIR)/
|
||||||
|
|
||||||
$(OUT_DIR)/%.html: $(ROOT_DIR)/%.html $(HTML_INCLUDES) $(BLOG_INDEX) | $(OUT_DIR)
|
$(TMP_DIR)/%.html: $(ROOT_DIR)/%.html | $(TMP_DIR)
|
||||||
|
python generate_headers.py $< > $@
|
||||||
|
|
||||||
|
$(OUT_DIR)/%.html: $(TMP_DIR)/%.html $(HTML_INCLUDES) $(BLOG_INDEX) | $(OUT_DIR)
|
||||||
python ppp.py $< $(HTML_INCLUDES) $(BLOG_INDEX) > $@
|
python ppp.py $< $(HTML_INCLUDES) $(BLOG_INDEX) > $@
|
||||||
|
|
||||||
$(OUT_DIR)/%.css: $(ROOT_DIR)/%.css | $(OUT_DIR)
|
$(OUT_DIR)/%.css: $(ROOT_DIR)/%.css | $(OUT_DIR)
|
||||||
|
@ -40,6 +44,9 @@ $(OUT_DIR)/%.css: $(ROOT_DIR)/%.css | $(OUT_DIR)
|
||||||
$(OUT_DIR):
|
$(OUT_DIR):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
|
$(TMP_DIR):
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
$(BLOG_INDEX):
|
$(BLOG_INDEX):
|
||||||
mkdir -p $(BLOG_OUT_DIR)
|
mkdir -p $(BLOG_OUT_DIR)
|
||||||
make --directory $(BLOG_BASE_DIR) html
|
make --directory $(BLOG_BASE_DIR) html
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<ul class="nav-links">
|
<ul class="nav-links">
|
||||||
|
<li><a href="/about.html">about</a></li>
|
||||||
<li><a href="/blog.html">blog</a></li>
|
<li><a href="/blog.html">blog</a></li>
|
||||||
<li><a href="/gallery.html">gallery</a></li>
|
<li><a href="/gallery.html">gallery</a></li>
|
||||||
<li><a href="/vn/books.html">vn</a></li>
|
<li><a href="/vn/books.html">vn</a></li>
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
+++
|
||||||
|
description = computer whisperer
|
||||||
|
keywords = Cat Flynn, Ktyl, About, Computer Whisperer
|
||||||
|
+++
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<title>ktyl ~ computer whisperer</title>
|
||||||
|
|
||||||
|
<div class="nav">
|
||||||
|
#include titlestart.html
|
||||||
|
/about
|
||||||
|
#include titleend.html
|
||||||
|
#include nav.html
|
||||||
|
|
||||||
|
#include socials.html
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="page">
|
||||||
|
|
||||||
|
<div class="pfp">
|
||||||
|
<img src="pfp.jpg"></img>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1>Hi, I'm Cat</h1>
|
||||||
|
|
||||||
|
<div class="text-panel">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
I am an engineer/artist exploring human technology.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="separator"></div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
In my day job I find novel uses for interactive, immersive and games technology for training and simulation.
|
||||||
|
I am passionate about free and open source software, and the importance of developing tools that serve everyone.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
I tinker for fun and when I can, make things inspired by physics, the universe and boundaries, physical, imagined or otherwise.
|
||||||
|
I am currently most enamoured by optics, orbital mechanics and relativity.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Besides computing, I like caring for my plants, photography, and studying language, culture and philosophy.
|
||||||
|
I explore fashion, makeup, gender expression and regularly see live music.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="separator"></div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
For inquiries, professional or otherwise, please <a href="mailto:me@ktyl.dev">send me an email</a>!
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
#include planets.html
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -1,8 +1,11 @@
|
||||||
|
+++
|
||||||
|
description = blog
|
||||||
|
keywords = Cat Flynn, Ktyl, Blog
|
||||||
|
+++
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
#include header.html
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<title>ktyl ~ blog</title>
|
<title>ktyl ~ blog</title>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
#include header.html
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
#include titlestart.html
|
||||||
|
/contact
|
||||||
|
#include titleend.html
|
||||||
|
|
||||||
|
#include sidebar.html
|
||||||
|
#include planets.html
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -1,8 +1,11 @@
|
||||||
|
+++
|
||||||
|
description = gallery
|
||||||
|
keywords = Cat Flynn, Ktyl, Portfolio, Gallery, Ray Tracing, Relativity
|
||||||
|
+++
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
#include header.html
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<title>ktyl ~ gallery</title>
|
<title>ktyl ~ gallery</title>
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
+++
|
||||||
|
description = home
|
||||||
|
keywords = Cat Flynn, Ktyl, Portfolio, Showreel, Blog, Gallery
|
||||||
|
+++
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
#include header.html
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<title>ktyl ~ home</title>
|
<title>ktyl ~ home</title>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue