Fleshed out View MARC / Subjects Tabs
authorberick <berick@esilibrary.com>
Thu, 31 Mar 2011 21:48:47 +0000 (17:48 -0400)
committerberick <berick@esilibrary.com>
Thu, 31 Mar 2011 21:48:47 +0000 (17:48 -0400)
Record detail page has support for showing the 'extras' tabs.  Currently
supported tabs are View MARC (html) and extended subject info.  For
consistency w/ seed skin, subjects are now only shown in expanded
subjects area.

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/web/templates/default/opac/parts/record/body.tt2
Open-ILS/web/templates/default/opac/parts/record/extras.tt2
Open-ILS/web/templates/default/opac/parts/record/subjects.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/opac/parts/record/summary.tt2

index b947908..c58e2cf 100644 (file)
@@ -173,6 +173,7 @@ sub load_common {
 
     $ctx->{referer} = $self->cgi->referer;
     $ctx->{path_info} = $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');
 
@@ -252,7 +253,7 @@ sub load_login {
     # login succeeded, redirect as necessary
 
     my $acct = $self->apache->unparsed_uri;
-    $acct =~ s#/login#/myopac/main#;
+    $acct =~ s|/login|/myopac/main|;
 
     return $self->generic_redirect(
         $cgi->param('redirect_to') || $acct,
index c3716d5..c2da192 100644 (file)
@@ -33,6 +33,14 @@ sub load_record {
     $self->ctx->{copy_limit} = $copy_limit;
     $self->ctx->{copy_offset} = $copy_offset;
 
+    for my $expand ($self->cgi->param('expand')) {
+        if($expand eq 'marchtml') {
+            $self->ctx->{marchtml} = $self->mk_marc_html($rec_id);
+        } elsif($expand eq 'subject') {
+            $self->ctx->{expand_subject} = 1;
+        }
+    }
+
     return Apache2::Const::OK;
 }
 
@@ -121,8 +129,10 @@ sub mk_copy_query {
 sub mk_marc_html {
     my($self, $rec_id) = @_;
 
-    $self->ctx->{marc_html} = $U->simplereq(
-        'open-ils.search', 'open-ils.search.biblio.record.html', $rec_id);
+    # could be optimized considerably by performing the xslt on the already fetched record
+    return $U->simplereq(
+        'open-ils.search', 
+        'open-ils.search.biblio.record.html', $rec_id);
 }
 
 1;
index f36182a..9de517d 100644 (file)
         <div class="clear-both"></div>
     </div>
 
-    <table width='100%' id='np_table' border='0' class="hide_me">
-        <tbody>
-            <tr class='color_4'>
-                <td style='vertical-align: top;' align="center">
-                    <span style="float:left"><a href="javascript:;"
-                        onclick="history.go(-1);">&laquo; Back</a></span>
-                    <span></span>
-                </td>
-            </tr>
-        </tbody>
-    </table>
-
-    <table style='' class='rdetail_header color_1 hide_me' width='100%'
-        border="0" cellspacing="0" cellpadding="0">
-        <tbody>
-            <tr>
-                <td width='33%' align='left' class="hide_me">
-                    <span>[% l("Record Summary") %]</span>
-                </td>
-                <td align='right' style='padding-right: 7px;' width='33%'>
-                    <span id='rdetail_exp_refworks_span' class='hide_me'
-                        style='padding-right: 7px;'>
-                        <a id='rdetail_exp_refworks'>[% l("Export to RefWorks") %]</a>
-                    </span>
-                    <span style='padding-right: 7px;' class='hide_me'
-                        id='rdetail_more_actions'>
-                        <select id='rdetail_more_actions_selector'
-                            style='max-width: 11em;' class="hide_me">
-                            <option value='start'>
-                                [% l("More Actions...") %]
-                            </option>
-                            <option disabled='disabled'>
-                                --------------
-                            </option>
-                            <option disabled='disabled'>
-                                [% l("Add to bookbag") %]
-                            </option>
-                            <option disabled='disabled'>
-                                --------------
-                            </option>
-                            <option value='new_bookbag'>
-                                [% l("Create a new bookbag") %]
-                            </option>
-                        </select>
-                    </span>
-                </td>
-            </tr>
-        </tbody>
-    </table>
-
     <div style='font-weight: bold; padding: 5px; margin: 5px; width: 100%;'
         class='hide_me color_4' id='rdetail_deleted_exp'>
         [% l("This record has been deleted from the database.  We recommend that you remove this title from any bookbags it may have been added to.") %]
     </div>
-
     [% INCLUDE "default/opac/parts/record/summary.tt2" %]
     <br />
-    <div style="width:100%;" class="hide_me">
-        <div style="float:right;" class="hide_me" id="lib_info_more">
-            <button>More...</button>
-        </div>
-        <div style="float:right;" class="hide_me" id="lib_info_less">
-            <button>...Less</button>
-        </div>
-    </div>
     [% INCLUDE "default/opac/parts/record/extras.tt2" %]
-
-    <div class='hide_me' id='rdetail_bb_none'>
-        [% l("(none)") %]
-    </div>
-    <div class='hide_me' id='rdetail_bb_item_success'>
-        [% l("Item successfully added to bookbag") %]
-    </div>
-    <div class='hide_me' id='rdetail_bb_new'>
-        [% l("Enter the name of the new bookbag") %]
-    </div>
-    <div class='hide_me' id='rdetail_bb_success'>
-        [% l("Bookbag successfully created") %]
-    </div>
 </div>
 <!-- ****************** end; page_rdetail.xml ***************************** -->
index 6db9b6e..292ed79 100644 (file)
@@ -1,5 +1,14 @@
+[% 
+    # Augments/alters the current URL to set expand=$tab
+    # for displaying expanded detail content. 
+    BLOCK rdetail_extras_tab_link;
+        SET foo = CGI.param('expand', tab);
+        ctx.unparsed_uri.replace('\?.*', '?' _ CGI.query_string);
+    END;
+%]
+
 <div id="rdetail_main_div">
-    <table class='hide_me rdetails_extra_links'>
+    <table class='rdetails_extra_links'>
         <thead>
             <tr>
                 <td id='rdetail_annotation_link' class='hide_me rdetail_extras_td'
@@ -12,8 +21,6 @@
     </table>
 
     <div id='rdetail_extras_div' style='width: 100%;'> 
-        <div id='rdetail_extras_loading' class='hide_me' 
-            style='padding: 10px;'>[% l("Loading...") %]</div>
 
         <div rel="rdetail_summary_div" rel2="summary" class="rdetail_extras hide_me" id="rdetail_summary_link">
             <div class="rdetail_extras_hr"></div>
             </table>
             <iframe width="100%" height="500" id="content_cafe_summary" frameborder="0"></iframe>
         </div>
-        
-        <div rel="rdetail_subject_div" rel2="subject" class="rdetail_extras hide_me" id="rdetail_subject_link">
-            <div class="rdetail_extras_hr"></div>
-            <div class="rdetail_extras_link">
-                <a href='javascript:rdetailShowExtra("subject");'><img
-                    alt="" src="[% ctx.media_prefix %]/images/rdetail_arrow.png" /></a>
-                <a href='javascript:rdetailShowExtra("subject");' class="rdetail_extras_lbl">subject</a>
-            </div>
-        </div>
-
-        <div id='rdetail_subject_div' class='rdetail_extras_div hide_me'> 
-            <table cellpadding="0" cellspacing="0" border="0">
-                <tr>
-                    <td width="1" style="padding-right:7px;" valign="top">
-                        <strong>Subject: </strong>
-                    </td>
-                    <td>
-                        <div id='rdetail_subject_container'></div>
-                    </td>
-                </tr>
-                <tr>
-                    <td width="1" style="padding:5px 7px 0px 0px;" valign="top">
-                        <strong>Genre: </strong>
-                    </td>
-                    <td style="padding-top:5px;">
-                        <div id='rdetail_genre_cont'></div>
-                    </td>
-                </tr>
-                <tr>
-                    <td width="1" style="padding:5px 7px 0px 0px;white-space:nowrap;"
-                        nowrap="nowrap" valign="top">
-                        <strong>Topic Heading: </strong>
-                    </td>
-                    <td style="padding-top:5px;">
-                        <div id='rdetail_topic_cont'></div>
-                    </td>
-                </tr>
-                <tr>
-                    <td width="1" style="padding:5px 7px 0px 0px;white-space:nowrap;"
-                        nowrap="nowrap" valign="top">
-                        <strong>Geographic Setting: </strong>
-                    </td>
-                    <td style="padding-top:5px;">
-                        <div id='rdetail_geo_cont'></div>
-                    </td>
-                </tr>
-                <tr>
-                    <td width="1" style="padding:5px 7px 0px 0px;white-space:nowrap;"
-                        nowrap="nowrap" valign="top">
-                        <strong>Biographical Subject: </strong>
-                    </td>
-                    <td style="padding-top:5px;">
-                        <div id='rdetail_bio_cont'></div>
-                    </td>
-                </tr>
-                <tr>
-                    <td width="1" style="padding:5px 7px 0px 0px;white-space:nowrap;"
-                        nowrap="nowrap" valign="top">
-                        <strong>Character Attributes: </strong>
-                    </td>
-                    <td style="padding-top:5px;">
-                        <div id='rdetail_attrib_cont'></div>
-                    </td>
-                </tr>
-                <tr>
-                    <td width="1" style="padding:5px 7px 0px 0px;" valign="top">
-                        <strong>Setting: </strong>
-                    </td>
-                    <td style="padding-top:5px;">
-                        <div id='rdetail_setting_cont'></div>
-                    </td>
-                </tr>
-                <tr>
-                    <td width="1" style="padding:5px 7px 0px 0px;white-space:nowrap;"
-                        nowrap="nowrap" valign="top">
-                        <strong>Time Period: </strong>
-                    </td>
-                    <td style="padding-top:5px;">
-                        <div id='rdetail_time_cont'></div>
-                    </td>
-                </tr>
-            </table>
-        </div>
 
+        [% INCLUDE "default/opac/parts/record/subjects.tt2" %]
+        
         <div rel="rdetail_content_div" rel2="content"
             class="rdetail_extras hide_me" id="rdetail_content_link">
             <div class="rdetail_extras_hr"></div>
                     alt="" src="[% ctx.media_prefix %]/images/rdetail_arrow.png" /></a>
                 <a href='javascript:rdetailShowExtra("cn");'
                     class="rdetail_extras_lbl">[% l("Shelf Browser") %]</a>
-            </div>
+           </div>
         </div>
 
         <div id='rdetail_cn_browse_div' style='text-align: center;' class='hide_me'>
 
         [% INCLUDE "default/opac/parts/record/copyinfo.tt2" %]
 
-        <div rel="rdetail_marc_div" rel2="marc" class="rdetail_extras hide_me" id="rdetail_viewmarc_link">
+        <div name='marchtml' rel="rdetail_marc_div" rel2="marc" class="rdetail_extras" id="rdetail_viewmarc_link">
             <div class="rdetail_extras_hr"></div>
             <div class="rdetail_extras_link">
-                <a href='javascript:rdetailShowExtra("marc");'><img
-                    alt="" src="[% ctx.media_prefix %]/images/rdetail_arrow.png" /></a>
-                <a href='javascript:rdetailShowExtra("marc");'
-                    class="rdetail_extras_lbl">[% l("MARC Record") %]</a>
+                [% marc_href = PROCESS rdetail_extras_tab_link(tab='marchtml') %]
+                <a href='[% marc_href %]'><img
+                    alt="[% l('MARC Record') %]" src="[% ctx.media_prefix %]/images/rdetail_arrow.png"/></a>
+                <a href='[% marc_href %]' class="rdetail_extras_lbl">[% l("MARC Record") %]</a>
             </div>
         </div>
-        <div id='rdetail_marc_div' class='rdetail_extras_div hide_me'>
-            <div id='rdetail_view_marc_box'></div>
-        </div>
+        [% IF ctx.marchtml %]
+        <div class='rdetail_extras_div'>[% ctx.marchtml %]</div>
+        [% END %]
     </div>
     <div id='rdetail_preview_full_text' class='hide_me'>[% l("Full text") %]</div>
     <div id='rdetail_preview_title' class='hide_me'>[% l("See the full text of this book.") %]</div>
diff --git a/Open-ILS/web/templates/default/opac/parts/record/subjects.tt2 b/Open-ILS/web/templates/default/opac/parts/record/subjects.tt2
new file mode 100644 (file)
index 0000000..50a83f6
--- /dev/null
@@ -0,0 +1,92 @@
+<div name='subject' rel="rdetail_subject_div" rel2="subject" class="rdetail_extras" id="rdetail_subject_link">
+    <div class="rdetail_extras_hr"></div>
+    <div class="rdetail_extras_link">
+        [% subj_href = PROCESS rdetail_extras_tab_link(tab='subject') %]
+        <a href='[% subj_href %]'><img
+            alt="[% l('Subject') %]" src="[% ctx.media_prefix %]/images/rdetail_arrow.png" /></a>
+        <a href='[% subj_href %]' class="rdetail_extras_lbl">[% l('Subject') %]</a>
+    </div>
+</div>
+
+[% IF ctx.expand_subject %]
+
+<div id='rdetail_subject_div' class='rdetail_extras_div'>
+    <table cellpadding="0" cellspacing="0" border="0">
+        <tr>
+            <td width="1" style="padding-right:7px;" valign="top">
+                <strong>[% l('Subject:') %] </strong>
+            </td>
+            <td>
+                [% BLOCK render_subject;
+                loc = CGI.param('loc') | uri;
+                xpath = xpath || '//*[starts-with(@tag,"6")]';
+                FOR node IN ctx.marc_xml.findnodes(xpath);
+                    all_terms = [];
+                    FOR subfield IN node.childNodes;
+                        NEXT UNLESS subfield.nodeName == "subfield";
+                        code = 0;
+                        FOR a IN subfield.attributes;
+                            IF a.nodeName == "code";
+                                code = a.nodeValue;
+                            END;
+                        END;
+                        NEXT UNLESS code.match('[a-z]');
+
+                        IF code.match('[vxyz]');
+                            " &mdash; ";
+                        END;
+                        # at this point, we actually have a partial term to use.
+                        single_term = subfield.textContent | html;
+                        all_terms.push(subfield.textContent);
+                        total_term = all_terms.join(" ").replace('\s+$', '') ; # XXX need to take care of any &'s, right?
+                        '<a href="' _ ctx.opac_root _ '/results?qtype=subject&query=' _ total_term _ '&loc=' _ loc _ '">' _ single_term _ '</a>';
+                    END;
+                    "<br />";
+                END %]
+                [% END %]
+                [% s = PROCESS render_subject; IF s.match('\S'); s; END; %]
+            </td>
+        </tr>
+
+        [%
+            subjects = [
+                {
+                    label => l('Genre: '),
+                    xpath => '//*[@tag="655"]|//*[@tag="659"]'
+                }, {
+                    label => l('Topic Heading: '),
+                    xpath => '//*[@tag="690"]'
+                }, {
+                    label => l('Geographic Setting: '),
+                    xpath => '//*[@tag="691"]'
+                }, {
+                    label => l('Biographical Subject: '),
+                    xpath => '//*[@tag="692"]'
+                }, {
+                    label => l('Character Attributes: '),
+                    xpath => '//*[@tag="693"]'
+                }, {
+                    label => l('Setting: '),
+                    xpath => '//*[@tag="698"]'
+                }, {
+                    label => l('Time Period: '),
+                    xpath => '//*[@tag="699"]'
+                }
+            ];
+
+            FOREACH subj IN subjects;
+                '<!-- SUBJECT = ' _ subj.label _ ' : xpath = ' _ subj.xpath _ ' -->';
+                content = PROCESS render_subject(xpath=subj.xpath);
+                IF content.match('\S') %]
+                <tr>
+                    <td width="1" style="padding:5px 7px 0px 0px;" valign="top">
+                        <strong>[% subj.label %]</strong>
+                    </td>
+                    <td style="padding-top:5px;"><div>[% content %] </div></td>
+                </tr>
+        [% END; END; %]
+    </table>
+</div>
+
+[% END %]
+
index a62508d..eaa77a4 100644 (file)
                             </td>
                             <td valign="top" id='rdetail_pubdate'>[% attrs.pubdate %]</td>
                         </tr>
-                        <tr>
-                            <!--<td nowrap='nowrap' valign="top">
-                                <strong id="rdetail_sum_lbl">Summary</strong>
-                            </td>
-                            <td valign="top" id='rdetail_abstract'></td>-->
-                            [% BLOCK render_subject;
-                            loc = CGI.param('loc') | uri;
-                            FOR node IN ctx.marc_xml.findnodes('//*[starts-with(@tag,"6")]');
-                                all_terms = [];
-                                FOR subfield IN node.childNodes;
-                                    NEXT UNLESS subfield.nodeName == "subfield";
-                                    code = 0;
-                                    FOR a IN subfield.attributes;
-                                        IF a.nodeName == "code";
-                                            code = a.nodeValue;
-                                        END;
-                                    END;
-                                    NEXT UNLESS code.match('[a-z]');
-
-                                    IF code.match('[vxyz]');
-                                        " &mdash; ";
-                                    END;
-                                    # at this point, we actually have a partial
-                                    # term to use.
-                                    single_term = subfield.textContent | html;
-                                    all_terms.push(subfield.textContent);
-                                    total_term = all_terms.join(" ").replace('\s+$', '') ; # XXX need to take care of any &'s, right?
-                                    '<a href="' _ ctx.opac_root _ '/results?qtype=subject&query=' _ total_term _ '&loc=' _ loc _ '">' _ single_term _ '</a>';
-                                END;
-                                "<br />";
-                            END %]
-                            [% END %]
-                            [% s = PROCESS render_subject; IF s.match('\S') %]
-                            <td nowrap='nowrap' valign="top">
-                                <strong id="rdetail_sub_lbl">[% l("Subjects") %]</strong>
-                            </td>
-                            <td valign="top" colspan="3">[% s %]</td>
-                            [% END %]
-                        </tr>
                     </table>
                 </div>
             </td>