55 lines
1.1 KiB
Bash
Executable File
55 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
rootDir='./tmp/'
|
|
targetDir='post/'
|
|
|
|
post() {
|
|
tmp=".swap"
|
|
full=".fullswap"
|
|
base=$(basename $1)
|
|
# 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
|
|
rm -f $tmp
|
|
# 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
|
|
}
|
|
|
|
[[ -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'
|
|
post './prebuild/index.md'
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
for file in $@;do
|
|
post $file
|
|
done
|
|
|
|
if [ -z $@ ]
|
|
then
|
|
while read line
|
|
do
|
|
post $line
|
|
done < "${1:-/dev/stdin}"
|
|
fi
|