From 908667d2ca9e31f68f465918db361373691a93fd Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Sat, 26 Oct 2013 19:24:02 -0400 Subject: [PATCH] Add library hours and mailing address to schema.org output Signed-off-by: Dan Scott --- .../lib/OpenILS/WWW/EGCatLoader/Library.pm | 26 ++++++++++++--- Open-ILS/src/templates/opac/library.tt2 | 39 +++++++++++++--------- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm index 985343298c..18094dd3be 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm @@ -19,17 +19,13 @@ sub load_library { $self->timelog("load_library() began"); my $lib_id = $ctx->{page_args}->[0]; - - $self->apache->log->warn("got library $lib_id!"); $lib_id = $self->_resolve_org_id_or_shortname($lib_id); - $self->apache->log->warn("now got library $lib_id!"); return Apache2::Const::HTTP_BAD_REQUEST unless $lib_id; my $aou = $ctx->{get_aou}->($lib_id); my $sname = $aou->parent_ou; - $self->apache->log->warn("now got library $sname"); $ctx->{library} = $aou; if ($aou->parent_ou) { @@ -38,6 +34,28 @@ sub load_library { $self->timelog("got basic lib info"); + # Get mailing address + if ($aou->mailing_address) { + my $session = OpenSRF::AppSession->create("open-ils.actor"); + $ctx->{mailing_address} = + $session->request('open-ils.actor.org_unit.address.retrieve', + $aou->mailing_address)->gather(1); + } + + # Get current hours of operation + my $hours = $self->editor->retrieve_actor_org_unit_hours_of_operation($lib_id); + if ($hours) { + $ctx->{hours} = $hours; + # Generate naive schema.org format + $ctx->{hours_schema} = "Mo " . substr($hours->dow_0_open, 0, 5) . "-" . substr($hours->dow_0_close, 0, 5) . + ",Tu " . substr($hours->dow_1_open, 0, 5) . "-" . substr($hours->dow_1_close, 0, 5) . + ",We " . substr($hours->dow_2_open, 0, 5) . "-" . substr($hours->dow_2_close, 0, 5) . + ",Th " . substr($hours->dow_3_open, 0, 5) . "-" . substr($hours->dow_3_close, 0, 5) . + ",Fr " . substr($hours->dow_4_open, 0, 5) . "-" . substr($hours->dow_4_close, 0, 5) . + ",Sa " . substr($hours->dow_5_open, 0, 5) . "-" . substr($hours->dow_5_close, 0, 5) . + ",Su " . substr($hours->dow_6_open, 0, 5) . "-" . substr($hours->dow_6_close, 0, 5); + } + return Apache2::Const::OK; } diff --git a/Open-ILS/src/templates/opac/library.tt2 b/Open-ILS/src/templates/opac/library.tt2 index a7a6a4f92b..7321457ade 100644 --- a/Open-ILS/src/templates/opac/library.tt2 +++ b/Open-ILS/src/templates/opac/library.tt2 @@ -7,6 +7,19 @@

[% ctx.library.name %]

+ [%- IF ctx.hours_schema; %] +

[% l('Opening hours') %]

+ + [% END; -%] + [%- IF (ctx.library.email OR ctx.library.phone); %]

[% l('Contact information') %]

[%- IF ctx.library.email; %] @@ -17,24 +30,20 @@ [% END; %] [% END; %] -

[% l('Opening hours') %]

-
Pull in from actor.hours_of_operation
- -
[%- IF ctx.library.mailing_address; %] -
-

[% l('Mailing address') %]

- [%# Pull in actor.org_address properties here %] - ctx.library.mailing_address.street1
- IF we have it - ctx.library.mailing_address.street2 -

- ctx.library.mailing_address.city
- ctx.library.mailing_address.state
- ctx.library.mailing_address.country
- ctx.library.mailing_address.post_code
+
+
+

[% l('Mailing address') %]

+ [% ctx.mailing_address.street1 %] + [%- IF ctx.mailing_address.street2; "
"; ctx.mailing_address.street2; END; %] +

+ [% ctx.mailing_address.city %]
+ [% ctx.mailing_address.state %]
+ [% ctx.mailing_address.country %]
+ [% ctx.mailing_address.post_code %]
+
[%- END; %] -
[%- IF ctx.library.parent_ou; %]

Branch relationship

-- 2.11.0