From f286e5062d44ebad0d604fbafbb490944336b657 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 27 Aug 2022 09:17:42 -0700 Subject: [PATCH] First cut at a photos site --- config.toml | 5 + content/photos/_index.md | 3 + content/photos/photos.css | 99 +++++++++++++++++++ .../development/photo_exif_table.html | 15 +++ layouts/partials/head.html | 2 +- layouts/partials/photo_exif_table.html | 27 +++++ layouts/photos/list.html | 12 +++ layouts/photos/single.html | 46 +++++++++ 8 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 content/photos/_index.md create mode 100644 content/photos/photos.css create mode 100644 layouts/partials/development/photo_exif_table.html create mode 100644 layouts/partials/photo_exif_table.html create mode 100644 layouts/photos/list.html create mode 100644 layouts/photos/single.html diff --git a/config.toml b/config.toml index d1063b9..1571c67 100644 --- a/config.toml +++ b/config.toml @@ -34,6 +34,10 @@ name = 'Eryn Wells' identifier = 'about' name = 'About' url = '/about/' + [[menu.main]] + identifier = 'photos' + name = 'Photos' + url = '/photos/' [outputFormats] [outputFormats.RSS] @@ -53,6 +57,7 @@ description = 'Home page of Eryn Wells' [permalinks] blog = 'blog/:year/:month/:slug/' +photos = 'photos/:year/:month/:slug/' [taxonomies] category = 'categories' diff --git a/content/photos/_index.md b/content/photos/_index.md new file mode 100644 index 0000000..b548e3b --- /dev/null +++ b/content/photos/_index.md @@ -0,0 +1,3 @@ +--- +title: Photos +--- diff --git a/content/photos/photos.css b/content/photos/photos.css new file mode 100644 index 0000000..9966fa6 --- /dev/null +++ b/content/photos/photos.css @@ -0,0 +1,99 @@ +:root { + --photo-params-background: #ddd; + --photo-params-border-color: #aaa; +} + +@media (prefers-color-scheme: dark) { + :root { + --photo-params-background: #444; + --photo-params-background: #777; + } +} + +ul.grid { + align-items: center; + display: flex; + flex-direction: row; + flex-wrap: wrap; + gap: 5px; + justify-content: flex-start; + margin: 0; + padding: 0; +} + +.grid li { + display: block; + height: 210px; + list-style: none; + width: 210px; +} + +.grid li img { + border-radius: 0.5rem; +} + +.photo-params { + background-color: var(--photo-params-background); + border-collapse: collapse; + border-radius: 6px; + margin: 1rem auto; + table-layout: fixed; + text-align: center; + width: 66%; +} + +.photo-params thead td { + border-bottom: 1px solid var(--photo-params-border-color); + font-size: 80%; + font-weight: bold; +} + +.photo-params tr.exposure-attributes td { + border-top: 1px solid var(--photo-params-border-color); + border-left: 1px solid var(--photo-params-border-color); +} + +.photo-params tr.exposure-attributes td:first-child { + border-left: none; +} + +.photo-params td { + font-size: 75%; + padding: 1rem; +} + +.photo-params td:last-child { + text-align: end; +} + +.photo-params td:first-child { + text-align: start; +} + +.photo-params .make-model { + font-weight: bold; +} + +.photo-params .size { + border-left: 0; +} + +.photo-params .location { + border-right: 0; +} + +.photo-params.debug thead { + font-size: 2rem; + font-weight: bold; + border-bottom: 2px solid var(--dark); +} + +.photo-params.debug { + width: 100%; +} + +.photo-params.debug td { + border: 1px solid var(--photo-params-border-color); + overflow: scroll; + vertical-align: top; +} diff --git a/layouts/partials/development/photo_exif_table.html b/layouts/partials/development/photo_exif_table.html new file mode 100644 index 0000000..60f254c --- /dev/null +++ b/layouts/partials/development/photo_exif_table.html @@ -0,0 +1,15 @@ +
+ Debug EXIF Data + + + + + + {{ range $k, $v := .Tags }} + + + + + {{ end }} +
KeyValue
{{ $k }}{{ $v }}
+
diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 52b6f2f..1880a6e 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -8,7 +8,7 @@ {{- if eq .Kind "page" -}} - {{- else -}} + {{ else }} {{- end -}} diff --git a/layouts/partials/photo_exif_table.html b/layouts/partials/photo_exif_table.html new file mode 100644 index 0000000..5f8eb5b --- /dev/null +++ b/layouts/partials/photo_exif_table.html @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + +
{{ .Tags.Make }} {{ .Tags.Model }}
+ {{ $lat := float .Lat }}{{ $latDir := cond (eq $lat 0) "" (cond (gt $lat 0) "N" "S") }} + {{ .Lat | lang.FormatNumber (cond (ne $lat 0) 3 0) }}º{{ $latDir }}, + {{ $long := float .Long }}{{ $longDir := cond (eq $long 0) "" (cond (gt $long 0) "E" "W") }} + {{ .Long | lang.FormatNumber (cond (ne $long 0) 3 0) }}º{{ $longDir }} + + {{ $widthpx := .Tags.PixelXDimension }} + {{ $heightpx := .Tags.PixelYDimension }} + {{ if and (gt $widthpx 0) (gt $heightpx 0) }} + {{ $megapixels := div (mul $widthpx $heightpx) 1e6 }} + {{ $megapixels | lang.FormatNumber 0 }} MP • {{ $widthpx }} × {{ $heightpx }} + {{ end }} +
{{ with .Tags.ISOSpeedRatings }}ISO {{ . }}{{ end }}{{ with .Tags.FocalLengthIn35mmFilm }}{{ . }} mm{{ end }}{{ with .Tags.FNumber }}ƒ{{ . }}{{ end }}{{ with .Tags.ExposureTime }}{{ . }} s{{ end }}
diff --git a/layouts/photos/list.html b/layouts/photos/list.html new file mode 100644 index 0000000..ec43345 --- /dev/null +++ b/layouts/photos/list.html @@ -0,0 +1,12 @@ +{{ define "main" }} +
+ +
+{{ end }} diff --git a/layouts/photos/single.html b/layouts/photos/single.html new file mode 100644 index 0000000..d0e86f7 --- /dev/null +++ b/layouts/photos/single.html @@ -0,0 +1,46 @@ +{{ define "main" }} +
+ + +{{ if .Title }} +
+ {{ partial "development/draft_tag.html" . }} +
+

{{ .Title }}

+ +
+
+{{ end }} + +{{ $photos := .Resources.ByType "image" }} +{{ if eq (len $photos) 0 }} +{{ errorf "Missing photo from photos page %q" .Path }} +{{ end }} + +{{ if eq (len $photos) 1 }} +{{ $img := index $photos 0 }} +
+ +
+ + {{ .Content }} + + {{ partial "photo_exif_table.html" $img.Exif }} + + {{ if in ($.Site.BaseURL | string) "localhost" }} + {{ partial "development/photo_exif_table.html" $img.Exif }} + {{ end }} +{{ else }} +
+ +
+{{ end }} + +
+{{ end }}