LP#1992827: Improve OPAC URI display user/miker/lp-1992827-improved-opac-uri-display
authorMike Rylander <mrylander@gmail.com>
Thu, 13 Oct 2022 16:12:42 +0000 (12:12 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 13 Oct 2022 16:12:42 +0000 (12:12 -0400)
Currently, the web staff client displays URIs in a slightly different
(and arguably better/more complete) way than the OPAC. In particular,
the staff client includes any 856 with an ind2 value of 0, 1, or 2, and
provides a label indicating the purpose of the URI based on the ind2
value. The OPAC, on the other hand, only displays 856s with an ind2 of 0
or 1, and does not distinguish the purpose.

This commit both implements the "purpose" labeling and allows ind2=2
URIs to be displayed.  Both BooPAC and TPAC templates are adjusted.

This does not change the way Located URIs are excluded from OPAC
display, they are still filtered out based on the existence of subfield
9.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates-bootstrap/opac/parts/misc_util.tt2
Open-ILS/src/templates-bootstrap/opac/parts/record/summary.tt2
Open-ILS/src/templates/opac/parts/misc_util.tt2
Open-ILS/src/templates/opac/parts/record/summary.tt2

index 7e976fd..b6a3a4c 100755 (executable)
 
         # Extract the 856 URLs that are not otherwise represented by asset.uri's
         args.online_res = [];
-        FOR node IN xml.findnodes('//*[@tag="856" and @ind1="4" and (@ind2="0" or @ind2="1")]');
+        FOR node IN xml.findnodes('//*[@tag="856" and @ind1="4" and (@ind2="0" or @ind2="1" or @ind2="2")]');
             IF node.findnodes('./*[@code="9" or @code="w" or @code="n"]'); NEXT; END; # asset.uri's
+            lind2 = node.getAttribute('ind2') || '';
+            ltype = '';
+            IF lind2 == '0'; ltype = l('Electronic Resource:'); END;
+            IF lind2 == '1'; ltype = l('Version of Resource:'); END;
+            IF lind2 == '2'; ltype = l('Related Resource:'); END;
             label = node.findnodes('./*[@code="y"]');
             notes = node.findnodes('./*[@code="z" or @code="3"]');
             FOR href IN node.findnodes('./*[@code="u"]');
                 args.online_res.push({
                     href => href.textContent,
                     link => (loop.first AND label) ? label.textContent : href.textContent,
-                    note => (loop.first) ? notes.textContent : ''
+                    note => (loop.first) ? notes.textContent : '',
+                    type => ltype
                 });
             END;
         END;
index 94ae7f5..ee5d355 100755 (executable)
@@ -530,12 +530,16 @@ ctx.metalinks.push('
                     filtered_href = uri.href | html;
                     filtered_link = uri.link ? uri.link : '' | html;
                     filtered_note = uri.note ? uri.note : '' | html;
+                    filtered_type = uri.type ? uri.type : '' | html;
                 -%]
                 [%- IF num_uris == 1 -%]
                 <p class="rdetail_uri" property="offers" vocab="http://schema.org/" typeof="Offer">
                     [%- ELSE -%]
                     <li class="rdetail_uri" property="offers" vocab="http://schema.org/" typeof="Offer">
                         [%- END -%]
+                        [%- IF filtered_type.length > 0 -%]
+                            <strong> [% filtered_type %] </strong>
+                        [%- END -%]
                         <a href="[% filtered_href %]" class="uri_link" property="url">
                             [%- IF filtered_href != filtered_link;
                             '<span property="description">' _ filtered_link _ '</span>';
index 283bcb0..d54cdbb 100644 (file)
 
         # Extract the 856 URLs that are not otherwise represented by asset.uri's
         args.online_res = [];
-        FOR node IN xml.findnodes('//*[@tag="856" and @ind1="4" and (@ind2="0" or @ind2="1")]');
+        FOR node IN xml.findnodes('//*[@tag="856" and @ind1="4" and (@ind2="0" or @ind2="1" or @ind2="2")]');
             IF node.findnodes('./*[@code="9" or @code="w" or @code="n"]'); NEXT; END; # asset.uri's
+            lind2 = node.getAttribute('ind2') || '';
+            ltype = '';
+            IF lind2 == '0'; ltype = l('Electronic Resource:'); END;
+            IF lind2 == '1'; ltype = l('Version of Resource:'); END;
+            IF lind2 == '2'; ltype = l('Related Resource:'); END;
             label = node.findnodes('./*[@code="y"]');
             notes = node.findnodes('./*[@code="z" or @code="3"]');
             FOR href IN node.findnodes('./*[@code="u"]');
                 args.online_res.push({
                     href => href.textContent, 
                     link => (loop.first AND label) ? label.textContent : href.textContent,
-                    note => (loop.first) ? notes.textContent : ''
+                    note => (loop.first) ? notes.textContent : '',
+                    type => ltype
                 });
             END;
         END;
index b6e4f25..88ed699 100644 (file)
@@ -218,12 +218,16 @@ IF num_uris > 0;
             filtered_href = uri.href | html;
             filtered_link = uri.link ? uri.link : '' | html;
             filtered_note = uri.note ? uri.note : '' | html;
+            filtered_type = uri.type ? uri.type : '' | html;
         -%]
         [%- IF num_uris == 1 -%]
             <p class="rdetail_uri" property="offers" vocab="http://schema.org/" typeof="Offer">
         [%- ELSE -%]
             <li class="rdetail_uri" property="offers" vocab="http://schema.org/" typeof="Offer">
         [%- END -%]
+        [%- IF filtered_type.length > 0 -%]
+            <strong> [% filtered_type %] </strong>
+        [%- END -%]
         <a href="[% filtered_href %]" class="uri_link" property="url" target="_blank" rel="noopener">
         [%- IF filtered_href != filtered_link;
                 '<span property="description">' _ filtered_link _ '</span>';