From 9d9672a320a28f40d9f87e5cdd4ca353ef33c86f Mon Sep 17 00:00:00 2001 From: shockrah Date: Tue, 14 Jul 2020 16:39:30 -0700 Subject: [PATCH] Upload functions are now just wrappers around a more fundamental function Features - - full html reupload => -h - folder html reupload => f [FOLDER] - root html reupload => r --- upload.sh | 59 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/upload.sh b/upload.sh index e2db8c4..c1fe9ea 100644 --- a/upload.sh +++ b/upload.sh @@ -6,26 +6,57 @@ url="https://neocities.org" auth="Authorization: Bearer $KEY" site=.mirror -html() { - # Total reupload of the site's html - pushd $site > /dev/null - echo `pwd` - for f in $(find -name '*.html');do +_upload_html() { + if [ ${1:0:1} = "" ];then + echo Path must start with ./ + exit 1 + fi + for f in $@;do remote_path=${f:1} curl -H "$auth" -F "$remote_path=@$f" $url/api/upload done - popd > /dev/null +} + +html() { + # Total reupload of the site's html + _upload_html $(find -name '*.html') +} + +roots() { + _upload_html ./*.html +} + +folder() { + if [ -z $1];then + echo No folder specified > /dev/stderr + else + pushd $1 > /dev/null + _upload_html ./*.html + popd > /dev/null + fi +} + +_help() { +cat < Reuploads all the html content + r => Uploads all root html pages + f [FOLDER] => Upload all html in [FOLDER] +EOF } if [ -z $1 ];then -cat < /dev/null + while getopts ':Hhrf:' opt;do + case $opt in + H) _help;; + h) _upload_html $(find -name '*.html');; # Upload all html content + r) _upload_html ./*.html;; # Upload all root html pages + f) _upload_html $1/*.html;;# Upload html in the spec'd folder + esac + done + popd > /dev/null fi