more rdetail extras cleanup; added support for authors display
authorberick <berick@esilibrary.com>
Fri, 1 Apr 2011 20:26:12 +0000 (16:26 -0400)
committerberick <berick@esilibrary.com>
Fri, 1 Apr 2011 20:26:12 +0000 (16:26 -0400)
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/web/css/skin/default/opac/style.css
Open-ILS/web/templates/default/opac/parts/record/authors.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/opac/parts/record/extras.tt2

index c58e2cf..a95b8be 100644 (file)
@@ -173,6 +173,7 @@ sub load_common {
 
     $ctx->{referer} = $self->cgi->referer;
     $ctx->{path_info} = $self->cgi->path_info;
+    $ctx->{full_path} = $ctx->{base_path} . $self->cgi->path_info;
     $ctx->{unparsed_uri} = $self->apache->unparsed_uri;
     $ctx->{opac_root} = $ctx->{base_path} . "/opac"; # absolute base url
     $ctx->{is_staff} = ($self->apache->headers_in->get('User-Agent') =~ 'oils_xulrunner');
index 27f36a7..ff9153b 100644 (file)
@@ -979,3 +979,4 @@ a.dash-link:hover { text-decoration: underline !important; }
 .hold-editor-controls a { padding-left: 2em; }
 
 #rdetail_cn_browse_div { text-align: center; }
+.rdetail-author-div { padding-bottom: 10px; }
diff --git a/Open-ILS/web/templates/default/opac/parts/record/authors.tt2 b/Open-ILS/web/templates/default/opac/parts/record/authors.tt2
new file mode 100644 (file)
index 0000000..5d9db77
--- /dev/null
@@ -0,0 +1,51 @@
+[%  
+
+authors = [
+    {
+        type => 'author', 
+        label => l('Authors: '),
+        xpath => '//*[@tag="100"]|//*[@tag="110"]|//*[@tag="111"]'
+    }, {
+        type => 'added', 
+        label => l('Added Authors: '),
+        xpath => '//*[@tag="700"]|//*[@tag="710"]|//*[@tag="711"]'
+    }, {
+        type => 'credits', 
+        label => l('Credits: '),
+        xpath => '//*[@tag="100"]|//*[@tag="110"]|//*[@tag="111"]'
+    }, {
+        type => 'cast', 
+        label => l('Cast: '),
+        xpath => '//*[@tag="508"]'
+    }, {
+        type => 'notes', 
+        label => l('Author Notes: '),
+        xpath => '' # Comes from added content...
+    }
+];
+
+BLOCK build_author_links;
+    FOR node IN ctx.marc_xml.findnodes(xpath);
+        FOR subfield IN node.childNodes;
+            NEXT UNLESS subfield.nodeName == "subfield";
+            code = subfield.getAttribute('code');
+            NEXT UNLESS code.match('[a-z]');
+            term = subfield.textContent | html;
+            '<br/><a href="' _ ctx.opac_root _ '/results?qtype=author&query=' _ term _ '&loc=' _ loc _ '">' _ term _ '</a>';
+        END;
+    END;
+END;
+%]
+
+<div id='rdetail_authors_div' class='rdetail_extras_div'>
+[% FOREACH author IN authors;
+    NEXT UNLESS author.xpath; 
+    links = PROCESS build_author_links(xpath=author.xpath);
+    IF links.match('\S') %]
+    <strong>[% author.label %]</strong>
+    <div class='rdetail-author-div'>[% links %]</div>
+    [% END %]
+[% END %]
+</div>
+
+
index f66b77b..a87248b 100644 (file)
@@ -1,34 +1,5 @@
-[% 
-    # Builds a link like so: $orig_link&expand=$tab#$tab
-    # use of 'SET foo =' prevents unintended inline rendering of values
-    BLOCK rdetail_extras_tab_link;
-        cgi = CGI();
-        SET foo = cgi.param('expand', tab);
-        url = ctx.unparsed_uri.replace('\?.*', '?' _ cgi.query_string);
-        SET foo = url.replace('#.*', ''); # clear any existing anchor
-        url _ '#' _ tab; # anchor on the tab name
-    END;
-%]
-
 <div id="rdetail_main_div">
-
     <div id='rdetail_extras_div' style='width: 100%;'> 
-        
-        <!-- SAMPLE AUTHORS LAYOUT / MOVE TO INCLUDE'D TEMPLATE
-        <div id='rdetail_authors_div' class='rdetail_extras_div hide_me'>
-            <strong>Authors:</strong>
-            <div id="rdetail_authors_inner" style="padding-bottom:10px;"></div>
-            <strong>Added Authors:</strong>
-            <div id="rdetail_moar_authors" style="padding-bottom:10px;"></div>
-            <strong>Credits:</strong>
-            <div id="rdetail_credits" style="padding-bottom:10px;"></div>
-            <strong>Cast:</strong>
-            <div id="rdetail_cast" style="padding-bottom:10px;"></div>
-            <strong>Author Notes:</strong>
-            <div id='rdetail_anotes_div' class='rdetail_extras_div'> </div>
-        </div>
-        -->
-        
         <!-- SAMPLE AWARDS LAYOUT / MOVE TO INCLUDE'D TEMPLATE
         <div id='rdetail_awards_div' class='rdetail_extras_div hide_me'> 
             <strong>Awards:</strong>
         </div>
         -->
 
-        [%
-            # Hidden extras are not yet implemented.  Some may require JS
-            extras = [
-                {name => 'summary',  label => l('Summary &amp; More'), hide => 1}, # Content Cafe
-                {name => 'content',  label => l('Contents'), hide => 1}, # ToC
-                {name => 'authors',  label => l('Authors'), hide => 1}, 
-                {name => 'series',   label => l('Series'), hide => 1}, 
-                {name => 'awards',   label => l('Series'), hide => 1}, 
-                {name => 'subject',  label => l('Subject')}, 
-                {name => 'annotation',  label => l('Annotation'), hide => 1}, 
-                {name => 'reviews',  label => l('Reviews'), hide => 1}, 
-                {name => 'excerpt',  label => l('Excerpt'), hide => 1},
-                {name => 'preview',  label => l('Preview'), hide => 1}, 
-                {name => 'novelist', label => l('Suggestions by NoveList'), hide => 1},
-                {name => 'cnbrowse', label => l('Shelf Browser'), hide => 1},
-                {name => 'copyinfo', label => l('Copy Summary'), hide => 1}, 
-                {name => 'marchtml', label => l('MARC Record')}
-            ];
+        [%  # Hidden extras are not yet implemented.  Some may require JS
+
+        extras = [
+            {name => 'summary',  label => l('Summary &amp; More'), hide => 1}, # Content Cafe
+            {name => 'content',  label => l('Contents'), hide => 1}, # ToC
+            {name => 'authors',  label => l('Authors')}, 
+            {name => 'series',   label => l('Series'), hide => 1}, 
+            {name => 'awards',   label => l('Series'), hide => 1}, 
+            {name => 'subjects', label => l('Subject')}, 
+            {name => 'annotation', label => l('Annotation'), hide => 1}, 
+            {name => 'reviews',  label => l('Reviews'), hide => 1}, 
+            {name => 'excerpt',  label => l('Excerpt'), hide => 1},
+            {name => 'preview',  label => l('Preview'), hide => 1}, 
+            {name => 'novelist', label => l('Suggestions by NoveList'), hide => 1},
+            {name => 'cnbrowse', label => l('Shelf Browser'), hide => 1},
+            {name => 'copyinfo', label => l('Copy Summary'), hide => 1}, 
+            {name => 'marchtml', label => l('MARC Record')}
+        ];
+
+        FOREACH extra IN extras;
+            IF extra.hide; NEXT; END; 
+            name = extra.name;
         %]
-        [% FOREACH extra IN extras %]
-            [% IF extra.hide; NEXT; END; %]
         <div class="rdetail_extras">
             <div class="rdetail_extras_hr"></div>
             <div class="rdetail_extras_link">
-                [% href = PROCESS rdetail_extras_tab_link(tab=extra.name) %]
-                <a name='[% extra.name %]' href='[% href %]'><img
+                [% href = ctx.full_path _ '?expand=' _ name _ '#' _ name; %]
+                <a name='[% name %]' href='[% href %]'><img
                     alt='[% extra.label %]' src="[% ctx.media_prefix %]/images/rdetail_arrow.png" /></a>
                 <a href='[% href %]' class="rdetail_extras_lbl">[% extra.label %]</a>
             </div>
         </div>
         <div class='rdetail_extras_div'>
-            [%  name = extra.name; 
-                exp_name = 'expand_' _ name;
+            [%  exp_name = 'expand_' _ name;
                 IF ctx.$exp_name;
-                    IF name == 'subject';
-                        INCLUDE "default/opac/parts/record/subjects.tt2";
-                    ELSIF name == 'reviews';
-                    ELSIF name == 'excerpt';
-                    ELSIF name == 'preview';
-                    ELSIF name == 'novelist';
-                    ELSIF name == 'cnbrowse';
-                    ELSIF name == 'copyinfo';
-                    ELSIF name == 'marchtml';
+                    IF name == 'marchtml';
                         ctx.marchtml;
+                    ELSE;
+                        # Load the template for the selected extra
+                        INCLUDE "default/opac/parts/record/${name}.tt2";
                     END;
                 END; 
             %]