69 lines
2.4 KiB
Bash
Executable file
69 lines
2.4 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
|
|
}
|
|
|
|
dostats() {
|
|
[ -d $OUTPATH ]
|
|
echo -e "Used space:"
|
|
echo -e " ├── content: $(du -hs content | cut -f1)"
|
|
echo -e " ├── output: $(du -hs $OUTPATH | cut -f1)"
|
|
echo -e " └── all: $(du -hs . | cut -f1)"
|
|
echo
|
|
echo -e "File types:"
|
|
echo -e " ├── total: $(find $OUTPATH -type f | wc -l)"
|
|
echo -e " ├── total known: $(find $OUTPATH -type f | grep -iE '\.(jpg|png|webp|gif|ico|css|php|html)' | wc -l)"
|
|
echo -e " ├── HTML: $(find $OUTPATH -type f -iname '*.html' | wc -l)"
|
|
echo -e " ├── CSS: $(find $OUTPATH -type f -iname '*.css' | wc -l)"
|
|
echo -e " ├── PHP: $(find $OUTPATH -type f -iname '*.php' | wc -l)"
|
|
echo -e " ├── images: $(find $OUTPATH -type f | grep -iE '\.(jpg|png|webp|gif|ico)' | wc -l)"
|
|
echo -e " └── other:"
|
|
find $OUTPATH -type f | rev | cut -d. -f1 | rev | sort | uniq -c | grep -viE 'html|css|php|jpg|png|webp|gif|ico' | awk '{ print " ├── " $2 ": " $1 }'
|
|
echo -e " └── total: $(find $OUTPATH -type f | rev | cut -d. -f1 | rev | sort | grep -viE 'html|php|jpg|png|webp|gif|css|ico' | wc -l)"
|
|
}
|
|
|
|
while getopts "bcsS" flag; do
|
|
case ${flag} in
|
|
b) dobuild=y;;
|
|
c) doclean=y;;
|
|
s) dosync=y;;
|
|
S) dostats=y;;
|
|
esac
|
|
done
|
|
|
|
[ -v doclean ] && rm -rfv output ||:
|
|
[ -v dobuild ] && runbuild
|
|
[ -v dosync ] && runsync ||:
|
|
[ -v dostats ] && dostats ||:
|