diff options
-rwxr-xr-x | tools/yelp-build.in | 98 | ||||
-rw-r--r-- | xslt/Makefile.am | 1 | ||||
-rw-r--r-- | xslt/mal-files.xsl | 249 |
3 files changed, 261 insertions, 87 deletions
diff --git a/tools/yelp-build.in b/tools/yelp-build.in index ce24f87..b76349c 100755 --- a/tools/yelp-build.in +++ b/tools/yelp-build.in @@ -26,6 +26,7 @@ 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' +xsl_mal_files='@DATADIR@/xslt/mal-files.xsl' mkdir_p () { if [ ! -d "$1" ]; then @@ -375,99 +376,27 @@ yelp_html_mal2html () { xsl='file://'`echo "$xsl_mal2html" | urlencode` fi echo '<xsl:import href="'"$xsl"'"/>' + echo '<xsl:include href="'"$xsl_mal_files"'"/>' + echo '<xsl:output method="text"/>' yelp_html_xsl_common html_cache_url='file://'`echo "$html_cache_file" | urlencode` echo '<xsl:param name="mal.cache.file" select="'"'$html_cache_url'"'"/>' echo '<xsl:template match="/">' echo '<xsl:for-each select="cache:cache/mal:page">' + echo '<xsl:variable name="href" select="@cache:href"/>' echo '<xsl:for-each select="document(@cache:href)/mal:page">' echo '<xsl:call-template name="html.output"/>' + echo '<xsl:call-template name="mal.files.copy">' + echo ' <xsl:with-param name="href" select="substring-after($href, '\''file://'\'')"/>' + echo '</xsl:call-template>' echo '</xsl:for-each>' echo '</xsl:for-each>' echo '</xsl:template>' echo '</xsl:stylesheet>' - ) | xsltproc $html_profile --xinclude -o "$html_out"/ - "$html_tmp_infile" - ( - echo '<xsl:stylesheet' - echo ' xmlns:xsl="http://www.w3.org/1999/XSL/Transform"' - echo ' xmlns:mal="http://projectmallard.org/1.0/"' - echo ' xmlns:cache="http://projectmallard.org/cache/1.0/"' - echo ' xmlns:e="http://projectmallard.org/experimental/"' - echo ' xmlns:exsl="http://exslt.org/common"' - echo ' xmlns:html="http://www.w3.org/1999/xhtml"' - echo ' extension-element-prefixes="exsl"' - echo ' version="1.0">' - xsl='file://'`echo "$xsl_mal2xhtml" | urlencode` - echo '<xsl:import href="'"$xsl"'"/>' - echo '<xsl:output method="text"/>' - echo '<xsl:template name="dirname">' - echo ' <xsl:param name="str"/>' - echo ' <xsl:if test="contains($str, '\''/'\'')">' - echo ' <xsl:value-of select="substring-before($str, '\''/'\'')"/>' - echo ' <xsl:text>/</xsl:text>' - echo ' <xsl:call-template name="dirname">' - echo ' <xsl:with-param name="str" select="substring-after($str, '\''/'\'')"/>' - echo ' </xsl:call-template>' - echo ' </xsl:if>' - echo '</xsl:template>' - echo '<xsl:template match="/">' - echo '<xsl:for-each select="cache:cache/mal:page">' - echo ' <xsl:variable name="dir">' - echo ' <xsl:call-template name="dirname">' - echo ' <xsl:with-param name="str" select="substring-after(@cache:href, '\''file://'\'')"/>' - echo ' </xsl:call-template>' - echo ' </xsl:variable>' - echo ' <xsl:variable name="node" select="document(@cache:href)/mal:page"/>' - # Media - echo ' <xsl:for-each select="$node//mal:media | $node//e:mouseover">' - echo ' <xsl:if test="not(contains(@src, '\'':'\''))">' - echo ' <xsl:value-of select="concat('"'-'"', $dir, @src, '"' '"')"/>' - echo ' <xsl:value-of select="concat(@src, '"'
'"')"/>' - echo ' </xsl:if>' - echo ' </xsl:for-each>' - # Syntax highlighting - echo ' <xsl:for-each select="$node//mal:code[@mime]">' - echo ' <xsl:variable name="out">' - echo ' <xsl:call-template name="mal2html.pre"/>' - echo ' </xsl:variable>' - echo ' <xsl:variable name="class">' - echo ' <xsl:value-of select="exsl:node-set($out)/*/html:pre[last()]/@class"/>' - echo ' </xsl:variable>' - echo ' <xsl:if test="starts-with($class, '\''contents syntax brush-'\'')">' - echo ' <xsl:text>+'"${yelp_js_dir}"'/jquery.syntax.brush.</xsl:text>' - echo ' <xsl:value-of select="substring-after($class, '\''contents syntax brush-'\'')"/>' - echo ' <xsl:text>.js ./
</xsl:text>' - echo ' </xsl:if>' - echo ' </xsl:for-each>' - # Icons - echo ' <xsl:for-each select="$node//mal:note">' - echo ' <xsl:variable name="style" select="concat('\'' '\'', @style, '\'' '\'')"/>' - echo ' <xsl:choose>' - # echo ' <xsl:when test="contains($style, '\'' advanced '\'')">' - # echo ' <xsl:text>+'"${yelp_icon_dir}"'/yelp-note-advanced.png ./
</xsl:text>' - # echo ' </xsl:when>' - echo ' <xsl:when test="contains($style, '\'' bug '\'')">' - echo ' <xsl:text>+'"${yelp_icon_dir}"'/yelp-note-bug.png ./
</xsl:text>' - echo ' </xsl:when>' - echo ' <xsl:when test="contains($style, '\'' important '\'')">' - echo ' <xsl:text>+'"${yelp_icon_dir}"'/yelp-note-important.png ./
</xsl:text>' - echo ' </xsl:when>' - echo ' <xsl:when test="contains($style, '\'' sidebar '\'')"/>' - echo ' <xsl:when test="contains($style, '\'' tip '\'')">' - echo ' <xsl:text>+'"${yelp_icon_dir}"'/yelp-note-tip.png ./
</xsl:text>' - echo ' </xsl:when>' - echo ' <xsl:when test="contains($style, '\'' warning '\'')">' - echo ' <xsl:text>+'"${yelp_icon_dir}"'/yelp-note-warning.png ./
</xsl:text>' - echo ' </xsl:when>' - echo ' <xsl:otherwise>' - echo ' <xsl:text>+'"${yelp_icon_dir}"'/yelp-note.png ./
</xsl:text>' - echo ' </xsl:otherwise>' - echo ' </xsl:choose>' - echo ' </xsl:for-each>' - echo '</xsl:for-each>' - echo '</xsl:template>' - echo '</xsl:stylesheet>' - ) | xsltproc --xinclude - "$html_tmp_infile" | sort | uniq | + ) | (cd "$html_out" && xsltproc $html_profile --xinclude \ + --stringparam mal.files.copy.icon.dir "$yelp_icon_dir" \ + --stringparam mal.files.copy.js.dir "$yelp_js_dir" \ + - "$html_tmp_infile") | sort | uniq | \ while read line; do use_internal_datadir=`expr substr "$line" 1 1` line=`expr substr "$line" 2 1000` @@ -485,11 +414,6 @@ yelp_html_mal2html () { cp "$line_src" "$line_dest" fi done - cp "${yelp_js_dir}/jquery.js" "$html_out/$html_internal_datadir" - cp "${yelp_js_dir}/jquery.syntax.js" "$html_out/$html_internal_datadir" - cp "${yelp_js_dir}/jquery.syntax.core.js" "$html_out/$html_internal_datadir" - cp "${yelp_js_dir}/jquery.syntax.layout.yelp.js" "$html_out/$html_internal_datadir" - rm "$html_tmp_infile" if [ "x$html_cache_file_is_tmp" = "xyes" ]; then rm "$html_cache_file" diff --git a/xslt/Makefile.am b/xslt/Makefile.am index 2c26e6d..5dd0ef4 100644 --- a/xslt/Makefile.am +++ b/xslt/Makefile.am @@ -4,6 +4,7 @@ xsl_DATA = \ comments.xsl \ mal-epub.xsl \ mal-opf.xsl \ + mal-files.xsl \ mal-ncx.xsl \ mal-status.xsl \ mal-rng.xsl diff --git a/xslt/mal-files.xsl b/xslt/mal-files.xsl new file mode 100644 index 0000000..9ecabe0 --- /dev/null +++ b/xslt/mal-files.xsl @@ -0,0 +1,249 @@ +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:mal="http://projectmallard.org/1.0/" + xmlns:if="http://projectmallard.org/if/1.0/" + xmlns:e="http://projectmallard.org/experimental/" + xmlns:exsl="http://exslt.org/common" + xmlns:html="http://www.w3.org/1999/xhtml" + version="1.0"> + +<xsl:param name="mal.files.copy.icon.dir"/> +<xsl:param name="mal.files.copy.js.dir"/> + +<xsl:template name="mal.files.copy"> + <xsl:param name="node" select="."/> + <xsl:param name="href"/> + <xsl:value-of select="concat('+', $mal.files.copy.js.dir, '/jquery.js ./
')"/> + <xsl:value-of select="concat('+', $mal.files.copy.js.dir, '/jquery.syntax.js ./
')"/> + <xsl:value-of select="concat('+', $mal.files.copy.js.dir, '/jquery.syntax.core.js ./
')"/> + <xsl:value-of select="concat('+', $mal.files.copy.js.dir, '/jquery.syntax.layout.yelp.js ./
')"/> + <xsl:apply-templates mode="mal.files.copy.block.mode"> + <xsl:with-param name="dir"> + <xsl:call-template name="mal.files.copy.dirname"> + <xsl:with-param name="href" select="$href"/> + </xsl:call-template> + </xsl:with-param> + </xsl:apply-templates> +</xsl:template> + +<xsl:template name="mal.files.copy.dirname"> + <xsl:param name="href"/> + <xsl:if test="contains($href, '/')"> + <xsl:value-of select="substring-before($href, '/')"/> + <xsl:text>/</xsl:text> + <xsl:call-template name="mal.files.copy.dirname"> + <xsl:with-param name="href" select="substring-after($href, '/')"/> + </xsl:call-template> + </xsl:if> +</xsl:template> + +<xsl:template mode="mal.files.copy.media.mode" match="*"/> + +<xsl:template mode="mal.files.copy.media.mode" match="mal:media | e:mouseover"> + <xsl:param name="dir"/> + <xsl:if test="not(contains(@src, ':') or substring(@src, 1, 1) = '/')"> + <xsl:value-of select="concat('-', $dir, @src, ' ', @src, '
')"/> + </xsl:if> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" match="text()"/> + +<xsl:template mode="mal.files.copy.block.mode" match="*"> + <xsl:param name="dir"/> + <xsl:param name="restricted" select="false()"/> + <xsl:if test="not($restricted)"> + <xsl:variable name="if"> + <xsl:call-template name="mal.if.test"/> + </xsl:variable> + <xsl:if test="$if != ''"> + <xsl:apply-templates mode="mal.files.copy.block.mode"> + <xsl:with-param name="dir" select="$dir"/> + <xsl:with-param name="restricted" select="true()"/> + </xsl:apply-templates> + </xsl:if> + </xsl:if> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" match="mal:info"> + <xsl:param name="dir"/> + <xsl:apply-templates mode="mal.files.copy.block.mode" + select="mal:title | mal:desc | mal:license/* | mal:link/* | mal:revision/* | mal:credit"> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" match="mal:p | mal:screen"> + <xsl:param name="dir"/> + <xsl:variable name="if"> + <xsl:call-template name="mal.if.test"/> + </xsl:variable> + <xsl:if test="$if != ''"> + <xsl:apply-templates mode="mal.files.copy.media.mode" select=".//mal:media"> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> + </xsl:if> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" match="mal:title | mal:subtitle | mal:desc | mal:cite | mal:credit"> + <xsl:param name="dir"/> + <xsl:apply-templates mode="mal.files.copy.media.mode" select=".//mal:media"> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" match="mal:code"> + <xsl:param name="dir"/> + <xsl:variable name="if"> + <xsl:call-template name="mal.if.test"/> + </xsl:variable> + <xsl:if test="$if != ''"> + <xsl:apply-templates mode="mal.files.copy.media.mode" select=".//mal:media"> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> + <xsl:if test="$html.syntax.highlight and @mime"> + <xsl:variable name="brush"> + <xsl:call-template name="html.syntax.class"/> + </xsl:variable> + <xsl:if test="starts-with($brush, 'syntax brush-')"> + <xsl:value-of select="concat('+', $mal.files.copy.js.dir, '/jquery.syntax.brush.', + substring-after($brush, 'syntax brush-'), '.js ./
')"/> + </xsl:if> + </xsl:if> + </xsl:if> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" + match="mal:example | mal:quote | mal:listing | mal:figure | + mal:synopsis | mal:links | mal:list | mal:steps | + mal:terms | mal:tree | mal:item | mal:table | + mal:section | if:if"> + <xsl:param name="dir"/> + <xsl:variable name="if"> + <xsl:call-template name="mal.if.test"/> + </xsl:variable> + <xsl:if test="$if != ''"> + <xsl:apply-templates mode="mal.files.copy.block.mode"> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> + </xsl:if> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" match="mal:media | e:mouseover"> + <xsl:param name="dir"/> + <xsl:variable name="if"> + <xsl:call-template name="mal.if.test"/> + </xsl:variable> + <xsl:if test="$if != ''"> + <xsl:apply-templates mode="mal.files.copy.media.mode" select="."> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> + </xsl:if> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" match="mal:comment"> + <xsl:param name="dir"/> + <xsl:variable name="if"> + <xsl:call-template name="mal.if.test"/> + </xsl:variable> + <xsl:if test="$if != ''"> + <xsl:if test="$mal2html.editor_mode + or processing-instruction('mal2html.show_comment')"> + <xsl:apply-templates mode="mal.files.copy.block.mode"> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> + </xsl:if> + </xsl:if> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" match="mal:note"> + <xsl:param name="dir"/> + <xsl:variable name="if"> + <xsl:call-template name="mal.if.test"/> + </xsl:variable> + <xsl:if test="$if != ''"> + <xsl:variable name="style" select="concat(' ', @style, ' ')"/> + <xsl:choose> + <!-- + <xsl:when test="contains($style, ' advanced ')"> + <xsl:value-of select="concat('+', $mal.files.copy.icon.dir, '/yelp-note-advanced.png ./
')"/> + </xsl:when> + --> + <xsl:when test="contains($style, ' bug ')"> + <xsl:value-of select="concat('+', $mal.files.copy.icon.dir, '/yelp-note-bug.png ./
')"/> + </xsl:when> + <xsl:when test="contains($style, ' important ')"> + <xsl:value-of select="concat('+', $mal.files.copy.icon.dir, '/yelp-note-important.png ./
')"/> + </xsl:when> + <xsl:when test="contains($style, ' sidebar ')"/> + <xsl:when test="contains($style, ' tip ')"> + <xsl:value-of select="concat('+', $mal.files.copy.icon.dir, '/yelp-note-tip.png ./
')"/> + </xsl:when> + <xsl:when test="contains($style, ' warning ')"> + <xsl:value-of select="concat('+', $mal.files.copy.icon.dir, '/yelp-note-warning.png ./
')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('+', $mal.files.copy.icon.dir, '/yelp-note.png ./
')"/> + </xsl:otherwise> + </xsl:choose> + <xsl:apply-templates mode="mal.files.copy.block.mode"> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> + </xsl:if> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" match="mal:tr | mal:td"> + <xsl:param name="dir"/> + <xsl:apply-templates mode="mal.files.copy.block.mode"> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" match="if:choose"> + <xsl:param name="dir"/> + <xsl:apply-templates mode="mal.files.copy.block.mode" select="if:when[1]"> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" match="if:when"> + <xsl:param name="dir"/> + <xsl:variable name="if"> + <xsl:call-template name="mal.if.test"/> + </xsl:variable> + <xsl:if test="$if != ''"> + <xsl:apply-templates mode="mal.files.copy.block.mode"> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> + </xsl:if> + <xsl:if test="$if != 'true'"> + <xsl:apply-templates mode="mal.files.copy.block.mode" select="following-sibling::*[1]"> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> + </xsl:if> +</xsl:template> + +<xsl:template mode="mal.files.copy.block.mode" match="if:else"> + <xsl:param name="dir"/> + <xsl:apply-templates mode="mal.files.copy.block.mode"> + <xsl:with-param name="dir" select="$dir"/> + </xsl:apply-templates> +</xsl:template> + +<xsl:template match="/false"> +<!-- + <xsl:variable name="dir"> + <xsl:call-template name="mal.files.dirname"> + <xsl:with-param name="str" select="substring-after(@cache:href, 'file://')"/> + </xsl:call-template> + </xsl:variable> +--> + <xsl:variable name="node" select="document(@cache:href)/mal:page"/> + + + <!-- Syntax --> + + <!-- Icons --> + <xsl:for-each select="$node//mal:note"> + </xsl:for-each> +</xsl:template> +</xsl:stylesheet> |