LP1054322 - libparent-perl not needed for Ubuntu Precise
[working/Evergreen.git] / Open-ILS / src / extras / openurl_map.pl
1 #!/usr/bin/perl
2 #
3
4 $|=1;
5
6 while (my $openurl = <>) {
7         my $opensearch = '/opac/extras/opensearch/1.1/-/marcxml/-/?';
8         my @parts = split('&', $openurl);
9
10         my %params = (
11                 kw => '',
12                 au => '',
13                 ti => '',
14         searchOrg => '',
15         searchSort => '',
16         searchSortDir => '',
17         searchLang => '',
18         startIndex => '',
19         count => '',
20         );
21
22         for (@parts) {
23                 if (/^au[^=]+=(.*)$/o) {
24                         $params{au} .= $1 . ' ';
25                 } elsif (/^[sa]?title=(.*)$/o) {
26                         $params{ti} .= $1 . ' ';
27                 } elsif (/^e?is.n=(.*)$/o) {
28                         $params{kw} .= $1 . ' ';
29                 } elsif (/^searchSort=(.*)$/o) {
30                         $params{searchSort} = $1;
31                 } elsif (/^searchSortDir=(.*)$/o) {
32                         $params{searchSortDir} = $1;
33                 } elsif (/^searchLang=(.*)$/o) {
34                         $params{searchLang} = $1;
35                 } elsif (/^startIndex=(.*)$/o) {
36                         $params{startIndex} = $1;
37                 } elsif (/^count=(.*)$/o) {
38                         $params{count} = $1;
39                 } elsif (/^searchOrg=(.*)$/o) {
40                         $params{searchOrg} = $1;
41                 } elsif (/^[^=]+=(.*)$/o) {
42                         $params{kw} .= $1 . ' ';
43                 }
44         }
45         
46         $opensearch .= join('&', map { "$_=$params{$_}" } keys %params );
47
48         print $opensearch . "\n";
49
50 };