From dc8c4dd9170439b518bcff6780cafed00666bef3 Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 7 Mar 2006 03:29:49 +0000 Subject: [PATCH] adding opensearch description generator and org targeting support git-svn-id: svn://svn.open-ils.org/ILS/trunk@3277 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm | 93 ++++++++++++++++++- 1 file changed, 89 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm index 2c5dbc0723..776a68d1af 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm @@ -317,12 +317,78 @@ sub bookbag_feed { return Apache2::Const::OK; } +sub opensearch_osd { + my $version = shift; + my $class = shift; + my $base = shift; + + if ($version eq '1.0') { + print < + + $base/1.0/-/$class/-/{searchTerms}?startPage={startPage}&startIndex={startIndex}&count={count} + http://a9.com/-/spec/opensearchrss/1.0/ + $class + Search by $class + Search the OPAC by $class. + book library + harry+potter + Mike Rylander for GPLS/PINES + feedback\@open-ils.org + open + false + +OSD + } else { + print < + + $class + Search the OPAC by $class. + book library + + + + + + + + + + + + + + + Search by $class + + Mike Rylander for GPLS/PINES + open + false + en-us + UTF-8 + UTF-8 + +OSD + } + + return Apache2::Const::OK; +} + sub opensearch_feed { my $apache = shift; return Apache2::Const::DECLINED if (-e $apache->filename); - print "Content-type: application/xml; charset=utf-8\n\n"; - my $cgi = new CGI; (my $unapi = $cgi->url) =~ s{[^/]+/?$}{unapi}; @@ -332,6 +398,19 @@ sub opensearch_feed { my $base = $cgi->url; my $path = $apache->path_info; + if ($path =~ m{^/?(1\.\d{1})/([^/]+)/osd.xml}o) { + + my $version = $1; + my $class = $2; + + if ($class eq '-') { + $class = 'keyword'; + } + + return opensearch_osd($version, $class, $base); + } + + my $page = $cgi->param('startPage') || 1; my $offset = $cgi->param('startIndex') || 1; my $limit = $cgi->param('count') || 10; @@ -342,7 +421,11 @@ sub opensearch_feed { $offset -= 1; } - my ($terms,$class,$type,$version) = reverse split '/', $path; + my ($terms,$class,$type,$org,$version) = reverse split '/', $path; + + if ($org !~ /^[1-9]{1}[0-9]*$/o) { + $org = 1; + } if ($version eq '1.0') { $type = 'rss2'; @@ -358,7 +441,7 @@ sub opensearch_feed { my $recs = $search->request( 'open-ils.search.biblio.record.class.search' => $class, { term => $terms, - org_unit => 1, + org_unit => $org, limit => $limit, offset => $offset, } @@ -430,6 +513,8 @@ sub opensearch_feed { ); + print "Content-type: application/xml; charset=utf-8\n\n"; + print entityize($feed->toString) . "\n"; return Apache2::Const::OK; } -- 2.43.2