2019-04-25 04:43:28 +00:00
|
|
|
#!/bin/bash
|
2018-11-25 23:37:40 +00:00
|
|
|
# compiles new post into target directory
|
2019-04-25 21:45:19 +00:00
|
|
|
rootDir='./tmp/'
|
2019-03-13 21:53:50 +00:00
|
|
|
|
2019-04-25 04:43:28 +00:00
|
|
|
mdRoot='./prebild/'
|
|
|
|
mPostDir='./prebuild/post/'
|
2019-03-13 21:53:50 +00:00
|
|
|
|
2019-04-24 22:31:49 +00:00
|
|
|
# Right now:
|
|
|
|
# no images
|
|
|
|
# root pages
|
|
|
|
# post pages
|
2019-03-13 22:00:37 +00:00
|
|
|
|
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)
|
|
|
|
cat 'templates/post-header.html' > $tmp
|
|
|
|
pandoc $1 >> $tmp
|
|
|
|
cat 'templates/post-footer.html' >> $tmp
|
|
|
|
sed -i "3i <title>${base%.*}</title>" $tmp
|
|
|
|
# finally move this post to its proper location in the _rootDir
|
|
|
|
mv $tmp "$rootDir/post/${base%.*}.html"
|
2018-06-22 20:19:27 +00:00
|
|
|
}
|
2018-06-18 09:16:33 +00:00
|
|
|
|
2019-04-25 04:43:28 +00:00
|
|
|
# Options:
|
|
|
|
# -f post-file
|
|
|
|
# -s stylesheet
|
|
|
|
#[[ -z $# ]] && echo "./make.sh -h" && echo 'for more info' && exit 0
|
|
|
|
|
|
|
|
target=""
|
|
|
|
stylesheet=""
|
2019-04-25 21:45:19 +00:00
|
|
|
while getopts "f:h" opt; do
|
2019-04-25 04:43:28 +00:00
|
|
|
case $opt in
|
|
|
|
h)
|
|
|
|
echo '-h shows this prompt'
|
|
|
|
;;
|
|
|
|
f)
|
|
|
|
target=$2
|
|
|
|
echo "Target post $2"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# attempt to build the new post
|
|
|
|
[[ -z $target ]] && echo 'No target' && exit 0
|
2019-04-25 21:45:19 +00:00
|
|
|
post $target
|