From 7157fac03485b30b3ad7c2ea0a0cdd4286ba3e6e Mon Sep 17 00:00:00 2001 From: kaa Date: Sun, 29 Sep 2024 12:47:00 -0700 Subject: monthly.sh --- photographed/monthly.sh | 113 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100755 photographed/monthly.sh (limited to 'photographed') diff --git a/photographed/monthly.sh b/photographed/monthly.sh new file mode 100755 index 0000000..c8a849a --- /dev/null +++ b/photographed/monthly.sh @@ -0,0 +1,113 @@ +#!/bin/sh + +site="https://mesacsclub.com/kaa/Photo"; +neocities="https://kaa.neocities.org/Photo"; + +getyear() { + sed -e 's|-.*||' +} +getmonth() { + sed -e 's|^[0-9][0-9][0-9][0-9]-||' -e 's|-.*||' +} +getday() { + sed -e 's|^[0-9][0-9][0-9][0-9]-[0-9][0-9]-||' -e 's|-.*||' +} + +padimg() { + p=$1 + + printf "\t\t\t" + printf "\t\t\t\t%s%s%s" "" + printf "\t\t\t\n" + printf "\t\t\t
\n" +} +humonth() { + if [ "$1" -eq 1 ] + then + echo "january" + elif [ "$1" -eq 2 ] + then + echo "february" + elif [ "$1" -eq 3 ] + then + echo "march" + elif [ "$1" -eq 4 ] + then + echo "april" + elif [ "$1" -eq 5 ] + then + echo "may" + elif [ "$1" -eq 6 ] + then + echo "june" + elif [ "$1" -eq 7 ] + then + echo "july" + elif [ "$1" -eq 8 ] + then + echo "august" + elif [ "$1" -eq 9 ] + then + echo "september" + elif [ "$1" -eq 10 ] + then + echo "october" + elif [ "$1" -eq 11 ] + then + echo "november" + elif [ "$1" -eq 12 ] + then + echo "december" + else + echo "mystery" + fi +} + +pyear=0 +pmonth=0 +pday=0 +poutfn="" +outfn="" +newday=0 +lastfn=$(cat photo | while read -r line +do + if [ $newday -eq 1 ] + then + printf "\t\t\t

$pyear
$(humonth $pmonth) $pday

" >> $outfn + newday=0 + fi + + year=$(echo $line | getyear) + month=$(echo $line | getmonth) + day=$(echo $line | getday) + + if [ $year -ne $pyear ] || [ $month -ne $pmonth ] + then + nextoutfn=photographed/${year}-${month}.html + if ! [ -z $outfn ] + then + printf "\t\t\t

later

" >> $outfn + printf "\t\t\t

earlier

" >> $outfn + cat footer/photographed.txt >> $outfn + fi + outfn=$nextoutfn + echo $outfn + cat header/photographed.txt > $outfn + fi + + if [ $pday -ne $day ] + then + newday=1 + fi + + padimg $line >> $outfn + + pyear=$year + pmonth=$month + pday=$day +done | tail -1) + +printf "\t\t\t

later

" >> $lastfn +cat footer/photographed.txt >> $lastfn -- cgit v1.2.3