#!/bin/bash # Dependencies: mktemp, sed, imagemagick, basename, grep, sort # Config variables siteroot="../2minNoods_siteroot" noodspp=40 # Don't touch these pageno=1 noodcount=1 photolist="$(mktemp --suffix='.txt')" mkdir -p "$siteroot/img/thumbs" # html and css stolen from: https://perfectmotherfuckingwebsite.com/ # a.button stolen from: https://stackoverflow.com/a/2906586 pageheader=''' 2minNoods

2minNoods


''' rm -v "$siteroot"/index.*.html echo '' > "$siteroot/index.html" ls *.jpg | sort -k2 -t'_' -r > "$photolist" while read i; do if [ -f "$i" ]; then if [ ! -f "$siteroot/img/$i" ]; then echo "Resizing $i" convert "$i" -quality 70 -strip -auto-orient -resize "960^>" "$siteroot/img/thumbs/$i" convert "$i" -quality 90 -strip -auto-orient -resize "2160^>" "$siteroot/img/$i" fi if [[ $noodcount -eq 1 ]]; then echo "$pageheader" > "$siteroot/index.$pageno.html" fi echo '

'"$(basename $i .jpg)"'


' >> "$siteroot/index.$pageno.html" ((noodcount++)) if [[ $noodcount -gt $noodspp ]]; then ((pageno++)) noodcount=1 fi fi done < "$photolist" for ((page=1;page<=pageno;page++)); do htmlpagenumbers=$( 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" "$photolist"; then rm -v "$siteroot/img/thumbs/$pic" "$siteroot/img/$pic" fi done rm -v "$photolist"