basic searching within the opensearch results
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 22 Mar 2006 23:25:46 +0000 (23:25 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 22 Mar 2006 23:25:46 +0000 (23:25 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3413 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm
Open-ILS/web/opac/extras/os.css
Open-ILS/xsl/ATOM2XHTML.xsl

index af6d597..bad6b89 100644 (file)
@@ -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'
        );
 
index 285acd0..043b475 100644 (file)
@@ -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); 
 }
 
index d5883c7..f03ee5a 100644 (file)
@@ -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;
index 3781a0a..5a928d9 100644 (file)
@@ -176,6 +176,31 @@ To-do list:
                                        <xsl:if test="$t-authors and (managingEditor | atom:author | dc:creator | dc:publisher | atom:contributor | dc:contributor)"><p><xsl:value-of select="concat($t-authors,' ')" /><xsl:apply-templates select="managingEditor | atom:author | dc:creator | dc:publisher | atom:contributor | dc:contributor" /></p></xsl:if>
                                        <xsl:if test="$t-categories and (atom:category | category)"><xsl:value-of select="concat($t-categories, ' ')" /><p><xsl:apply-templates select="atom:category | category" /></p></xsl:if>
                                </div>
+
+                               <div id="searchdiv">
+                                       <b>Search:</b>
+                                       <form method="GET">
+                                               <xsl:attribute name="action"><xsl:value-of select="concat($base_dir, 'opensearch/1.1/', $lib, '/html/keyword')" /></xsl:attribute>
+                                               <input class="searchbox" type="text" name="searchTerms" value="keywords" onfocus="this.value='';"/>
+                                       </form>
+                                       <form method="GET">
+                                               <xsl:attribute name="action"><xsl:value-of select="concat($base_dir, 'opensearch/1.1/', $lib, '/html/title')" /></xsl:attribute>
+                                               <input class="searchbox" type="text" name="searchTerms" value="titles" onfocus="this.value='';"/>
+                                       </form>
+                                       <form method="GET">
+                                               <xsl:attribute name="action"><xsl:value-of select="concat($base_dir, 'opensearch/1.1/', $lib, '/html/author')" /></xsl:attribute>
+                                               <input class="searchbox" type="text" name="searchTerms" value="authors" onfocus="this.value='';"/>
+                                       </form>
+                                       <form method="GET">
+                                               <xsl:attribute name="action"><xsl:value-of select="concat($base_dir, 'opensearch/1.1/', $lib, '/html/subject')" /></xsl:attribute>
+                                               <input class="searchbox" type="text" name="searchTerms" value="subjects" onfocus="this.value='';"/>
+                                       </form>
+                                       <form method="GET">
+                                               <xsl:attribute name="action"><xsl:value-of select="concat($base_dir, 'opensearch/1.1/', $lib, '/html/series')" /></xsl:attribute>
+                                               <input class="searchbox" type="text" name="searchTerms" value="series" onfocus="this.value='';"/>
+                                       </form>
+                                       <br/>
+                               </div>
                                
                                <!-- text input: if present in an opensearch feed, this is probably a search box -->
                                <xsl:if test="textInput | rss1:textinput"><xsl:apply-templates select="(textInput | rss1:textinput)[1]"><xsl:with-param name="query" select="$query" /></xsl:apply-templates></xsl:if>
@@ -387,7 +412,7 @@ To-do list:
                                                <xsl:value-of select="concat($maybeurl, '#', $category)" />
                                        </xsl:when>
                                        <xsl:otherwise>
-                                               <xsl:value-of select="concat($base_dir, 'opensearch/1.1/', $lib, '/html/subject/', translate(normalize-space($name), ' ,()', '+'))" />
+                                               <xsl:value-of select="concat($base_dir, 'opensearch/1.1/', $lib, '/html/subject?searchTerms=', $name)" />
                                        </xsl:otherwise>
                                </xsl:choose>
                        </xsl:variable>