cleaned up make script a ton

This commit is contained in:
shockrah 2019-09-10 19:36:09 -07:00
parent ffe219765f
commit 9a7de5e192

26
make.sh
View File

@ -4,24 +4,21 @@ targetDir='post/'
source .creds source .creds
url="https://$user:$pass@neocities.org/api/upload" url="https://$user:$pass@neocities.org/api/upload"
# auto tools should be able to fix this
post() { post() {
tmp=".swap" tmp=".swap"
full=".fullswap" full=".fullswap"
base=$(basename $1) base=`basename $1`
# First build the content of the site # First build the content of the site
pandoc $1 | sed '3i </div>' >> $tmp pandoc $1 > $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 # Title, images and tables get added/fixed here
sed -i "5i <title>${base%.*}</title>" $full sed "s/{TITLE}/<title>${base%.*}<\/title>/g" ./templates/post-header.html > $full
sed -i "s/<img/<img class=\"pure-img\"/g" $full cat $tmp ./templates/post-footer.html >> $full
sed -i 's/<table>/<table class="pure-table">/g' $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" mv $full "$rootDir/$targetDir/${base%.*}.html"
rm -f $full rm -f $tmp
} }
upload() { upload() {
@ -39,6 +36,11 @@ _help() {
} }
mkdir -p "$rootDir/post" mkdir -p "$rootDir/post"
if [ -z $1 ]
then
exit 0
fi
while getopts ":srhup:" opt;do while getopts ":srhup:" opt;do
case "$opt" in case "$opt" in
s) s)
@ -61,7 +63,7 @@ while getopts ":srhup:" opt;do
done done
;; ;;
u) u)
upload;; upload;; # this needs a proper fix according to api
h) h)
_help;; _help;;
esac esac