Changeset 16cc943
- Timestamp:
- 13/04/2012 11:16:40 (14 months ago)
- Branches:
- master
- Children:
- 750ccaa
- Parents:
- 11027c0
- git-author:
- Eric van der Vlist <vdv@dyomedea.com> (13/04/2012 11:16:40)
- git-committer:
- Eric van der Vlist <vdv@dyomedea.com> (13/04/2012 11:16:40)
- Location:
- archiver/pipelines/actions
- Files:
-
- 2 added
- 2 edited
-
archive-resource.xpl (modified) (6 diffs)
-
archive-set.xpl (modified) (2 diffs)
-
mediatypes/README.txt (added)
-
mediatypes/html.xpl (added)
Legend:
- Unmodified
- Added
- Removed
-
archiver/pipelines/actions/archive-resource.xpl
r11027c0 r16cc943 25 25 <!-- Store the archive in the database --> 26 26 <p:processor name="oxf:pipeline"> 27 <p:input name="config" href="/data-access.xpl 28 "/> 27 <p:input name="config" href="/data-access.xpl"/> 29 28 <p:input name="data" transform="oxf:xslt" href="#data"> 30 29 <config xsl:version="2.0"> … … 50 49 51 50 <!-- HTML document : need to update the links... --> 52 <p:when test="/archive/response/document/@content-type='text/html'"> 53 54 <!-- Store the document --> 55 <p:processor name="oxf:file-serializer"> 56 <p:input name="config"> 57 <config> 58 <scope>session</scope> 59 </config> 60 </p:input> 61 <p:input name="data" href="#archive#xpointer(/archive/response/document)"/> 62 <p:output name="data" id="url-written"/> 63 </p:processor> 64 65 <!-- And read it as HTML --> 51 <p:when test="/archive/response/document/@content-type=('text/html')"> 52 53 <!-- Call the corresponding pipeline to extract the links and rewrite them --> 66 54 <p:processor name="oxf:url-generator"> 67 <p:input name="config" transform="oxf:xslt" href="# url-written">55 <p:input name="config" transform="oxf:xslt" href="#archive"> 68 56 <config xsl:version="2.0"> 69 57 <url> 70 <xsl:value-of select="/*"/> 58 <xsl:text>oxf:/actions/mediatypes/</xsl:text> 59 <xsl:value-of select="substring-after(/archive/response/document/@content-type, '/')"/> 60 <xsl:text>.xpl</xsl:text> 71 61 </url> 72 <mode>html</mode> 73 </config> 74 </p:input> 75 <p:output name="data" id="html" debug="html"/> 76 </p:processor> 77 78 <!-- Get a list of links to update --> 79 <!-- TODO: support links in inline CSS --> 80 <p:processor name="oxf:unsafe-xslt"> 81 <p:input name="data" href="#html"/> 82 <p:input name="request" href="#archive#xpointer(/archive/request)"/> 83 <p:input name="config"> 84 <xsl:stylesheet version="2.0"> 85 <xsl:variable name="base" select="doc('input:request')/request/location"/> 86 <xsl:template match="/"> 87 <links> 88 <xsl:variable name="links" as="node()*"> 89 <xsl:apply-templates/> 90 </xsl:variable> 91 <xsl:for-each-group select="$links" group-by="@href"> 92 <xsl:variable name="abs-href" select="resolve-uri(@href, $base)"/> 93 <xsl:variable name="tokens" select="tokenize($abs-href, '/')"/> 94 <xsl:variable name="last-token" select="$tokens[last()]"/> 95 <xsl:variable name="tokens2" select="tokenize($last-token, '\.')"/> 96 <xsl:variable name="extension" select="$tokens2[last()]"/> 97 <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}" 98 filename="{saxon:string-to-hexBinary($abs-href, 'utf-8')}.xml"> 99 <xsl:copy-of select="@*"/> 100 </link> 101 </xsl:for-each-group> 102 </links> 103 </xsl:template> 104 <xsl:template match="text()"/> 105 <xsl:template match="link[@rel='stylesheet']"> 106 <link> 107 <xsl:copy-of select="@*"/> 108 </link> 109 </xsl:template> 110 <xsl:template match="img"> 111 <link href="{@src}" type="image/*"/> 112 </xsl:template> 113 <xsl:template match="script[@src]"> 114 <link href="{@src}" type="{@type}"/> 115 </xsl:template> 116 </xsl:stylesheet> 117 </p:input> 118 <p:output name="data" id="links" debug="links"/> 119 </p:processor> 120 121 <!-- Update the links --> 122 <p:processor name="oxf:unsafe-xslt"> 123 <p:input name="data" href="#html"/> 124 <p:input name="request" href="#archive#xpointer(/archive/request)"/> 125 <p:input name="links" href="#links"/> 126 <p:input name="config"> 127 <xsl:stylesheet version="2.0"> 128 <xsl:variable name="links" select="doc('input:links')/links"/> 129 <xsl:variable name="base" select="doc('input:request')/request/location"/> 130 <xsl:key name="link" match="link" use="@href"/> 131 <xsl:template match="@*|node()"> 132 <xsl:copy> 133 <xsl:apply-templates select="@*|node()"/> 134 </xsl:copy> 135 </xsl:template> 136 <xsl:template match="link[@rel='stylesheet']/@href|img/@src|script/@src"> 137 <xsl:attribute name="{name(.)}"> 138 <xsl:value-of select="$links/key('link', current())/@new-href"/> 139 </xsl:attribute> 140 </xsl:template> 141 <xsl:template match="link[@rel!='stylesheet']/@href|a/@href"> 142 <xsl:attribute name="{name(.)}"> 143 <xsl:value-of select="resolve-uri(., $base)"/> 144 </xsl:attribute> 145 </xsl:template> 146 </xsl:stylesheet> 147 </p:input> 148 <p:output name="data" id="rewritten" debug="rewritten"/> 149 </p:processor> 62 </config> 63 </p:input> 64 <p:output name="data" id="pipeline"/> 65 </p:processor> 66 67 <p:processor name="oxf:pipeline"> 68 <p:input name="config" href="#pipeline"/> 69 <p:input name="archive" href="#archive"/> 70 <p:output name="rewritten" id="rewritten"/> 71 <p:output name="links" id="links"/> 72 </p:processor> 73 150 74 151 75 <!-- Store the rewritten document in the database --> 152 76 <p:processor name="oxf:pipeline"> 153 <p:input name="config" href="/data-access.xpl 154 "/> 77 <p:input name="config" href="/data-access.xpl"/> 155 78 <p:input name="data" transform="oxf:xslt" href="#data"> 156 79 <config xsl:version="2.0"> … … 175 98 <!-- Update the archive index --> 176 99 <p:processor name="oxf:pipeline"> 177 <p:input name="config" href="/data-access.xpl 178 "/> 100 <p:input name="config" href="/data-access.xpl"/> 179 101 <p:input name="data" transform="oxf:xslt" href="#data"> 180 102 <config xsl:version="2.0"> … … 214 136 <!-- Update the queue --> 215 137 <p:processor name="oxf:pipeline"> 216 <p:input name="config" href="/data-access.xpl 217 "/> 138 <p:input name="config" href="/data-access.xpl"/> 218 139 <p:input name="data" transform="oxf:xslt" href="aggregate('root', #data, #links)"> 219 140 <config xsl:version="2.0"> … … 267 188 <!-- Update the archive index --> 268 189 <p:processor name="oxf:pipeline"> 269 <p:input name="config" href="/data-access.xpl 270 "/> 190 <p:input name="config" href="/data-access.xpl"/> 271 191 <p:input name="data" transform="oxf:xslt" href="#data"> 272 192 <config xsl:version="2.0"> … … 302 222 <!-- Update the queue --> 303 223 <p:processor name="oxf:pipeline"> 304 <p:input name="config" href="/data-access.xpl 305 "/> 224 <p:input name="config" href="/data-access.xpl"/> 306 225 <p:input name="data" transform="oxf:xslt" href="#data"> 307 226 <config xsl:version="2.0"> -
archiver/pipelines/actions/archive-set.xpl
r11027c0 r16cc943 41 41 42 42 <p:processor name="oxf:pipeline"> 43 <p:input name="config" href="/data-access.xpl 44 "/> 43 <p:input name="config" href="/data-access.xpl"/> 45 44 <p:input name="data" href="#data-access-data"/> 46 45 <p:input name="param"> … … 67 66 68 67 <p:processor name="oxf:pipeline"> 69 <p:input name="config" href="/data-access.xpl 70 "/> 68 <p:input name="config" href="/data-access.xpl"/> 71 69 <p:input name="data" transform="oxf:xslt" href="#data-access-data"> 72 70 <config xsl:version="2.0">
Note: See TracChangeset
for help on using the changeset viewer.
