diff options
| author | Johannes Herman <johannes.herman@gmail.com> | 2026-03-16 11:14:21 +0100 |
|---|---|---|
| committer | Johannes Herman <johannes.herman@gmail.com> | 2026-03-16 11:14:21 +0100 |
| commit | caa30dd45d3ae76405a7f4ecc9641521c1fb8895 (patch) | |
| tree | 5641956935e8ef6cb487d47456b884443e5118e8 /bin/makepage | |
initial
Diffstat (limited to 'bin/makepage')
| -rwxr-xr-x | bin/makepage | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/makepage b/bin/makepage new file mode 100755 index 0000000..386f0de --- /dev/null +++ b/bin/makepage @@ -0,0 +1,36 @@ +#!/bin/sh -eu + +. ./config + +title="${1:-$TITLE}" +content=$(cat) + +awk \ + -v title="$title" \ + -v content="$content" \ + -v header="$TEMP_HEAD" \ + -v footer="$TEMP_FOOT" \ + ' +function replace(str, pat, rep, out, parts, n, i) { + n = split(str, parts, pat) + out = parts[1] + for (i = 2; i <= n; i++) + out = out rep parts[i] + return out +} + +BEGIN { + while ((getline line < header) > 0) hbuf = hbuf line "\n" + close(header) + while ((getline line < footer) > 0) fbuf = fbuf line "\n" + close(footer) +} + +{ + line = $0 + line = replace(line, "{{TITLE}}", title) + line = replace(line, "{{CONTENT}}", content) + line = replace(line, "{{HEADER}}", hbuf) + line = replace(line, "{{FOOTER}}", fbuf) + print line +}' "$TEMP_PAGE" |
