[yelp-tools] yelp-check: Added check for missing media files
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp-tools] yelp-check: Added check for missing media files
- Date: Sun, 2 Feb 2014 19:02:46 +0000 (UTC)
commit ddee793ab2f2ff7366ef2bdde79ebb44e2395b55
Author: Shaun McCance <shaunm gnome org>
Date: Sun Feb 2 14:02:24 2014 -0500
yelp-check: Added check for missing media files
tools/yelp-check.in | 43 ++++++++++++++++++++++++++++++++++++++++++-
xslt/Makefile.am | 3 ++-
xslt/media.xsl | 44 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 88 insertions(+), 2 deletions(-)
---
diff --git a/tools/yelp-check.in b/tools/yelp-check.in
index 05531a6..d1fe831 100755
--- a/tools/yelp-check.in
+++ b/tools/yelp-check.in
@@ -21,6 +21,7 @@ xsl_mal_license='@DATADIR@/xslt/mal-license.xsl'
xsl_mal_status='@DATADIR@/xslt/mal-status.xsl'
xsl_mal_rng='@DATADIR@/xslt/mal-rng.xsl'
xsl_comments='@DATADIR@/xslt/comments.xsl'
+xsl_media='@DATADIR@/xslt/media.xsl'
urlencode () {
# We usually don't want to urlencode slashes, because we're
@@ -111,6 +112,7 @@ yelp_usage () {
echo " ids Find Mallard page IDs that do not match file names"
echo " license Report the license of Mallard pages"
echo " links Find broken xref or linkend links in a document"
+ echo " media Find broken references to media files"
echo " orphans Find orphaned pages in a Mallard document"
echo " status Report the status of Mallard pages"
echo " validate Validate files against a DTD or RNG"
@@ -144,6 +146,15 @@ yelp_usage_links () {
echo " -i Ignore xrefs where href is present"
) 1>&2
}
+yelp_usage_media () {
+ (
+ echo "Usage: yelp-check media <FILES>"
+ echo ""
+ 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."
+ ) 1>&2
+}
yelp_usage_orphans () {
(
echo "Usage: yelp-check orphans <FILES>"
@@ -169,7 +180,7 @@ yelp_usage_license () {
echo "Usage: yelp-check license <FILES>"
echo ""
echo " Report the license of the Mallard page files FILES. Each"
- echo " matching page is reporting along with its status, reported"
+ echo " matching page is reporting along with its license, reported"
echo " based on the href attribute of the license element. Common"
echo " licenses use a shortened identifier. Pages with multiple"
echo " licenses have the identifiers separated by spaces. Pages"
@@ -462,6 +473,33 @@ yelp_links () {
exit $ret
}
+yelp_media_page () {
+ ext=`echo "$1" | sed -e 's/.*\.//'`
+ bname=`basename "$1" ".$ext"`
+ xsltproc --stringparam basename "$bname" "$xsl_media" "$1"
+}
+
+yelp_media () {
+ if [ "$#" = "0" -o "x$1" = "x--help" ]; then
+ 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
+ src=$(urldecode $(echo "$line" | cut -d' ' -f2))
+ if [ ! -f "$src" ]; then
+ echo $line
+ fi
+ done
+}
+
yelp_orphans_page () {
(
echo '<xsl:stylesheet'
@@ -812,6 +850,9 @@ case "x$cmd" in
"xlicense")
yelp_license "$@"
;;
+ "xmedia")
+ yelp_media "$@"
+ ;;
"xstatus")
yelp_status "$@"
;;
diff --git a/xslt/Makefile.am b/xslt/Makefile.am
index d2dc1e3..f4e62af 100644
--- a/xslt/Makefile.am
+++ b/xslt/Makefile.am
@@ -8,7 +8,8 @@ xsl_DATA = \
mal-license.xsl \
mal-ncx.xsl \
mal-status.xsl \
- mal-rng.xsl
+ mal-rng.xsl \
+ media.xsl
EXTRA_DIST = \
mal-ncx.xsl.in \
diff --git a/xslt/media.xsl b/xslt/media.xsl
new file mode 100644
index 0000000..3b6d7e6
--- /dev/null
+++ b/xslt/media.xsl
@@ -0,0 +1,44 @@
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:mal="http://projectmallard.org/1.0/"
+ xmlns:ui="http://projectmallard.org/ui/1.0/"
+ xmlns:uix="http://projectmallard.org/experimental/ui/"
+ xmlns:db="http://docbook.org/ns/docbook"
+ version="1.0">
+
+<xsl:output method="text"/>
+
+<xsl:param name="basename"/>
+
+<xsl:template match="/*[namespace-uri(.) = ''] | /db:*">
+ <xsl:for-each select="
+ //audiodata | //imagedata | //videodata |
+ //db:audiodata | //db:imagedata | //db:videodata">
+ <xsl:variable name="src">
+ <xsl:choose>
+ <xsl:when test="@fileref">
+ <xsl:value-of select="@fileref"/>
+ </xsl:when>
+ <xsl:when test="@entityref">
+ <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:value-of select="$basename"/>
+ <xsl:text>: </xsl:text>
+ <xsl:value-of select="$src"/>
+ <xsl:text>
</xsl:text>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match="/mal:page">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:for-each select="//mal:media | //uix:thumb | //ui:thumb">
+ <xsl:value-of select="$id"/>
+ <xsl:text>: </xsl:text>
+ <xsl:value-of select="@src"/>
+ <xsl:text>
</xsl:text>
+ </xsl:for-each>
+</xsl:template>
+
+</xsl:stylesheet>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]