* subversion/libsvn_repos/repos.c
[svn.git] / www / validate.sh
blobf32af614468177d9fc0f4c8c55365bf7c943a630
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/branding/.download-complete" ]; then
12 BRANDING_URL="http://subversion.tigris.org/branding"
13 mkdir -p "$WWWDIR/branding/"{css,scripts,images}
14 for i in tigris inst print; do
15 ensure "$BRANDING_URL/css/$i.css" "branding/css"
16 done
17 ensure "$BRANDING_URL/scripts/tigris.js" "branding/scripts"
18 for f in `sed -n -e 's,.*url(\.\./images/\([^)]*\).*,\1,;tp' \
19 -etp -ed -e:p -ep $WWWDIR/branding/css/*.css`; do
20 case $f in
21 collapsed_big.gif|expanded_big.gif) ;; # 404!
22 *) ensure "$BRANDING_URL/images/$f" "branding/images" ;;
23 esac
24 done
25 touch "$WWWDIR/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 "$WWWDIR"/merge-tracking/*.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