From 6393ead3b28965149197cacaf5b3838db6601db3 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 26 Jan 2012 11:49:55 -0500 Subject: [PATCH] kpac : breadcrumbs, paging, misc Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- Open-ILS/examples/kpac.xml | 21 +++++---- .../src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm | 10 +++- Open-ILS/src/templates/kpac/category.tt2 | 8 ++-- Open-ILS/src/templates/kpac/index.tt2 | 2 +- Open-ILS/src/templates/kpac/parts/base.tt2 | 37 +-------------- Open-ILS/src/templates/kpac/parts/breadcrumb.tt2 | 38 ++++++++++++++++ Open-ILS/src/templates/kpac/parts/footer.tt2 | 8 ++++ Open-ILS/src/templates/kpac/parts/grid.tt2 | 39 ++++++---------- Open-ILS/src/templates/kpac/parts/header.tt2 | 23 ++++++++++ Open-ILS/src/templates/kpac/parts/paginate.tt2 | 50 ++++++++++++++++++++ Open-ILS/src/templates/kpac/parts/subpage.tt2 | 20 +++----- Open-ILS/src/templates/kpac/parts/util.tt2 | 44 ++++++++++++++++++ Open-ILS/src/templates/kpac/search_results.tt2 | 53 +++++----------------- Open-ILS/web/css/skin/default/kpac/style.css | 4 +- 14 files changed, 226 insertions(+), 131 deletions(-) create mode 100644 Open-ILS/src/templates/kpac/parts/breadcrumb.tt2 create mode 100644 Open-ILS/src/templates/kpac/parts/footer.tt2 create mode 100644 Open-ILS/src/templates/kpac/parts/header.tt2 create mode 100644 Open-ILS/src/templates/kpac/parts/paginate.tt2 mode change 100755 => 100644 Open-ILS/src/templates/kpac/parts/subpage.tt2 create mode 100644 Open-ILS/src/templates/kpac/parts/util.tt2 diff --git a/Open-ILS/examples/kpac.xml b/Open-ILS/examples/kpac.xml index 92182e1087..c905cc1335 100644 --- a/Open-ILS/examples/kpac.xml +++ b/Open-ILS/examples/kpac.xml @@ -22,15 +22,18 @@ - - su:mammal audience(j) - su:mammal audience(j) - su:mammal audience(j) - su:mammal audience(j) - su:mammal audience(j) - su:mammal audience(j) - - + + su:piano + su:guitar + su:trumpet + su:drums + su:bass + su:clarinet + + + su:entertainment sort('pubdate')#descending + su:politics sort('pubdate')#descending + su:economy sort('pubdate')#descending diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm index bbbba4506e..266c821822 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm @@ -23,14 +23,19 @@ sub load { $self->load_kpac_config; my $path = $self->apache->path_info; + ($self->ctx->{page} = $path) =~ s#.*/(.*)#$1#g; return $self->load_simple("index") if $path =~ m|kpac/index|; return $self->load_simple("category") if $path =~ m|kpac/category|; return $self->load_simple("checkout") if $path =~ m|kpac/checkout|; return $self->load_simple("checkout_results") if $path =~ m|kpac/checkout_results|; - return $self->load_simple("detailed") if $path =~ m|kpac/detailed|; + + # note: sets page=rresult return $self->load_rresults if $path =~ m|kpac/search_results|; # inherited from tpac + # note: sets page=record + return $self->load_simple("detailed") if $path =~ m|kpac/detailed|; + # ---------------------------------------------------------------- # Everything below here requires SSL # ---------------------------------------------------------------- @@ -86,8 +91,9 @@ sub load_kpac_config { $ou = $org->parent_ou; } - $self->ctx->{kpac_layout} = $kpac_config->{pages}->{page}->{$layout->{page}}; + $self->ctx->{kpac_layout} = $layout; $self->ctx->{kpac_config} = $kpac_config; + $self->ctx->{kpac_root} = $self->ctx->{base_path} . "/kpac"; } diff --git a/Open-ILS/src/templates/kpac/category.tt2 b/Open-ILS/src/templates/kpac/category.tt2 index 0a63e9d0dc..6ff11a197a 100644 --- a/Open-ILS/src/templates/kpac/category.tt2 +++ b/Open-ILS/src/templates/kpac/category.tt2 @@ -1,12 +1,14 @@ [% PROCESS "opac/parts/header.tt2"; PROCESS "kpac/parts/grid.tt2"; WRAPPER "kpac/parts/subpage.tt2"; - ctx.page_title = ctx.kpac_layout.name %] + page_id = trail_endpoint(); + page = ctx.kpac_config.pages.page.$page_id; + ctx.page_title = page.name %] -

