#!/usr/bin/env bash
# requires pandoc
# coreutils
# uuidgen
# tidy
# the_silver_searcher (could use grep instead)
set -o errexit
set -o nounset
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
SITENAME="wiki"
SITEURL="https://elioat.tilde.institute/wiki"
SITESTYLES="$SITEURL"/styles.css
SITEDESCRIPTION="a little wiki"
if [[ -f updated ]]; then
LASTUPDATE=$(
'$(fold -sw 80 <"$file")'
]]>
'
echo -e "$rss_entry" >> ../public/feed.xml
fi
done
cd ..
echo -e "$RSSEND" >> public/feed.xml
# this is stupid and superfluous, but I was bugged by the weirdly formatted RSS output
tidy \
-xml \
--show-body-only yes \
--indent auto \
--indent-spaces 2 \
--quiet yes \
-w 80 \
-m \
--force-output y \
--wrap 0 \
public/feed.xml
if [ $i -gt 0 ];
then
build_logs "$@"
fi
echo "$TIMESTAMP" > updated
echo "updated" $i "items."
}
help_text() {
echo '
mynah, a little wiki bird
usage: ./mynah
-b(uild)....to build the site
-s(earch)...to search for a pattern across all wiki entries
-d(eploy)...to publish the public directory to a host
-h(elp).....to display this message
-n(est).....to start a new wiki
'
}
if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
help_text "$@"
exit
elif [[ "${1-}" =~ ^-*b(uild)?$ ]]; then
build "$@"
exit
elif [[ "${1-}" =~ ^-*s(earch)?$ ]]; then
ag "$2" content/*
exit
elif [[ "${1-}" =~ ^-*d(eploy)?$ ]]; then
scp -r public/* elioat@tilde.institute:~/public_html/wiki/
scp styles.css elioat@tilde.institute:~/public_html/wiki/
scp -r bin/* elioat@tilde.institute:~/public_html/wiki/bin/
exit
elif [[ "${1-}" =~ ^-*n(est)?$ ]]; then
if [[ -f content ]]; then
echo -e "
a content directory already exists
so you can't build a new nest here
"
else
mkdir content public
touch archive.md changelog.md updated public/feed.xml
fi
exit
fi
cd "$(dirname "$0")"
main() {
help_text "$@"
}
main "$@"