Root/scripts/schhist2web

Source at commit 0d537612c3df6d6f58cc93955bda9c8042e8052c created 13 years 7 months ago.
By Werner Almesberger, Allow markup to be synchronized with other (better resolution) pair of images.
1#!/bin/sh
2
3THUMB_OPTS="-w 3 -d 60 -n 1,1,0"
4
5
6shrink()
7{
8    pnmscale -width 120 "$@" || exit
9}
10
11
12pngdiff()
13{
14    # pngdiff preproc outfile arg ...
15    pp="$1"
16    of="$2"
17    shift 2
18    if ! PATH=$PATH:`dirname $0`/ppmdiff ppmdiff "$@" "$out/_tmp"; then
19    rm -f "$out/_tmp"
20    return 1
21    fi
22    $pp "$out/_tmp" | pnmtopng >"$of"
23    rm "$out/_tmp"
24}
25
26
27usage()
28{
29    echo "usage: $0 [top-dir] [top-schem] [outdir]" 2>&1
30    exit 1
31}
32
33
34if [ ! -z "$1" -a -d "$1/.git" ]; then
35    dir="$1"
36    shift
37else
38    dir=.
39    while [ ! -d $dir/.git ]; do
40    if [ $dir -ef $dir/.. ]; then
41        echo "no .git/ directory found in hierarchy" 1>&2
42        exit 1
43    fi
44    dir=$dir/..
45    done
46fi
47
48if [ ! -z "$1" -a -f "$dir/$1" -a \
49  -f "$dir"/`dirname "$1"`/`basename "$1" .sch`.pro ]; then
50    sch="$1"
51    shift
52else
53    for n in "$dir"/*.sch; do
54    [ -f `dirname "$n"`/`basename "$n" .sch`.pro ] || continue
55    if [ ! -z "$sch" ]; then
56        echo "multiple choices for top-level .sch file" 1>&2
57        exit 1
58    fi
59    sch="$n"
60    done
61    if [ -z "$sch" -o "$sch" = "$dir/*.sch" ]; then
62    echo "no candidate for top-level .sch file found" 1>&2
63    exit 1
64    fi
65fi
66
67if [ ! -z "$1" ] && [ ! -e "$1" ] || [ -d "$1" -a ! -d "$1"/.git ]; then
68    out="$1"
69    shift
70else
71    out=_out
72fi
73
74[ -z "$1" ] || usage
75
76PATH=`dirname "$0"`:"$PATH"
77first=`gitenealogy "$dir/$sch" | sed '$s/ .*//p;d'`
78schname=`gitenealogy "$dir/$sch" | sed '$s/^.* //p;d'`
79
80# @@@ POOR MAN'S CACHE
81if true; then
82
83rm -rf "$out"
84mkdir -p "$out/names"
85
86for n in $first `git rev-list --reverse $first..HEAD`; do
87echo Processing $n
88    new=`gitenealogy "$dir/$sch" | sed "/^$n /s///p;d"`
89    if [ ! -z "$new" ]; then
90echo Name change $schname to $new
91    schname="$new"
92    fi
93    mkdir "$out/ppm_$n"
94    gitsch2ppm "$dir" "$schname" $n "$out/ppm_$n" || exit
95    gitsch2ppm -w 500 "$dir" "$schname" $n "$out/fat_$n" || exit
96    for m in "$out/ppm_$n/"*; do
97    [ "$m" = "$out/ppm_$n/*" ] && break
98    touch "$out/names/"`basename "$m" .ppm`
99    done
100done
101
102fi
103
104cat <<EOF >"$out/index.html"
105<HTML>
106<BODY>
107<TABLE bgcolor="#f0f0ff" callpadding=1>
108<TR>
109EOF
110for m in `ls -1 "$out/names"`; do
111    echo "<TD><B>$m</B>" >>"$out/index.html"
112done
113
114head=`git rev-list HEAD~1..HEAD`
115next="$head"
116for n in `git rev-list $first..HEAD~1` $first; do
117    empty=true
118    s="<TR><TR>"
119    mkdir -p "$out/diff_$next" "$out/thumb_$next"
120    for m in `ls -1 "$out/names"`; do
121    a="$out/ppm_$n/$m.ppm"
122    fat_a="$out/fat_$n/$m.ppm"
123    b="$out/ppm_$next/$m.ppm"
124    fat_b="$out/fat_$next/$m.ppm"
125    diff="$out/diff_$next/$m.png"
126    thumb="$out/thumb_$next/$m.png"
127
128    if [ -f "$a" -a -f "$b" ]; then
129        s="$s<TD>"
130        pngdiff cat "$diff" "$a" "$b" || continue
131        pngdiff shrink "$thumb" -f $THUMB_OPTS "$fat_a" "$fat_b" \
132          "$a" "$b" || exit
133    elif [ -f "$a" ]; then
134        s="$s<TD>"
135        pngdiff cat "$diff" -f -c 1,0,0 "$a" "$a" || exit
136        pngdiff shrink "$thumb" -f -c 1,0,0 $THUMB_OPTS "$fat_a" "$fat_a" \
137          || exit
138    elif [ -f "$out/$next/$m.ppm" ]; then
139        s="$s<TD>"
140        pngdiff cat "$diff" -f -c 0,1,0 "$b" "$b" || exit
141        pngdiff shrink "$thumb" -f -c 0,1,0 $THUMB_OPTS "$fat_b" "$fat_b" \
142          || exit
143    else
144        s="$s<TD>"
145        continue
146    fi
147    echo "$s" >>"$out/index.html"
148    s=
149    empty=false
150    echo "<A href=\"diff_$next/$m.png\"><IMG src=\"thumb_$next/$m.png\"></A>" >>"$out/index.html"
151    done
152    if ! $empty; then
153    (
154        cat <<EOF
155$s<TD valign="middle">
156<TABLE bgcolor="#000000" cellspacing=0 width="100%"><TR><TD></TABLE>
157EOF
158    mkdir -p "$out/diff_$next" "$out/thumb_$next"
159        echo "<PRE>"
160        git log --pretty=short $n..$next
161        echo "</PRE>"
162    ) >>"$out/index.html"
163    fi
164    next=$n
165done
166
167echo "</TABLE>" >>"$out/index.html"
168exit 1
169

Archive Download this file



interactive