From ffe3083b33bba34fa4b017b9ac81c32e4d41a734 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Sat, 26 Oct 2013 17:32:22 -0400 Subject: [PATCH] First inklings of library schema.org support Signed-off-by: Dan Scott --- .../src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm | 2 + .../lib/OpenILS/WWW/EGCatLoader/Library.pm | 44 ++++++++++++++++++++ Open-ILS/src/templates/opac/library.tt2 | 47 ++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm create mode 100644 Open-ILS/src/templates/opac/library.tt2 diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index 0af9399168..e5ceb0f242 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -20,6 +20,7 @@ use Time::HiRes; use OpenILS::WWW::EGCatLoader::Util; use OpenILS::WWW::EGCatLoader::Account; use OpenILS::WWW::EGCatLoader::Browse; +use OpenILS::WWW::EGCatLoader::Library; use OpenILS::WWW::EGCatLoader::Search; use OpenILS::WWW::EGCatLoader::Record; use OpenILS::WWW::EGCatLoader::Container; @@ -121,6 +122,7 @@ sub load { return $self->load_simple("advanced") if $path =~ m:opac/(advanced|numeric|expert):; + return $self->load_library if $path =~ m|opac/library|; return $self->load_rresults if $path =~ m|opac/results|; return $self->load_print_record if $path =~ m|opac/record/print|; return $self->load_record if $path =~ m|opac/record/\d|; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm new file mode 100644 index 0000000000..985343298c --- /dev/null +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm @@ -0,0 +1,44 @@ +package OpenILS::WWW::EGCatLoader; +use strict; use warnings; +use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST); +use OpenSRF::Utils::Logger qw/$logger/; +use OpenILS::Utils::CStoreEditor qw/:funcs/; +use OpenILS::Utils::Fieldmapper; +use OpenILS::Application::AppUtils; +my $U = 'OpenILS::Application::AppUtils'; + +# context additions: +# library : aou object +# parent: aou object +sub load_library { + my $self = shift; + my %kwargs = @_; + my $ctx = $self->ctx; + $ctx->{page} = '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) { + $ctx->{parent} = $ctx->{get_aou}->($aou->parent_ou); + } + + $self->timelog("got basic lib info"); + + return Apache2::Const::OK; +} + +1; diff --git a/Open-ILS/src/templates/opac/library.tt2 b/Open-ILS/src/templates/opac/library.tt2 new file mode 100644 index 0000000000..a7a6a4f92b --- /dev/null +++ b/Open-ILS/src/templates/opac/library.tt2 @@ -0,0 +1,47 @@ +[%- PROCESS "opac/parts/header.tt2"; + WRAPPER "opac/parts/base.tt2"; + INCLUDE "opac/parts/topnav.tt2"; + ctx.page_title = l("Library details: [_1]", ctx.library.name); +-%] + [% INCLUDE "opac/parts/searchbar.tt2" %] +
+

[% ctx.library.name %]

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

[% l('Contact information') %]

+ [%- IF ctx.library.email; %] +
[% l('Email address: ') %][% ctx.library.email %]
+ [%- END; %] + [%- IF ctx.library.phone; %] +
[% l('Telephone: ') %][% ctx.library.phone %]
+ [% 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
+
+ [%- END; %] +
+ + [%- IF ctx.library.parent_ou; %] +

Branch relationship

+
[% l('Parent library: ') %] + [% ctx.parent.name %] +
+ [% END; -%] + +
+[%- END %] -- 2.11.0