Add SFX integration into base TT OPAC, with config.tt2 entries
authorDan Scott <dan@coffeecode.net>
Wed, 29 Jun 2011 17:05:43 +0000 (13:05 -0400)
committerDan Scott <dan@coffeecode.net>
Wed, 29 Jun 2011 17:05:43 +0000 (13:05 -0400)
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 <dscott@laurentian.ca>
Open-ILS/web/templates/default/opac/parts/config.tt2
Open-ILS/web/templates/default/opac/parts/misc_util.tt2
Open-ILS/web/templates/default/opac/parts/record/summary.tt2
Open-ILS/web/templates/default/opac/parts/result/table.tt2

index fd1c3e9..74fa111 100644 (file)
@@ -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';
+
 %]
index 5d4249e..752ce57 100644 (file)
 
         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"]');
index 63db6ed..74569c5 100644 (file)
@@ -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
+%]
 <!-- ****************** rdetail_summary.xml ***************************** -->
 <abbr class="unapi-id" title='tag:[% ctx.hostname %],[% date.format(date.now, '%Y') %]:biblio-record_entry/[% ctx.bre_id %]'></abbr>
 
                             </td>
                             <td valign="top" id='rdetail_physical_desc'>[% attrs.phys_desc %]</td>
                         </tr>
+                        [% IF openurl.enabled == 'true'; FOR issn IN args.issns %]
+                            [% sfx = ResolverResolver.resolve_issn(issn, openurl.baseurl)%]
+                            [% FOR res IN sfx %]
+                            <tr name="results_issn_tr">
+                                <td valign="top">
+                                    <strong><a href="[% res.target_url %]">
+                                        [% res.public_name %]</a></strong>
+                                </td>
+                                <td>[% res.target_coverage %]</td>
+                            </tr>
+                            [% END %]
+                        [% END %]
                         <tr>
                             <td nowrap='nowrap' valign="top">
                                 <strong id="rdetail_ed_lbl">[% IF attrs.edition; l("Edition"); END %]</strong>
index 964312a..6b5db2f 100644 (file)
@@ -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;
                                                             </td>
                                                             <td>[% attrs.isbn %]</td>
                                                         </tr>
+                                                        [% IF openurl.enabled == 'true'; FOR issn IN args.issns %]
+                                                            [% sfx = ResolverResolver.resolve_issn(issn, openurl.baseurl)%]
+                                                            [% FOR res IN sfx %]
+                                                        <tr name="results_issn_tr">
+                                                            <td valign="top">
+                                                                <strong><a href="[% res.target_url %]">
+                                                                [% res.public_name %]</a></strong>
+                                                            </td>
+                                                            <td>[% res.target_coverage %]</td>
+                                                        </tr>
+                                                            [% END %]
+                                                        [% END %]
+
                                                         <tr name="results_edition_tr" class="[% attrs.edition ? '' : 'hide_me' %]">
                                                             <td valign="top">
                                                                 <strong>[% l('Edition:') %]</strong>