diff options
Diffstat (limited to 'www/photo.causal.agency/generate.sh')
-rw-r--r-- | www/photo.causal.agency/generate.sh | 89 |
1 files changed, 67 insertions, 22 deletions
diff --git a/www/photo.causal.agency/generate.sh b/www/photo.causal.agency/generate.sh index 558b8a54..83a3128b 100644 --- a/www/photo.causal.agency/generate.sh +++ b/www/photo.causal.agency/generate.sh @@ -35,20 +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 lens film + local page=$1 + local title=$(page_title $page) + local date body lens film note - if test -f $date/lens; then - lens=$(encode $date/lens) + 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 $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/,ƒ/, @@ -57,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 @@ -75,7 +94,8 @@ page_head() { details { max-width: 78ch; margin: 0.5em auto; } </style> <h1>${title}</h1> - <p>📷 ${lens}${film:+ 🎞️ }${film:-}</p> + <p>${date:+📆 }${date:-} 📷 ${body:-}${body:+ 🔘 }${lens:-}${film:+ 🎞️ }${film:-}</p> + ${note:+<p>}${note:-}${note:+</p>} EOF } @@ -101,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 @@ -120,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 @@ -205,23 +236,37 @@ 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}/*.JPG; 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} fi - page_photo $photo $preview ${photo%.JPG}.txt >>$page + 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 @@ -229,7 +274,7 @@ atom_head >static/feed.atom for date; do index_page $date >>static/index.html atom_entry_head $date >>static/feed.atom - for photo in ${date}/*.JPG; do + for photo in ${date}/*.[Jj][Pp][Gg]; do thumbnail=$(thumbnail $photo) index_photo $date $photo $thumbnail >>static/index.html index_photo $date $photo $thumbnail $Root | encode >>static/feed.atom |