First inklings of schema.org support
authorDan Scott <dan@coffeecode.net>
Sun, 18 Mar 2012 02:52:07 +0000 (22:52 -0400)
committerDan Scott <dscott@laurentian.ca>
Fri, 30 Mar 2012 15:50:09 +0000 (11:50 -0400)
Just get the itemscope and very rudimentary mapping for the primary
itemtype into record details.

Signed-off-by: Dan Scott <dan@coffeecode.net>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/src/templates/opac/parts/misc_util.tt2
Open-ILS/src/templates/opac/parts/record/body.tt2

index 5586d60..3b9f9a2 100644 (file)
@@ -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);
             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;
 %]
index c5d9ec8..4b49435 100644 (file)
@@ -3,7 +3,7 @@
     PROCESS get_marc_attrs args=attrs;
     stop_parms = ['expand','cnoffset'];
 %]
-<div id='canvas_main' class='canvas'>
+<div id='canvas_main' class='canvas' itemscope itemtype='[% args.schema.itemtype %]'>
 
     [% IF ctx.search_result_index >= 0 %]
     <div id="rdetail_header">