summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/Makefile83
-rwxr-xr-xexamples/gipfel2html139
2 files changed, 222 insertions, 0 deletions
diff --git a/examples/Makefile b/examples/Makefile
new file mode 100644
index 0000000..ac44fb7
--- /dev/null
+++ b/examples/Makefile
@@ -0,0 +1,83 @@
+# gipfelweb: static, CSS-only web galleries of gipfel-annotated
+# panoramas. Port of the historical examples/ pipeline to the Rust
+# stack: gipfel-cli replaces the C binary, ImageMagick replaces
+# netpbm + jhead (convert preserves the gipfel comment and EXIF).
+#
+# usage: put annotated *.jpg files (optionally per-image %.opts with
+# extra gipfel-cli arguments and %.title with a display title) in a
+# directory and run
+#
+# make -f /path/to/gipfel/examples/Makefile gipfelweb
+#
+# variables:
+# GIPFEL_CLI path to the gipfel-cli binary
+# DATA hill database used for the peak view
+# GIPFEL2HTML html generator script
+
+here := $(dir $(lastword $(MAKEFILE_LIST)))
+GIPFEL_CLI ?= $(abspath $(here)../target/release/gipfel-cli)
+DATA ?= $(abspath $(here)../gipfel.dat)
+GIPFEL2HTML ?= $(here)gipfel2html
+
+images := $(wildcard *.jpg)
+slides := $(addprefix gipfelweb/slides/, $(images))
+thumbs := $(addprefix gipfelweb/thumbs/, $(images))
+positions := $(addprefix gipfelweb/gipfel/, $(addsuffix .pos, $(basename $(images))))
+imgpos := $(addprefix gipfelweb/gipfel/, $(addsuffix .imgs, $(basename $(images))))
+hillpos := $(addprefix gipfelweb/gipfel/, $(addsuffix .hills, $(basename $(images))))
+html := $(addprefix gipfelweb/, $(addsuffix .html, $(basename $(images))))
+htmlhills := $(addprefix gipfelweb/hills/, $(addsuffix .html, $(basename $(images))))
+
+all:
+ echo "make gipfelweb - create a HTML based view of gipfel oriented"
+ echo "images in the current directory."
+
+gipfelweb: dirs $(slides) $(thumbs) $(imgpos) $(hillpos) $(html) $(htmlhills)
+
+clean:
+ rm -rf gipfelweb/gipfel
+
+clobber:
+ rm -rf gipfelweb
+
+dirs:
+ mkdir -p gipfelweb/slides
+ mkdir -p gipfelweb/thumbs
+ mkdir -p gipfelweb/hills
+ mkdir -p gipfelweb/gipfel
+
+gipfelweb/slides/%.jpg: %.jpg
+ convert $< -filter Lanczos -resize 20000x500\> -quality 94 $@
+
+gipfelweb/thumbs/%.jpg: %.jpg
+ convert $< -filter Point -resize 400x50\> -quality 80 $@
+
+gipfelweb/gipfel/%.pos: %.jpg
+ $(GIPFEL_CLI) export-position $< > $@
+
+gipfelweb/gipfel/%.imgs: gipfelweb/slides/%.jpg %.opts gipfelweb/gipfel/index.gipfel
+ $(GIPFEL_CLI) `cat $*.opts` export-hills $< -d $(DATA) -e gipfelweb/gipfel/index.gipfel > $@
+
+gipfelweb/gipfel/%.imgs: gipfelweb/slides/%.jpg gipfelweb/gipfel/index.gipfel
+ $(GIPFEL_CLI) export-hills $< -d $(DATA) -e gipfelweb/gipfel/index.gipfel > $@
+
+gipfelweb/gipfel/%.hills: gipfelweb/slides/%.jpg %.opts
+ $(GIPFEL_CLI) `cat $*.opts` export-hills $< -d $(DATA) > $@
+
+gipfelweb/gipfel/%.hills: gipfelweb/slides/%.jpg
+ $(GIPFEL_CLI) export-hills $< -d $(DATA) > $@
+
+gipfelweb/gipfel/index.gipfel: $(positions)
+ cat $(positions) > gipfelweb/gipfel/index.gipfel
+
+gipfelweb/%.html: gipfelweb/slides/%.jpg gipfelweb/gipfel/%.imgs %.title $(thumbs)
+ $(GIPFEL2HTML) images "`cat $*.title`" $* > $@
+
+gipfelweb/%.html: gipfelweb/slides/%.jpg gipfelweb/gipfel/%.imgs $(thumbs)
+ $(GIPFEL2HTML) images $* $* > $@
+
+gipfelweb/hills/%.html: gipfelweb/slides/%.jpg gipfelweb/gipfel/%.hills %.title
+ $(GIPFEL2HTML) hills "`cat $*.title`" $* > $@
+
+gipfelweb/hills/%.html: gipfelweb/slides/%.jpg gipfelweb/gipfel/%.hills
+ $(GIPFEL2HTML) hills $* $* > $@
diff --git a/examples/gipfel2html b/examples/gipfel2html
new file mode 100755
index 0000000..49814c3
--- /dev/null
+++ b/examples/gipfel2html
@@ -0,0 +1,139 @@
+#!/bin/sh
+
+MODE="$1"
+TITLE="$2"
+FILE="$3"
+
+if [ "$MODE" = "images" ]; then
+ DATAFILE="gipfelweb/gipfel/${FILE}.imgs"
+else
+ DATAFILE="gipfelweb/gipfel/${FILE}.hills"
+fi
+
+cat << EOF
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
+<html>
+<head>
+EOF
+
+echo "<title>$TITLE</title>"
+
+cat << EOF
+<style type="text/css">
+#gipfel { display: block; position: relative; margin: 0; padding: 0; }
+#gipfel li { visibility: hidden; list-style-type: none; position: absolute; background: url(25w.png); border: 1px solid black; font-family: sans-serif; font-size: x-small; color: #000; padding: 0; line-height: 1.3em; overflow: hidden; }
+#gipfel span { visibility: hidden; position: absolute; left: 0; right: 0; display: block; padding: 5px; }
+#gipfel:hover li { visibility: visible; }
+#gipfel li:hover span {visibility: visible;}
+EOF
+
+IFS=" "
+i=0
+grep -v "^#" ${DATAFILE} | \
+while read name height x y dist flags dummy; do
+ if [ "$MODE" = "images" ]; then
+ thumb_w=`identify -format %w gipfelweb/thumbs/${name}`
+ thumb_h=`identify -format %h gipfelweb/thumbs/${name}`
+
+ echo "#id_${i} {left:$((${x} - 10 / 2))px; top: $((${y} - 6 / 2))px; width: 10px; height: 6px;}"
+ echo "#id_${i}:hover {width: ${thumb_w}px; height: ${thumb_h}px; background: url(thumbs/${name});}"
+ else
+ echo "#id_${i} {left:$((${x} - 4 / 2))px; top: $((${y} - 4 / 2))px; width: 4px; height: 4px;}"
+ echo "#id_${i}:hover {width: 200px; height: 20px;}"
+ fi
+
+ i=$((${i} + 1))
+done
+
+cat << EOF
+</style></head>
+<body bgcolor="#919faa">
+<br/>
+<br/>
+EOF
+
+echo "<h3>$TITLE</h3>"
+
+if [ "$MODE" = "images" ]; then
+ echo "<a href=\"hills/${FILE}.html\">show hill names</a>"
+else
+ echo "<a href=\"../${FILE}.html\">back to gipfelweb</a>"
+fi
+
+cat << EOF
+<table border="0" cellpadding="0" cellspacing="1" bgcolor="black">
+<tr><td>
+<table border="0" cellpadding="10" cellspacing="0" bgcolor="white">
+<tr><td>
+<div id="gipfel">
+EOF
+
+if [ "$MODE" = "images" ]; then
+ echo "<img src=\"slides/${FILE}.jpg\"/>"
+else
+ echo "<img src=\"../slides/${FILE}.jpg\"/>"
+fi
+
+
+echo "<ul>"
+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 "<li id=\"id_${i}\"><a href=\"${name%.jpg}.html\"><span>${THUMB_TITLE} (${height}m)</span></a></li>"
+ else
+ echo "<li id=\"id_${i}\"><span>${name} (${height}m)</span></li>"
+ fi
+
+ i=$((${i} + 1))
+done
+echo "</ul>"
+
+cat << EOF
+</div>
+</td></tr>
+</table>
+</td></tr>
+</table>
+<br/>
+<b>Created with <a href="http://www.ecademix.com/JohannesHofmann/gipfel.html">gipfel</a></b>
+<br/>
+<br/>
+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.
+fi
+
+cat << EOF
+<br/>
+Move the mouse over the rectangle to see details.
+<br/>
+<br/>
+This image is visible on these images:<br/>
+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 "<a href=\"${img}.html\"><img src=\"thumbs/${img}.jpg\"></a><br/>"
+ else
+ echo "<a href=\"../${img}.html\"><img src=\"../thumbs/${img}.jpg\"></a><br/>"
+ fi
+done
+
+
+cat << EOF
+</body>
+</html>
+EOF