[yelp-tools] yelp-build: Place generated files in yelp subdir in epub



commit 4e2d15aae9f6f9dac641cfebe4ada868b4c07611
Author: Shaun McCance <shaunm gnome org>
Date:   Sun May 15 19:48:51 2011 -0400

    yelp-build: Place generated files in yelp subdir in epub

 tools/yelp-build.in |   38 ++++++++++++++++++++++++++------------
 xslt/Makefile.am    |    1 +
 xslt/mal-epub.xsl   |    7 +++++++
 xslt/mal-opf.xsl.in |   31 +++++++++++++++++--------------
 4 files changed, 51 insertions(+), 26 deletions(-)
---
diff --git a/tools/yelp-build.in b/tools/yelp-build.in
index 0e94cb4..8f5f965 100755
--- a/tools/yelp-build.in
+++ b/tools/yelp-build.in
@@ -23,6 +23,7 @@ xsl_mal2html='@XSL_MAL2HTML@'
 xsl_mal2xhtml='@XSL_MAL2XHTML@'
 yelp_icon_dir='@YELP_ICON_DIR@'
 yelp_js_dir='@YELP_JS_DIR@'
+xsl_mal_epub='@DATADIR@/xslt/mal-epub.xsl'
 xsl_mal_opf='@DATADIR@/xslt/mal-opf.xsl'
 xsl_mal_ncx='@DATADIR@/xslt/mal-ncx.xsl'
 
