Beanstalk Test 1: searching
authorBill Erickson <berick@esilibrary.com>
Mon, 2 Apr 2012 21:50:45 +0000 (17:50 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 2 Apr 2012 21:50:45 +0000 (17:50 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/Beanstalk.pm [new file with mode: 0644]
Open-ILS/src/templates/beanstalk/base.tt2 [new file with mode: 0644]
Open-ILS/src/templates/beanstalk/home.tt2 [new file with mode: 0644]
Open-ILS/src/templates/beanstalk/results.tt2 [new file with mode: 0644]

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/Beanstalk.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/Beanstalk.pm
new file mode 100644 (file)
index 0000000..ca34c22
--- /dev/null
@@ -0,0 +1,25 @@
+package OpenILS::WWW::Beanstalk;
+use base q/OpenILS::WWW::EGCatLoader/;
+use strict; use warnings;
+use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST);
+
+
+sub load {
+    my $self = shift;
+
+    $self->init_ro_object_cache;
+    my $stat = $self->load_common;
+    return $stat unless $stat == Apache2::Const::OK;
+
+    $self->ctx->{opac_root} =~ s/opac/beanstalk/g;
+
+    my $path = $self->apache->path_info;
+
+    return $self->load_simple("home") if $path =~ m|beanstalk/home|;
+    return $self->load_rresults if $path =~ m|beanstalk/results|;
+
+    return Apache2::Const::OK;
+}
+
+1;
+
diff --git a/Open-ILS/src/templates/beanstalk/base.tt2 b/Open-ILS/src/templates/beanstalk/base.tt2
new file mode 100644 (file)
index 0000000..915ebcf
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns='http://www.w3.org/1999/xhtml' lang='[% ctx.locale %]' xml:lang='[% ctx.locale %]'>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+        [% IF ctx.refresh %]
+        <meta http-equiv="refresh" content="[% ctx.refresh %]">
+        [% ELSIF ctx.authtime %]
+        <meta http-equiv="refresh" content="[% ctx.authtime %]; url=[% ctx.logout_page %]">
+        [% END %]
+        <title>[% l('Catalog - [_1]', ctx.page_title) %]</title>
+    </head>
+    <body>
+        [% content %] 
+    </body>
+</html>
diff --git a/Open-ILS/src/templates/beanstalk/home.tt2 b/Open-ILS/src/templates/beanstalk/home.tt2
new file mode 100644 (file)
index 0000000..4a1c761
--- /dev/null
@@ -0,0 +1,19 @@
+[%  
+    PROCESS 'opac/parts/header.tt2';
+    WRAPPER 'beanstalk/base.tt2';
+    PROCESS 'opac/parts/org_selector.tt2'
+%]
+<form action="[% ctx.opac_root %]/results" method="GET">
+    <div><img src='[% ctx.media_prefix %]/images/eg_tiny_logo.jpg'/></div>
+    <div>[% l('Search the Catalog') %]</div>
+    <div>
+        <input type="text" id="search_box" name="query"
+            value="[% CGI.param('query') | html %]"
+            autofocus x-webkit-speech />
+    </div>
+    <div>[% INCLUDE "opac/parts/qtype_selector.tt2" id="qtype" %]</div>
+    <div>[% INCLUDE build_org_selector show_loc_groups=1 %]</div>
+    </div>
+    <div><input type="submit" value="[% l('Search') %]" alt="[% l('Search') %]"/></div>
+</form>
+[% END %]
diff --git a/Open-ILS/src/templates/beanstalk/results.tt2 b/Open-ILS/src/templates/beanstalk/results.tt2
new file mode 100644 (file)
index 0000000..40c42d8
--- /dev/null
@@ -0,0 +1,35 @@
+[%  PROCESS "opac/parts/header.tt2";
+    WRAPPER "beanstalk/base.tt2";
+    PROCESS "opac/parts/misc_util.tt2";
+
+    ctx.page_title = l("Search Results: ") _ CGI.param('query') | html;
+    page = CGI.param('page');
+    page = page.match('^\d+$') ? page : 0; # verify page is a sane value
+
+    page_count = ctx.page_size == 0 ? 1 : POSIX.ceil(ctx.hit_count / ctx.page_size);
+    ctx.result_start = 1 + ctx.page_size * page;
+    ctx.result_stop = ctx.page_size * (page + 1);
+    IF ctx.result_stop > ctx.hit_count; ctx.result_stop = ctx.hit_count; END;
+    result_count = ctx.result_start;
+
+%]
+
+<table>
+    [%  FOR rec IN ctx.records;
+            attrs = {marc_xml => rec.marc_xml};
+            PROCESS get_marc_attrs args=attrs;
+            IF CGI.param('detail_record_view');
+                attrs.title = attrs.title_extended;
+            END 
+    -%]
+    <tr class="result_table_row">
+        <td>
+            <a href="[% mkurl(ctx.opac_root _ '/record/' _ rec.id) %]"
+                [% HTML.attributes(title => l('Display record details for "[_1]"', attrs.title)) %]
+                >[% attrs.title | html %]</a>
+        </td>
+    </tr>
+[% END %]
+</table>
+
+[% END %]