50 lines
1.5 KiB
Bash
Executable file
50 lines
1.5 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
# tw_publish: Build a single index.html file in the tiddlywiki's 'output/'
|
|
# directory, and then move it to the wiki's root directory.
|
|
|
|
yell() { echo "$0: $*" >&2; }
|
|
die() { yell "$*"; exit 111; }
|
|
try() { "$@" || die "cannot $*"; }
|
|
|
|
while getopts ":v" args; do
|
|
case "$args" in
|
|
v) set -x ;;
|
|
*) die "invalid option -$OPTARG... quitting;" ;;
|
|
esac
|
|
done
|
|
shift $((OPTIND-1)) # Shift args so wiki-name becomes $1
|
|
|
|
if ! command -v tiddlywiki >/dev/null; then
|
|
die "package 'tiddlywiki' can not be found... quitting;"
|
|
fi
|
|
|
|
DOMAIN="tdback.net/"
|
|
TITLE="tdback's blog"
|
|
DESC="Posts about things I'm working on"
|
|
WIKI="$HOME/wikis/$1"
|
|
|
|
[ "$#" -eq 0 ] && die "please specify a tiddlywiki... quitting;"
|
|
|
|
[ ! -e "$WIKI" ] && die "tiddlywiki '$WIKI' does not exist... quitting;"
|
|
|
|
# Build our initial index.html file containing the entire tiddlywiki.
|
|
try tiddlywiki "$WIKI" --build index >/dev/null
|
|
|
|
# Now we need to "patch" the html file so it can pass the webring audit.
|
|
# See: https://codeberg.org/SystemCrafters/craftering/pulls/15
|
|
head -n -2 "$WIKI"/output/index.html | try sed '$a \
|
|
<div style="display: none">\
|
|
<a href="https://craftering.systemcrafters.net/@tdback/previous"></a>\
|
|
<a href="https://craftering.systemcrafters.net/">craftering</a>\
|
|
<a href="https://craftering.systemcrafters.net/@tdback/next"></a>\
|
|
</div>\
|
|
</body>\
|
|
</html>' >"$WIKI"/index.html
|
|
|
|
# Generate the RSS feed.
|
|
try tw_rss -wiki "$WIKI" -title "$TITLE" -domain "$DOMAIN" -desc "$DESC" -tls
|
|
|
|
# Clean up output directory.
|
|
rm "$WIKI"/output/*
|
|
rmdir "$WIKI"/output/
|