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) {
$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';
);
$feed->root($root);
$feed->lib($org);
+ $feed->search($terms);
$feed->title("Search results for [$class => $terms] at ".$org_unit->[0]->name);
$feed->creator($host);
$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'
);
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;
my $self = shift;
my $base = $self->base;
my $root = $self->root;
+ my $search = $self->search;
my $lib = $self->lib || '-';
$self->composeDoc;
# 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);
}
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;
<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>
<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>