From 87f9709a981b80d8b66eb8b9b50a57ce92fe74cd Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 10 Jun 2005 22:45:21 +0000 Subject: [PATCH] better support for ranking and OpenILL integration git-svn-id: svn://svn.open-ils.org/ILS/trunk@799 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/extras/opensearch.pm | 57 +++++++++++++++++------------- Open-ILS/src/extras/opensearch.ttk | 17 ++++++--- Open-ILS/src/extras/opensearch.xml | 6 ++-- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/Open-ILS/src/extras/opensearch.pm b/Open-ILS/src/extras/opensearch.pm index 63864b2fee..0ec38ab66b 100644 --- a/Open-ILS/src/extras/opensearch.pm +++ b/Open-ILS/src/extras/opensearch.pm @@ -9,6 +9,7 @@ use APR::Const -compile => qw(:error SUCCESS); use Apache::RequestRec (); use Apache::RequestIO (); use Apache::RequestUtil; +use LWP::UserAgent; use CGI (); use Template qw(:template); @@ -21,36 +22,42 @@ sub handler { my $apache = shift; print "Content-type: text/xml; charset=utf-8\n\n"; - my $template = Template->new( { - OUTPUT => $apache, - ABSOLUTE => 1, - RELATIVE => 1, - PLUGIN_BASE => 'OpenILS::Template::Plugin', - INCLUDE_PATH => ['/pines/cvs/ILS/Open-ILS/src/extras'], - PRE_CHOMP => 1, - POST_CHOMP => 1, - } - ); + my $cgi = new CGI; + + if (my $fetch = $cgi->param('fetch')) { - try { + print LWP::UserAgent->new->get($fetch)->content; - if( ! $template->process( 'opensearch.ttk' ) ) { - warn "Error processing template opensearch.ttk\n"; - warn "Error Occured: " . $template->error(); - my $err = $template->error(); - $err =~ s/\n/\/g; - print "
Unable to process template:

" . $err . "!!!
"; - } - - } catch Error with { - my $e = shift; - warn "Error processing template opensearch.ttk: $e - $@ \n"; - print "


Error

$e

$@

"; - return; - }; + } else { + my $template = Template->new( { + OUTPUT => $apache, + ABSOLUTE => 1, + RELATIVE => 1, + PLUGIN_BASE => 'OpenILS::Template::Plugin', + INCLUDE_PATH => ['/pines/cvs/ILS/Open-ILS/src/extras'], + PRE_CHOMP => 1, + POST_CHOMP => 1, + } + ); + try { + + if( ! $template->process( 'opensearch.ttk' ) ) { + warn "Error processing template opensearch.ttk\n"; + warn "Error Occured: " . $template->error(); + my $err = $template->error(); + $err =~ s/\n/\/g; + print "
Unable to process template:

" . $err . "!!!
"; + } + } catch Error with { + my $e = shift; + warn "Error processing template opensearch.ttk: $e - $@ \n"; + print "


Error

$e

$@

"; + return; + }; + } return Apache::OK; } diff --git a/Open-ILS/src/extras/opensearch.ttk b/Open-ILS/src/extras/opensearch.ttk index 5be64ef5eb..6aa7f7aa78 100644 --- a/Open-ILS/src/extras/opensearch.ttk +++ b/Open-ILS/src/extras/opensearch.ttk @@ -24,8 +24,9 @@ type = CGI.param('mr_search_type'); string = CGI.param('mr_search_query'); location = CGI.param('mr_search_location'); depth = CGI.param('mr_search_depth'); +max_rank = CGI.param('max_rank'); limit = pagesize; -offset = ((itempage - 1) * pagesize) - 1; +offset = (itempage - 1) * pagesize; IF offset < 0; offset = 0; @@ -42,20 +43,25 @@ j = id_req.wait_complete(); list = id_req.recv().content(); j = id_req.finish; -max_rank = 0; +IF max_rank == '{relevanceScale}'; + max_rank = 0; +END; -%] - + Pines Catalogue Search: [% string | html %] - http://http://gapines.org/opensearch/?target=mr_result&mr_search_type=[% type %]&mr_search_query=[% string | uri | html %]&page=[% itempage %]&mr_search_depth=[% depth %]&mr_search_location=[% location %] + http://http://gapines.org/opensearch/?target=mr_result&mr_search_type=[% type %]&mr_search_query=[% string | uri | html %]&page=[% itempage %]&mr_search_depth=[% depth %]&mr_search_location=[% location %]&pagesize=[% pagesize %]&max_rank=[% max_rank %] Search results for "[% string | html %]" at gapines.org en-us &copy;2004-2005, Georga Public Library Service. [% count %] [% offset + 1 %] [% pagesize %] + [%- mr_list = list.ids; @@ -66,6 +72,7 @@ FOREACH mr_id IN mr_list; IF max_rank == 0; max_rank = mr_id.1; + ' ' _ max_rank _ "\n"; END; rank = mr_id.1 / max_rank; @@ -79,7 +86,7 @@ FOREACH mr_id IN mr_list; [% mods.title() | html %] http://gapines.org/opac/?sub_frame=1&target=record_result&page=0&mrid=[% mr_id.0 %]&hits_per_page=10 - [% rank %] + [% rank %] [%- IF mods.author(); diff --git a/Open-ILS/src/extras/opensearch.xml b/Open-ILS/src/extras/opensearch.xml index 9fa0dfa3c3..9f5edffab6 100644 --- a/Open-ILS/src/extras/opensearch.xml +++ b/Open-ILS/src/extras/opensearch.xml @@ -1,6 +1,8 @@ - - http://gapines.org/opensearch/?target=mr_result&mr_search_type=keyword&mr_search_query={searchTerms}&page={startPage}&mr_search_depth=0&mr_search_location=1 + + http://gapines.org/opensearch/?target=mr_result&mr_search_type=keyword&mr_search_query={searchTerms}&page={startPage}&mr_search_depth=0&mr_search_location=1&pagesize={count}&max_rank={relevanceScale} http://a9.com/-/spec/opensearchrss/1.0/ Pines Pines Consortium Catalogue -- 2.43.2