From 2f94c327bee44ecf36b6fb5ba2aaf23c199f0df2 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Sat, 17 Mar 2012 22:52:07 -0400 Subject: [PATCH] First inklings of schema.org support Just get the itemscope and very rudimentary mapping for the primary itemtype into record details. Signed-off-by: Dan Scott Signed-off-by: Mike Rylander --- Open-ILS/src/templates/opac/parts/misc_util.tt2 | 12 +++++++++++- Open-ILS/src/templates/opac/parts/record/body.tt2 | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/templates/opac/parts/misc_util.tt2 b/Open-ILS/src/templates/opac/parts/misc_util.tt2 index 5586d603f1..3b9f9a2f2d 100644 --- a/Open-ILS/src/templates/opac/parts/misc_util.tt2 +++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2 @@ -3,6 +3,13 @@ # get_marc_attrs( { marc_xml => doc } ) BLOCK get_marc_attrs; xml = args.marc_xml; + + # Map item types to schema.org types; impedance mismatch :( + args.schema.itemtype = {}; + schema_typemap = {}; + schema_typemap.a = 'http://schema.org/Book'; + schema_typemap.j = 'http://schema.org/MusicRecording'; + args.isbns = []; FOR isbn IN xml.findnodes('//*[@tag="020"]/*[@code="a"]'); args.isbns.push(isbn.textContent); @@ -208,10 +215,13 @@ node = xml.findnodes( '//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]'); IF node AND node.textContent; + type = node.textContent; args.format_label = node.getAttribute('coded-value') - args.format_icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ node.textContent _ '.png'; + args.schema.itemtype = schema_typemap.$type; + args.format_icon = ctx.media_prefix _ '/images/format_icons/' _ icon_style _ '/' _ type _ '.png'; LAST; END; END; + END; %] diff --git a/Open-ILS/src/templates/opac/parts/record/body.tt2 b/Open-ILS/src/templates/opac/parts/record/body.tt2 index c5d9ec8923..4b49435fef 100644 --- a/Open-ILS/src/templates/opac/parts/record/body.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/body.tt2 @@ -3,7 +3,7 @@ PROCESS get_marc_attrs args=attrs; stop_parms = ['expand','cnoffset']; %] -
+
[% IF ctx.search_result_index >= 0 %]
-- 2.11.0