2019-04-25 04:43:28 +00:00
|
|
|
#!/bin/bash
|
2019-04-25 21:45:19 +00:00
|
|
|
rootDir='./tmp/'
|
2019-04-30 20:36:36 +00:00
|
|
|
targetDir='post/'
|
2019-03-13 21:53:50 +00:00
|
|
|
|
2018-06-22 20:19:27 +00:00
|
|
|
post() {
|
2019-04-25 21:45:19 +00:00
|
|
|
tmp=".swap"
|
2019-06-08 07:12:56 +00:00
|
|
|
full=".fullswap"
|
2019-04-25 21:45:19 +00:00
|
|
|
base=$(basename $1)
|
2019-06-08 07:12:56 +00:00
|
|
|
# First build the content of the site
|
|
|
|
pandoc $1 | sed '3i </div>' >> $tmp
|
|
|
|
sed -i '1i <div class="header">' $tmp
|
|
|
|
# next we glue together the header and footer
|
|
|
|
cat ./templates/post-header.html $tmp ./templates/post-footer.html > $full
|
2019-04-25 21:53:21 +00:00
|
|
|
rm -f $tmp
|
2019-06-08 07:12:56 +00:00
|
|
|
# Title, images and tables get added/fixed here
|
|
|
|
sed -i "5i <title>${base%.*}</title>" $full
|
|
|
|
sed -i "s/<img/<img class=\"pure-img\"/g" $full
|
|
|
|
sed -i 's/<table>/<table class="pure-table">/g' $full
|
|
|
|
|
|
|
|
# finally move this post to its proper location in the _rootDir
|
|
|
|
mv $full "$rootDir/$targetDir/${base%.*}.html"
|
|
|
|
rm -f $full
|
2018-06-22 20:19:27 +00:00
|
|
|
}
|
2018-06-18 09:16:33 +00:00
|
|
|
|
2019-05-02 01:41:02 +00:00
|
|
|
[[ -z $rootDir/post/ ]] && mkdir -p $rootDir/post
|
|
|
|
|
|
|
|
# root and style page cases where we don't want to do anything else
|
|
|
|
case $1 in
|
|
|
|
"s")
|
|
|
|
cp style.css $rootDir
|
|
|
|
cp style.css $rootDir/$targetDir
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
"r")
|
|
|
|
echo 'Building the root pages'
|
|
|
|
targetDir=''
|
|
|
|
post './prebuild/about.md'
|
|
|
|
post './prebuild/links.md'
|
2019-05-02 20:15:49 +00:00
|
|
|
post './prebuild/index.md'
|
2019-05-02 01:41:02 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2019-04-25 21:53:21 +00:00
|
|
|
for file in $@;do
|
2019-04-25 22:38:39 +00:00
|
|
|
post $file
|
2019-04-25 04:43:28 +00:00
|
|
|
done
|
2019-04-26 22:18:05 +00:00
|
|
|
|
|
|
|
if [ -z $@ ]
|
|
|
|
then
|
|
|
|
while read line
|
|
|
|
do
|
|
|
|
post $line
|
|
|
|
done < "${1:-/dev/stdin}"
|
|
|
|
fi
|