From aede8ef7c28ded91eff64e907f3601d302934d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Fri, 8 Jan 2016 12:12:12 -0300 Subject: [PATCH] [SIGNED-OFF]Bug 15527: Custom stylesheet in extended mode Add a parameter to YAML config file in order to specify a local XSLT used style the XML returned by OAI Server. Some doc. Move default XSLT from /opac-tmpl/xslt to /opac-tmpl/bootstrap/css/OAI.xslt. Signed-off-by: Hector Castro Works as advertised --- Koha/OAI/Server/Repository.pm | 28 ++++++++++++++++------ .../opac-tmpl/{xslt => bootstrap/css}/OAI.xslt | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) rename koha-tmpl/opac-tmpl/{xslt => bootstrap/css}/OAI.xslt (99%) diff --git a/Koha/OAI/Server/Repository.pm b/Koha/OAI/Server/Repository.pm index 374ce29..ee667ed 100644 --- a/Koha/OAI/Server/Repository.pm +++ b/Koha/OAI/Server/Repository.pm @@ -65,12 +65,19 @@ respecively MARC21slim2OAIDC.xsl for MARC21 and MARC21slim2OAIDC.xsl for UNIMARC. In extended mode, it's possible to parameter other format than marcxml or -Dublin Core. A new syspref OAI-PMH:ConfFile specify a YAML configuration file -which list available metadata formats and XSL file used to create them from -marcxml records. If this syspref isn't set, Koha OAI server works in simple -mode. A configuration file koha-oai.conf can look like that: +Dublin Core. Syspref OAI-PMH:ConfFile specify a YAML configuration file which +list available metadata formats and XSL file used to create them from marcxml +records. If this syspref isn't set, Koha OAI server works in simple mode. + +Extended mode is required when you want: (a) to return item info +(C parameter), (b) to provide other metadata format than +oai_dc/marcxml (C parameter), (c) to provide a localized OAI server +view (C parameter). + +A configuration file koha-oai.conf can look like that: --- + xslt: /usr/local/koha/xslt/serverview.xslt format: vs: metadataPrefix: vs @@ -103,8 +110,9 @@ sub new { $self->{ koha_stylesheet } = { }; # Build when needed # Load configuration file if defined in OAI-PMH:ConfFile syspref - if ( my $file = C4::Context->preference("OAI-PMH:ConfFile") ) { - $self->{ conf } = LoadFile( $file ); + my $conf = C4::Context->preference("OAI-PMH:ConfFile"); + if ( $conf ) { + $self->{ conf } = $conf = LoadFile( $conf ); my @formats = keys %{ $self->{conf}->{format} }; $self->{ koha_metadata_format } = \@formats; } @@ -136,7 +144,13 @@ sub new { } $response->set_handler( XML::SAX::Writer->new( Output => *STDOUT ) ); - $response->xslt( "/opac-tmpl/xslt/OAI.xslt" ); + + $response->xslt( + $conf && $conf->{xslt} + ? $conf->{xslt} + : "/opac-tmpl/bootstrap/css/OAI.xslt" + ); + $response->generate; bless $self, $class; diff --git a/koha-tmpl/opac-tmpl/xslt/OAI.xslt b/koha-tmpl/opac-tmpl/bootstrap/css/OAI.xslt similarity index 99% rename from koha-tmpl/opac-tmpl/xslt/OAI.xslt rename to koha-tmpl/opac-tmpl/bootstrap/css/OAI.xslt index 976f0c2..9407611 100644 --- a/koha-tmpl/opac-tmpl/xslt/OAI.xslt +++ b/koha-tmpl/opac-tmpl/bootstrap/css/OAI.xslt @@ -808,7 +808,7 @@ + select="$text" /> -- 2.1.4