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.
This commit is contained in:
parent
4eae5b771f
commit
b63eeffb0f
5 changed files with 69 additions and 32 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -68,20 +68,20 @@ telodendria-signify.pub</a>.
|
|||
<th>Signature</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>v0.1.1</td>
|
||||
<td>${TELODENDRIA_VERSION}</td>
|
||||
<td>
|
||||
<a href="/pub/v0.1.1/Telodendria-v0.1.1.tar.gz">
|
||||
Telodendria-v0.1.1.tar.gz
|
||||
<a href="/pub/v${TELODENDRIA_VERSION}/Telodendria-v${TELODENDRIA_VERSION}.tar.gz">
|
||||
<code>Telodendria-v${TELODENDRIA_VERSION}.tar.gz</code>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/pub/v0.1.1/Telodendria-v0.1.1.tar.gz.sha256">
|
||||
SHA256
|
||||
<a href="/pub/v${TELODENDRIA_VERSION}/Telodendria-v${TELODENDRIA_VERSION}.tar.gz.sha256">
|
||||
<code>Telodendria-v${TELODENDRIA_VERSION}.tar.gz.sha256</code>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/pub/v0.1.1/Telodendria-v0.1.1.tar.gz.sig">
|
||||
Signify
|
||||
<a href="/pub/v${TELODENDRIA_VERSION}/Telodendria-v${TELODENDRIA_VERSION}.tar.gz.sig">
|
||||
<code>Telodendria-v${TELODENDRIA_VERSION}.tar.gz.sig</code>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -278,6 +278,8 @@ Extremely simple HTTP server.
|
|||
<hr>
|
||||
<p>
|
||||
© 2022 Jordan Bancino <@jordan:bancino.net>
|
||||
<br>
|
||||
Updated on ${DATE}.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
38
tools/bin/td
38
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue