mod_rewrite mapping script for openurl->opensearch
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 4 Jun 2008 00:53:52 +0000 (00:53 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 4 Jun 2008 00:53:52 +0000 (00:53 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@9761 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/extras/openurl_map.pl [new file with mode: 0755]

diff --git a/Open-ILS/src/extras/openurl_map.pl b/Open-ILS/src/extras/openurl_map.pl
new file mode 100755 (executable)
index 0000000..a376df7
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+#
+
+$|=1;
+
+while (my $openurl = <>) {
+       my $opensearch = '/opac/extras/opensearch/1.1/-/marcxml/-/?';
+       my @parts = split('&', $openurl);
+
+       my %params = (
+               kw => '',
+               au => '',
+               ti => '',
+       );
+
+       for (@parts) {
+               if (/^au[^=]+=(.*)$/o) {
+                       $params{au} .= $1 . ' ';
+               } elsif (/^[sa]?title=(.*)$/o) {
+                       $params{ti} .= $1 . ' ';
+               } elsif (/^e?is.n=(.*)$/o) {
+                       $params{kw} .= $1 . ' ';
+               } elsif (/^[^=]+=(.*)$/o) {
+                       $params{kw} .= $1 . ' ';
+               }
+       }
+       
+       $opensearch .= join('&', map { "$_=$params{$_}" } keys %params );
+
+       print $opensearch . "\n";
+
+};