diff options
Diffstat (limited to 'www/photo.causal.agency/generate.sh')
-rw-r--r-- | www/photo.causal.agency/generate.sh | 86 |
1 files changed, 64 insertions, 22 deletions
diff --git a/www/photo.causal.agency/generate.sh b/www/photo.causal.agency/generate.sh index 26279229..83a3128b 100644 --- a/www/photo.causal.agency/generate.sh +++ b/www/photo.causal.agency/generate.sh @@ -35,23 +35,36 @@ encode() { } page_title() { - date -j -f '%F' $1 '+%B %e, %Y' + case $1 in + (leader) echo 'Film Leader';; + (20*) date -j -f '%F' $1 '+%B %e, %Y';; + (0*) echo Roll $(dc -e "${1}p");; + esac } page_head() { - local date=$1 - local title=$(page_title $date) - local body lens film + local page=$1 + local title=$(page_title $page) + local date body lens film note - if test -f $date/body; then - body=$(encode $date/body) + if test -f $page/date; then + date=$(sed 's/\([0-9]\)-\([0-9]\)/\1โ\2/g' $page/date | encode) + fi + if test -f $page/body; then + body=$(encode $page/body) fi - if test -f $date/lens; then - lens=$(encode $date/lens) + if test -f $page/lens; then + lens=$( + sed ' + s,f/,ฦ/,g + s/\([0-9]\)-\([0-9]\)/\1โ\2/g + ' $page/lens | + encode + ) else lens=$( identify -format '%[EXIF:LensModel]' \ - $date/$(ls -1 $date | head -n 1) 2>/dev/null | + $page/$(ls -1 $page | head -n 1) 2>/dev/null | sed ' s/\([A-Z]\)\([0-9]\)/\1 \2/ s,f/,ฦ/, @@ -60,8 +73,11 @@ page_head() { encode ) fi - if test -f $date/film; then - film=$(encode $date/film) + if test -f $page/film; then + film=$(encode $page/film) + fi + if test -f $page/note; then + note=$(encode $page/note) fi cat <<-EOF @@ -78,7 +94,8 @@ page_head() { details { max-width: 78ch; margin: 0.5em auto; } </style> <h1>${title}</h1> - <p>๐ท ${body:-}${body:+ ยท }${lens}${film:+ ๐๏ธ }${film:-}</p> + <p>${date:+๐ }${date:-} ๐ท ${body:-}${body:+ ๐ }${lens:-}${film:+ ๐๏ธ }${film:-}</p> + ${note:+<p>}${note:-}${note:+</p>} EOF } @@ -104,14 +121,21 @@ photo_id() { page_photo() { local photo=$1 preview=$2 description=$3 - if ! test -f $description; then - description=/dev/null - fi photo_info $photo cat <<-EOF <figure id="$(photo_id $photo)"> <a href="${photo##*/}"> + EOF + if test -f $description; then + cat <<-EOF <img src="../${preview}" alt="$(encode $description)"> + EOF + else + cat <<-EOF + <img src="../${preview}"> + EOF + fi + cat <<-EOF </a> <figcaption> EOF @@ -123,11 +147,15 @@ page_photo() { ${PhotographicSensitivity} ISO EOF fi - cat <<-EOF + if test -f $description; then + cat <<-EOF <details> <summary>description</summary> $(encode $description) </details> + EOF + fi + cat <<-EOF </figcaption> </figure> EOF @@ -208,13 +236,13 @@ atom_tail() { } set -- -for date in 20*; do - mkdir -p static/${date} - page=static/${date}/index.html +for entry in 20* 0*; do + mkdir -p static/${entry} + page=static/${entry}/index.html if ! test -f $page; then echo $page >&2 - page_head $date >$page - for photo in ${date}/*.[Jj][Pp][Gg]; do + page_head $entry >$page + for photo in ${entry}/*.[Jj][Pp][Gg]; do preview=$(preview $photo) if ! test -f static/${photo}; then ln $photo static/${photo} @@ -222,9 +250,23 @@ for date in 20*; do page_photo $photo $preview ${photo%.[Jj][Pp][Gg]}.txt >>$page done fi - set -- $date "$@" + set -- $entry "$@" done +mkdir -p static/leader +page=static/leader/index.html +if [ leader -nt $page ]; then + echo $page >&2 + page_head leader >$page + for photo in leader/*.[Jj][Pp][Gg]; do + preview=$(preview $photo) + if ! test -f static/${photo}; then + ln $photo static/${photo} + fi + page_photo $photo $preview xxx >>$page + done +fi + echo static/index.html >&2 index_head >static/index.html echo static/feed.atom >&2 |