From be32ff5da0fbcb5e84a357e7cdd93e8eb699f2a2 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Wed, 29 Jun 2011 13:05:43 -0400 Subject: [PATCH] Add SFX integration into base TT OPAC, with config.tt2 entries If openurl.enabled is true, then resolve ISBNs and ISSNs and display the corresponding electronic resources that we have available. Note that if there is a subfield 9 with SFX in either the ISBN or ISSN, then that is the preferred ISSN to use; otherwise we fall back to resolving all of the ISSNs in the record. Signed-off-by: Dan Scott --- .../web/templates/default/opac/parts/config.tt2 | 11 ++++++++ .../web/templates/default/opac/parts/misc_util.tt2 | 32 ++++++++++++++++++++++ .../default/opac/parts/record/summary.tt2 | 17 +++++++++++- .../templates/default/opac/parts/result/table.tt2 | 17 ++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/templates/default/opac/parts/config.tt2 b/Open-ILS/web/templates/default/opac/parts/config.tt2 index fd1c3e9a64..74fa1110b5 100644 --- a/Open-ILS/web/templates/default/opac/parts/config.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/config.tt2 @@ -16,4 +16,15 @@ ctx.refworks.url = 'http://www.refworks.com'; # in addition, you might want to proxy access to RefWorks - for example: # ctx.refworks.url = 'http://librweb.laurentian.ca/login?url=http://refworks.scholarsportal.info'; +############################################################################## +# OpenURL resolution +############################################################################## +# Evergreen provides the ability to point at an OpenURL resolver to find +# electronic resources for a given ISSN or ISBN. Currently, only the SFX +# resolver is supported. +############################################################################## + +openurl.enabled = 'false'; +openurl.baseurl = 'http://sfx.example.com/instance'; + %] diff --git a/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 b/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 index 5d4249e469..752ce5744c 100644 --- a/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 @@ -28,6 +28,38 @@ args.holdings = []; args.uris = []; + args.issns = []; + + # we use $9 of ISBN and ISSN as a flag for e-version + sfx_isbn = xml.findnodes('//*[@tag="020"]/*[@code="9"]'); + IF sfx_isbn; + IF sfx_isbn.textContent == "SFX"; + my_parent = sfx_isbn.parentNode(); + sfx_isbn = my_parent.findnodes('./*[@code="a"]'); + sfx_isbn.replace('-', ''); + args.resolver_isbn = sfx_isbn.replace('\ .*', ''); + END; + END; + + sfx_issn = xml.findnodes('//*[@tag="022"]/*[@code="9"]'); + IF sfx_issn; + IF sfx_issn.textContent == "SFX"; + my_parent = sfx_issn.parentNode(); + sfx_issn = my_parent.findnodes('./*[@code="a"]'); + args.issns.push( + sfx_issn.textContent.replace('[^\d\-X]', '') + ); + END; + END; + + # we snag all issns if no SFX available + IF args.issns.size == 0; + FOR rawissn IN xml.findnodes('//*[@tag="022"]/*[@code="a"]'); + args.issns.push( + rawissn.textContent.replace('[^\d\-X]', '') + ); + END; + END; # URI info is in volumes/volume/uris/volume, instead of uri element FOR volume IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]'); diff --git a/Open-ILS/web/templates/default/opac/parts/record/summary.tt2 b/Open-ILS/web/templates/default/opac/parts/record/summary.tt2 index 63db6ed645..74569c5f7b 100644 --- a/Open-ILS/web/templates/default/opac/parts/record/summary.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/record/summary.tt2 @@ -1,4 +1,7 @@ -[% ctx.page_title = attrs.title | html_entity %] +[% PROCESS "default/opac/parts/misc_util.tt2"; + USE ResolverResolver; + ctx.page_title = attrs.title | html_entity +%] @@ -80,6 +83,18 @@ [% attrs.phys_desc %] + [% IF openurl.enabled == 'true'; FOR issn IN args.issns %] + [% sfx = ResolverResolver.resolve_issn(issn, openurl.baseurl)%] + [% FOR res IN sfx %] + + + + [% res.public_name %] + + [% res.target_coverage %] + + [% END %] + [% END %] [% IF attrs.edition; l("Edition"); END %] diff --git a/Open-ILS/web/templates/default/opac/parts/result/table.tt2 b/Open-ILS/web/templates/default/opac/parts/result/table.tt2 index 964312ac65..6b5db2f72b 100644 --- a/Open-ILS/web/templates/default/opac/parts/result/table.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/result/table.tt2 @@ -1,5 +1,9 @@ [% PROCESS "default/opac/parts/misc_util.tt2"; + IF openurl.enabled == 'true'; + USE ResolverResolver; + END; + ctx.result_start = 1 + ctx.page_size * page; ctx.result_stop = ctx.page_size * (page + 1); IF ctx.result_stop > ctx.hit_count; ctx.result_stop = ctx.hit_count; END; @@ -116,6 +120,19 @@ [% attrs.isbn %] + [% IF openurl.enabled == 'true'; FOR issn IN args.issns %] + [% sfx = ResolverResolver.resolve_issn(issn, openurl.baseurl)%] + [% FOR res IN sfx %] + + + + [% res.public_name %] + + [% res.target_coverage %] + + [% END %] + [% END %] + [% l('Edition:') %] -- 2.11.0