kpac : config and template work
authorBill Erickson <berick@esilibrary.com>
Fri, 16 Mar 2012 16:00:58 +0000 (12:00 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 30 Jul 2012 19:03:20 +0000 (15:03 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/examples/apache/eg_vhost.conf
Open-ILS/examples/kpac.xml [deleted file]
Open-ILS/examples/kpac.xml.example [new file with mode: 0644]
Open-ILS/src/Makefile.am
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm
Open-ILS/src/templates/kpac/getit.tt2

index 5d5551b..62980a2 100644 (file)
@@ -603,6 +603,7 @@ RewriteRule ^/openurl$ ${openurl:%1} [NE,PT]
     # Expire the HTML quickly since we're loading dynamic data for each page
     ExpiresActive On
     ExpiresByType text/html "access plus 5 seconds"
+    PerlSetVar KPacConfigFile "/openils/conf/kpac.xml.example"
     
     # For use with embedded Content Cafe content
     #SetEnv OILS_CONTENT_CAFE_USER 123
diff --git a/Open-ILS/examples/kpac.xml b/Open-ILS/examples/kpac.xml
deleted file mode 100644 (file)
index 6672bff..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<kpac version="1.0" xmlns="http://evergreen-ils.org/spec/OPAC/kpac/v1">
-    <pages>
-        <!-- top-level layout pages -->
-        <page id="1" columns="5" name="Home" img="/images/home.jpg">
-            <cell type="topic">10</cell>
-            <cell type="topic">11</cell>
-            <cell type="topic">12</cell>
-            <cell type="topic">13</cell>
-            <cell type="topic">14</cell>
-            <cell type="topic">15</cell>
-            <cell type="topic">16</cell>
-            <cell type="topic">17</cell>
-            <cell type="topic">18</cell>
-            <cell type="topic">19</cell>
-        </page>
-
-        <!-- sample alternate layout -->
-        <page id="23" columns="3" name="ABC Home" img="/images/abc-logo.jpg">
-            <cell type="topic">11</cell>
-            <cell type="topic">10</cell>
-            <cell type="topic">12</cell>
-        </page>
-
-        <!-- topic pages -->
-        <page id="10" columns="3" name="Musical Instruments" img="category.png">
-            <cell name="Piano"    img="category.png" type="search">su:piano</cell>
-            <cell name="Guitar"   img="category.png" type="search">su:guitar</cell>
-            <cell name="Trumpet"  img="category.png" type="search">su:trumpet</cell>
-            <cell name="Drums"    img="category.png" type="search">su:drums</cell>
-            <cell name="Bass"     img="category.png" type="search">su:bass</cell>
-            <cell name="Clarinet" img="category.png" type="link">http://en.wikipedia.org/wiki/Clarinet</cell>
-        </page>
-        <page id="11" columns="3" name="Current Events" img="category.png">
-            <cell name="Entertainment"  img="category.png" type="search">su:entertainment sort(pubdate)#descending</cell>
-            <cell name="Politics"       img="category.png" type="search">su:politics sort(pubdate)#descending</cell>
-            <cell name="Economy"        img="category.png" type="search">su:economy sort(pubdate)#descending</cell>
-        </page>
-        <page id="12" columns="3" name="Programming" img="category.png">
-        </page>
-        <page id="13" columns="3" name="It's Alive!" img="category.png">
-        </page>
-        <page id="14" columns="3" name="Book Series" img="category.png">
-        </page>
-        <page id="15" columns="3" name="Book Series" img="category.png">
-        </page>
-        <page id="16" columns="3" name="Book Series" img="category.png">
-        </page>
-        <page id="17" columns="3" name="Book Series" img="category.png">
-        </page>
-        <page id="18" columns="3" name="Book Series" img="category.png">
-        </page>
-        <page id="19" columns="3" name="Book Series" img="category.png">
-        </page>
-    </pages>
-
-    <layout owner="1" page="1"/>
-    <layout owner="213" page="23"/>
-</kpac>
diff --git a/Open-ILS/examples/kpac.xml.example b/Open-ILS/examples/kpac.xml.example
new file mode 100644 (file)
index 0000000..6672bff
--- /dev/null
@@ -0,0 +1,58 @@
+<kpac version="1.0" xmlns="http://evergreen-ils.org/spec/OPAC/kpac/v1">
+    <pages>
+        <!-- top-level layout pages -->
+        <page id="1" columns="5" name="Home" img="/images/home.jpg">
+            <cell type="topic">10</cell>
+            <cell type="topic">11</cell>
+            <cell type="topic">12</cell>
+            <cell type="topic">13</cell>
+            <cell type="topic">14</cell>
+            <cell type="topic">15</cell>
+            <cell type="topic">16</cell>
+            <cell type="topic">17</cell>
+            <cell type="topic">18</cell>
+            <cell type="topic">19</cell>
+        </page>
+
+        <!-- sample alternate layout -->
+        <page id="23" columns="3" name="ABC Home" img="/images/abc-logo.jpg">
+            <cell type="topic">11</cell>
+            <cell type="topic">10</cell>
+            <cell type="topic">12</cell>
+        </page>
+
+        <!-- topic pages -->
+        <page id="10" columns="3" name="Musical Instruments" img="category.png">
+            <cell name="Piano"    img="category.png" type="search">su:piano</cell>
+            <cell name="Guitar"   img="category.png" type="search">su:guitar</cell>
+            <cell name="Trumpet"  img="category.png" type="search">su:trumpet</cell>
+            <cell name="Drums"    img="category.png" type="search">su:drums</cell>
+            <cell name="Bass"     img="category.png" type="search">su:bass</cell>
+            <cell name="Clarinet" img="category.png" type="link">http://en.wikipedia.org/wiki/Clarinet</cell>
+        </page>
+        <page id="11" columns="3" name="Current Events" img="category.png">
+            <cell name="Entertainment"  img="category.png" type="search">su:entertainment sort(pubdate)#descending</cell>
+            <cell name="Politics"       img="category.png" type="search">su:politics sort(pubdate)#descending</cell>
+            <cell name="Economy"        img="category.png" type="search">su:economy sort(pubdate)#descending</cell>
+        </page>
+        <page id="12" columns="3" name="Programming" img="category.png">
+        </page>
+        <page id="13" columns="3" name="It's Alive!" img="category.png">
+        </page>
+        <page id="14" columns="3" name="Book Series" img="category.png">
+        </page>
+        <page id="15" columns="3" name="Book Series" img="category.png">
+        </page>
+        <page id="16" columns="3" name="Book Series" img="category.png">
+        </page>
+        <page id="17" columns="3" name="Book Series" img="category.png">
+        </page>
+        <page id="18" columns="3" name="Book Series" img="category.png">
+        </page>
+        <page id="19" columns="3" name="Book Series" img="category.png">
+        </page>
+    </pages>
+
+    <layout owner="1" page="1"/>
+    <layout owner="213" page="23"/>
+</kpac>
index d250f58..8fe8302 100644 (file)
@@ -46,6 +46,7 @@ sysconf_DATA = $(examples)/action_trigger_filters.json.example \
               $(examples)/oils_sip.xml.example \
               $(examples)/lib_ips.txt.example \
               $(examples)/oils_yaz.xml.example \
+              $(examples)/kpac.xml.example \
               $(examples)/oils_z3950.xml.example 
 
 #----------------------------
index 34a81f6..7622374 100644 (file)
@@ -15,9 +15,9 @@ my $kpac_config;
 sub load {
     my $self = shift;
 
-    $self->init_ro_object_cache;
+    $self->init_ro_object_cache; 
 
-    my $stat = $self->load_common;
+    my $stat = $self->load_common; 
     return $stat unless $stat == Apache2::Const::OK;
 
     $self->load_kpac_config;
@@ -27,22 +27,16 @@ sub load {
 
     return $self->load_simple("home") if $path =~ m|kpac/home|;
     return $self->load_simple("category") if $path =~ m|kpac/category|;
-    return $self->load_rresults if $path =~ m|kpac/results|; # inherited 
-    return $self->load_record(no_search => 1) if $path =~ m|kpac/record|; # inherited
+    return $self->load_rresults if $path =~ m|kpac/results|;
+    return $self->load_record(no_search => 1) if $path =~ m|kpac/record|; 
 
     # ----------------------------------------------------------------
     #  Everything below here requires SSL
     # ----------------------------------------------------------------
     return $self->redirect_ssl unless $self->cgi->https;
 
-    # XXX auth vs. no-auth, pending list answers
     return $self->load_simple("getit_results") if $path =~ m|kpac/getit_results|;
-
-    if ($path =~ m|kpac/getit|) { # after getit_results
-        my $stat = $self->load_record(no_search => 1);
-        $self->ctx->{page} = 'getit'; # repair the page
-        return $stat;
-    }
+    return $self->load_getit if $path =~ m|kpac/getit|;
 
     # ----------------------------------------------------------------
     #  Everything below here requires authentication
@@ -54,12 +48,46 @@ sub load {
     return Apache2::Const::OK;
 }
 
+sub load_getit {
+    my $self = shift;
+    my $ctx = $self->ctx;
+
+    # first load the record
+    my $stat = $self->load_record(no_search => 1);
+    return $stat unless $stat == Apache2::Const::OK;
+
+    $self->ctx->{page} = 'getit'; # repair the page
+
+    # if the user is logged in, fetch his bookbags
+    if ($ctx->{user}) {
+        $ctx->{bookbags} = $self->editor->search_container_biblio_record_entry_bucket(
+            [{
+                    owner => $ctx->{user}->id, 
+                    btype => 'bookbag'
+                }, {
+                    order_by => {cbreb => 'name'},
+                    limit => $self->cgi->param('bbag_limit') || 100,
+            }],
+            {substream => 1}
+        );
+    }
+
+    $self->ctx->{page} = 'getit'; # repair the page
+    return Apache2::Const::OK;
+}
+
 
 sub load_kpac_config {
     my $self = shift;
-    my $path = '/home/berick/code/Evergreen/Open-ILS/examples/kpac.xml'; # TODO: apache config
 
-    unless ($kpac_config) {
+    if (!$kpac_config) {
+        my $path = $self->apache->dir_config('KPacConfigFile');
+
+        if (!$path) {
+            $self->apache->log->error("KPacConfigFile required!");
+            return;
+        }
+        
         $kpac_config = XMLin(
             $path,
             KeyAttr => ['id'],
@@ -68,8 +96,7 @@ sub load_kpac_config {
         );
     }
 
-    # TODO: make generic "whereami" sub for EGCatLoader.
-    my $ou = $self->ctx->{physical_loc} || $self->cgi->param('loc') || $self->ctx->{aou_tree}->()->id;
+    my $ou = $self->ctx->{physical_loc} || $self->_get_search_lib;
     my $layout;
 
     # Search up the org tree to find the nearest config for the context org unit
index 71ab91b..d665da5 100644 (file)
                 </div>
             </td>
 
-            <!-- TODO -->
             <td valign="top">
                 <div class="right_brain">
                     <div class="top_side">
-                        <h2>save it!</h2>
-                        <p>If you would like to save this item to a list to be requested later, please choose a location and click<br />Submit below.</p>
+                        <h2>[% l('save it!') %]</h2>
+                        <p>[% l('If you would like to save this item to a list to be requested later, please choose a location and click <br/>Submit below.') %]</p>
                     </div>
-                    <div class="checkout_box">
-                        <div class="box1_top">&nbsp;</div>
-                        <div class="box_inside">
-                            <p>Choose a Pickup Library:</p>
-                            <div class="pickup_lib"><select name="library"><option>Fairwood</option></select></div>
-                            <div class="hr">&nbsp;</div>
-                            <div><a href="javascript:;">View all KCLS libraries</a></div>
+                    [% IF ctx.user AND ctx.bookbags.size > 0 %]
+                        <div class="checkout_box">
+                            <div class="box1_top">&nbsp;</div>
+                            <div class="box_inside">
+                                <p>[% l('Add to one of your lists?') %]</p>
+                                <select name='bookbag'>
+                                    <option selected='selected'>[% l('-- Select a List --') %]</option>
+                                    [% FOR bbag IN ctx.bookbags %]
+                                        <option value="[% bbag.id %]">[% bbag.name | html %]</option>
+                                    [% END %]
+                                </select>
+                            </div>
                         </div>
-                    </div>
+                    [% END %]
                     <div class="submit_btn">
                         <a href="javascript:;"><img src="[% ctx.media_prefix %]/images/kpac/review_submit_btn.png" alt="submit" /></a>
                     </div>