Make the --svnadmin option compatible with the --options option.
[cvs2svn.git] / www / validate.sh
blobb71d9007649ee8d20b31e6f2f0657b4e0abe88df
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 */xhtml1-strict.dtd*) ;;
36 ensure "http://www.w3.org/TR/xhtml1/xhtml1.tgz" "."
37 rm -rf "$WWWDIR/xhtml1-20020801" "$LOCAL_CATALOG"
38 tar -zxvf "$WWWDIR/xhtml1.tgz"
39 xmlcatalog --noout --create "$LOCAL_CATALOG"
40 xmlcatalog --noout --add rewriteSystem "http://www.w3.org/TR/xhtml1/" \
41 "`cd \"$WWWDIR\" && pwd`/xhtml1-20020801/" "$LOCAL_CATALOG"
43 esac
45 test -r "$LOCAL_CATALOG" && export XML_CATALOG_FILES="$LOCAL_CATALOG"
47 if [ $# -eq 0 ]; then echo "Usage: ./validate.sh <filename>..." >&2; exit 1; fi
48 if [ "$1" = "all" ]; then
49 set - "$WWWDIR"/*.html
51 if [ $# -eq 1 ]; then xmllint --nonet --noout --valid "$1"; exit $?; fi
53 for f in "$@"; do
54 case $f in
55 *project_tools.html) echo "$f: Skipped" ;;
56 *.html) xmllint --nonet --noout --valid "$f" && echo -e \
57 "$f: "'\033[32mvalid\033[0m' || echo -e "$f: "'\033[31;1mINVALID\033[0m' ;;
58 *) echo "$f: Not HTML" ;;
59 esac
60 done