First inklings of library schema.org support
authorDan Scott <dscott@laurentian.ca>
Sat, 26 Oct 2013 21:32:22 +0000 (17:32 -0400)
committerDan Scott <dscott@laurentian.ca>
Fri, 1 Nov 2013 20:31:12 +0000 (16:31 -0400)
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Library.pm [new file with mode: 0644]
Open-ILS/src/templates/opac/library.tt2 [new file with mode: 0644]

index 0af9399..e5ceb0f 100644 (file)
@@ -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 (file)
index 0000000..9853432
--- /dev/null
@@ -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 (file)
index 0000000..a7a6a4f
--- /dev/null
@@ -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" %]
+    <div id="content-wrapper" class="content-wrapper-library-page" vocab="http://schema.org/" typeof="Library">
+    <h1 property="name">[% ctx.library.name %]</h1>
+
+    [%- IF (ctx.library.email OR ctx.library.phone); %]
+    <h2 id="contact-info">[% l('Contact information') %]</h2>
+    [%- IF ctx.library.email; %]
+        <div>[% l('Email address: ') %]<a href="mailto:[% ctx.library.email %]" property="email">[% ctx.library.email %]</a></div>
+    [%- END; %]
+    [%- IF ctx.library.phone; %]
+        <div>[% l('Telephone: ') %]<span property="telephone">[% ctx.library.phone %]</span></div>
+    [% END; %]
+    [% END; %]
+
+    <h2>[% l('Opening hours') %]</h2>
+    <div>Pull in from actor.hours_of_operation</div>
+
+    <div id="addresses">
+    [%- IF ctx.library.mailing_address; %]
+    <div id="mailing" property="location address" typeof="PostalAddess">
+        <h3 property="contactType">[% l('Mailing address') %]</h3>
+        [%# Pull in actor.org_address properties here %]
+        <span property="streetAddress">ctx.library.mailing_address.street1<br />
+            IF we have it - ctx.library.mailing_address.street2
+        </span><br />
+        <span property="addressLocality">ctx.library.mailing_address.city</span><br />
+        <span property="addressRegion">ctx.library.mailing_address.state</span><br />
+        <span property="addressCountry" typeof="Country">ctx.library.mailing_address.country</span><br />
+        <span property="postalCode">ctx.library.mailing_address.post_code</span><br />
+    </div>
+    [%- END; %]
+    </div>
+
+    [%- IF ctx.library.parent_ou; %]
+    <h2>Branch relationship</h2>
+    <div id="branch-info">[% l('Parent library: ') %]
+        <a property="branchOf" href="[% mkurl(ctx.opac_root _ '/library/' _ ctx.parent.shortname, {}, 1) %]">[% ctx.parent.name %]</a>
+    </div>
+    [%  END; -%]
+
+    </div>
+[%- END %]