paritybit.ca

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit db89308df43c1d289683050c768f7d16e961d006
parent 9ce1c15ed9b12ebeaf0d071eca9532c2a788261b
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Tue, 31 Dec 2019 22:33:48 -0500

Add ability to specify web-utility project or normal project

Diffstat:
Mpublish | 63+++++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 39 insertions(+), 24 deletions(-)

diff --git a/publish b/publish @@ -22,21 +22,6 @@ # $1 = flag which determines which action to take # $2 = file to act upon -if [ ! -f "$2" ]; then - echo "File $2 not found." - exit 2 -fi - -if [ ! -x "$(command -v rsync)" ]; then - echo "rsync is needed but was not found." - exit 3 -fi - -if [ ! -x "$(command -v ed)" ]; then - echo "ed is needed but was not found." - exit 3 -fi - mainFeed="public/feeds/sitewide-feed.xml" descriptionFile="/tmp/publish-description.txt" destination="paritybit.ca:uploads/" @@ -85,22 +70,52 @@ EOF exit 1 fi +if [ "$2" = "" ]; then + echo "Missing second argument." + exit 2 +fi + +if [ ! -f "$2" ]; then + echo "File $2 not found." + exit 2 +fi + +if [ ! -x "$(command -v rsync)" ]; then + echo "rsync is needed but was not found." + exit 3 +fi + +if [ ! -x "$(command -v ed)" ]; then + echo "ed is needed but was not found." + exit 3 +fi + # Make sure that there is an up-to-date compiled version of the page ./compile "$2" # Update the relevant category page if [ $publishBlog ]; then sed -i "/<ul>/a \ \ \ \ \<li\>$miniDate \<a href=\"$basePage\/$filename\"\>$pageTitle\<\/a\>\<\/li\>" pages/$basePage.md - elif [ $publishProject ]; then - # The meta text of the .md becomes the description on the projects.html page - metaText=$(sed '3!d' pages/"$basePage"/"$filename".md | cut -d# -f 2) - # Remove leading whitespace, surrounding quotes, forward slash characters - metaTextClean=$(echo -e "${metaText}" | sed -e 's/^[[:space:]]*//') - metaTextClean=$(sed -e 's/\//\\\//g' <<< "$metaTextClean") - metaTextClean=$(sed -e 's/^"//' -e 's/"$//' <<< "$metaTextClean") - sed -i "/<ul>/a \ \ \ \ \<li\>\<a href=\"$basePage\/$filename\"\>$pageTitle\<\/a\>: $metaTextClean\<\/li\>" pages/$basePage.md - + while true; do + read -p "Is this a web-utility? " yn + case $yn in + [Yy]* ) webUtil=1; break;; + [Nn]* ) webUtil=0; break;; + * ) echo "Please answer Y|y or N|n.";; + esac + done + if [ "$webUtil" = "1" ]; then + sed -i "/web-utils/a \ \ \ \ \<li\>\<a href=\"$basePage\/$filename\"\>$pageTitle\<\/a\>\<\/li\>" pages/$basePage.md + else + # The meta text of the .md becomes the description on the projects.html page + metaText=$(sed '3!d' pages/"$basePage"/"$filename".md | cut -d# -f 2) + # Remove leading whitespace, surrounding quotes, forward slash characters + metaTextClean=$(echo -e "${metaText}" | sed -e 's/^[[:space:]]*//') + metaTextClean=$(sed -e 's/\//\\\//g' <<< "$metaTextClean") + metaTextClean=$(sed -e 's/^"//' -e 's/"$//' <<< "$metaTextClean") + sed -i "/normal-projects/a \ \ \ \ \<li\>\<a href=\"$basePage\/$filename\"\>$pageTitle\<\/a\>: $metaTextClean\<\/li\>" pages/$basePage.md + fi else sed -i "/<ul>/a \ \ \ \ \<li\>\<a href=\"$basePage\/$filename\"\>$pageTitle\<\/a\>\<\/li\>" pages/$basePage.md fi