Living Creatures

+

[% page.name | html %]

 
- [% render_kpac_grid(ctx.kpac_config.pages.page.10); # TODO %] + [% render_kpac_grid(page_id) %]

Or click on an image to get started:

- [% render_kpac_grid(ctx.kpac_layout); %] + [% render_kpac_grid(ctx.kpac_layout.page) %]
diff --git a/Open-ILS/src/templates/kpac/parts/base.tt2 b/Open-ILS/src/templates/kpac/parts/base.tt2 index eb838d5a7d..e3d122aedb 100644 --- a/Open-ILS/src/templates/kpac/parts/base.tt2 +++ b/Open-ILS/src/templates/kpac/parts/base.tt2 @@ -10,42 +10,9 @@
- - - - + [% INCLUDE 'kpac/parts/header.tt2' %]
[% content %]
- - - - + [% INCLUDE 'kpac/parts/footer.tt2' %]
diff --git a/Open-ILS/src/templates/kpac/parts/breadcrumb.tt2 b/Open-ILS/src/templates/kpac/parts/breadcrumb.tt2 new file mode 100644 index 0000000000..4fa27cc801 --- /dev/null +++ b/Open-ILS/src/templates/kpac/parts/breadcrumb.tt2 @@ -0,0 +1,38 @@ + + diff --git a/Open-ILS/src/templates/kpac/parts/footer.tt2 b/Open-ILS/src/templates/kpac/parts/footer.tt2 new file mode 100644 index 0000000000..b738aee80d --- /dev/null +++ b/Open-ILS/src/templates/kpac/parts/footer.tt2 @@ -0,0 +1,8 @@ + + diff --git a/Open-ILS/src/templates/kpac/parts/grid.tt2 b/Open-ILS/src/templates/kpac/parts/grid.tt2 index fd3471a057..3a2d204f54 100644 --- a/Open-ILS/src/templates/kpac/parts/grid.tt2 +++ b/Open-ILS/src/templates/kpac/parts/grid.tt2 @@ -1,24 +1,15 @@ - [% - # Use absolute and fully-qualified image URLs as-is. - # Otherwise, use the kpac base path. - MACRO kpac_img_path(img) BLOCK; - IF img.match('^/') OR img.match('^https?://'); - img; - ELSE; - ctx.media_prefix _ '/images/kpac/' _ img; - END; - END; -%] - -[% - MACRO render_kpac_grid(page) BLOCK; - ncols = page.columns; - name = page.name; - idx = 0 %] +PROCESS 'kpac/parts/util.tt2'; + +# Renders a single 'page' grid + +MACRO render_kpac_grid(page_id) BLOCK; + page = ctx.kpac_config.pages.page.$page_id; + ncols = page.columns || 3; # avoid divide-by-zero + name = page.name; + idx = 0 %] - - [% + [% width = 100 / ncols; FOR cell IN page.cell; IF idx == ncols; @@ -28,20 +19,20 @@ idx = idx + 1; IF cell.type == 'topic'; - page_id = cell.content; - topic_page = ctx.kpac_config.pages.page.$page_id %] + tpage_id = cell.content; + topic_page = ctx.kpac_config.pages.page.$tpage_id %] - [% ELSIF cell.type == 'search'; %] - [% ELSIF cell.type == 'link'; %] - [% END %] diff --git a/Open-ILS/src/templates/kpac/parts/header.tt2 b/Open-ILS/src/templates/kpac/parts/header.tt2 new file mode 100644 index 0000000000..72756849d1 --- /dev/null +++ b/Open-ILS/src/templates/kpac/parts/header.tt2 @@ -0,0 +1,23 @@ + + diff --git a/Open-ILS/src/templates/kpac/parts/paginate.tt2 b/Open-ILS/src/templates/kpac/parts/paginate.tt2 new file mode 100644 index 0000000000..c87c9fa643 --- /dev/null +++ b/Open-ILS/src/templates/kpac/parts/paginate.tt2 @@ -0,0 +1,50 @@ +[% # paging, weeee + 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; +%] + +
[% topic_page.name %][% cell.name %][% cell.name %]
+ + + + + + + + + + + + [% IF showtop; href = mmkurl('').replace('#.*', '') %] + + [% END %] + +
+ [% class = ''; + href = '#'; + IF page > 0; + href = mkurl('', {page => page - 1}); + ELSE; class = class _ ' invisible'; END %] + + + [% class = ''; + href = '#'; + IF (page + 1) < page_count; + href = mkurl('', {page => page + 1}); + ELSE; class = class _ ' invisible'; END; + %] + +
diff --git a/Open-ILS/src/templates/kpac/parts/subpage.tt2 b/Open-ILS/src/templates/kpac/parts/subpage.tt2 old mode 100755 new mode 100644 index 0a40a99e8b..785f2d8cc5 --- a/Open-ILS/src/templates/kpac/parts/subpage.tt2 +++ b/Open-ILS/src/templates/kpac/parts/subpage.tt2 @@ -1,20 +1,12 @@ -[% WRAPPER "kpac/parts/base.tt2" %] +[% PROCESS 'kpac/parts/util.tt2'; WRAPPER "kpac/parts/base.tt2" %] + +
- [%# TODO BREADCRUMBS %] - + [% INCLUDE 'kpac/parts/breadcrumb.tt2' %]
diff --git a/Open-ILS/src/templates/kpac/parts/util.tt2 b/Open-ILS/src/templates/kpac/parts/util.tt2 new file mode 100644 index 0000000000..632c1800d7 --- /dev/null +++ b/Open-ILS/src/templates/kpac/parts/util.tt2 @@ -0,0 +1,44 @@ +[% + + # ----------------------------------------------------------------- + # Category trail/path utilities + # page trail looks like trail=id/id/id + + # adds an ID, esults in the full trail as a string + MACRO trail_append(node_id) BLOCK; + trail = CGI.param('trail'); + trail ? trail _ '/' _ node_id : node_id; + END; + + # last trail component/id as a string + MACRO trail_endpoint BLOCK; + trail = CGI.param('trail'); + list = trail ? trail.split('/') : []; + list().last; + END; + + MACRO trail_splice(page_id) BLOCK; + trail = CGI.param('trail'); + list = trail ? trail.split('/') : []; + path = ''; + FOR id IN list; + path = path ? path _ '/' _ id : id; + IF id == page_id; LAST; END; + END; + path; + END; + + # ----------------------------------------------------------------- + # Determines the full path to image URLs + # Use absolute and fully-qualified image URLs as-is. + # For all others, use the kpac base path. + MACRO kpac_img_path(img) BLOCK; + IF img.match('^/') OR img.match('^https?://'); + img; + ELSE; + ctx.media_prefix _ '/images/kpac/' _ img; + END; + END; +%] + + diff --git a/Open-ILS/src/templates/kpac/search_results.tt2 b/Open-ILS/src/templates/kpac/search_results.tt2 index e241606f4b..f059dc9800 100644 --- a/Open-ILS/src/templates/kpac/search_results.tt2 +++ b/Open-ILS/src/templates/kpac/search_results.tt2 @@ -2,33 +2,12 @@ PROCESS "opac/parts/misc_util.tt2"; # MARC PROCESS "kpac/parts/grid.tt2"; WRAPPER "kpac/parts/subpage.tt2"; - - ctx.page_title = l('Search Results') - 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; -%] + ctx.page_title = l('Search Results') %]

Search Results

- - - - - -
+ [% INCLUDE 'kpac/parts/paginate.tt2' %]
@@ -52,10 +31,15 @@
[% l('by [_1]', attrs.author) %]
[% attrs.holdings.0.label | html %]
-
[% l('[_1], [_2]', attrs.publisher, attrs.pubdate) | html %]
+
+ [% l('[_1], [_2]', attrs.publisher, attrs.pubdate) | html %] + [% IF attrs.phys_desc %]
[% attrs.phys_desc | html; END %] +
-
more info
-
get it
+
more info
+
get it
 
@@ -73,22 +57,7 @@ [% END %] diff --git a/Open-ILS/web/css/skin/default/kpac/style.css b/Open-ILS/web/css/skin/default/kpac/style.css index 451e0ffd21..ba050cea92 100755 --- a/Open-ILS/web/css/skin/default/kpac/style.css +++ b/Open-ILS/web/css/skin/default/kpac/style.css @@ -1015,7 +1015,9 @@ div.hr { background:url('/images/kpac/popup_br.png') no-repeat; } - +.invisible { + visibility : hidden; +} -- 2.11.0