summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/yelp-check.in96
1 files changed, 64 insertions, 32 deletions
diff --git a/tools/yelp-check.in b/tools/yelp-check.in
index 64452fa..48ae013 100755
--- a/tools/yelp-check.in
+++ b/tools/yelp-check.in
@@ -163,6 +163,9 @@ yelp_usage_media () {
echo " Find broken references to media files. In Mallard, this"
echo " checks media and thumb elements. In DocBook, this checks"
echo " audiodata, imagedata, and videodata elements."
+ echo ""
+ echo "Options:"
+ echo " -s Treat pages as belonging to a Mallard site"
) 1>&2
}
yelp_usage_orphans () {
@@ -362,11 +365,13 @@ yelp_hrefs () {
check_db=yelp_hrefs_page
check_page=yelp_hrefs_page
yelp_check_iter_args "$@" > "$check_out_file"
- ret=$(cat "$check_out_file" | wc -l)
- if test "x$ret" != "x0"; then ret="1"; fi
+ yelp_check_retval=$(wc -l < "$check_out_file")
+ if test "x$yelp_check_retval" != "x0"; then
+ yelp_check_retval=1
+ fi
cat "$check_out_file"
rm "$check_out_file"
- exit $ret
+ exit $yelp_check_retval
}
yelp_ids_page () {
@@ -541,28 +546,41 @@ yelp_links () {
fi
fi
done > "$check_out_file"
- ret=`cat "$check_out_file" | wc -l`
- if test "x$ret" != "x0"; then ret="1"; fi
+ yelp_check_retval=$(wc -l < "$check_out_file")
+ if test "x$yelp_check_retval" != "x0"; then
+ yelp_check_retval=1
+ fi
cat "$check_out_file"
+ rm "$check_out_file"
if [ "x$check_cache_file_is_tmp" = "xyes" ]; then
rm "$check_cache_file"
fi
- rm "$check_out_file"
- exit $ret
+ exit $yelp_check_retval
}
yelp_media_page () {
- ext=`echo "$1" | sed -e 's/.*\.//'`
- bname=`basename "$1" ".$ext"`
- dname=$(dirname "$xml")
- if [ x"$dname" = "." ]; then
+ ext=$(echo "$1" | sed -e 's/.*\.//')
+ bname=$(basename "$1" ".$ext")
+ dname=$(dirname "$1")
+ if [ "x$dname" = "x." ]; then
dname=""
else
dname="$dname"/
fi;
- xsltproc --stringparam basename "$bname" \
- --stringparam dirname "$dname" \
- "$xsl_media" "$1"
+ if [ "x$check_site" = "x1" ]; then
+ sdir=$(cd "$dname" && pwd)
+ sdir=${sdir##${check_site_root}}/
+ else
+ sdir="$dname"
+ fi
+ xsltproc "$xsl_media" "$1" | \
+ sort | uniq | \
+ while read line; do
+ src=$(urldecode "$line")
+ if [ ! -f "$dname$src" ]; then
+ echo "$sdir$bname: $line"
+ fi
+ done
}
yelp_media () {
@@ -570,21 +588,33 @@ yelp_media () {
yelp_usage_media
exit 1
fi
- for xml in "$@"; do
- if [ -d "$xml" ]; then
- for page in "$xml"/*.page; do
- yelp_media_page "$page"
- done
- else
- yelp_media_page "$xml"
- fi
- done | while read line; do
- dname=$(dirname $(echo "$line" | cut -d' ' -f1))
- src=$(urldecode $(echo "$line" | cut -d' ' -f2))
- if [ ! -f "$dname"/"$src" ]; then
- echo $line
- fi
+ while [ "$#" != "0" ]; do
+ case "$1" in
+ "-s")
+ check_site="1"
+ check_site_root=$(pwd)
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
done
+ if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
+ yelp_usage_media
+ exit 1
+ fi
+ check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
+ check_db=yelp_media_page
+ check_page=yelp_media_page
+ yelp_check_iter_args "$@" > "$check_out_file"
+ yelp_check_retval=$(wc -l < "$check_out_file")
+ if test "x$yelp_check_retval" != "x0"; then
+ yelp_check_retval=1
+ fi
+ cat "$check_out_file"
+ rm "$check_out_file"
+ exit $yelp_check_retval
}
yelp_orphans_page () {
@@ -651,14 +681,16 @@ yelp_orphans () {
yelp_orphans_page "$xml"
fi
done > "$check_out_file"
- ret=`cat "$check_out_file" | wc -l`
- if test "x$ret" != "x0"; then ret="1"; fi
+ yelp_check_retval=$(wc -l < "$check_out_file")
+ if test "x$yelp_check_retval" != "x0"; then
+ yelp_check_retval=1
+ fi
cat "$check_out_file"
+ rm "$check_out_file"
if [ "x$check_cache_file_is_tmp" = "xyes" ]; then
rm "$check_cache_file"
fi
- rm "$check_out_file"
- exit $ret
+ exit $yelp_check_retval
}
yelp_comments_page () {