From b63eeffb0f4fe87988c1d0beb909d9cdf4a5132f Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Wed, 14 Dec 2022 00:54:52 +0000 Subject: [PATCH] Implement variable substitution for site files. It was such a pain to update the links in site/index.html for v0.1.0, so this is necessary to prevent me from going insane manually updating all these version numbers sprinkled everywhere. --- README.txt | 5 ++--- man/man7/telodendria-changelog.7 | 7 +++++- site/index.html | 16 ++++++++------ site/style.css | 35 ++++++++++++++--------------- tools/bin/td | 38 +++++++++++++++++++++++++++++--- 5 files changed, 69 insertions(+), 32 deletions(-) diff --git a/README.txt b/README.txt index 56b2ea1..b18e168 100644 --- a/README.txt +++ b/README.txt @@ -53,10 +53,9 @@ To cut a new release for Telodendria, perform the following steps. This is just a reference for me so I don't mess it up. - Update tools/bin/td to declare the next version number. - - Update site/index.html with links to the new version. - - Make sure man/man7/telodendria-changelog.7 is up to date + - Make sure man/man7/telodendria-changelog.7 is up to date. with the latest information. - - Commit any changes made in the previous steps. + - Commit all changes. - Run the release recipe: td release - Deploy the site: td site diff --git a/man/man7/telodendria-changelog.7 b/man/man7/telodendria-changelog.7 index d4e3d6a..38de616 100644 --- a/man/man7/telodendria-changelog.7 +++ b/man/man7/telodendria-changelog.7 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: December 13 2022 $ +.Dd $Mdocdate: December 14 2022 $ .Dt TELODENDRIA-CHANGELOG 7 .Os Telodendria Project .Sh NAME @@ -40,6 +40,11 @@ Fixed a bug in that caused .Xr cvs 1 to be invoked in the wrong directory when tagging a new release. +.It +Added support for environment variable substitution in all site +files. This makes it easier to release +.Nm +versions. .El .Sh v0.1.0 .Pp diff --git a/site/index.html b/site/index.html index 422b4bc..d698d88 100644 --- a/site/index.html +++ b/site/index.html @@ -68,20 +68,20 @@ telodendria-signify.pub. Signature -v0.1.1 +${TELODENDRIA_VERSION} - -Telodendria-v0.1.1.tar.gz + +Telodendria-v${TELODENDRIA_VERSION}.tar.gz - -SHA256 + +Telodendria-v${TELODENDRIA_VERSION}.tar.gz.sha256 - -Signify + +Telodendria-v${TELODENDRIA_VERSION}.tar.gz.sig @@ -278,6 +278,8 @@ Extremely simple HTTP server.

© 2022 Jordan Bancino <@jordan:bancino.net> +
+Updated on ${DATE}.

diff --git a/site/style.css b/site/style.css index 37b2292..3698230 100644 --- a/site/style.css +++ b/site/style.css @@ -43,14 +43,6 @@ body { text-decoration: underline } -.Bd { - background-color: var(--color-snippet); - border-radius: var(--border-radius); - padding-left: 10px; - - overflow: auto; -} - h1 { text-align: center; } @@ -83,7 +75,6 @@ table { border-spacing: 0px; } - td, th { border: 1px solid var(--color-table-border); text-align: left; @@ -94,8 +85,23 @@ tr:nth-child(even) { background-color: var(--color-table-accent); } -/* The above styles are nice for real tables, but not for - * a man page synopsis. */ +/* Thanks Jonah! */ +#logo { + display: block; + margin: auto; + width: 50vw; + max-width: 400px; +} + +/* Mandoc overrides */ + +.Bd { + background-color: var(--color-snippet); + border-radius: var(--border-radius); + padding-left: 10px; + + overflow: auto; +} .Nm { width: fit-content; @@ -105,11 +111,4 @@ tr:nth-child(even) { border: none; } -/* Thanks Jonah! */ -#logo { - display: block; - margin: auto; - width: 50vw; - max-width: 400px; -} diff --git a/tools/bin/td b/tools/bin/td index 33f69d2..d26b428 100644 --- a/tools/bin/td +++ b/tools/bin/td @@ -63,6 +63,24 @@ mod_time() { fi } +# Substitute shell variables in a stream with their actual value +# in this shell. +setsubst() { + SED="/tmp/sed-$RANDOM.txt" + + ( + set | while IFS='=' read -r var val; do + val=$(echo "$val" | cut -d "'" -f 2) + echo "s|\\\${$var}|$val|g" + done + + echo "s|\\\${[a-zA-Z_]*}||g" + ) > "$SED" + + sed -f "$SED" $@ + rm "$SED" +} + # Build the source code, and generate the 'build/telodendria' # binary. recipe_build() { @@ -133,15 +151,29 @@ recipe_site() { exit 1 fi - cp -v site/* "$TELODENDRIA_PUB/" + DATE=$(date) + + cd site/ + find . -type f | while IFS= read -r file; do + dest="$TELODENDRIA_PUB/$file" + dir=$(dirname "$dest") + + echo "$dest" + + mkdir -p "$dir" + setsubst "$file" > "$dest" + done + cd - > /dev/null find man/ -name '*.[1-9]' | while IFS= read -r man; do dir=$(dirname "$man") html=$(basename "$man") mkdir -p "$TELODENDRIA_PUB/$dir/" - mandoc -Thtml -O style=/style.css,man=/man/man%S/%N.%S.html "$man" > "$TELODENDRIA_PUB/$dir/$html.html" - echo "$man -> $TELODENDRIA_PUB/$dir/$html.html" + mandoc -Thtml \ + -O style=/style.css,man=man/man%S/%N.%S.html "$man" \ + > "$TELODENDRIA_PUB/$dir/$html.html" + echo "$TELODENDRIA_PUB/$dir/$html.html" done }