summaryrefslogtreecommitdiffstats
path: root/HTML/Final/sneed/purchase/mkpages.sh
diff options
context:
space:
mode:
authormsglm <msglm@techchud.xyz>2023-01-14 05:31:48 -0600
committermsglm <msglm@techchud.xyz>2023-01-14 05:31:48 -0600
commit9d53d8857eaa1c9405894a88ca75bc4657e42f35 (patch)
treeeb1efc1d028b949dd83bb710c68be8eff58f26e7 /HTML/Final/sneed/purchase/mkpages.sh
downloadschool-code-master.tar.gz
school-code-master.tar.bz2
school-code-master.zip
Inital CommitHEADmaster
Diffstat (limited to 'HTML/Final/sneed/purchase/mkpages.sh')
-rwxr-xr-xHTML/Final/sneed/purchase/mkpages.sh52
1 files changed, 52 insertions, 0 deletions
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="<span class=ai title='This text is generated by a bot to cut down on development time! Any mistakes or insanity in the text should be taken with that fact in mind. See the About section for more information.'>$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 "/<!--Items-->/a <a href=\"purchase/$pageName\">\n <figure>\n <img alt=\"an image of $name\" src=\"assets/$imageLocation/$imageName\">\n <figcaption>$name<\/figcaption>\n <\/figure>\n <\/a>\n " ../store.html
+ sed -i -e "/<!--Items-->/a <option value=\"$name\"><\/option>\n " ../purchase-form.html
+
+done < "entries.json"