From 6bf66bb291daa4cb924185231e67ecaccf250337 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 30 Oct 2026 09:02:20 +0100 Subject: examples: modernize gipfelweb — responsive, dark/light, one page per panorama MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - markers positioned in percent of the slide (identify reads the dimensions), so the panorama scales with the viewport; a CSS-only 'Full resolution' checkbox switches to natural size with horizontal scrolling - peaks and photos now share one page; chip-style checkboxes toggle Peaks / Photos / Labels / Full resolution (pure CSS sibling selectors, no JavaScript) - interaction for all input types: hover (mouse), :focus-within (keyboard, markers are anchors), :target (touch, tap to open a popup); popups get below/left/right classes from the generator so they never leave the image - labels show distance (the data always had it): NAME · 2849 m · 12.3 km - new gallery index.html (thumbnail grid), dark/light via prefers-color-scheme, system font stack, lazy thumbnails, aria labels, viewport meta; stylesheet is a single external style.css - backlink updated to flpsed.org/gipfel.html - gipfel2html: LC_ALL=C (awk decimal separator), no pipe-subshell marker loops (counter must survive), exact cross-reference matching The old two-page (images/hills) split is gone; the hills view is the Peaks toggle now. --- examples/gipfel2html | 260 +++++++++++++++++++++++++++++---------------------- 1 file changed, 147 insertions(+), 113 deletions(-) (limited to 'examples/gipfel2html') diff --git a/examples/gipfel2html b/examples/gipfel2html index 49814c3..d6ad93f 100755 --- a/examples/gipfel2html +++ b/examples/gipfel2html @@ -1,139 +1,173 @@ #!/bin/sh +# gipfel2html — generate the modern, CSS-only gipfelweb pages. +# +# gipfel2html page one panorama page (peaks + photos) +# gipfel2html gallery thumbnail gallery index +# +# Markers are positioned in percent of the slide so the panorama can +# scale freely (responsive default; a CSS-only checkbox switches to +# full resolution with horizontal scrolling). Interaction is pure CSS: +# hover for mouse, :focus-within for keyboard, :target for touch. + +set -e +# awk must print dots as decimal separators regardless of locale +LC_ALL=C +export LC_ALL MODE="$1" -TITLE="$2" -FILE="$3" -if [ "$MODE" = "images" ]; then - DATAFILE="gipfelweb/gipfel/${FILE}.imgs" -else - DATAFILE="gipfelweb/gipfel/${FILE}.hills" -fi - -cat << EOF - - +AWK=awk + +# percent of slide dimension +pct() { $AWK -v v="$1" -v m="$2" 'BEGIN { printf "%.2f", v * 100 / m }'; } + +# integer percent (for threshold comparisons) +ipct() { $AWK -v v="$1" -v m="$2" 'BEGIN { printf "%d", v * 100 / m }'; } + +# meters -> "12.3 km" / "850 m" +fmt_dist() { + $AWK -v d="$1" 'BEGIN { if (d >= 1000) printf "%.1f km", d / 1000; else printf "%.0f m", d }' +} + +# edge classes so popups stay inside the image: below if near the top, +# left/right aligned if near a horizontal edge +edge_classes() { + xp="$1"; yp="$2" + cls="" + [ "$yp" -lt 25 ] && cls="below" + if [ "$xp" -lt 12 ]; then cls="$cls left" + elif [ "$xp" -gt 88 ]; then cls="$cls right" + fi + echo "$cls" +} + + +title_of() { + # display title for image base name $1: %.title file, else the name + if [ -e "$1.title" ]; then cat "$1.title"; else echo "$1"; fi +} + +head() { + cat << EOF + + + + +$1 — gipfel + + EOF - -echo "$TITLE" - -cat << EOF - - -
-
+ for f in "$@"; do + echo "\"${f}\"$(title_of "$f")" + done + cat << EOF + + + + + EOF - -echo "

$TITLE

" - -if [ "$MODE" = "images" ]; then - echo "show hill names" -else - echo "back to gipfelweb" + exit 0 fi +# ---- one panorama page ---- +FILE="$2" +SLIDE="gipfelweb/slides/${FILE}.jpg" +HILLS="gipfelweb/gipfel/${FILE}.hills" +IMGS="gipfelweb/gipfel/${FILE}.imgs" +TITLE=$(title_of "$FILE") +set -- $(identify -format "%w %h" "$SLIDE") +W="$1" H="$2" + +head "$TITLE" "" cat << EOF - - -
- - -
-
+ +
+

${TITLE}

+← Gallery +
+
+ + + + + + + + +
+
+${TITLE} +
    EOF -if [ "$MODE" = "images" ]; then - echo "" -else - echo "" +# note: no `cmd | while` pipes here — the loop body increments the +# marker counters and must run in the current shell +if [ -e "$HILLS" ]; then + i=0 + while IFS=" " read -r name height x y dist rest; do + case "$name" in \#*|"") continue ;; esac + xp=$(pct "$x" "$W"); yp=$(pct "$y" "$H") + cls=$(edge_classes "$(ipct "$x" "$W")" "$(ipct "$y" "$H")") + d=$(fmt_dist "$dist") + echo "
  • ${name} · ${height} m · ${d}
  • " + i=$((i + 1)) + done < "$HILLS" fi - -echo "
      " -i=0 -grep -v "^#" ${DATAFILE} | \ -while read name height x y dist flags dummy; do - if [ "$MODE" = "images" ]; then - THUMB_TITLE="${name%.jpg}" - if [ -e "${name%.jpg}.title" ]; then - THUMB_TITLE=`cat ${name%.jpg}.title` - fi - echo "
    • ${THUMB_TITLE} (${height}m)
    • " - else - echo "
    • ${name} (${height}m)
    • " - fi - - i=$((${i} + 1)) -done -echo "
    " +if [ -e "$IMGS" ]; then + j=0 + while IFS=" " read -r name height x y dist rest; do + case "$name" in \#*|"") continue ;; esac + [ "$name" = "${FILE}.jpg" ] && continue # no self links + xp=$(pct "$x" "$W"); yp=$(pct "$y" "$H") + cls=$(edge_classes "$(ipct "$x" "$W")" "$(ipct "$y" "$H")") + base="${name%.jpg}" + pt=$(title_of "$base") + d=$(fmt_dist "$dist") + echo "
  • \"${pt}\"${pt} · ${d}
  • " + j=$((j + 1)) + done < "$IMGS" +fi cat << EOF +
+
-
-
-
-Created with gipfel -
-
EOF -if [ "$MODE" = "images" ]; then - echo Move the mouse over the image to see other images. -else - echo Move the mouse over the image to see known mountains. +# related images: panoramas in which this one also appears +rel=$(awk -F'\t' -v n="${FILE}.jpg" '$1 == n { print FILENAME; exit }' \ + gipfelweb/gipfel/*.imgs 2>/dev/null || true) +if [ -n "$rel" ]; then + echo '' fi cat << EOF -
-Move the mouse over the rectangle to see details. -
-
-This image is visible on these images:
-EOF - -# exact match on the name column (a plain grep -l would also match -# substrings, e.g. test.jpg inside contest.jpg); exit keeps output to -# one line per file -awk -F'\t' -v n="${FILE}.jpg" '$1 == n { print FILENAME; exit }' gipfelweb/gipfel/*.imgs | \ -while read f; do - img="`basename ${f%.imgs}`" - if [ "$MODE" = "images" ]; then - echo "
" - else - echo "
" - fi -done - - -cat << EOF + + EOF -- cgit v1.2.3