From bfe4e58c3e2bd51b16bb94fa256f5b080f1123dc Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 22 Mar 2006 23:25:46 +0000 Subject: [PATCH] basic searching within the opensearch results git-svn-id: svn://svn.open-ils.org/ILS/trunk@3413 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm | 18 ++++++++----- .../src/perlmods/OpenILS/WWW/SuperCat/Feed.pm | 16 ++++++++++- Open-ILS/web/opac/extras/os.css | 17 ++++++++++++ Open-ILS/xsl/ATOM2XHTML.xsl | 27 ++++++++++++++++++- 4 files changed, 70 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm index af6d597540..bad6b89a65 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm @@ -452,8 +452,8 @@ sub opensearch_feed { my $lang = $cgi->param('language') || 'en-US'; $page = 1 if ($page !~ /^\d+$/); - $offset = 1 if ($offset =~ /^\d+$/); - $limit = 10 if ($limit =~ /^\d+$/); $limit = 25 if ($limit > 25); + $offset = 1 if ($offset !~ /^\d+$/); + $limit = 10 if ($limit !~ /^\d+$/); $limit = 25 if ($limit > 25); $lang = 'en-US' if ($lang =~ /^{/ or $lang eq '*'); if ($page > 1) { @@ -462,7 +462,12 @@ sub opensearch_feed { $offset -= 1; } - my ($terms,$class,$type,$org,$version) = reverse split '/', $path; + my (undef,$version,$org,$type,$class,$terms) = split '/', $path; + + $terms ||= $cgi->param('searchTerms'); + $class ||= $cgi->param('searchClass') || '-'; + $type ||= $cgi->param('responseType') || '-'; + $org ||= $cgi->param('searchOrg') || '-'; if ($version eq '1.0') { $type = 'rss2'; @@ -502,6 +507,7 @@ sub opensearch_feed { ); $feed->root($root); $feed->lib($org); + $feed->search($terms); $feed->title("Search results for [$class => $terms] at ".$org_unit->[0]->name); $feed->creator($host); @@ -530,19 +536,19 @@ sub opensearch_feed { $feed->link( next => - $base . $path . "?startIndex=" . int($offset + $limit + 1) . "&count=" . $limit => + $base . "/$version/$org/$type/$class?searchTerms=$terms&startIndex=" . int($offset + $limit + 1) . "&count=" . $limit => 'application/opensearch+xml' ) if ($offset + $limit < $recs->{count}); $feed->link( previous => - $base . $path . "?startIndex=" . int(($offset - $limit) + 1) . "&count=" . $limit => + $base . "/$version/$org/$type/$class?searchTerms=$terms&startIndex=" . int(($offset - $limit) + 1) . "&count=" . $limit => 'application/opensearch+xml' ) if ($offset); $feed->link( self => - $base . $path => + $base . "/$version/$org/$type/$class?searchTerms=$terms" => 'application/opensearch+xml' ); diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm index 285acd0892..043b4757f0 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm @@ -35,6 +35,13 @@ sub type { return $self->{type}; } +sub search { + my $self = shift; + my $search = shift; + $self->{search} = $search if ($search); + return $self->{search}; +} + sub lib { my $self = shift; my $lib = shift; @@ -409,6 +416,7 @@ sub toString { my $self = shift; my $base = $self->base; my $root = $self->root; + my $search = $self->search; my $lib = $self->lib || '-'; $self->composeDoc; @@ -425,7 +433,13 @@ sub toString { # parse the MODS xslt ... my $atom2html_xslt = $_xslt->parse_stylesheet( $_parser->parse_file($xslt_file) ); - my $new_doc = $atom2html_xslt->transform($self->{doc}, base_dir => "'$root'", lib => "'$lib'"); + my $new_doc = $atom2html_xslt->transform( + $self->{doc}, + base_dir => "'$root'", + lib => "'$lib'", + searchTerms => "'$search'", + ); + return $new_doc->toString(1); } diff --git a/Open-ILS/web/opac/extras/os.css b/Open-ILS/web/opac/extras/os.css index d5883c7aa8..f03ee5a7ec 100644 --- a/Open-ILS/web/opac/extras/os.css +++ b/Open-ILS/web/opac/extras/os.css @@ -10,6 +10,23 @@ p.nav { h1 { font-size: 1.5em; } + +input.searchbox { + font-size: 0.9em; + max-width: 10em; +} + +div#searchdiv { + z-index:10; + position:absolute; + top: 100; + right: 0; + background-color: lightgray; + border:2px solid lightblue; + filter: alpha(opacity=50); + -moz-opacity: .5; +} + div#header img { position: absolute; top: 0; diff --git a/Open-ILS/xsl/ATOM2XHTML.xsl b/Open-ILS/xsl/ATOM2XHTML.xsl index 3781a0a56b..5a928d9e14 100644 --- a/Open-ILS/xsl/ATOM2XHTML.xsl +++ b/Open-ILS/xsl/ATOM2XHTML.xsl @@ -176,6 +176,31 @@ To-do list:

+ +
+ Search: +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
@@ -387,7 +412,7 @@ To-do list: - + -- 2.43.2