aboutsummaryrefslogtreecommitdiff
path: root/tw_publish
blob: 6d1acbb74bd7fe1768abd07a09288fd8c2226110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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/