From 647c014f8c2f2e3e2a9cfc95ddcd6b1fb65319df Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Fri, 5 Apr 2013 16:10:01 -0400 Subject: [PATCH] TPAC: Fix schema.org name / dates for authors Per http://schema.org/Person, the birth date and death date are not supposed to be part of the name of a Person. We can separate these out correctly based on subfield d for 100 fields. Signed-off-by: Dan Scott Signed-off-by: Mike Rylander --- .../templates/opac/parts/record/authors.tt2 | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/templates/opac/parts/record/authors.tt2 b/Open-ILS/src/templates/opac/parts/record/authors.tt2 index 43a30608a0..94a887b7db 100644 --- a/Open-ILS/src/templates/opac/parts/record/authors.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/authors.tt2 @@ -28,7 +28,10 @@ BLOCK build_author_links; qterm = ''; iprop = ''; tlabel = ''; + birthdate = ''; + deathdate = ''; graphics = []; + tag = node.getAttribute('tag'); FOR subfield IN node.childNodes; NEXT UNLESS subfield.nodeName == "subfield"; code = subfield.getAttribute('code'); @@ -37,17 +40,27 @@ BLOCK build_author_links; tlabel = relators.$relcode || label; END; IF code == '6'; + target_field = tag; linked_fields = [subfield.textContent()]; - target_field = node.getAttribute('tag'); get_linked_880s; END; NEXT UNLESS code.match('[a-z]'); sf = subfield.textContent | html; - term = term _ ' ' _ sf; IF code.match('[acdq]'); sf_raw = subfield.textContent.replace('[#"^$\+\-,\.:;&|\[\]()]', ' '); qterm = qterm _ ' ' _ sf_raw; END; + # Only Persons have birth/death dates in schema.org + IF code.match('d') && tag.substr(1,2) == '00'; + IF subfield.textContent.match('^\s*\d{4}'); + birthdate = subfield.textContent.replace('^\s*(\d{4}).*$', '$1'); + END; + IF subfield.textContent.match('-\d{4}\s*$'); + deathdate = subfield.textContent.replace('^\s*.{4}\-(\d{4})\s*$', '$1'); + END; + ELSE; + term = term _ ' ' _ sf; + END; END; url = mkurl(ctx.opac_root _ '/results', {query => qterm, qtype => 'author'}, ['page', 'expand']); author_type = (tlabel || label) | html; @@ -57,7 +70,7 @@ BLOCK build_author_links; IF args.schema.itemtype && args.schema.itemtype.match('MusicAlbum'); iprop = ' itemtype="http://schema.org/MusicGroup" itemscope itemprop="byArtist"'; ELSE; - iprop = ' itemprop="accountablePerson"'; + iprop = ' itemtype="http://schema.org/Person" itemscope itemprop="author"'; END; ELSIF type == 'added'; iprop = ' itemprop="contributor"'; @@ -66,6 +79,12 @@ BLOCK build_author_links; IF iprop; ''; END; term.replace('^\s+', ''); IF iprop; ''; END; + IF birthdate; + ' ' _ birthdate _ '-'; + END; + IF deathdate; + '' _ deathdate _ ''; + END; ''; FOREACH link880 IN graphics; diratt = ''; -- 2.43.2