openbsd-webzine/issues/tools/make_issue.sh

50 lines
808 B
Bash
Raw Normal View History

2021-09-26 19:27:49 +00:00
#!/bin/sh
usage() {
echo "./$0 directory"
exit 1
}
die() {
echo "$1"
exit 1
}
testsite=0
if [ "$1" = "-t" ]
then
testsite=1
shift
fi
2021-09-26 19:27:49 +00:00
DIR=$(basename $1)
DESTFILENAME=$2
2021-09-26 19:27:49 +00:00
CURINODE=$(stat -f "%i" current/)
test -d "$DIR" || usage
test -d ../public/ || die "You must run this from openbsd-webzine/current"
ls $DIR/*.html 2>&1 >/dev/null || die "no html file in $DIR"
2021-09-29 16:44:26 +00:00
. ./${DIR}/metadata.sh
2021-09-26 19:27:49 +00:00
if [ "$(stat -f '%i' $DIR)" -eq "$CURINODE" ]
then
DEST=dev
else
DEST=public
fi
if test -z "$DESTFILENAME"
then
DESTFILENAME="../${DEST}/${DIR}.html"
fi
cat _common/header $DIR/*html _common/footer > $DESTFILENAME
2021-09-26 21:53:43 +00:00
# replace with issue number
2021-09-27 10:10:42 +00:00
issue="${1#issue-}"
sed -i "s/__ISSUE__/${issue}/g" $DESTFILENAME
2021-09-26 21:53:43 +00:00
# replace date
2021-09-29 16:44:26 +00:00
sed -i "s/__DATE__/${PUBLISHED_DATE}/" $DESTFILENAME