From 8eea7fc1b54feb890c5cb87d60634b6f00cba846 Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 31 Jul 2024 11:49:37 +0930 Subject: [PATCH] Add page numbers to top of page, use mktemp(1) for temp files --- 2minNoods.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/2minNoods.sh b/2minNoods.sh index d53c147..e666dc9 100755 --- a/2minNoods.sh +++ b/2minNoods.sh @@ -7,7 +7,7 @@ noodspp=40 mkdir -p "$siteroot/img/thumbs" pageno=1 noodcount=1 - +photolist="$(mktemp --suffix='.txt')" # html and css stolen from https://perfectmotherfuckingwebsite.com/ pageheader=''' @@ -57,13 +57,14 @@ a.button{

2minNoods

-
''' +
+''' rm -v "$siteroot"/index.*.html echo '' > "$siteroot/index.html" -ls *.jpg | sort -k2 -t'_' -r > "$siteroot/photolist.txt" +ls *.jpg | sort -k2 -t'_' -r > "$photolist" while read i; do if [ -f "$i" ]; then @@ -82,26 +83,30 @@ while read i; do noodcount=1 fi fi -done < "$siteroot/photolist.txt" +done < "$photolist" for ((page=1;page<=pageno;page++)); do - echo -n '
') + echo "$htmlpagenumbers" >> "$siteroot/index.$page.html" + sed -i "s%%$htmlpagenumbers%" "$siteroot/index.$page.html" + echo '' >> "$siteroot/index.$page.html" done echo "Searching for deleted images" for i in $siteroot/img/*.jpg; do pic="$(basename $i)" - if ! grep -Fxq "$pic" "$siteroot/photolist.txt"; then + if ! grep -Fxq "$pic" "$photolist"; then rm -v "$siteroot/img/thumbs/$pic" "$siteroot/img/$pic" fi done -rm -v "$siteroot/photolist.txt" +rm -v "$photolist"