Dummy (passthrough) implementation of the CSS support...
This commit is contained in:
parent
16cc943d48
commit
750ccaac7c
|
@ -48,7 +48,7 @@
|
||||||
<p:choose href="#archive">
|
<p:choose href="#archive">
|
||||||
|
|
||||||
<!-- HTML document : need to update the links... -->
|
<!-- HTML document : need to update the links... -->
|
||||||
<p:when test="/archive/response/document/@content-type=('text/html')">
|
<p:when test="/archive/response/document/@content-type=('text/html', 'text/css')">
|
||||||
|
|
||||||
<!-- Call the corresponding pipeline to extract the links and rewrite them -->
|
<!-- Call the corresponding pipeline to extract the links and rewrite them -->
|
||||||
<p:processor name="oxf:url-generator">
|
<p:processor name="oxf:url-generator">
|
||||||
|
@ -160,7 +160,8 @@ for $as in /archive-set
|
||||||
declare namespace util = "http://exist-db.org/xquery/util";
|
declare namespace util = "http://exist-db.org/xquery/util";
|
||||||
declare variable $links := $(links);
|
declare variable $links := $(links);
|
||||||
|
|
||||||
for $q in /queue return
|
for $q in /queue[$links/link/@abs-href]
|
||||||
|
return
|
||||||
update
|
update
|
||||||
insert
|
insert
|
||||||
for $href in distinct-values($links/link/@abs-href)
|
for $href in distinct-values($links/link/@abs-href)
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://saxon.sf.net/">
|
||||||
|
|
||||||
|
<p:param name="archive" type="input"/>
|
||||||
|
<p:param name="rewritten" type="output"/>
|
||||||
|
<p:param name="links" type="output"/>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Store the document -->
|
||||||
|
<p:processor name="oxf:file-serializer">
|
||||||
|
<p:input name="config">
|
||||||
|
<config>
|
||||||
|
<scope>session</scope>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="data" href="#archive#xpointer(/archive/response/document)"/>
|
||||||
|
<p:output name="data" id="url-written"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<!-- And read it as HTML -->
|
||||||
|
<p:processor name="oxf:url-generator">
|
||||||
|
<p:input name="config" transform="oxf:xslt" href="#url-written">
|
||||||
|
<config xsl:version="2.0">
|
||||||
|
<url>
|
||||||
|
<xsl:value-of select="/*"/>
|
||||||
|
</url>
|
||||||
|
<mode>text</mode>
|
||||||
|
</config>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="css" debug="css"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<!-- Get a list of links to update -->
|
||||||
|
<!-- TODO: support links in inline CSS -->
|
||||||
|
<!-- TODO: support iframes and objects -->
|
||||||
|
<p:processor name="oxf:unsafe-xslt">
|
||||||
|
<p:input name="data" href="#css"/>
|
||||||
|
<p:input name="request" href="#archive#xpointer(/archive/request)"/>
|
||||||
|
<p:input name="config">
|
||||||
|
<xsl:stylesheet version="2.0">
|
||||||
|
<xsl:variable name="base" select="doc('input:request')/request/location"/>
|
||||||
|
<xsl:template match="/">
|
||||||
|
<links>
|
||||||
|
<xsl:variable name="links" as="node()*">
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
</xsl:variable>
|
||||||
|
<xsl:for-each-group select="$links" group-by="@href">
|
||||||
|
<xsl:variable name="abs-href" select="resolve-uri(@href, $base)"/>
|
||||||
|
<xsl:variable name="tokens" select="tokenize($abs-href, '/')"/>
|
||||||
|
<xsl:variable name="last-token" select="$tokens[last()]"/>
|
||||||
|
<xsl:variable name="tokens2" select="tokenize($last-token, '\.')"/>
|
||||||
|
<xsl:variable name="extension" select="$tokens2[last()]"/>
|
||||||
|
<link abs-href="{$abs-href}" new-href="{saxon:string-to-hexBinary(substring($abs-href, 1, string-length($abs-href) - string-length($extension) - 1), 'utf-8')}.{$extension}"
|
||||||
|
filename="{saxon:string-to-hexBinary($abs-href, 'utf-8')}.xml">
|
||||||
|
<xsl:copy-of select="@*"/>
|
||||||
|
</link>
|
||||||
|
</xsl:for-each-group>
|
||||||
|
</links>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="text()"/>
|
||||||
|
<xsl:template match="link[@rel='stylesheet']">
|
||||||
|
<link>
|
||||||
|
<xsl:copy-of select="@*"/>
|
||||||
|
</link>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="img">
|
||||||
|
<link href="{@src}" type="image/*"/>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="script[@src]">
|
||||||
|
<link href="{@src}" type="{@type}"/>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="links-local" debug="links"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<p:processor name="oxf:identity">
|
||||||
|
<p:input name="data" href="#links-local"/>
|
||||||
|
<p:output name="data" ref="links"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<!-- Update the links -->
|
||||||
|
<p:processor name="oxf:unsafe-xslt">
|
||||||
|
<p:input name="data" href="#css"/>
|
||||||
|
<p:input name="request" href="#archive#xpointer(/archive/request)"/>
|
||||||
|
<p:input name="links" href="#links-local"/>
|
||||||
|
<p:input name="config">
|
||||||
|
<xsl:stylesheet version="2.0">
|
||||||
|
<xsl:variable name="links" select="doc('input:links')/links"/>
|
||||||
|
<xsl:variable name="base" select="doc('input:request')/request/location"/>
|
||||||
|
<xsl:key name="link" match="link" use="@href"/>
|
||||||
|
<xsl:template match="@*|node()">
|
||||||
|
<xsl:copy>
|
||||||
|
<xsl:apply-templates select="@*|node()"/>
|
||||||
|
</xsl:copy>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="link[@rel='stylesheet']/@href|img/@src|script/@src">
|
||||||
|
<xsl:attribute name="{name(.)}">
|
||||||
|
<xsl:value-of select="$links/key('link', current())/@new-href"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="link[@rel!='stylesheet']/@href|a/@href">
|
||||||
|
<xsl:attribute name="{name(.)}">
|
||||||
|
<xsl:value-of select="resolve-uri(., $base)"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
||||||
|
</p:input>
|
||||||
|
<p:output name="data" id="rewritten-local" debug="rewritten"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
<!-- It's a hack so that the document is not submitted as text through the xforms:submit processor... -->
|
||||||
|
<p:processor name="oxf:xslt">
|
||||||
|
<p:input name="config">
|
||||||
|
<document xsl:version="2.0">
|
||||||
|
<xsl:copy-of select="/"/>
|
||||||
|
</document>
|
||||||
|
</p:input>
|
||||||
|
<p:input name="data" href="#rewritten-local"/>
|
||||||
|
<p:output name="data" ref="rewritten"/>
|
||||||
|
</p:processor>
|
||||||
|
|
||||||
|
</p:config>
|
Loading…
Reference in New Issue