2019-08-18 07:03:51 +00:00
|
|
|
#!/bin/bash
|
2019-09-14 05:01:51 +00:00
|
|
|
rootDir='./site/'
|
2019-08-18 07:03:51 +00:00
|
|
|
targetDir='post/'
|
|
|
|
|
|
|
|
post() {
|
2019-09-14 04:58:46 +00:00
|
|
|
echo Building: $1
|
2019-08-18 07:03:51 +00:00
|
|
|
tmp=".swap"
|
|
|
|
full=".fullswap"
|
2019-09-11 02:36:09 +00:00
|
|
|
base=`basename $1`
|
2019-08-18 07:03:51 +00:00
|
|
|
# First build the content of the site
|
2019-09-11 02:36:09 +00:00
|
|
|
pandoc $1 > $tmp
|
2019-08-18 07:03:51 +00:00
|
|
|
# Title, images and tables get added/fixed here
|
2019-09-11 02:36:09 +00:00
|
|
|
sed "s/{TITLE}/<title>${base%.*}<\/title>/g" ./templates/post-header.html > $full
|
|
|
|
cat $tmp ./templates/post-footer.html >> $full
|
|
|
|
sed -i 's/<img/<img class="pure-img"/g;s/<table>/<table class="pure-table">/g' $full
|
2019-08-18 07:03:51 +00:00
|
|
|
|
2019-09-11 02:36:09 +00:00
|
|
|
# Move things to proper directory and cleanup
|
2019-08-18 07:03:51 +00:00
|
|
|
mv $full "$rootDir/$targetDir/${base%.*}.html"
|
2019-09-11 02:36:09 +00:00
|
|
|
rm -f $tmp
|
2019-08-18 07:03:51 +00:00
|
|
|
}
|
|
|
|
|
2019-09-14 04:58:46 +00:00
|
|
|
build_all() {
|
2019-09-14 05:39:12 +00:00
|
|
|
mkdir -p $rootDir/post/ $rootDir/fonts/ $rootDir/img/
|
2019-09-14 04:58:46 +00:00
|
|
|
|
|
|
|
cp style.css "$rootDir"
|
2019-09-14 05:30:28 +00:00
|
|
|
cp prebuild/post/style.css "$rootDir/post/"
|
2019-09-14 04:58:46 +00:00
|
|
|
|
|
|
|
cp fonts/* $rootDir/fonts/
|
|
|
|
|
2019-09-14 05:39:12 +00:00
|
|
|
cp img/ $rootDir/img/ -r
|
|
|
|
mv $rootDir/img/favicon.png $rootDir/
|
|
|
|
|
2019-09-14 04:58:46 +00:00
|
|
|
# Try to get xargs to deal with this ugliness
|
|
|
|
for r in prebuild/*md;do
|
|
|
|
post $r
|
|
|
|
done
|
|
|
|
for p in prebuild/post/*md;do
|
|
|
|
post $p
|
|
|
|
done
|
2019-08-18 08:54:44 +00:00
|
|
|
}
|
|
|
|
|
2019-08-18 07:03:51 +00:00
|
|
|
_help() {
|
|
|
|
echo 'Options:
|
2019-09-14 03:16:48 +00:00
|
|
|
-h show this prompt
|
|
|
|
-p [postDirectory/*] (takes a list of paths to build from)
|
|
|
|
-r build root pages
|
|
|
|
-s copy stylesheets
|
|
|
|
-l run live server'
|
2019-08-18 07:03:51 +00:00
|
|
|
}
|
2019-09-14 03:16:48 +00:00
|
|
|
server() {
|
|
|
|
cd $rootDir
|
|
|
|
echo 'Address: 0.0.0.0:8080'
|
|
|
|
python -m SimpleHTTPServer 8080
|
|
|
|
}
|
|
|
|
|
2019-09-11 02:36:09 +00:00
|
|
|
if [ -z $1 ]
|
|
|
|
then
|
2019-09-11 04:32:20 +00:00
|
|
|
_help
|
2019-09-11 02:36:09 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-09-14 05:01:51 +00:00
|
|
|
while getopts ":aslrhp:" opt;do
|
2019-08-18 07:03:51 +00:00
|
|
|
case "$opt" in
|
2019-09-14 04:58:46 +00:00
|
|
|
a)
|
|
|
|
build_all;;
|
2019-08-18 07:03:51 +00:00
|
|
|
s)
|
2019-09-14 05:30:28 +00:00
|
|
|
cp style.css "$rootDir"
|
|
|
|
cp prebuild/post/style.css "$rootDir/$targetDir"
|
2019-08-18 07:03:51 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
r)
|
|
|
|
# Fix targetDir so that it points to the root of the site output
|
|
|
|
targetDir=''
|
|
|
|
post './prebuild/about.md'
|
|
|
|
post './prebuild/links.md'
|
|
|
|
post './prebuild/index.md'
|
2020-01-26 04:37:23 +00:00
|
|
|
post './prebuild/stream.md'
|
2019-08-18 07:03:51 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
p)
|
|
|
|
for file in ${@:2};do
|
|
|
|
post $file
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
h)
|
|
|
|
_help;;
|
2019-09-14 03:16:48 +00:00
|
|
|
l)
|
|
|
|
server;;
|
2019-08-18 07:03:51 +00:00
|
|
|
esac
|
|
|
|
done
|