summary refs log tree commit diff
path: root/www/photo.causal.agency/generate.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--www/photo.causal.agency/generate.sh107
1 files changed, 90 insertions, 17 deletions
diff --git a/www/photo.causal.agency/generate.sh b/www/photo.causal.agency/generate.sh
index 4b30db92..83a3128b 100644
--- a/www/photo.causal.agency/generate.sh
+++ b/www/photo.causal.agency/generate.sh
@@ -15,14 +15,14 @@ resize() {
 preview() {
 	local photo=$1
 	local preview=preview/${photo##*/}
-	resize $photo 25% static/$preview
+	resize $photo 1500000@ static/$preview
 	echo $preview
 }
 
 thumbnail() {
 	local photo=$1
 	local thumbnail=thumbnail/${photo##*/}
-	resize $photo 5% static/$thumbnail
+	resize $photo 60000@ static/$thumbnail
 	echo $thumbnail
 }
 
@@ -35,12 +35,51 @@ 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 page=$1
+	local title=$(page_title $page)
+	local date body lens film note
+
+	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]' \
+				$page/$(ls -1 $page | head -n 1) 2>/dev/null |
+			sed '
+				s/\([A-Z]\)\([0-9]\)/\1 \2/
+				s,f/,ƒ/,
+				s/\([0-9]\)-\([0-9]\)/\1–\2/g
+			' |
+			encode
+		)
+	fi
+	if test -f $page/film; then
+		film=$(encode $page/film)
+	fi
+	if test -f $page/note; then
+		note=$(encode $page/note)
+	fi
+
 	cat <<-EOF
 	<!DOCTYPE html>
 	<meta charset="utf-8">
@@ -48,12 +87,15 @@ page_head() {
 	<link rel="alternate" type="application/atom+xml" href="../feed.atom">
 	<title>${title}</title>
 	<style>
-	html { color: #bbb; background-color: black; font-family: sans-serif; }
+	html { color: #bbb; background-color: black; font-family: monospace; }
+	p { text-align: center; }
 	figure { margin: 1em; padding-top: 0.5em; text-align: center; }
 	img { max-width: calc(100vw - 2.5em); max-height: calc(100vh - 2.5em); }
 	details { max-width: 78ch; margin: 0.5em auto; }
 	</style>
 	<h1>${title}</h1>
+	<p>${date:+📆 }${date:-} 📷 ${body:-}${body:+ 🔘 }${lens:-}${film:+ 🎞️ }${film:-}</p>
+	${note:+<p>}${note:-}${note:+</p>}
 	EOF
 }
 
@@ -79,24 +121,41 @@ 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
+	if test -n "${ExposureTime}"; then
+		cat <<-EOF
 			${ExposureTime} ·
 			ƒ/$(bc -S 1 -e ${FNumber}) ·
 			$(bc -e ${FocalLength}) mm ·
 			${PhotographicSensitivity} ISO
+		EOF
+	fi
+	if test -f $description; then
+		cat <<-EOF
 			<details>
 				<summary>description</summary>
 				$(encode $description)
 			</details>
+		EOF
+	fi
+	cat <<-EOF
 		</figcaption>
 	</figure>
 	EOF
@@ -177,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
@@ -201,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
/bin/man1/downgrade.1?id=803fc57e267fc55e557f22545cf6b4fcb3fbbdee&follow=1'>Add downgrade IRC botJune McEnroe 2021-09-14Sort by title if authors matchJune McEnroe There are probably better things to sort by but title definitely always exists. 2021-09-13Swap-remove tags as they're foundJune McEnroe This makes it even faster. From ~1s on a sqlite3.c amalgamation to ~0.85s. 2021-09-12Replace htagml regex with strncmpJune McEnroe Since ctags only ever produces regular expressions of the form /^re$/ or /^re/ with no other special characters, instead unescape the pattern and simply use strncmp. Running on a sqlite3.c amalgamation, the regex version takes ~37s while the strncmp version takes ~1s, producing identical output. Big win! 2021-09-11Also defer printing comment for lone close-parensJune McEnroe 2021-09-10Publish "git-comment"June McEnroe 2021-09-10Add git comment --pretty optionJune McEnroe 2021-09-08Defer printing comment if line is blank or closing braceJune McEnroe This fixes badly indented comments. 2021-09-08Up default min-repeat to 30 linesJune McEnroe 2021-09-08Handle dirty lines in git-commentJune McEnroe 2021-09-08Document and install git-commentJune McEnroe 2021-09-08Add repeat and all options to git-commentJune McEnroe 2021-09-08Add group threshold to git-commentJune McEnroe