@@ -178,6 +179,16 @@ yelp_cache () {
 }
 
 yelp_html_xsl_common () {
+    if [ "x$html_internal_datadir" != "x" ]; then
+        echo '<xsl:variable name="yelp.internal.datadir" select="'"'$html_internal_datadir'"'"/>'
+        echo '<xsl:param name="html.css.root" select="$yelp.internal.datadir"/>'
+        echo '<xsl:param name="html.js.root" select="$yelp.internal.datadir"/>'
+    else
+        echo '<xsl:variable name="yelp.internal.datadir" select="'"''"'"/>'
+    fi
+    if [ "x$html_internal_xsl" != "x" ]; then
+        echo '<xsl:include href="file://'`urlencode "$html_internal_xsl"`'"/>'
+    fi
     if [ "x$html_custom" != "x" ]; then
         echo '<xsl:include href="file://'`urlencode "$html_custom"`'"/>'
     fi
@@ -193,7 +204,7 @@ yelp_html_xsl_common () {
     echo '</xsl:variable>'
     echo '<xsl:template name="html.css">'
     echo ' <xsl:param name="node" select="."/>'
-    echo ' <exsl:document href="{$yelp.locale}.css" method="text">'
+    echo ' <exsl:document href="{$yelp.internal.datadir}{$yelp.locale}.css" method="text">'
     echo '  <xsl:call-template name="html.css.content">'
     echo '   <xsl:with-param name="node" select="$node"/>'
     echo '  </xsl:call-template>'
@@ -205,7 +216,7 @@ yelp_html_xsl_common () {
     echo ' <xsl:call-template name="html.js.jquery">'
     echo '  <xsl:with-param name="node" select="$node"/>'
     echo ' </xsl:call-template>'
-    echo ' <exsl:document href="yelp.js" method="text">'
+    echo ' <exsl:document href="{$yelp.internal.datadir}yelp.js" method="text">'
     echo '  <xsl:call-template name="html.js.content">'
     echo '   <xsl:with-param name="node" select="$node"/>'
     echo '  </xsl:call-template>'
@@ -286,11 +297,11 @@ yelp_html_db2html () {
             echo '</xsl:template>'
             echo '</xsl:stylesheet>'
         ) | xsltproc --xinclude - "$xml" | sort | uniq | while read icon; do
-            cp "${yelp_icon_dir}/${icon}.png" "$html_out"
+            cp "${yelp_icon_dir}/${icon}.png" "$html_out/$html_internal_datadir"
         done;
         # Copy jQuery
-        cp "${yelp_js_dir}/jquery.js" "$html_out"
-        cp "${yelp_js_dir}/jquery.syntax.js" "$html_out"
+        cp "${yelp_js_dir}/jquery.js" "$html_out/$html_internal_datadir"
+        cp "${yelp_js_dir}/jquery.syntax.js" "$html_out/$html_internal_datadir"
         (
             echo '<xsl:stylesheet'
             echo ' xmlns:xsl="http://www.w3.org/1999/XSL/Transform";'
@@ -316,7 +327,7 @@ yelp_html_db2html () {
         ) | xsltproc --xinclude - "$xml" | sort | uniq \
             | grep '^contents syntax ' | sed -e 's/^contents syntax brush-/brush./' \
             | while read js; do
-            cp "${yelp_js_dir}/jquery.syntax.${js}.js" "$html_out"
+            cp "${yelp_js_dir}/jquery.syntax.${js}.js" "$html_out/$html_internal_datadir"
         done
     done
 }
@@ -404,11 +415,11 @@ yelp_html_page2html () {
         echo '</xsl:template>'
         echo '</xsl:stylesheet>'
     ) | xsltproc --xinclude - "$xml" | sort | uniq | while read icon; do
-        cp "${yelp_icon_dir}/${icon}.png" "$html_out"
+        cp "${yelp_icon_dir}/${icon}.png" "$html_out/$html_internal_datadir"
     done;
     # Copy jQuery
-    cp "${yelp_js_dir}/jquery.js" "$html_out"
-    cp "${yelp_js_dir}/jquery.syntax.js" "$html_out"
+    cp "${yelp_js_dir}/jquery.js" "$html_out/$html_internal_datadir"
+    cp "${yelp_js_dir}/jquery.syntax.js" "$html_out/$html_internal_datadir"
     (
         echo '<xsl:stylesheet'
         echo ' xmlns:xsl="http://www.w3.org/1999/XSL/Transform";'
@@ -434,7 +445,7 @@ yelp_html_page2html () {
     ) | xsltproc --xinclude - "$xml" | sort | uniq \
         | grep '^contents syntax ' | sed -e 's/^contents syntax brush-/brush./' \
         | while read js; do
-        cp "${yelp_js_dir}/jquery.syntax.${js}.js" "$html_out"
+        cp "${yelp_js_dir}/jquery.syntax.${js}.js" "$html_out/$html_internal_datadir"
     done
 }
 
@@ -541,14 +552,17 @@ yelp_epub () {
     epub_data_out=`mktemp -d`
     html_out="$epub_data_out/OPS"
     mkdir "$html_out"
+    mkdir "$html_out/yelp"
+    html_internal_datadir="yelp/"
+    html_internal_xsl="$xsl_mal_epub"
     yelp_html_mal2html "$@"
 
     epub_id=`uuidgen`
-    epub_icons=`(cd "$html_out" && ls yelp-*.png)`
+    epub_data=`(cd "$html_out" && ls yelp/*.*)`
     xsltproc \
         -o "$html_out/opf.opf" \
         --stringparam opf.id "$epub_id" \
-        --stringparam opf.icons "$epub_icons" \
+        --stringparam opf.data "$epub_data" \
         "$xsl_mal_opf" "$epub_cache_file"
     xsltproc \
         -o "$html_out/ncx.ncx" \
diff --git a/xslt/Makefile.am b/xslt/Makefile.am
index 4edcc83..de4eee2 100644
--- a/xslt/Makefile.am
+++ b/xslt/Makefile.am
@@ -1,6 +1,7 @@
 xsldir=$(datadir)/yelp-tools/xslt
 
 xsl_DATA =		\
+	mal-epub.xsl	\
 	mal-opf.xsl	\
 	mal-ncx.xsl	\
 	mal-rng.xsl
diff --git a/xslt/mal-epub.xsl b/xslt/mal-epub.xsl
new file mode 100644
index 0000000..2a585bb
--- /dev/null
+++ b/xslt/mal-epub.xsl
@@ -0,0 +1,7 @@
+<xsl:stylesheet
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+    xmlns:mal="http://projectmallard.org/1.0/";
+    exclude-result-prefixes="mal"
+    version="1.0">
+
+</xsl:stylesheet>
diff --git a/xslt/mal-opf.xsl.in b/xslt/mal-opf.xsl.in
index c6ab921..b56b524 100644
--- a/xslt/mal-opf.xsl.in
+++ b/xslt/mal-opf.xsl.in
@@ -11,7 +11,7 @@
     version="1.0">
 
 <xsl:param name="opf.id"/>
-<xsl:param name="opf.icons"/>
+<xsl:param name="opf.data"/>
 
 <xsl:include href="file://@XSL_MAL_LINK@"/>
 <xsl:include href="file://@XSL_MAL_SORT@"/>
@@ -90,19 +90,22 @@
     <manifest>
       <item id="ncx" href="ncx.ncx" media-type="application/x-dtbncx+xml"/>
 
-      <xsl:for-each select="mal:page/@xml:lang[not(. = ../preceding-sibling::mal:page/@xml:lang)]">
-        <item id="stylesheet-{.}.css" href="{.}.css" media-type="text/css"/>
-      </xsl:for-each>
-      <xsl:if test="mal:page[not(@xml:lang)] and not(mal:page[ xml:lang = 'C'])">
-        <item id="stylesheet-C.css" href="C.css" media-type="text/css"/>
-      </xsl:if>
-
-      <item id="data-jquery.js" href="jquery.js" media-type="text/javascript"/>
-      <item id="data-jquery.syntax.js" href="jquery.syntax.js" media-type="text/javascript"/>
-      <item id="data-yelp.js" href="yelp.js" media-type="text/javascript"/>
-
-      <xsl:for-each select="str:split(normalize-space($opf.icons))">
-        <item id="data-{.}" href="{.}" media-type="image/png"/>
+      <xsl:for-each select="str:split(normalize-space($opf.data))">
+        <item id="data-{.}" href="{.}">
+          <xsl:attribute name="media-type">
+            <xsl:choose>
+              <xsl:when test="substring(., string-length(.) - 3) = '.png'">
+                <xsl:text>image/png</xsl:text>
+              </xsl:when>
+              <xsl:when test="substring(., string-length(.) - 3) = '.css'">
+                <xsl:text>text/css</xsl:text>
+              </xsl:when>
+              <xsl:when test="substring(., string-length(.) - 2) = '.js'">
+                <xsl:text>text/javascript</xsl:text>
+              </xsl:when>
+            </xsl:choose>
+          </xsl:attribute>
+        </item>
       </xsl:for-each>
 
       <xsl:variable name="media">



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