doit/doit
2024-07-20 16:18:23 +03:00

48 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
[ -z $1 ] && echo "oopsie, no command!" && false
PANDOCOPTS="--wrap=none --quiet --lua-filter=./treat-unknown-as-metadata.lua --template templates/main.html"
OUTPATH="output"
SERVPATH="CUSTOMIZE THIS"
runbuild() {
echo -e '------------\nbuilding...'
time=$EPOCHREALTIME
mkdir -p output
for thing in $(find content/); do
input=$thing
output=$OUTPATH/${input##content/}
outlink=${input##content/}
outlink=${outlink%%.org}
[ $input -ot $output ] && echo -e "skipping ${input}..." && continue
[ $input -ot $OUTPATH/$outlink.html ] && echo -e "skipping ${input}..." && continue
echo -e "processing ${input}..."
[ -f $thing ] && [[ $thing = *'.org' ]] && pandoc $PANDOCOPTS -V outfn=$outlink $input -o ${output%%.org}.html
[ -f $thing ] && [[ $thing = !(*.org) ]] && cp -u $input $output
[ -d $thing ] && mkdir -p $output
done
for i in $OUTPATH/blog/20*.html; do
touch $i
done
echo "done in $(bc <<< "scale = 2; ($EPOCHREALTIME - $time)/1")s"
}
runsync() {
echo -e '------------\nsyncing...'
echo "customize this"
return
rsync -have ssh $OUTPATH/ $SERVPATH
}
while getopts "bcs" flag; do
case ${flag} in
b) dobuild=y;;
c) doclean=y;;
s) dosync=y;;
esac
done
[ -v doclean ] && rm -rfv output ||:
[ -v dobuild ] && runbuild
[ -v dosync ] && runsync || true