Date:2010-08-27 17:47:51 (10 years 1 month ago)
Author:Werner Almesberger
Commit:099b62649b992f7ae7f652788ced1a603cf88d9e
Message:schhist2web: use a cache by default and give the user control over it.

- scripts/schhist2web (THUMB_OPTS): make shared pixels in thumbnails a
bit darker
- scripts/schhist2web (usage): described the arguments
- scripts/schhist2web: new option -c dir to set the cache directory
- scripts/schhist2web: new option -n to remake the cache
- scripts/schhist2web: path name in new file detection was incorrect
- scripts/schhist2web: use "$index" instead of open-coding "$out/index.html"
- scripts/gitsch2ppm: changed temp directory name from _schdiff_a to
_gitsch2ppm
Files: scripts/gitsch2ppm (1 diff)
scripts/schhist2web (9 diffs)

Change Details

scripts/gitsch2ppm
8181[ "$commit" != HEAD -o -f "$dir/$schem" ] || usage
8282[ -d "$dir/.git" ] || usage
8383
84tmp="$dir/../_schdiff_a"
84tmp="$dir/../_gitsch2ppm"
8585sch="$tmp/$sdir"
8686
8787rm -rf "$tmp"
scripts/schhist2web
11#!/bin/sh
22
3THUMB_OPTS="-w 3 -d 60 -n 1,1,0"
3OUTDIR=_out
4THUMB_OPTS="-w 3 -d 60 -c 0.5,0.5,0.5 -n 1,1,0"
45
56
67shrink()
...... 
2627
2728usage()
2829{
29    echo "usage: $0 [top-dir] [top-schem] [outdir]" 2>&1
30    cat <<EOF 2>&1
31usage: $0 [-c cache-dir] [-n] [top-dir] [top-schem] [out-dir]
32
33  top-dir top-level directory of the git archive (default: locate it)
34  top-schem root sheet of the schematics (default: locate it in top-dir)
35  out-dir output directory (default: $OUTDIR)
36  -n don't use previous cache content (rebuild the cache)
37  -c cache-dir cache directory (default: same as out-dir)
38EOF
3039    exit 1
3140}
3241
3342
43no_cache=false
44while true; do
45    case "$1" in
46    -n) no_cache=true;;
47    -c) [ -z "$1" ] && usage
48    cache="$1"
49    shift;;
50    -*) usage;;
51    *) break;;
52    esac
53done
54
3455if [ ! -z "$1" -a -d "$1/.git" ]; then
3556    dir="$1"
3657    shift
...... 
4364    fi
4465    dir=$dir/..
4566    done
67    echo "found top-dir: $dir" 1>&2
4668fi
4769
4870if [ ! -z "$1" -a -f "$dir/$1" -a \
...... 
6284    echo "no candidate for top-level .sch file found" 1>&2
6385    exit 1
6486    fi
87    echo "found root sheet: $sch" 1>&2
6588fi
6689
6790if [ ! -z "$1" ] && [ ! -e "$1" ] || [ -d "$1" -a ! -d "$1"/.git ]; then
6891    out="$1"
6992    shift
7093else
71    out=_out
94    out=$OUTDIR
7295fi
96[ -z "$cache" ] && cache="$out"
7397
7498[ -z "$1" ] || usage
7599
...... 
77101first=`gitenealogy "$dir/$sch" | sed '$s/ .*//p;d'`
78102schname=`gitenealogy "$dir/$sch" | sed '$s/^.* //p;d'`
79103
80# @@@ POOR MAN'S CACHE
81if true; then
82
83rm -rf "$out"
104rm -rf "$out/diff_*" "$out/thumb_*" "$out/names"
84105mkdir -p "$out/names"
106$no_cache && rm -rf "$cache"
107mkdir -p "$cache"
85108
86109for n in $first `git rev-list --reverse $first..HEAD`; do
87110echo Processing $n
88111    new=`gitenealogy "$dir/$sch" | sed "/^$n /s///p;d"`
89112    if [ ! -z "$new" ]; then
90echo Name change $schname to $new
113    echo Name change $schname to $new 1>&2
91114    schname="$new"
92115    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
116    if [ ! -d "$cache/ppm_$n" ]; then
117    rm -rf "$cache/ppm_$n"
118    mkdir "$cache/ppm_$n"
119    gitsch2ppm "$dir" "$schname" $n "$cache/ppm_$n" || exit
120    gitsch2ppm -w 500 "$dir" "$schname" $n "$out/fat_$n" || exit
121    fi
122    for m in "$cache/ppm_$n/"*; do
123    [ "$m" = "$cache/ppm_$n/*" ] && break
98124    touch "$out/names/"`basename "$m" .ppm`
99125    done
100126done
101127
102fi
103
104cat <<EOF >"$out/index.html"
128index="$out/index.html"
129cat <<EOF >"$index"
105130<HTML>
106131<BODY>
107132<TABLE bgcolor="#f0f0ff" callpadding=1>
108133<TR>
109134EOF
110135for m in `ls -1 "$out/names"`; do
111    echo "<TD><B>$m</B>" >>"$out/index.html"
136    echo "<TD><B>$m</B>" >>"$index"
112137done
113138
114139head=`git rev-list HEAD~1..HEAD`
...... 
118143    s="<TR><TR>"
119144    mkdir -p "$out/diff_$next" "$out/thumb_$next"
120145    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"
146    a="$cache/ppm_$n/$m.ppm"
147    fat_a="$cache/fat_$n/$m.ppm"
148    b="$cache/ppm_$next/$m.ppm"
149    fat_b="$cache/fat_$next/$m.ppm"
125150    diff="$out/diff_$next/$m.png"
126151    thumb="$out/thumb_$next/$m.png"
127152
...... 
135160        pngdiff cat "$diff" -f -c 1,0,0 "$a" "$a" || exit
136161        pngdiff shrink "$thumb" -f -c 1,0,0 $THUMB_OPTS "$fat_a" "$fat_a" \
137162          || exit
138    elif [ -f "$out/$next/$m.ppm" ]; then
163    elif [ -f "$b" ]; then
139164        s="$s<TD>"
140165        pngdiff cat "$diff" -f -c 0,1,0 "$b" "$b" || exit
141166        pngdiff shrink "$thumb" -f -c 0,1,0 $THUMB_OPTS "$fat_b" "$fat_b" \
...... 
144169        s="$s<TD>"
145170        continue
146171    fi
147    echo "$s" >>"$out/index.html"
172    echo "$s" >>"$index"
148173    s=
149174    empty=false
150    echo "<A href=\"diff_$next/$m.png\"><IMG src=\"thumb_$next/$m.png\"></A>" >>"$out/index.html"
175    echo "<A href=\"diff_$next/$m.png\"><IMG src=\"thumb_$next/$m.png\"></A>" >>"$index"
151176    done
152177    if ! $empty; then
153178    (
...... 
159184        echo "<PRE>"
160185        git log --pretty=short $n..$next
161186        echo "</PRE>"
162    ) >>"$out/index.html"
187    ) >>"$index"
163188    fi
164189    next=$n
165190done
166191
167echo "</TABLE>" >>"$out/index.html"
192echo "</TABLE>" >>"$index"
168193exit 1

Archive Download the corresponding diff file



interactive