diff options
author | Shaun McCance <shaunm@gnome.org> | 2015-06-17 23:56:42 -0400 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2015-06-17 23:56:42 -0400 |
commit | 52f6a118201328ab89b4acbfd5818d5592e2a57e (patch) | |
tree | e424959f62f33304d7caf10c0be9fee081bf59e7 | |
parent | fbd32f47e0217dbee34901ec7ea468146c26dc3c (diff) | |
download | yelp-tools-52f6a118201328ab89b4acbfd5818d5592e2a57e.tar.gz |
yelp-build: Mallard Sites support for cache
Probably won't gain Sites support for building HTML. Use a site tool
like Pintail for that. But being able to generate site-aware cache
means more of the yelp-check commands can be site-aware.
-rwxr-xr-x | tools/yelp-build.in | 60 |
1 files changed, 46 insertions, 14 deletions
diff --git a/tools/yelp-build.in b/tools/yelp-build.in index 9eda997..a0d4bea 100755 --- a/tools/yelp-build.in +++ b/tools/yelp-build.in @@ -107,6 +107,7 @@ yelp_usage_cache () { echo "" echo "Options:" echo " -o OUT Output cache to the file OUT" + echo " -s Treat pages as belonging to a Mallard site" ) 1>&2 } yelp_usage_epub () { @@ -151,29 +152,54 @@ yelp_paths_normalize () { done | tr '\n' ' ' } +yelp_cache_in_page () { + fbase=$(basename "$1") + fdir=$( (cd $(dirname "$1") && pwd) ) + sdir=${fdir##${cache_site_root}}/ + url=file://$(echo "$fdir/$fbase" | urlencode) + if [ "x$cache_site" = "x1" ]; then + siteattr=' site:dir="'"$sdir"'"' + fi + echo '<page cache:href="'"$url"'"'"$siteattr"'/>' +} + +yelp_cache_in_site () { + for dir in "$1"/*; do + if [ -d "$dir" ]; then + if [ $(basename "$dir") != "__pintail__" ]; then + yelp_cache_in_site "$dir" + fi + fi + done + for page in "$1"/*.page; do + if [ -e "$page" ]; then + yelp_cache_in_page "$page" + fi + done +} + yelp_cache_in () { echo '<cache:cache xmlns:cache="http://projectmallard.org/cache/1.0/"' + if [ "x$cache_site" = "x1" ]; then + echo ' xmlns:site="http://projectmallard.org/site/1.0/"' + fi echo ' xmlns="http://projectmallard.org/1.0/">' for page in "$@"; do if [ -d "$page" ]; then - for sub in "$page"/*.page; do - fbase=`basename "$sub"` - fdir=`dirname "$sub"` - fdir=`(cd "$fdir" && pwd)` - echo "$fdir/$fbase" - done + if [ "x$cache_site" = "x1" ]; then + yelp_cache_in_site "$page" + else + for sub in "$page"/*.page; do + yelp_cache_in_page "$sub" + done + fi else - fbase=`basename "$page"` - fdir=`dirname "$page"` - fdir=`(cd "$fdir" && pwd)` - echo "$fdir/$fbase" + yelp_cache_in_page "$page" fi - done | urlencode | - while read line; do - echo '<page cache:href="file://'"$line"'"/>' done echo '</cache:cache>' } + yelp_cache () { cache_out="index.cache" while [ "$#" != "0" ]; do @@ -183,6 +209,11 @@ yelp_cache () { cache_out="$1" shift ;; + "-s") + cache_site="1" + cache_site_root=$(pwd) + shift + ;; *) break ;; @@ -193,7 +224,8 @@ yelp_cache () { exit 1 fi yelp_cache_in "$@" | xsltproc --path "$html_paths" \ - --xinclude -o "$cache_out" "$xsl_mal_cache" - + --xinclude -o "$cache_out" \ + "$xsl_mal_cache" - } yelp_html_xsl_common () { |