2019-08-18 07:03:51 +00:00
|
|
|
#!/bin/bash
|
|
|
|
rootDir='./site/'
|
|
|
|
targetDir='post/'
|
2019-08-18 08:54:44 +00:00
|
|
|
source .creds
|
|
|
|
url="https://$user:$pass@neocities.org/api/upload"
|
2019-08-18 07:03:51 +00:00
|
|
|
|
2019-09-11 02:36:09 +00:00
|
|
|
# auto tools should be able to fix this
|
2019-08-18 07:03:51 +00:00
|
|
|
post() {
|
|
|
|
tmp=".swap"
|
|
|
|
full=".fullswap"
|
2019-09-11 02:36:09 +00:00
|
|
|
base=`basename $1`
|
2019-08-18 07:03:51 +00:00
|
|
|
# First build the content of the site
|
2019-09-11 02:36:09 +00:00
|
|
|
pandoc $1 > $tmp
|
2019-08-18 07:03:51 +00:00
|
|
|
# Title, images and tables get added/fixed here
|
2019-09-11 02:36:09 +00:00
|
|
|
sed "s/{TITLE}/<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
|
2019-08-18 07:03:51 +00:00
|
|
|
|
2019-09-11 02:36:09 +00:00
|
|
|
# Move things to proper directory and cleanup
|
2019-08-18 07:03:51 +00:00
|
|
|
mv $full "$rootDir/$targetDir/${base%.*}.html"
|
2019-09-11 02:36:09 +00:00
|
|
|
rm -f $tmp
|
2019-08-18 07:03:51 +00:00
|
|
|
}
|
|
|
|
|
2019-08-18 08:54:44 +00:00
|
|
|
upload() {
|
|
|
|
cd $rootDir
|
|
|
|
name=''
|
|
|
|
# first the root pages
|
|
|
|
find -type f | xargs 'name=basename %';curl -f "$name=@%" $url
|
|
|
|
}
|
|
|
|
|
2019-08-18 07:03:51 +00:00
|
|
|
_help() {
|
|
|
|
echo 'Options:
|
|
|
|
-p [postDirectory/*]
|
|
|
|
-r (build root pages)
|
|
|
|
-s (copy stylesheets)'
|
|
|
|
}
|
|
|
|
mkdir -p "$rootDir/post"
|
|
|
|
|
2019-09-11 02:36:09 +00:00
|
|
|
if [ -z $1 ]
|
|
|
|
then
|
2019-09-11 04:32:20 +00:00
|
|
|
_help
|
2019-09-11 02:36:09 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-08-18 08:54:44 +00:00
|
|
|
while getopts ":srhup:" opt;do
|
2019-08-18 07:03:51 +00:00
|
|
|
case "$opt" in
|
|
|
|
s)
|
|
|
|
cp style.css "$rootDir" # root stylesheet
|
|
|
|
cp style.css "$rootDir/$targetDir" # post stylesheet
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
r)
|
|
|
|
# Fix targetDir so that it points to the root of the site output
|
|
|
|
targetDir=''
|
|
|
|
post './prebuild/about.md'
|
|
|
|
post './prebuild/links.md'
|
|
|
|
post './prebuild/index.md'
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
p)
|
|
|
|
for file in ${@:2};do
|
|
|
|
#echo $file
|
|
|
|
post $file
|
|
|
|
done
|
|
|
|
;;
|
2019-08-18 08:54:44 +00:00
|
|
|
u)
|
2019-09-11 02:36:09 +00:00
|
|
|
upload;; # this needs a proper fix according to api
|
2019-08-18 07:03:51 +00:00
|
|
|
h)
|
|
|
|
_help;;
|
|
|
|
esac
|
|
|
|
done
|