From 9d53d8857eaa1c9405894a88ca75bc4657e42f35 Mon Sep 17 00:00:00 2001 From: msglm Date: Sat, 14 Jan 2023 05:31:48 -0600 Subject: Inital Commit --- HTML/Final/sneed/purchase/mkpages.sh | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 HTML/Final/sneed/purchase/mkpages.sh (limited to 'HTML/Final/sneed/purchase/mkpages.sh') diff --git a/HTML/Final/sneed/purchase/mkpages.sh b/HTML/Final/sneed/purchase/mkpages.sh new file mode 100755 index 0000000..63e56a7 --- /dev/null +++ b/HTML/Final/sneed/purchase/mkpages.sh @@ -0,0 +1,52 @@ +#!/bin/bash +cp ../store.html.orig ../store.html +cp ../purchase-form.html.orig ../purchase-form.html +while IFS= read -r line +do + name=$(echo "$line"|jq .name|tr -d '"') + AI=$(echo "$line"|jq .ai|tr -d '"') + imageLocation=$(echo "$line"|jq .location|tr -d '"') + imageName=$(echo "$line"|jq .image|tr -d '"') + #imageName=$(echo "$name"|tr ' ' '-'|sed -e 's/$/.webp/g') + pageName=$(echo "$name"|tr ' ' '-'|tr -d "'"|sed -e 's/$/.html/g') + price=$(echo "$line"|jq .price|tr -d '"') + desc=$(echo "$line"|jq .desc|tr -d '"') + if [ "$AI" = "true" ] + #if [ "false" = "true" ] + then + aitext=$(./textgen.py 200 "$desc") + + while [[ pass -eq 0 ]] + do + aitext=$(./textgen.py 200 "$desc") + if [[ "$aitext" == *"/"* ]] + then + echo "detected a slash" + pass=0 + elif [[ "$aitext" == "" ]] + then + echo "text was empty" + pass=0 + elif [[ "$aitext" = *"http"* ]] + then + echo "detected an http url" + pass=0 + else + pass=1 + fi + done + + desc="$aitext<\/span>" + echo "$desc" + fi + cp -v "template.html" "$pageName" + sed -i -e "s/;IMG;/..\/assets\/$imageLocation\/$imageName/g" "$pageName" + sed -i -e "s/;TITLE;/$name/g" "$pageName" + sed -i -e "s/;PRICE;/$price/g" "$pageName" + #sed -i -e "s/;DESC;/$desc/g" "$pageName" + perl -pe "s/;DESC;/$desc/" -i "$pageName" || sed -i -e "s/;DESC;/$desc/g" "$pageName" || sed -i -e "s/;DESC;/$name/g" "$pageName" + + sed -i -e "//a \n
\n \"an\n
$name<\/figcaption>\n <\/figure>\n <\/a>\n " ../store.html + sed -i -e "//a