From f955e769750594f7278c455d0d33f31d4809dfaf Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Sun, 18 Mar 2012 23:13:12 -0400 Subject: [PATCH] Add basic schema.org microdata to record details It's shocking how little we can easily and reliably extract from MARC to map to schema.org's metadata structure. However, what I could get shows up relatively nicely on Google's Rich Snippets testing tool. Signed-off-by: Dan Scott Signed-off-by: Mike Rylander --- Open-ILS/src/templates/opac/parts/record/authors.tt2 | 14 ++++++++++++-- Open-ILS/src/templates/opac/parts/record/subjects.tt2 | 2 +- Open-ILS/src/templates/opac/parts/record/summary.tt2 | 11 ++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/templates/opac/parts/record/authors.tt2 b/Open-ILS/src/templates/opac/parts/record/authors.tt2 index fc06cac74c..4a0419cfdf 100644 --- a/Open-ILS/src/templates/opac/parts/record/authors.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/authors.tt2 @@ -28,6 +28,7 @@ BLOCK build_author_links; FOR node IN ctx.marc_xml.findnodes(xpath); term = ''; qterm = ''; + iprop = ''; FOR subfield IN node.childNodes; NEXT UNLESS subfield.nodeName == "subfield"; code = subfield.getAttribute('code'); @@ -39,7 +40,14 @@ BLOCK build_author_links; END; url = mkurl(ctx.opac_root _ '/results', {query => qterm, qtype => 'author'}, ['page', 'expand']); author_type = label | html; - '' _ term _ ' (' _ author_type _ '). '; + + # schema.org changes + IF type == 'author'; + iprop = ' itemprop="accountablePerson"'; + ELSIF type == 'added'; + iprop = ' itemprop="contributor"'; + END; + '' _ term.replace('^\s+', '') _ ' (' _ author_type _ '). '; END; END; %] @@ -47,7 +55,9 @@ END;
[%- FOREACH author IN authors; NEXT UNLESS author.xpath; - links = PROCESS build_author_links(xpath=author.xpath, label=author.label); + links = PROCESS build_author_links( + xpath=author.xpath, label=author.label, type=author.type + ); IF links.match('\S') %] [% links %] [%- END %] diff --git a/Open-ILS/src/templates/opac/parts/record/subjects.tt2 b/Open-ILS/src/templates/opac/parts/record/subjects.tt2 index 59e26a55c6..52d9ac86cd 100644 --- a/Open-ILS/src/templates/opac/parts/record/subjects.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/subjects.tt2 @@ -57,7 +57,7 @@ [% subj.label %] - [% content %] + [% content %] diff --git a/Open-ILS/src/templates/opac/parts/record/summary.tt2 b/Open-ILS/src/templates/opac/parts/record/summary.tt2 index 7ca150eb06..c652d88940 100644 --- a/Open-ILS/src/templates/opac/parts/record/summary.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/summary.tt2 @@ -51,7 +51,7 @@ [% attrs.format_label %]
[%- END %] -

[% attrs.title_extended | html %]

+

[% attrs.title_extended | html %]

[%- INCLUDE "opac/parts/record/authors.tt2" %] @@ -115,7 +115,7 @@ IF num_uris > 0; [%- IF attrs.isbns.0; FOR isbn IN attrs.isbns %]
  • [% l('ISBN:'); %] - [% isbn | html %] + [% isbn | html %]
  • [%- END %] [%- END %] @@ -141,7 +141,12 @@ IF num_uris > 0; [%- IF attrs.publisher %]
  • [% l("Publisher:") %] - [% attrs.publisher | html %] [% IF attrs.pubdate; attrs.pubdate | html; END %] + [% + attrs.publisher | html; + %][% IF attrs.pubdate; %]
  • [%- END %] -- 2.11.0