From 9a7de5e19227bdbf6acfd1f21d93baa51316826a Mon Sep 17 00:00:00 2001 From: shockrah Date: Tue, 10 Sep 2019 19:36:09 -0700 Subject: [PATCH] cleaned up make script a ton --- make.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/make.sh b/make.sh index fb509a3..62dc9a9 100755 --- a/make.sh +++ b/make.sh @@ -4,24 +4,21 @@ targetDir='post/' source .creds url="https://$user:$pass@neocities.org/api/upload" +# auto tools should be able to fix this post() { tmp=".swap" full=".fullswap" - base=$(basename $1) + base=`basename $1` # First build the content of the site - pandoc $1 | sed '3i ' >> $tmp - sed -i '1i
' $tmp - # next we glue together the header and footer - cat ./templates/post-header.html $tmp ./templates/post-footer.html > $full - rm -f $tmp + pandoc $1 > $tmp # Title, images and tables get added/fixed here - sed -i "5i ${base%.*}" $full - sed -i "s///g' $full + sed "s/{TITLE}/${base%.*}<\/title>/g" ./templates/post-header.html > $full + cat $tmp ./templates/post-footer.html >> $full + sed -i 's/<img/<img class="pure-img"/g;s/<table>/<table class="pure-table">/g' $full - # finally move this post to its proper location in the _rootDir + # Move things to proper directory and cleanup mv $full "$rootDir/$targetDir/${base%.*}.html" - rm -f $full + rm -f $tmp } upload() { @@ -39,6 +36,11 @@ _help() { } mkdir -p "$rootDir/post" +if [ -z $1 ] +then + exit 0 +fi + while getopts ":srhup:" opt;do case "$opt" in s) @@ -61,7 +63,7 @@ while getopts ":srhup:" opt;do done ;; u) - upload;; + upload;; # this needs a proper fix according to api h) _help;; esac