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
|
|
|
|
2019-04-26 22:18:05 +00:00
|
|
|
[[ -z $rootDir/post/ ]] && mkdir -p $rootDir/post
|
|
|
|
|
2018-06-22 20:19:27 +00:00
|
|
|
post() {
|
2019-04-25 04:43:28 +00:00
|
|
|
# First get the body of the document
|
2019-04-25 21:45:19 +00:00
|
|
|
tmp=".swap"
|
|
|
|
base=$(basename $1)
|
2019-04-26 22:18:05 +00:00
|
|
|
# cat the files together
|
|
|
|
pandoc $1 | cat 'templates/post-header.html' - 'templates/post-footer.html' >> $tmp
|
|
|
|
sed -i "5i <title>${base%.*}</title>" $tmp
|
|
|
|
sed -i "s/<img/<img class=\"pure-img\"/g" $tmp
|
|
|
|
sed -i 's/<table>/<table class="pure-table">/g' $tmp
|
2019-04-30 20:36:36 +00:00
|
|
|
# turn the header into an actual header
|
|
|
|
sed -i '30i <div class="header">' $tmp
|
|
|
|
sed -i '32i </div>' $tmp # change this to 33 once we finalized for the subheading
|
2019-04-25 21:45:19 +00:00
|
|
|
# finally move this post to its proper location in the _rootDir
|
2019-04-26 22:33:30 +00:00
|
|
|
mv $tmp "$rootDir/$targetDir/${base%.*}.html"
|
2019-04-25 21:53:21 +00:00
|
|
|
rm -f $tmp
|
2018-06-22 20:19:27 +00:00
|
|
|
}
|
2018-06-18 09:16:33 +00:00
|
|
|
|
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
|