[yelp-tools] [tools/yelp-build.in] Adding yelp-build, just "cache" for now



commit 392626dc711dc0d885f1a909ebd224b7487d9f8a
Author: Shaun McCance <shaunm gnome org>
Date:   Wed Dec 22 17:09:04 2010 -0500

    [tools/yelp-build.in] Adding yelp-build, just "cache" for now

 .gitignore          |    2 +
 configure.ac        |    2 +-
 tools/Makefile.am   |    4 +-
 tools/yelp-build.in |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/yelp-cache.in |   36 -----------------------
 5 files changed, 83 insertions(+), 39 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 55fd8a0..c284cc4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,5 @@ intltool-merge.in
 intltool-update.in
 missing
 py-compile
+tools/yelp-build
+tools/yelp-new
diff --git a/configure.ac b/configure.ac
index b1860c4..44ad4ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,7 +43,7 @@ AC_CONFIG_FILES([
 Makefile
 templates/Makefile
 tools/Makefile
-tools/yelp-cache
+tools/yelp-build
 tools/yelp-new
 xml2po/Makefile
 xml2po/xml2po.pc
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 4e99986..3d48378 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,6 +1,6 @@
 aclocaldir = $(datadir)/aclocal
 aclocal_DATA = yelp.m4
 
-bin_SCRIPTS = yelp-cache yelp-new
+bin_SCRIPTS = yelp-build yelp-new
 
-EXTRA_DIST = yelp-cache.in yelp-new.in $(aclocal_DATA)
+EXTRA_DIST = yelp-build.in yelp-new.in $(aclocal_DATA)
diff --git a/tools/yelp-build.in b/tools/yelp-build.in
new file mode 100755
index 0000000..3cb16af
--- /dev/null
+++ b/tools/yelp-build.in
@@ -0,0 +1,78 @@
+#!/bin/sh
+# yelp-cache - Create a Mallard cache file
+# Copyright (C) 2010 Shaun McCance <shaunm gnome org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+xsl_mal_cache='@XSL_MAL_CACHE@'
+
+urlencode () {
+    echo "$1" | LANG=C awk '
+BEGIN {
+  for (i = 1; i <= 255; i++) chars[sprintf("%c", i)] = i;
+}
+{
+  ret = "";
+  for (i = 1; i <= length($0); i++) {
+    c = substr($0, i, 1);
+    if (c ~ /[\/a-zA-Z0-9._-]/)
+      ret = ret c;
+    else
+      ret = ret sprintf("%%%X%X", int(chars[c] / 16), chars[c] % 16);
+  }
+  print ret;
+}'
+}
+
+yelp_usage () {
+    echo "Usage: yelp-build <COMMAND> [OPTIONS] [FILES]"
+    echo ""
+    echo "Commands:"
+    echo "  cache - Create a Mallard cache file"
+}
+
+if [ $# = 0 ]; then
+    yelp_usage
+    exit 1
+fi
+
+yelp_cache_ls () {
+    fbase=`basename "$1"`
+    fdir=`dirname "$1"`
+    fdir=`(cd "$fdir" && pwd)`
+    echo '<page cache:href="file://'`urlencode "$fdir/$fbase"`'"/>'
+}
+yelp_cache () {
+    (
+        echo '<cache:cache xmlns:cache="http://projectmallard.org/cache/1.0/";'
+        echo '  xmlns="http://projectmallard.org/1.0/";>'
+        for page in "$@"; do
+            if [ -d "$page" ]; then
+                for sub in "$page"/*.page; do
+                    yelp_cache_ls "$sub"
+                done
+            else
+                yelp_cache_ls "$page"
+            fi
+        done
+        echo '</cache:cache>'
+    ) | xsltproc "$xsl_mal_cache" -
+}
+
+cmd="$1"
+shift
+if [ "x$cmd" = "xcache" ]; then
+    yelp_cache "$@"
+fi



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]