Bug 17785: Fix OAI-PMH's XSLT-generated URLs under Plack

Look at e.g. the URL for Show More at the end of the output of Records or
Identifiers. If you use Plack, you will see that it refers to
yourserver:/opac/oai.pl, which is not correct.

This is caused by using CGI's self_url in combination with script alias,
mounting point, etc. Note that we cannot solve this problem in the code of
Koha only. Since HTTP::OAI modules also call self_url, we still end up
with some wrong url's.

Instead of a larger architectural operation on Apache and Plack config files,
this patch adjusts the final xslt transformation on the OAI response.
It hardcodes the correct path only once, in a xslt variable. And replaces
all oai:OAI-PMH/oai:request/text() calls, containing wrong URLs, by this
variable.

Test plan:
Run oai.pl. Try the various verbs.
Verify that the URLs point to /cgi-bin/koha/oai.pl.

Edit: changed commit subject

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Works as expected. Good workaround until a definitive solution is implemented.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 1b492938e4)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
This commit is contained in:
Marcel de Rooy 2016-12-20 16:11:36 +01:00 committed by Katrin Fischer
parent aae8f936df
commit 269bbee289
1 changed files with 15 additions and 13 deletions

View File

@ -18,6 +18,8 @@
<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
<xsl:variable name="oai_script_name">/cgi-bin/koha/oai.pl</xsl:variable>
<xsl:template match="/">
<html>
<head>
@ -44,7 +46,7 @@
</xsl:if>
<xsl:attribute name="href">
<xsl:value-of
select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=Identify')"></xsl:value-of>
select="concat($oai_script_name,'?verb=Identify')"></xsl:value-of>
</xsl:attribute>
Identify
</a>
@ -56,7 +58,7 @@
</xsl:if>
<xsl:attribute name="href">
<xsl:value-of
select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=ListSets')"></xsl:value-of>
select="concat($oai_script_name, '?verb=ListSets')"></xsl:value-of>
</xsl:attribute>
Sets
</a>
@ -68,7 +70,7 @@
</xsl:if>
<xsl:attribute name="href">
<xsl:value-of
select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=ListRecords&amp;metadataPrefix=oai_dc')"></xsl:value-of>
select="concat($oai_script_name, '?verb=ListRecords&amp;metadataPrefix=oai_dc')"></xsl:value-of>
</xsl:attribute>
Records
</a>
@ -80,7 +82,7 @@
</xsl:if>
<xsl:attribute name="href">
<xsl:value-of
select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=ListIdentifiers&amp;metadataPrefix=oai_dc')"></xsl:value-of>
select="concat($oai_script_name, '?verb=ListIdentifiers&amp;metadataPrefix=oai_dc')"></xsl:value-of>
</xsl:attribute>
Identifiers
</a>
@ -93,7 +95,7 @@
</xsl:if>
<xsl:attribute name="href">
<xsl:value-of
select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=ListMetadataFormats')"></xsl:value-of>
select="concat($oai_script_name, '?verb=ListMetadataFormats')"></xsl:value-of>
</xsl:attribute>
Metadata Formats
</a>
@ -238,14 +240,14 @@
<a>
<xsl:attribute name="href">
<xsl:value-of
select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=ListRecords&amp;metadataPrefix=oai_dc&amp;set=', oai:setSpec/text())" />
select="concat($oai_script_name, '?verb=ListRecords&amp;metadataPrefix=oai_dc&amp;set=', oai:setSpec/text())" />
</xsl:attribute>
Records
</a>
<a>
<xsl:attribute name="href">
<xsl:value-of
select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=ListIdentifiers&amp;metadataPrefix=oai_dc&amp;set=', oai:setSpec/text())" />
select="concat($oai_script_name, '?verb=ListIdentifiers&amp;metadataPrefix=oai_dc&amp;set=', oai:setSpec/text())" />
</xsl:attribute>
Identifiers
</a>
@ -303,7 +305,7 @@
<a>
<xsl:attribute name="href">
<xsl:value-of
select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=ListRecords&amp;metadataPrefix=oai_dc&amp;set=', text())" />
select="concat($oai_script_name, '?verb=ListRecords&amp;metadataPrefix=oai_dc&amp;set=', text())" />
</xsl:attribute>
<xsl:value-of select="text()" />
</a>
@ -367,7 +369,7 @@
<a>
<xsl:attribute name="href">
<xsl:value-of
select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=ListRecords&amp;metadataPrefix=oai_dc&amp;set=', text())" />
select="concat($oai_script_name, '?verb=ListRecords&amp;metadataPrefix=oai_dc&amp;set=', text())" />
</xsl:attribute>
<xsl:value-of select="text()" />
</a>
@ -415,7 +417,7 @@
<div class="col-lg-4">
<a class="btn btn-default pull-right">
<xsl:attribute name="href">
<xsl:value-of select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=GetRecord&amp;metadataPrefix=oai_dc&amp;identifier=', oai:identifier/text())" />
<xsl:value-of select="concat($oai_script_name, '?verb=GetRecord&amp;metadataPrefix=oai_dc&amp;identifier=', oai:identifier/text())" />
</xsl:attribute>
View Details
</a>
@ -444,7 +446,7 @@
<a>
<xsl:attribute name="href">
<xsl:value-of
select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=ListRecords&amp;metadataPrefix=oai_dc&amp;set=', text())" />
select="concat($oai_script_name, '?verb=ListRecords&amp;metadataPrefix=oai_dc&amp;set=', text())" />
</xsl:attribute>
<xsl:value-of select="text()" />
</a>
@ -481,7 +483,7 @@
<a class="btn btn-default pull-right">
<xsl:attribute name="href">
<xsl:value-of
select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=ListRecords&amp;metadataPrefix=', oai:metadataPrefix/text())" />
select="concat($oai_script_name, '?verb=ListRecords&amp;metadataPrefix=', oai:metadataPrefix/text())" />
</xsl:attribute>
List Records
</a>
@ -505,7 +507,7 @@
<div class="text-center">
<a class="btn btn-primary">
<xsl:attribute name="href">
<xsl:value-of select="concat(/oai:OAI-PMH/oai:request/text(), '?verb=',/oai:OAI-PMH/oai:request/@verb,'&amp;resumptionToken=', text())"></xsl:value-of>
<xsl:value-of select="concat($oai_script_name, '?verb=',/oai:OAI-PMH/oai:request/@verb,'&amp;resumptionToken=', text())"></xsl:value-of>
</xsl:attribute>
Show More
</a>