LP1930614 Bootstrap OPAC Summary Block
authorTerran McCanna <tmccanna@georgialibraries.org>
Wed, 2 Jun 2021 19:29:53 +0000 (15:29 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 25 Mar 2022 21:24:11 +0000 (17:24 -0400)
This breaks out the summary (from the 520 field) from the rest
of the MARC data so that it displays above/outside of the More
Details button on the record page.

Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Ruth Frasur <rfrasur@library.in.gov>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
foo

Open-ILS/src/templates-bootstrap/opac/parts/record/contents-summaryonly.tt2 [new file with mode: 0644]
Open-ILS/src/templates-bootstrap/opac/parts/record/contents.tt2
Open-ILS/src/templates-bootstrap/opac/parts/record/summary.tt2

diff --git a/Open-ILS/src/templates-bootstrap/opac/parts/record/contents-summaryonly.tt2 b/Open-ILS/src/templates-bootstrap/opac/parts/record/contents-summaryonly.tt2
new file mode 100644 (file)
index 0000000..3778321
--- /dev/null
@@ -0,0 +1,61 @@
+[%-
+summary_contents =  [
+    {
+        display_field => 'abstract',
+        label => l('Summary: '),
+        xpath => '//*[@tag="520"]'
+    }
+];
+
+BLOCK render_summary_contents;
+    xpath = xpath || '//*[starts-with(@tag,"520")]';
+    FOR node IN ctx.marc_xml.findnodes(xpath);
+        all_content = [];
+        graphics = [];
+        FOR subfield IN node.childNodes;
+            NEXT UNLESS subfield.nodeName == "subfield";
+            code = subfield.getAttribute('code');
+            IF code == '6';
+               linked_fields = [subfield.textContent()];
+               target_field = node.getAttribute('tag');
+               get_linked_880s;
+            END;
+            NEXT UNLESS code.match('[a-z]');
+            all_content.push(subfield.textContent);
+        END;
+        total_contents = all_content.join(" ").replace('\s+$', '');
+        %] [% "<div class='content_field'>"; total_contents | html ; "</div>";
+        FOREACH link880 IN graphics;
+            '<div class="graphic880"' _ link880.dir _ '>';
+            link880.value | html;
+            '</div>';
+        END;
+    END;
+END;
+
+BLOCK render_all_summary_contents;
+    FOREACH cont IN summary_contents;
+        content = '';
+        df = cont.display_field;
+        IF df AND attrs.hl.$df.size;
+            content = '<!-- highlighted -->' _ attrs.hl.$df.join('<br/>');
+        ELSE;
+            content = PROCESS render_summary_contents(xpath=cont.xpath);
+        END;
+        IF content.match('\S');
+-%]
+<tr>
+    <td class='rdetail_content_type'>[% cont.label %]</td>
+    <td class='rdetail_content_value' property='keywords'>[% content %]</td>
+</tr>
+        [%- END; %]
+    [%- END; %]
+[%- END %]
+
+[%-  content_html = PROCESS render_all_summary_contents;
+    IF content_html.length > 0;
+%]
+
+<p>[%- content_html %]</p>
+
+[%- END %]
index efe3349..ee13110 100755 (executable)
@@ -51,10 +51,6 @@ contents =  [
         label => l('Date/Time and Place of an Event Note: '),
         xpath => '//*[@tag="518"]'
     }, {
-        display_field => 'abstract',
-        label => l('Summary, etc.: '),
-        xpath => '//*[@tag="520"]'
-    }, {
         label => l('Target Audience Note: '),
         xpath => '//*[@tag="521"]'
     }, {
index f55058a..bf7b8d9 100755 (executable)
@@ -69,6 +69,7 @@ ctx.metalinks.push('
                 END;
                 -%]
                 [%- INCLUDE "opac/parts/record/authors.tt2" %]
+                [%- INCLUDE "opac/parts/record/contents-summaryonly.tt2" %]
                 <div>
                     <button id="btnMore" data-toggle="collapse" data-target="#demo"
                         class="btn btn-action btn-sm my-3"><i class="fas fa-info-circle" aria-hidden="true"></i> [%l ("More Details") %]</button>