aboutsummaryrefslogtreecommitdiff
path: root/tw_publish
diff options
context:
space:
mode:
authortdback <tyler@tdback.net>2024-12-04 18:50:37 -0500
committertdback <tyler@tdback.net>2024-12-04 18:50:37 -0500
commit58347fdfe21315ad3ccc0bd7c4703a8ec7aae797 (patch)
tree393fe8d69962e070c522e889b672ee9e97a88207 /tw_publish
initial commit to new repo
Diffstat (limited to 'tw_publish')
-rwxr-xr-xtw_publish50
1 files changed, 50 insertions, 0 deletions
diff --git a/tw_publish b/tw_publish
new file mode 100755
index 0000000..6d1acbb
--- /dev/null
+++ b/tw_publish
@@ -0,0 +1,50 @@
+#!/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/