35 lines
847 B
Bash
Executable File
35 lines
847 B
Bash
Executable File
#!/bin/bash
|
|
rootDir='./tmp/'
|
|
targetDir='post/'
|
|
|
|
[[ -z $rootDir/post/ ]] && mkdir -p $rootDir/post
|
|
|
|
post() {
|
|
# First get the body of the document
|
|
tmp=".swap"
|
|
base=$(basename $1)
|
|
# 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
|
|
# 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
|
|
# finally move this post to its proper location in the _rootDir
|
|
mv $tmp "$rootDir/$targetDir/${base%.*}.html"
|
|
rm -f $tmp
|
|
}
|
|
|
|
for file in $@;do
|
|
post $file
|
|
done
|
|
|
|
if [ -z $@ ]
|
|
then
|
|
while read line
|
|
do
|
|
post $line
|
|
done < "${1:-/dev/stdin}"
|
|
fi
|