From c32903ff0749ba1ddb0f25b3f584696377be294f Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Tue, 9 Jul 2013 12:30:31 -0400 Subject: [PATCH] Add microdata for holdings via http://schema.org/Offer Map library name to Offer/seller, shelving location to Offer/availableAtOrFrom, call number to Offer/sku, barcode to Offer/serialNumber, copy status to Offer/availability, and ISBN-13 to gtin13. Use the additionalType of Product to give these offers an obvious relationship. Surface copy counts as AggregateOffer instances. Signed-off-by: Dan Scott --- .../perlmods/lib/OpenILS/Application/AppUtils.pm | 1 + Open-ILS/src/templates/opac/parts/misc_util.tt2 | 9 +++++++ Open-ILS/src/templates/opac/parts/record/body.tt2 | 1 + .../templates/opac/parts/record/copy_counts.tt2 | 9 +++++-- .../src/templates/opac/parts/record/copy_table.tt2 | 30 +++++++++++++++++----- .../src/templates/opac/parts/record/summary.tt2 | 8 +++++- 6 files changed, 48 insertions(+), 10 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm index 92f1dafa6f..5c5074e57b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm @@ -1961,6 +1961,7 @@ sub basic_opac_copy_query { {column => 'holdable', alias => 'location_holdable'} ], ccs => [ + {column => 'id', alias => 'status_code'}, {column => 'name', alias => 'copy_status'}, {column => 'holdable', alias => 'status_holdable'} ], diff --git a/Open-ILS/src/templates/opac/parts/misc_util.tt2 b/Open-ILS/src/templates/opac/parts/misc_util.tt2 index 5c18d60a96..697403ac4b 100644 --- a/Open-ILS/src/templates/opac/parts/misc_util.tt2 +++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2 @@ -228,6 +228,14 @@ # clean up the ISBN args.isbn_clean = args.isbns.0.replace('\ .*', ''); + FOR isbn IN args.isbns; + clean_isbn = isbn.replace('\ .*', ''); + clean_isbn = clean_isbn.replace('-', ''); + IF clean_isbn.length == 13; + args.gtin13 = clean_isbn; + LAST; + END; + END; # Extract the 856 URLs that are not otherwise represented by asset.uri's args.online_res = []; @@ -366,6 +374,7 @@ location => loc.textContent, library => circlib.textContent, status => status.textContent, + status_code => status.getAttribute('ident'), barcode => copy.getAttribute('barcode'), owner => volume.getAttribute('lib') }; diff --git a/Open-ILS/src/templates/opac/parts/record/body.tt2 b/Open-ILS/src/templates/opac/parts/record/body.tt2 index 2e74d66b21..d334acc4ae 100644 --- a/Open-ILS/src/templates/opac/parts/record/body.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/body.tt2 @@ -5,6 +5,7 @@ ctx.record_attrs = attrs; # capture for JS %]
+ [%- INCLUDE "opac/parts/record/navigation.tt2" %] [%- IF ctx.bib_is_dead %]
diff --git a/Open-ILS/src/templates/opac/parts/record/copy_counts.tt2 b/Open-ILS/src/templates/opac/parts/record/copy_counts.tt2 index a400aad9cd..e2a865af3e 100644 --- a/Open-ILS/src/templates/opac/parts/record/copy_counts.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/copy_counts.tt2 @@ -17,7 +17,9 @@ ou_name = cp_org_unit.name; displayed_ous.$ou_name = 1; %] -
  • +
  • + + [% l('[quant,_1,copy,copies] at [_2].', ou_avail, ou_name) | html %] [%- this_depth = ctx.get_aou(ou_id).ou_type.depth; IF ou_avail > 0 && this_depth != ctx.copy_depth %] @@ -35,7 +37,10 @@ UNLESS depth < 0 || displayed_ous.exists(ou_name); %] [%- IF attrs.plib_copy_counts.$depth.count > 0; %] -
  • [% +
  • + + + [%- l('[_1] of [quant,_2,copy,copies] available at [_3].', attrs.plib_copy_counts.$depth.available, attrs.plib_copy_counts.$depth.count, diff --git a/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 b/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 index 9a71bcef81..be2ebec6ce 100644 --- a/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 @@ -67,11 +67,11 @@ END; callnum = callnum _ " " _ callnum_suffix; END; -%] - + [%- IF serial_holdings %] [%- copy_info.holding_label | html; -%] - [%- ELSE %] + [%- ELSE %] [%- org_name = ctx.get_aou(copy_info.circ_lib).name; lib_url = ctx.get_org_setting(copy_info.circ_lib, 'lib.info_url'); @@ -80,16 +80,20 @@ END; IF lib_url; ''; END; -%] [% END %] - [% callnum | html %] [% IF ctx.get_org_setting(CGI.param('loc') OR ctx.aou_tree.id, 'sms.enable') == 1 %](Text)[% END %] + [% callnum | html %] [% IF ctx.get_org_setting(CGI.param('loc') OR ctx.aou_tree.id, 'sms.enable') == 1 %](Text)[% END %] [%- IF has_parts == 'true' %] [% copy_info.part_label | html %] [%- END %] - + [%- IF ctx.is_staff -%] [% copy_info.barcode | html %] [%- ELSE -%][% copy_info.barcode | html %] - [%- END -%] - [% copy_info.copy_location | html %] + [%- END -%] + [%- IF attrs.gtin13; + ''; + END; -%] + + [% copy_info.copy_location | html %] [%- IF ctx.is_staff %] [% copy_info.age_protect ? @@ -149,7 +153,19 @@ END; l("Not holdable"); END %] [%- END %] - [% copy_info.copy_status | html %] + [%- + # Hard-coded to match defaults in config.copy_status + IF (copy_info.status_code == 0 OR copy_info.status_code == 7); + ''; + ELSIF copy_info.status_code == 1; + ''; + ELSIF copy_info.status_code == 9; + ''; + ELSIF copy_info.status_code == 12; + ''; + END; + copy_info.copy_status | html; + -%] [% IF copy_info.due_date; date.format( diff --git a/Open-ILS/src/templates/opac/parts/record/summary.tt2 b/Open-ILS/src/templates/opac/parts/record/summary.tt2 index a38bd54f7e..db3f4ca54e 100644 --- a/Open-ILS/src/templates/opac/parts/record/summary.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/summary.tt2 @@ -108,8 +108,14 @@ IF num_uris > 0;
    [%- IF num_uris > 1 %]
      [% END %] [%- FOR uri IN merged_uris %] - [%- IF num_uris == 1 %]

      [% ELSE %]

    • [% END %] + [%- IF num_uris == 1 -%] +

      + [%- ELSE -%] +

    • + [%- END -%] [% uri.link %][% ' - ' _ uri.note IF uri.note %] + + [%- IF attrs.gtin13; ''; END; %] [%- IF num_uris == 1 %]

      [% ELSE %]
    • [% END %] [%- END %] [%- IF num_uris > 1 %]
    [% END %] -- 2.11.0