Fix the expansion of the $Source$ keyword.
[cvs2svn.git] / www / validate.sh
blob0364c84ef3bdea77ef3b5bb0cd6fa17339c1abc1
1 #!/bin/bash -e
3 WWWDIR="`dirname \"$0\"`"
4 ensure ()
6 LOCALFILE="$WWWDIR/$2/`basename \"$1\"`"
7 test -f "$LOCALFILE" || wget -O "$LOCALFILE" "$1"
10 # Download files necessary to preview the web pages locally.
11 if [ ! -r "$WWWDIR/tigris-branding/.download-complete" ]; then
12 BRANDING_URL="http://cvs2svn.tigris.org/branding"
13 mkdir -p "$WWWDIR/tigris-branding/"{css,scripts,images}
14 for i in tigris inst print; do
15 ensure "$BRANDING_URL/css/$i.css" "tigris-branding/css"
16 done
17 ensure "$BRANDING_URL/scripts/tigris.js" "tigris-branding/scripts"
18 for f in `sed -n -e 's,.*url(\.\./images/\([^)]*\).*,\1,;tp' \
19 -etp -ed -e:p -ep $WWWDIR/tigris-branding/css/*.css`; do
20 case $f in
21 collapsed_big.gif|expanded_big.gif) ;; # 404!
22 *) ensure "$BRANDING_URL/images/$f" "tigris-branding/images" ;;
23 esac
24 done
25 touch "$WWWDIR/tigris-branding/.download-complete"
28 # Check we have DTDs available
29 LOCAL_CATALOG="$WWWDIR/xhtml1.catalog"
30 if [ ! -r "$LOCAL_CATALOG" ]; then
31 RESULT=`echo 'resolve "-//W3C//DTD XHTML 1.0 Strict//EN" ' \
32 '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"' | xmlcatalog --shell`
33 case $RESULT in
34 *file:///*)
35 # It looks like the system already provides this
38 ensure "http://www.w3.org/TR/xhtml1/xhtml1.tgz" "."
39 rm -rf "$WWWDIR/xhtml1-20020801" "$LOCAL_CATALOG"
40 tar -zxvf "$WWWDIR/xhtml1.tgz"
41 xmlcatalog --noout --create "$LOCAL_CATALOG"
42 xmlcatalog --noout --add rewriteSystem "http://www.w3.org/TR/xhtml1/" \
43 "`cd \"$WWWDIR\" && pwd`/xhtml1-20020801/" "$LOCAL_CATALOG"
45 esac
47 test -r "$LOCAL_CATALOG" && export XML_CATALOG_FILES="$LOCAL_CATALOG"
49 if [ $# -eq 0 ]; then echo "Usage: ./validate.sh <filename>..." >&2; exit 1; fi
50 if [ "$1" = "all" ]; then
51 set - "$WWWDIR"/*.html
53 if [ $# -eq 1 ]; then xmllint --nonet --noout --valid "$1"; exit $?; fi
55 for f in "$@"; do
56 case $f in
57 *project_tools.html) echo "$f: Skipped" ;;
58 *.html) xmllint --nonet --noout --valid "$f" && echo -e \
59 "$f: "'\033[32mvalid\033[0m' || echo -e "$f: "'\033[31;1mINVALID\033[0m' ;;
60 *) echo "$f: Not HTML" ;;
61 esac
62 done