Added awards expansion to navigation. Changed fields in authors.
authorGarry Collum <gcollum@gmail.com>
Wed, 1 Jun 2016 18:58:54 +0000 (14:58 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 10 Aug 2016 16:21:05 +0000 (12:21 -0400)
Open-ILS/src/kcpl_templates/opac/parts/record/authors.tt2 [new file with mode: 0644]
Open-ILS/src/kcpl_templates/opac/parts/record/awards.tt2 [new file with mode: 0644]
Open-ILS/src/kcpl_templates/opac/parts/record/body.tt2 [new file with mode: 0644]
Open-ILS/src/kcpl_templates/opac/parts/record/navigation.tt2 [new file with mode: 0644]

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 (file)
index 0000000..6db9017
--- /dev/null
@@ -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 = ' <span class="rdetail-author-div"' _ iprop _ ' resource="' _ contrib_ref _ '"><a href="' _ url _ '"><span resource="' _ contrib_ref _ '">';
+        IF iprop; authtml = authtml _ '<span property="name">'; END;
+        authtml = authtml _ link_term.replace('^\s+', '');
+        IF iprop; authtml = authtml _ '</span>'; END;
+        IF birthdate;
+            authtml = authtml _ ' <span property="birthDate">' _ birthdate _ '</span>-';
+        END;
+        IF deathdate;
+            authtml = authtml _ '<span property="deathDate">' _ deathdate _ '</span>';
+        END;
+        authtml = authtml _ '</span></a>'; # 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 _ ' <span class="graphic880"' _ diratt _ '>';
+            link880.value | html;
+            authtml = authtml _ '</span>';
+        END;
+        authtml = authtml _ ' (<span property="description">' _ author_type _ '</span>). ';
+        authtml = authtml _ '</span>'; # End author span
+        authlist.push(authtml);
+    END;
+END;
+%]
+
+<div class='rdetail_authors_div'>
+[%- 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 %]
+</div>
+
+
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 (file)
index 0000000..7b38bc2
--- /dev/null
@@ -0,0 +1,20 @@
+<div class='rdetail_extras_div'> 
+    <div style="margin-bottom:20px;"></div>
+
+    <!-- Chilifresh patron reviews -->
+    [% IF ENV.GBC.CHILIFRESH %]
+    <strong>[% l('Patron Reviews:') %]</strong>
+    <div style="margin-bottom:20px;">
+        <span class="chili_review" id="isbn_[% attrs.isbn_clean | html %]"> </span>
+        <div id="chili_review_[% attrs.isbn_clean | html %]" style="display: none;" align="center" width="100%"></div>
+    </div>
+    [% END %]
+
+    <!-- Novelist suggestions-->
+    [% IF ENV.OILS_NOVELIST_URL %] 
+        <div id='novelist-loading'>[% l('Loading...') %]</div>
+        <div data-novelist-novelistselect="[% attrs.isbn_clean || attrs.upc %]"></div>
+    [% END %]
+
+</div>
+
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 (file)
index 0000000..2801670
--- /dev/null
@@ -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('<meta property="og:type" content="http://schema.org/' _ args.schema.itemtype _ '" />');
+%]
+<div id='canvas_main' class='canvas' vocab="http://schema.org/" typeof='[% args.schema.itemtype %] Product' resource="#schemarecord">
+[%- FOREACH link IN args.links.sameAs; %]
+    <link property="sameAs" href="[% link %]">
+[%- END; %]
+[%- FOREACH link IN args.links.exampleOfWork; %]
+    <link property="exampleOfWork" href="[% link %]">
+[%- END; %]
+    [%- INCLUDE "opac/parts/record/navigation.tt2" %]
+    [%- IF ctx.bib_is_dead %]
+    <div id='rdetail_deleted_exp'>
+        [% 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.") %]
+    </div>
+    [%- END %]
+    [% INCLUDE "opac/parts/record/summary.tt2" %]
+    [%- INCLUDE "opac/parts/record/navigation.tt2" %]
+</div>
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 (file)
index 0000000..033fc88
--- /dev/null
@@ -0,0 +1,43 @@
+[% IF ctx.search_result_index.defined && ctx.search_result_index >= 0 %]
+<div class="rdetail_header">
+    <span class="rdetail_results">
+        <a href='[% mkurl(ctx.opac_root _ '/results', {}, stop_parms); %]'><span class="nav_arrow_fix">&#9668;</span> [% l('Search Results') %]</a>
+        <!-- stash these in JS for the web staff client to find -->
+        <script>
+            window.search_result_hit_count = [% ctx.hit_count %];
+            window.search_result_index = [% ctx.search_result_index %];
+        </script>
+        <span class="rdetail_result_count">
+            [% l('Showing Item [_1] of [_2]', ctx.search_result_index + 1, ctx.hit_count) %]
+        </span>
+    </span>
+    [%- INCLUDE "opac/parts/pref_lib_display.tt2" %]
+    <div class="rdetail_result_nav">
+        [%
+            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);
+        %]
+        <a class='np_nav_link classic_link' title='[% l("Previous Record") %]'
+            href='[% ctx.prev_rec_url %]&amp;expand=awards'><span class="nav_arrow_fix">&#9668;</span> [% l('Previous') %]</a>
+        [% 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);
+        %]
+        <a class='np_nav_link classic_link' title='[% l("Next Record") %]'
+            href='[% ctx.next_rec_url %]&amp;expand=awards'>[% l('Next') %] <span class="nav_arrow_fix">&#9658;</span></a>
+        [% END %]
+
+    </div>
+</div>
+[% END %]