Properly handle output subdirectories

This commit is contained in:
Lucidiot 2021-03-17 20:31:10 +01:00
parent e0e05482d3
commit f2154e4468
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
1 changed files with 23 additions and 2 deletions

View File

@ -32,6 +32,24 @@
</xsl:choose>
</xsl:template>
<xsl:template name="substring-before-last">
<xsl:param name="string1" select="''" />
<xsl:param name="string2" select="''" />
<xsl:if test="$string1 != '' and $string2 != ''">
<xsl:variable name="head" select="substring-before($string1, $string2)" />
<xsl:variable name="tail" select="substring-after($string1, $string2)" />
<xsl:value-of select="$head" />
<xsl:if test="contains($tail, $string2)">
<xsl:value-of select="$string2" />
<xsl:call-template name="substring-before-last">
<xsl:with-param name="string1" select="$tail" />
<xsl:with-param name="string2" select="$string2" />
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="/">
<xsl:text><![CDATA[#!/bin/bash
@ -54,7 +72,7 @@ function log {
[ -z "$DIR" ] && DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
log Building to $DIR/feeds
mkdir -p $DIR/feeds/_rss
mkdir -p $DIR/feeds
if ! command -v json2xml >/dev/null 2>&1; then
log "Adding $DIR/bin to PATH"
@ -75,7 +93,10 @@ fi
<xsl:if test="contains(./itsb:output/text(), '/')">
<xsl:text>mkdir -p $DIR/feeds/</xsl:text>
<xsl:value-of select="substring-before(./itsb:output/text(), '/')" />
<xsl:call-template name="substring-before-last">
<xsl:with-param name="string1" select="./itsb:output/text()" />
<xsl:with-param name="string2" select="'/'" />
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:if>