From 17cdd8ef364502897fcd5e6418ec36ab2f5e4dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haoran=20S=2E=20Diao=20=28=E5=88=81=E6=B5=A9=E7=84=B6=29?= <0@hairydiode.xyz> Date: Sat, 6 Sep 2025 16:27:26 -0700 Subject: Added generator script, don't judge me this thing is almost a decade old and I was a literal child when I wrote it --- gen.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 gen.sh (limited to 'gen.sh') diff --git a/gen.sh b/gen.sh new file mode 100755 index 0000000..99b0639 --- /dev/null +++ b/gen.sh @@ -0,0 +1,43 @@ +pages=$(ls -S -t cont/| grep html | grep -v index.html) #lists the actual content +#-S -t so that the files are roughly in time order +#index is excluded and appended at the end to make sure it gets processed last +pages="$pages index.html" +#clears the index +rm index +for page in $pages; do + #clears page and page.tmp + rm $page $page.tmp + #adds the header + cat src/header.html >> $page.tmp + + #finds the [SETTITLE], but ignores \[SETTITLE], then filters out the [SETTITLE] part + #the head is to make it use the last one + title=$(cat cont/$page | grep '\[SETTITLE\]'| sed '/\\\[SETTITLE\]/d; s/\[SETTITLE\]//' | tail -n 1) + #does the same for the date + date=$(cat cont/$page | grep '\[SETDATE\]'| sed '/\\\[SETDATE\]/d; s/\[SETDATE\]//' | tail -n 1) + + + #replaces \[SETTITLE] with [SETTITLE], and removes lines with legitimate [SETTITLE]s in a temporary file + cat cont/$page | sed '/\\\[SETTITLE\]/bx; /\[SETTITLE\].*/d;:x s/\\\[SETTITLE\]/\[SETTITLE\]/' >> $page.tmp + #same for the date + cat $page.tmp | sed '/\\\[SETDATE\]/bx; /\[SETDATE\].*/d;:x s/\\\[SETDATE\]/\[SETDATE\]/' >> $page + + #adds the index if its the homepage + if [ "$page" == "index.html" ]; then + cat index >> $page + rm index + fi + #adds the footer + cat src/footer.html >> $page + + #replaces \[TITLE] with [TITLE] and [TITLE] with $title, "" is used so the $ still applies + + #however that means "\\\\" becomes "\\" when passed to sed from bash, and finally interpreted as a literal \ by sed + cat $page | sed "/\\\\\[TITLE\]/bx; s/\[TITLE\]/$title/; :x s/\\\\\[TITLE\]/\[TITLE\]/" > $page.tmp + #same with date + cat $page.tmp | sed "/\\\\\[DATE\]/bx; s/\[DATE\]/$date/; :x s/\\\\\[DATE\]/\[DATE\]/" > $page + + rm $page.tmp + #adds to the index + echo "[$title] $date" >> index +done -- cgit v1.1