# (e.g. NOVELIST) into here or to an outer container shared by
# both /opac and /eg/opac since some are used in both places
</Location>
+<Location /eg/kpac>
+ PerlSetVar OILSWebContextLoader "OpenILS::WWW::EGKPacLoader"
+ # Expire the HTML quickly since we're loading dynamic data for each page
+ ExpiresActive On
+ ExpiresByType text/html "access plus 5 seconds"
+
+ # For use with embedded Content Cafe content
+ #SetEnv OILS_CONTENT_CAFE_USER 123
+ #SetEnv OILS_CONTENT_CAFE_PASS 456
+ # Consider copying/moving other added content configs
+ # (e.g. NOVELIST) into here or to an outer container shared by
+ # both /opac and /eg/opac since some are used in both places
+</Location>
+
# Note: the template processor will decline handling anything it does not
<cell type="topic">10</cell>
<cell type="topic">12</cell>
</page>
- <page id="10" columns="3" name="Animals" img="/images/lion.jpg">
+ <page id="10" columns="3" name="Animals" img="/images/format_icons/item_type/a.png">
<cell name="Mammals" img="/images/koala.jpg" type="search">su:mammal audience(j)</cell>
<cell name="Reptiles" img="/images/snake.jpg" type="search">su:reptile audience(j)</cell>
<cell name="Fish" img="/images/fish.jpg" type="search">su:fish audience(j)</cell>
<cell name="Aliens" img="/images/aliens.jpg" type="search">su:aliens audience(j)</cell>
<cell name="Other Reading..." img="/images/book.jpg" type="link">http://wikipedia.org/animals</cell>
</page>
- <page id="11" columns="1" name="Vegetables" img="/images/carrot.jpg">
+ <page id="11" columns="1" name="Vegetables" img="/images/format_icons/item_type/a.png">
<cell name="Greens" img="/images/kale.jpg" type="saved_search">92</cell>
<cell name="Bulbs" img="/images/onion.jpg" type="search">onions and such audience(j)</cell>
</page>
- <page id="12" columns="3" name="Minerals" img="/images/rock.jpg">
+ <page id="12" columns="3" name="Minerals" img="/images/format_icons/item_type/a.png">
<cell name="Igneous" img="/images/volcano.jpg" type="search">su:igneous rock audience(j)</cell>
<cell name="Sedimenatry" img="/images/lake.jpg" type="search">su:sedimentary rock audience(j)</cell>
<cell name="Metamorphic" img="/images/marble.jpg" type="search">su:metamorphic rock audience(j)</cell>
--- /dev/null
+package OpenILS::WWW::EGKPacLoader;
+use base 'OpenILS::WWW::EGCatLoader';
+use strict; use warnings;
+use XML::Simple;
+use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST);
+use OpenSRF::Utils::Logger qw/$logger/;
+use OpenILS::Application::AppUtils;
+use OpenILS::Utils::CStoreEditor qw/:funcs/;
+my $U = 'OpenILS::Application::AppUtils';
+my $kpac_config;
+
+# -----------------------------------------------------------------------------
+# Override our parent's load() sub so we can do kpac-specific path routing.
+# -----------------------------------------------------------------------------
+sub load {
+ my $self = shift;
+
+ $self->init_ro_object_cache;
+
+ my $stat = $self->load_common;
+ return $stat unless $stat == Apache2::Const::OK;
+
+ $self->load_kpac_config;
+
+ my $path = $self->apache->path_info;
+
+ return $self->load_simple("home") if $path =~ m|kpac/home|;
+
+ # ----------------------------------------------------------------
+ # Everything below here requires SSL
+ # ----------------------------------------------------------------
+ return $self->redirect_ssl unless $self->cgi->https;
+ return $self->load_logout if $path =~ m|kpac/logout|;
+
+ if($path =~ m|kpac/login|) {
+ return $self->load_login unless $self->editor->requestor; # already logged in?
+
+ # This will be less confusing to users than to be shown a login form
+ # when they're already logged in.
+ return $self->generic_redirect(
+ sprintf(
+ "https://%s%s/kpac/home",
+ $self->apache->hostname, $self->ctx->{base_path}
+ )
+ );
+ }
+
+
+ # ----------------------------------------------------------------
+ # Everything below here requires authentication
+ # ----------------------------------------------------------------
+ return $self->redirect_auth unless $self->editor->requestor;
+
+ # AUTH pages
+
+ 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) {
+ $kpac_config = XMLin(
+ $path,
+ KeyAttr => ['id'],
+ ForceArray => ['layout', 'page', 'cell'],
+ NormaliseSpace => 2
+ );
+ }
+
+ # TODO: make generic "whoami" sub for EGCatLoader.
+ my $ou = $self->ctx->{physical_loc} || $self->cgi->param('loc') || $self->ctx->{aou_tree}->()->id;
+ my $layout;
+
+ # Search up the org tree to find the nearest config for the context org unit
+ while (my $org = $self->ctx->{get_aou}->($ou)) {
+ ($layout) = grep {$_->{owner} eq $org->id} @{$kpac_config->{layout}};
+ last if $layout;
+ $ou = $org->parent_ou;
+ }
+
+ $self->ctx->{kpac_layout} = $kpac_config->{pages}->{page}->{$layout->{page}};
+ $self->ctx->{kpac_config} = $kpac_config;
+}
+
+
+
+1;
+
--- /dev/null
+[%
+ PROCESS "opac/parts/header.tt2";
+ PROCESS "kpac/parts/page.tt2";
+ WRAPPER "kpac/parts/base.tt2";
+ ctx.page_title = l("Home")
+%]
+
+ [% render_kpac_page(ctx.kpac_layout); %]
+
+[% END %]
--- /dev/null
+<!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.authtime %]
+ <meta http-equiv="refresh" content="[% ctx.authtime %];[% ctx.logout_page %]">
+ [% END %]
+ <title>[% l("Kid's Catalog - [_1]", ctx.page_title) %]</title>
+ </head>
+ <body>
+ [% content %]
+ [%# INCLUDE 'opac/parts/js.tt2' %]
+ </body>
+</html>
--- /dev/null
+[%
+ MACRO render_kpac_page(page) BLOCK;
+ ncols = page.columns;
+ name = page.name;
+ idx = 0 %]
+<table>
+ <tr>
+ [% FOR cell IN page.cell;
+ IF idx == ncols;
+ %]</tr><tr>[%
+ idx = 0;
+ END;
+ idx = idx + 1;
+
+ IF cell.type == 'topic';
+ page_id = cell.content;
+ topic_page = ctx.kpac_config.pages.page.$page_id %]
+
+ <td>[% topic_page.name %]</td>
+ <td><img src="[% ctx.media_prefix %][% topic_page.img %]"</td>
+
+ [% ELSIF cell.type == 'search'; %]
+
+ <td>[% cell.name _ ' : ' _ cell.content %]</td>
+ <td><img src="[% ctx.media_prefix %][% cell.img %]"</td>
+
+ [% ELSIF cell.type == 'link'; %]
+
+ <td>[% cell.name _ ' : ' _ cell.content %]</td>
+ <td><img src="[% ctx.media_prefix %][% cell.img %]"</td>
+
+ [% END %]
+ [% END %]
+ </tr>
+</table>
+[% END %]