Update cvs2git.html.
[cvs2svn.git] / www / validate.sh
blob2177d31f5b40349b14e8464e408cb4f3ec037848
1 #!/bin/bash -e
3 # If this script gives errors like
5 # warning: failed to load external entity "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
7 # and you happen to be using a Debian-derived version of Linux, it
8 # might help to run (as root)
10 # apt-get install w3c-dtd-xhtml
12 WWWDIR="`dirname \"$0\"`"
13 ensure ()
15 LOCALFILE="$WWWDIR/$2/`basename \"$1\"`"
16 test -f "$LOCALFILE" || wget -O "$LOCALFILE" "$1"
19 # Download files necessary to preview the web pages locally.
20 if [ ! -r "$WWWDIR/tigris-branding/.download-complete" ]; then
21 BRANDING_URL="http://cvs2svn.tigris.org/branding"
22 mkdir -p "$WWWDIR/tigris-branding/"{css,scripts,images}
23 for i in tigris inst print; do
24 ensure "$BRANDING_URL/css/$i.css" "tigris-branding/css"
25 done
26 ensure "$BRANDING_URL/scripts/tigris.js" "tigris-branding/scripts"
27 for f in `sed -n -e 's,.*url(\.\./images/\([^)]*\).*,\1,;tp' \
28 -etp -ed -e:p -ep $WWWDIR/tigris-branding/css/*.css`; do
29 case $f in
30 collapsed_big.gif|expanded_big.gif) ;; # 404!
31 *) ensure "$BRANDING_URL/images/$f" "tigris-branding/images" ;;
32 esac
33 done
34 touch "$WWWDIR/tigris-branding/.download-complete"
37 # Check we have DTDs available
38 LOCAL_CATALOG="$WWWDIR/xhtml1.catalog"
39 if [ ! -r "$LOCAL_CATALOG" ]; then
40 RESULT=`echo 'resolve "-//W3C//DTD XHTML 1.0 Strict//EN" ' \
41 '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"' | xmlcatalog --shell`
42 case $RESULT in
43 *file:///*)
44 # It looks like the system already provides this
47 ensure "http://www.w3.org/TR/xhtml1/xhtml1.tgz" "."
48 rm -rf "$WWWDIR/xhtml1-20020801" "$LOCAL_CATALOG"
49 tar -zxvf "$WWWDIR/xhtml1.tgz"
50 xmlcatalog --noout --create "$LOCAL_CATALOG"
51 xmlcatalog --noout --add rewriteSystem "http://www.w3.org/TR/xhtml1/" \
52 "`cd \"$WWWDIR\" && pwd`/xhtml1-20020801/" "$LOCAL_CATALOG"
54 esac
56 test -r "$LOCAL_CATALOG" && export XML_CATALOG_FILES="$LOCAL_CATALOG"
58 if [ $# -eq 0 ]; then echo "Usage: ./validate.sh <filename>..." >&2; exit 1; fi
59 if [ "$1" = "all" ]; then
60 set - "$WWWDIR"/*.html
62 if [ $# -eq 1 ]; then xmllint --nonet --noout --valid "$1"; exit $?; fi
64 for f in "$@"; do
65 case $f in
66 *project_tools.html) echo "$f: Skipped" ;;
67 *.html) xmllint --nonet --noout --valid "$f" && echo -e \
68 "$f: "'\033[32mvalid\033[0m' || echo -e "$f: "'\033[31;1mINVALID\033[0m' ;;
69 *) echo "$f: Not HTML" ;;
70 esac
71 done