From: Bill Erickson Date: Fri, 16 Mar 2012 16:00:58 +0000 (-0400) Subject: kpac : config and template work X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=aa33fc0ef3f2d80de7474a6815ee629c9d0fca8a;p=contrib%2FConifer.git kpac : config and template work Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/examples/apache/eg_vhost.conf b/Open-ILS/examples/apache/eg_vhost.conf index 5d5551be8e..62980a2783 100644 --- a/Open-ILS/examples/apache/eg_vhost.conf +++ b/Open-ILS/examples/apache/eg_vhost.conf @@ -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 index 6672bff2a7..0000000000 --- a/Open-ILS/examples/kpac.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - - - - - 11 - 10 - 12 - - - - - su:piano - su:guitar - su:trumpet - su:drums - su:bass - http://en.wikipedia.org/wiki/Clarinet - - - su:entertainment sort(pubdate)#descending - su:politics sort(pubdate)#descending - su:economy sort(pubdate)#descending - - - - - - - - - - - - - - - - - - - - - - diff --git a/Open-ILS/examples/kpac.xml.example b/Open-ILS/examples/kpac.xml.example new file mode 100644 index 0000000000..6672bff2a7 --- /dev/null +++ b/Open-ILS/examples/kpac.xml.example @@ -0,0 +1,58 @@ + + + + + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + + + + + 11 + 10 + 12 + + + + + su:piano + su:guitar + su:trumpet + su:drums + su:bass + http://en.wikipedia.org/wiki/Clarinet + + + su:entertainment sort(pubdate)#descending + su:politics sort(pubdate)#descending + su:economy sort(pubdate)#descending + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/Makefile.am b/Open-ILS/src/Makefile.am index d250f58c47..8fe83020ff 100644 --- a/Open-ILS/src/Makefile.am +++ b/Open-ILS/src/Makefile.am @@ -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 #---------------------------- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm index 34a81f6278..7622374247 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm @@ -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 diff --git a/Open-ILS/src/templates/kpac/getit.tt2 b/Open-ILS/src/templates/kpac/getit.tt2 index 71ab91b800..d665da5b5f 100644 --- a/Open-ILS/src/templates/kpac/getit.tt2 +++ b/Open-ILS/src/templates/kpac/getit.tt2 @@ -75,22 +75,26 @@ -
-

save it!

-

If you would like to save this item to a list to be requested later, please choose a location and click
Submit below.

+

[% l('save it!') %]

+

[% l('If you would like to save this item to a list to be requested later, please choose a location and click
Submit below.') %]

-
-
 
-
-

Choose a Pickup Library:

-
-
 
- + [% IF ctx.user AND ctx.bookbags.size > 0 %] +
+
 
+
+

[% l('Add to one of your lists?') %]

+ +
-
+ [% END %]
submit