From 489f7e2d8d0be2f7b5cd7f3fbfc1bee4dd193cba Mon Sep 17 00:00:00 2001 From: miker Date: Sat, 15 Mar 2008 01:29:21 +0000 Subject: [PATCH] fixing the slimpac git-svn-id: svn://svn.open-ils.org/ILS/trunk@9032 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm | 48 ++++++++++++++----- .../src/perlmods/OpenILS/WWW/SuperCat/Feed.pm | 4 ++ 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm index a7707c76a7..48f74764a8 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm @@ -29,6 +29,8 @@ use OpenSRF::Utils::Logger qw/$logger/; use MARC::Record; use MARC::File::XML; +my $log = 'OpenSRF::Utils::Logger'; + # set the bootstrap config when this module is loaded my ($bootstrap, $cstore, $supercat, $actor, $parser, $search, $xslt, $cn_browse_xslt, %browse_types); @@ -957,9 +959,11 @@ sub opensearch_feed { $lang = $cgi->param('searchLang') if $cgi->param('searchLang'); $lang = '' if ($lang eq '*'); - $sort = $cgi->param('searchSort') if $cgi->param('searchSort'); - $sortdir = $cgi->param('searchSortDir') if $cgi->param('searchSortDir'); - $terms .= " " . $cgi->param('searchTerms') if $cgi->param('searchTerms'); + $sort = $cgi->param('searchSort') || ''; + $sortdir = $cgi->param('searchSortDir') || ''; + + $terms .= " " if ($terms); + $terms .= $cgi->param('searchTerms') if $cgi->param('searchTerms'); $class = $cgi->param('searchClass') if $cgi->param('searchClass'); $class ||= '-'; @@ -977,11 +981,16 @@ sub opensearch_feed { my $sut = $cgi->param('su'); my $set = $cgi->param('se'); - $terms .= " keyword: $kwt" if ($kwt); - $terms .= " title: $tit" if ($tit); - $terms .= " author: $aut" if ($aut); - $terms .= " subject: $sut" if ($sut); - $terms .= " series: $set" if ($set); + $terms .= " " if ($terms && $kwt); + $terms .= "keyword: $kwt" if ($kwt); + $terms .= " " if ($terms && $tit); + $terms .= "title: $tit" if ($tit); + $terms .= " " if ($terms && $aut); + $terms .= "author: $aut" if ($aut); + $terms .= " " if ($terms && $sut); + $terms .= "subject: $sut" if ($sut); + $terms .= " " if ($terms && $set); + $terms .= "series: $set" if ($set); if ($version eq '1.0') { $type = 'rss2'; @@ -1008,6 +1017,8 @@ sub opensearch_feed { $terms = decode_utf8($terms); $lang = 'eng' if ($lang eq 'en-US'); + $log->debug("OpenSearch terms: $terms"); + my $org_unit; if ($org eq '-') { $org_unit = $actor->request( @@ -1022,12 +1033,14 @@ sub opensearch_feed { my $recs = $search->request( 'open-ils.search.biblio.multiclass.query' => { org_unit => $org_unit->[0]->id, - offset => $limit, - limit => $offset, + offset => $offset - 1, + limit => $limit, ($lang ? ( 'language' => $lang ) : ()), - } => $terms + } => $terms => 1 )->gather(1); + $log->debug("Hits for [$terms]: $recs->{count}"); + my $feed = create_record_feed( 'record', $type, @@ -1036,12 +1049,15 @@ sub opensearch_feed { $org, $flesh_feed ); + + $log->debug("Feed created..."); + $feed->root($root); $feed->lib($org); $feed->search($terms); $feed->class($class); - $feed->title("Search results for [$class => $terms] at ".$org_unit->[0]->name); + $feed->title("Search results for [$terms] at ".$org_unit->[0]->name); $feed->creator($host); $feed->update_ts(gmtime_ISO8601()); @@ -1067,6 +1083,8 @@ sub opensearch_feed { $limit, ); + $log->debug("...basic feed data added..."); + $feed->link( next => $base . "/$version/$org/$type/$class?searchTerms=$terms&searchSort=$sort&searchSortDir=$sortdir&searchLang=$lang&startIndex=" . int($offset + $limit + 1) . "&count=" . $limit => @@ -1111,6 +1129,8 @@ sub opensearch_feed { $feed->link( 'unapi-server' => $unapi); + $log->debug("...feed links added..."); + # $feed->link( # opac => # $root . "../$lang/skin/default/xml/rresult.xml?rt=list&" . @@ -1118,7 +1138,9 @@ sub opensearch_feed { # 'text/html' # ); - print entityize($feed->toString) . "\n"; + print $cgi->header( -type => $feed->type, -charset => 'UTF-8') . entityize($feed->toString) . "\n"; + + $log->debug("...and feed returned."); return Apache2::Const::OK; } diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm index 92def65cf6..44a5f74648 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm @@ -5,8 +5,11 @@ use OpenSRF::EX qw(:try); use XML::LibXML; use XML::LibXSLT; use OpenSRF::Utils::SettingsClient; +use OpenSRF::Utils::Logger qw/$logger/; use CGI; +my $log = 'OpenSRF::Utils::Logger'; + sub exists { my $class = shift; my $type = shift; @@ -212,6 +215,7 @@ sub composeDoc { sub toString { my $self = shift; $self->composeDoc; + $log->debug("Document composed"); return $self->{doc}->toString(1); } -- 2.43.2