From f08f67034800131ee78edb7f17b7762a45ae2272 Mon Sep 17 00:00:00 2001 From: Garry Collum Date: Wed, 1 Jun 2016 14:58:54 -0400 Subject: [PATCH] Added awards expansion to navigation. Changed fields in authors. --- .../kcpl_templates/opac/parts/record/authors.tt2 | 166 +++++++++++++++++++++ .../kcpl_templates/opac/parts/record/awards.tt2 | 20 +++ .../src/kcpl_templates/opac/parts/record/body.tt2 | 23 +++ .../opac/parts/record/navigation.tt2 | 43 ++++++ 4 files changed, 252 insertions(+) create mode 100644 Open-ILS/src/kcpl_templates/opac/parts/record/authors.tt2 create mode 100644 Open-ILS/src/kcpl_templates/opac/parts/record/awards.tt2 create mode 100644 Open-ILS/src/kcpl_templates/opac/parts/record/body.tt2 create mode 100644 Open-ILS/src/kcpl_templates/opac/parts/record/navigation.tt2 diff --git a/Open-ILS/src/kcpl_templates/opac/parts/record/authors.tt2 b/Open-ILS/src/kcpl_templates/opac/parts/record/authors.tt2 new file mode 100644 index 0000000000..6db9017668 --- /dev/null +++ b/Open-ILS/src/kcpl_templates/opac/parts/record/authors.tt2 @@ -0,0 +1,166 @@ +[%- + +PROCESS "opac/parts/relators.tt2"; + +author_cnt = 0; +authors = [ + { + type => 'author', + label => l('Author'), + xpath => '//*[@tag="100"]|//*[@tag="110"]|//*[@tag="111"]' + }, { + type => 'added', + label => l('Added Entry'), + xpath => '//*[@tag="700"]|//*[@tag="710"]|//*[@tag="711"]' + }, { + type => 'cast', + label => l('Cast'), + xpath => '//*[@tag="508"]' + }, { + type => 'notes', + label => l('Author Notes: '), + xpath => '' # Comes from added content... + } +]; + +BLOCK normalize_qterm; + subfield.textContent.replace('[#"^$\+\-,\.:;&|\[\]()]', ' '); +END; + +BLOCK normalize_authors; + link_term = link_term _ ' ' _ sf; + sf_raw = PROCESS normalize_qterm; + qterm = qterm _ ' ' _ sf_raw; + indexed_term = 1; +END; + +BLOCK build_author_links; + FOR node IN ctx.marc_xml.findnodes(xpath); + author_cnt = author_cnt + 1; + contrib_ref = '#schemacontrib' _ author_cnt; + iprop = ''; # schema.org item type / property + link_term = ''; # Linked term (e.g. Personal name + Fuller form of name) + supp_term = ''; # Supplementary terms + qterm = ''; # Search query + tlabel = ''; + birthdate = ''; + deathdate = ''; + graphics = []; + tag = node.getAttribute('tag'); + FOR subfield IN node.childNodes; + indexed_term = ''; + NEXT UNLESS subfield.nodeName == "subfield"; + code = subfield.getAttribute('code'); + IF code == '4'; + relcode = subfield.textContent.substr(0,3); + tlabel = relators.$relcode || label; + END; + IF code == '6'; + target_field = tag; + linked_fields = [subfield.textContent()]; + get_linked_880s; + END; + NEXT UNLESS code.match('[a-z]'); + sf = subfield.textContent | html; + + # Only Persons have birth/death dates in schema.org + # Match personal/corporate/conference MODS subfields + IF tag.substr(1,2) == '00'; + IF code.match('[abcqu]'); + PROCESS normalize_authors; + END; + IF code.match('d'); + IF subfield.textContent.match('^\s*\d{4}'); + birthdate = subfield.textContent.replace('^\s*(\d{4}).*$', '$1'); + END; + IF subfield.textContent.match('-\d{4}.*$'); + deathdate = subfield.textContent.replace('^\s*.{4}\-(\d{4}).*$', '$1'); + END; + indexed_term = 1; + sf_raw = PROCESS normalize_qterm; + qterm = qterm _ sf_raw; + END; + ELSIF tag.substr(1,2) == '10'; + IF code.match('[abcdn]'); + PROCESS normalize_authors; + END; + ELSIF code.match('[acdeq]'); + PROCESS normalize_authors; + END; + UNLESS indexed_term; + supp_term = supp_term _ ' ' _ sf; + END; + END; + url = mkurl(ctx.opac_root _ '/results', {query => qterm.replace('^\s*(.*?)\s*$', '$1'), qtype => 'author'}, stop_parms.merge(expert_search_parms, general_search_parms, browse_search_parms, facet_search_parms)); + author_type = (tlabel || label) | html; + + # schema.org changes + IF type == 'author'; + IF tag.substr(1,2) == '10' && args.schema.itemtype && args.schema.itemtype.match('MusicAlbum'); + iprop = ' typeof="MusicGroup" property="byArtist"'; + ELSIF tag.substr(1,2) == '00'; + iprop = ' typeof="Person" property="author"'; + ELSE; + iprop = ' typeof="Organization" property="author"'; + END; + ELSIF type == 'added'; + IF tag.substr(1,2) == '00'; + iprop = ' typeof="Person" property="contributor'; + ELSE; + iprop = ' typeof="Organization" property="contributor'; + END; + IF relcode; + iprop = iprop _ ' http://id.loc.gov/vocabulary/relators/' _ relcode; + END; + iprop = iprop _ '"'; + END; + authtml = ' '; + IF iprop; authtml = authtml _ ''; END; + authtml = authtml _ link_term.replace('^\s+', ''); + IF iprop; authtml = authtml _ ''; END; + IF birthdate; + authtml = authtml _ ' ' _ birthdate _ '-'; + END; + IF deathdate; + authtml = authtml _ '' _ deathdate _ ''; + END; + authtml = authtml _ ''; # End search link + + # Display supplemental terms (mostly about the author's work) + IF supp_term; + authtml = authtml _ ' ' _ supp_term; + END; + + # Display linked 880 fields + FOREACH link880 IN graphics; + diratt = ''; + IF link880.dir; + diratt = ' dir="' _ link880.dir _ '"'; + END; + authtml = authtml _ ' '; + link880.value | html; + authtml = authtml _ ''; + END; + authtml = authtml _ ' (' _ author_type _ '). '; + authtml = authtml _ ''; # End author span + authlist.push(authtml); + END; +END; +%] + +
+[%- FOREACH author IN authors; + NEXT UNLESS author.xpath; + authlist = []; + PROCESS build_author_links( + xpath=author.xpath, label=author.label, type=author.type + ); + IF authlist.size; + FOREACH authtml IN authlist; + authtml; + END; + END; +END %] +
+ + diff --git a/Open-ILS/src/kcpl_templates/opac/parts/record/awards.tt2 b/Open-ILS/src/kcpl_templates/opac/parts/record/awards.tt2 new file mode 100644 index 0000000000..7b38bc262d --- /dev/null +++ b/Open-ILS/src/kcpl_templates/opac/parts/record/awards.tt2 @@ -0,0 +1,20 @@ +
+
+ + + [% IF ENV.GBC.CHILIFRESH %] + [% l('Patron Reviews:') %] +
+ + +
+ [% END %] + + + [% IF ENV.OILS_NOVELIST_URL %] +
[% l('Loading...') %]
+
+ [% END %] + +
+ diff --git a/Open-ILS/src/kcpl_templates/opac/parts/record/body.tt2 b/Open-ILS/src/kcpl_templates/opac/parts/record/body.tt2 new file mode 100644 index 0000000000..2801670de8 --- /dev/null +++ b/Open-ILS/src/kcpl_templates/opac/parts/record/body.tt2 @@ -0,0 +1,23 @@ +[%- attrs = {marc_xml => ctx.marc_xml}; + PROCESS "opac/parts/misc_util.tt2"; + PROCESS get_marc_attrs args=attrs; + stop_parms = ['expand','cnoffset','copy_offset','copy_limit']; + ctx.record_attrs = attrs; # capture for JS + ctx.metalinks.push(''); +%] +
+[%- FOREACH link IN args.links.sameAs; %] + +[%- END; %] +[%- FOREACH link IN args.links.exampleOfWork; %] + +[%- END; %] + [%- INCLUDE "opac/parts/record/navigation.tt2" %] + [%- IF ctx.bib_is_dead %] +
+ [% l("This record has been deleted from the database. We recommend that you remove this title from any lists it may have been added to.") %] +
+ [%- END %] + [% INCLUDE "opac/parts/record/summary.tt2" %] + [%- INCLUDE "opac/parts/record/navigation.tt2" %] +
diff --git a/Open-ILS/src/kcpl_templates/opac/parts/record/navigation.tt2 b/Open-ILS/src/kcpl_templates/opac/parts/record/navigation.tt2 new file mode 100644 index 0000000000..033fc88b53 --- /dev/null +++ b/Open-ILS/src/kcpl_templates/opac/parts/record/navigation.tt2 @@ -0,0 +1,43 @@ +[% IF ctx.search_result_index.defined && ctx.search_result_index >= 0 %] +
+ + [% l('Search Results') %] + + + + [% l('Showing Item [_1] of [_2]', ctx.search_result_index + 1, ctx.hit_count) %] + + + [%- INCLUDE "opac/parts/pref_lib_display.tt2" %] +
+ [% + IF ctx.prev_search_record; + prev_args = {}; + IF ctx.search_page > 0 AND + ctx.search_result_index % ((ctx.page_size * ctx.search_page)) == 0; # first record in the page + prev_args.page = ctx.search_page - 1; + END; + ctx.prev_rec_url = mkurl(ctx.prev_search_record, prev_args, stop_parms); + %] + [% l('Previous') %] + [% END %] + + [% + IF ctx.next_search_record; + next_args = {}; + IF (ctx.page_size * (ctx.search_page + 1)) == ctx.search_result_index + 1; + next_args.page = ctx.search_page + 1; + END; + ctx.next_rec_url = mkurl(ctx.next_search_record, next_args, stop_parms); + %] + [% l('Next') %] + [% END %] + +
+
+[% END %] -- 2.11.0