hey, maybe I should commit sometime today
authorsenator <lebbeous@esilibrary.com>
Tue, 8 Feb 2011 23:12:05 +0000 (18:12 -0500)
committersenator <lebbeous@esilibrary.com>
Tue, 8 Feb 2011 23:12:05 +0000 (18:12 -0500)
results page partly working. woof.

Open-ILS/web/css/skin/default/opac/style.css
Open-ILS/web/templates/default/opac/parts/libselect.tt2
Open-ILS/web/templates/default/opac/parts/marc_misc.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/opac/parts/result/header.tt2
Open-ILS/web/templates/default/opac/parts/result/table.tt2
Open-ILS/web/templates/default/opac/results.tt2

index ef6f49d..1dc531f 100644 (file)
@@ -657,7 +657,7 @@ div.select-wrapper:hover {
        padding-left:15px;
 }
 
-
+.result_table_subtable { width: 100%; border-collapse: collapse; border: 0; }
 
 
 
@@ -891,4 +891,4 @@ div.select-wrapper:hover {
 }
 #rdetail_copy_info_table { font-size: 8pt; }
 #rdetail_copy_info_table td { padding: 3px; }
-
+.search_page_nav_link { cursor: pointer; }
index f41d0e4..59cdfa6 100644 (file)
@@ -24,7 +24,7 @@
 
 <!-- ****************** libselect.xml ***************************** -->
     <span id='depth_selector_span'>
-        [% PROCESS build_org_selector name='loc' %]
+        [% PROCESS build_org_selector name='loc' value=loc %]
     </span>
     <span id='lib_selector_span'>
         <a id='lib_selector_link' class='classic_link'
diff --git a/Open-ILS/web/templates/default/opac/parts/marc_misc.tt2 b/Open-ILS/web/templates/default/opac/parts/marc_misc.tt2
new file mode 100644 (file)
index 0000000..4b5708e
--- /dev/null
@@ -0,0 +1,52 @@
+[% 
+    # Extract MARC fields from XML
+    #   get_marc_attrs( { marc_xml => doc } )
+    BLOCK get_marc_attrs;
+        xml = args.marc_xml;
+        args.isbn = xml.findnodes('//*[@tag="020"]/*[@code="a"]').shift.textContent;
+        args.upc = xml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent;
+        args.issn = xml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
+        args.title = xml.findnodes('//*[@tag="245"]/*[@code="a"]').textContent;
+        args.author = xml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
+        args.publisher = xml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
+        args.pubdate = xml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
+        # clean up the ISBN
+        args.isbn_clean = args.isbn.replace('\ .*', '');
+
+        # KCLS-specific stuff; needs to change
+        args.mattype = xml.findnodes('//*[@tag="998"]/*[@code="d"]').textContent;
+        args.kcls_cn = xml.findnodes('//*[@tag="092" or @tag="099"]/*').textContent;
+
+    END;
+
+    icon_by_mattype = {     # XXX KCLS-specific
+        "a" => "media_book.jpg",
+        "b" => "media_magazines.jpg",
+        "c" => "media_printedmusic.jpg",
+        "d" => "media_microform.jpg",
+        "e" => "media_equipment.jpg",
+        "f" => "media_films.jpg",
+        "g" => "",
+        "h" => "media_dvd.jpg",
+        "i" => "media_bookoncassette.jpg",
+        "j" => "media_musiccd.jpg",
+        "k" => "media_musiccassette.jpg",
+        "l" => "media_musicrecord.jpg",
+        "m" => "media_software.jpg",
+        "n" => "media_bookoncd.jpg",
+        "o" => "media_kit.jpg",
+        "p" => "media_newspaper.jpg",
+        "q" => "media_largeprint.jpg",
+        "r" => "media_3dobject.jpg",
+        "s" => "media_slide.jpg",
+        "t" => "media_online.jpg",
+        "u" => "media_eaudio.jpg",
+        "v" => "media_ebooktext.jpg",
+        "w" => "media_eaudio.jpg",
+        "x" => "media_downloadmusic.jpg",
+        "y" => "media_downloadvideo.jpg",
+        "z" => "media_map.jpg",
+        "2" => "media_cassettewithbook.jpg",
+        "5" => "media_cdwithbook.jpg"
+    };
+%]
index 07e1382..c7e2f58 100644 (file)
@@ -1,36 +1,55 @@
+[%  q = query | url;
+    np_link = '?query=' _ q;
+    IF loc;
+        np_link = np_link _ "&loc=" _ loc;
+    END;
+    IF depth or depth == 0;
+        np_link = np_link _ "&depth=" _ depth;
+    END;
+    ctx.result_start = 1 + ctx.page_size * page;
+    ctx.result_stop = 1 + ctx.page_size * (page + 1);
+    IF ctx.result_stop > ctx.hit_count; ctx.result_stop = ctx.hit_count; END;
+%]
 <div style="height: 10px;"></div>
 <div id="results_header_nav1">
     <table cellpadding="0" cellspacing="0" border="0" width="100%">
         <tr>
             <td class="h1" width="116">Search Results</td>
-            <td valign="bottom" nowrap="nowrap" width="320" style="white-space:nowrap;" class="hide_me" id="result_numbers1">
-                <span> [% l("Results") %] </span>
-                <span id='offset_start' style='font-weight:bold'></span>
-                <span>&nbsp;- </span>
-                <span id='offset_end' style='font-weight:bold'></span>
-                <span>&nbsp;[% l("of") %] </span>
-                <span id='result_count' style='font-weight:bold'></span>
+            <td valign="bottom" nowrap="nowrap" width="320"
+                style="white-space:nowrap;" id="result_numbers1">
+                [% l("Results") %]
+                <strong>[% ctx.result_start %]</strong>
+                &nbsp;-
+                <strong>[% ctx.result_stop  %] </strong>
+                &nbsp;[% l("of") %]
+                <strong>[% ctx.hit_count %]</strong>
                 <span style='padding-left: 6px;'>
                     (page
+                    <strong>[% page + 1 %]</strong>
+                    &nbsp;[% l("of") %]
+                    <strong>[% page_count %]</strong>)
                 </span>
-                <span id='current_page'></span>
-                <span>&nbsp;[% l("of") %] </span>
-                <span id='num_pages'></span>)
             </td>
             <td align="right" valign="bottom">
-                <span id='start_end_links_span' class='hide_me'>
+                <span id='start_end_links_span'>
+                    [% IF page > 0 %]
                     <a class='search_page_nav_link' id='prev_link'
-                        title='[% l("Previous page") %]' style="cursor:pointer;">
+                        href="[% np_link _ '&page=' _ (page - 1) %]"
+                        title='[% l("Previous page") %]'>
                         <span class="nav_arrow_fix">&#9668;</span> Previous
                     </a>
+                    [% END %]
                     <span class='hide_me' id='result_info_div'
                         style='padding-left: 11px; padding-right:11px;'>
                         <span id="nav_pages"></span>
                     </span>
+                    [% IF (page + 1) < page_count %]
                     <a class='search_page_nav_link' id='next_link'
-                        title='[% l("Next page") %]' style="cursor:pointer;">
+                        href="[% np_link _ '&page=' _ (page + 1) %]"
+                        title='[% l("Next page") %]'>
                         Next <span class="nav_arrow_fix">&#9658;</span>
                     </a>
+                    [% END %]
                 </span>
             </td>
         </tr>
index 0d2a569..ab5b9e6 100644 (file)
@@ -1,7 +1,7 @@
-<!-- Search results are spit into this table -->
+[%  PROCESS "default/opac/parts/marc_misc.tt2";
+    SET result_count = ctx.result_start; %]
 <!-- ****************** result_table.xml ***************************** -->
 <div id="result_table_div">
-    
     <table cellpadding="0" cellspacing="0" border="0" width="100%">
         <tr>
             <td valign="top" width="1" style="padding-right:20px;">
                 <table id="res_table" cellpadding="0" cellspacing="0"
                     border="0" width="100%" style="margin-top:10px;">
                     <tbody id="result_table">
-                        <tr id='result_table_template' class='hide_me'>
-                            <td class='result_table_row' align='left'
-                                width='100%'>
-                                <table cellpadding="0" cellspacing="0"
-                                    border="0" width="100%"
-                                    class='result_table_subtable'
-                                    id="results_table"
-                                    style="border-collapse: collapse;">
+                    [%  FOR rec IN ctx.records;
+                            attrs = {marc_xml => rec.marc_xml};
+                            PROCESS get_marc_attrs args=attrs %]
+                        <tr>
+                            <td class='result_table_row' align='left' width='100%'>
+                                <table cellpadding="0" cellspacing="0" class='result_table_subtable'>
                                     <tbody class='result_table_subtbody'>
                                         <tr name='counts_row'>
                                             <td width="58" valign="top"
                                                 style="font-weight:bold;padding-left:10px;"
-                                                name="results_row_count">1.
-                                            </td>
+                                                name="results_row_count">[%
+                                                    result_count; result_count = result_count + 1
+                                                %].</td>
                                             <td class='result_table_pic_header'
                                                 width="78" nowrap="nowrap" valign="top">
-                                                <a><img alt="Image of item"
+                                                [% ident = attrs.isbn_clean || attrs.upc; IF ident; %]
+                                                <a href="record/[% rec.bre.id %]"><img alt="Image of item"
                                                         name='item_jacket' class='result_table_pic'
-                                                        src='${ident}' /></a><br />
+                                                        src='[% ctx.media_prefix %]/opac/extras/ac/jacket/small/[% ident %]' /></a><br />
+                                                [% END %]
                                             </td>
                                             <td class='result_table_title_cell'
                                                 name='result_table_title_cell'
                                                 valign="top">
-                                                <div style="font-weight:bold;">
-                                                    <a title="[% l("View titles for this record") %]"
-                                                        name='item_title' class='search_link'>
-                                                    </a>
+                                                <div class="bold">
+                                                    <a title="[% attrs.title %]" name='item_title'
+                                                        href="record/[% rec.bre.id %]"
+                                                        class='search_link'>[% attrs.title %]</a>
                                                 </div>
                                                 <span style="font-size:11px;">
                                                     <div>
                                                         <em>
-                                                            <a title="[% l("Perform an Author Search") %]" name='item_author' class='search_link'></a>
+                                                            <a title="[% l("Perform an Author Search") %]"
+                                                                name='item_author'
+                                                                href="results?query=author%3a[% attrs.author | replace('[,\.:;]', '') | uri %]&loc=[% loc %]"
+                                                                class='search_link'>[% attrs.author %]</a>
                                                         </em> &nbsp;&nbsp;
-                                                        <span name="results_pub_date"></span>
+                                                        [% attrs.pubdate %]
                                                     </div>
                                                     <table cellpadding="0" cellspacing="0" border="0"
                                                         class="results_info_table">
                                                         <tr name='bib_cn_list' class='result_table_title_cell'>
                                                             <td colspan='2'>
-                                                                <span><strong>Call number:</strong></span>
+                                                                <strong>Call number:</strong>
+                                                                [% args.kcls_cn %]
                                                             </td>
                                                         </tr>
-                                                        <tr name="results_pub_tr" class="hide_me">
+                                                        <tr name="results_pub_tr" class="[% attrs.publisher ? '' : 'hide_me' %]">
                                                             <td valign="top">
                                                                 <strong>Publisher:</strong>
                                                             </td>
-                                                            <td>
-                                                                <span name="results_pub"></span>
-                                                            </td>
+                                                            <td>[% attrs.publisher; %]</td>
                                                         </tr>
-                                                        <tr name="results_isbn_tr" class="hide_me">
+                                                        <tr name="results_isbn_tr" class="[% attrs.isbn ? '' : 'hide_me' %]">
                                                             <td valign="top">
                                                                 <strong>ISBN:</strong>
                                                             </td>
-                                                            <td>
-                                                                <span name="results_isbn"></span>
-                                                            </td>
+                                                            <td>[% attrs.isbn %]</td>
                                                         </tr>
                                                         <tr name="results_edition_tr" class="hide_me">
                                                             <td valign="top">
                                                 <div class="hide_me">
                                                     <span name='result_table_extra_span' class='hide_me'>
                                                         <span name='result_table_pub_box'
-                                                            style='padding-left: 10px;'> 
+                                                            style='padding-left: 10px;'>
                                                             <span name='result_table_edition_span'
                                                                 style='padding-left: 10px;'></span> |
                                                             <span name='result_table_pub_span'> </span> |
                                                 class='result_table_format_cell' align="center" width="1"
                                                 style="padding:0px 10px;">
                                                 <img alt="Format" src="" class="hide_me" name="" />
-                                                <span class='hide_me' 
-                                                    style='color: #9999FF; padding-left: 10px; font-size: 7pt; font-weight: 300;'> 
+                                                <span class='hide_me'
+                                                    style='color: #9999FF; padding-left: 10px; font-size: 7pt; font-weight: 300;'>
                                                     <span>[% l("Match Score: ") %] </span>
                                                     <span name='relevancy_span'> </span>
                                                 </span>
                                                         </div>
                                                     </div>
                                                     <div style="float:right;margin-right:17px;">
-                                                        <img alt="Format" class="hide_me" src=""
-                                                        name="result_mat_type" />
+                                                    [%  key = attrs.mattype;
+                                                        format_desc = ctx.find_citm(key).value;
+                                                        icon_filename = icon_by_mattype.$key;
+                                                        IF icon_filename; %]
+                                                        <img alt="[% format_desc %]" title="[% format_desc %]"
+                                                            src="[% ctx.media_prefix _ '/images/' _ icon_filename %]" />
+                                                    [% END %]
                                                     </div>
                                                 </div>
                                             </td>
                                         </tr>
-                            
                                         <!-- Placeholder for ChiliFresh Review -->
                                         <tr class="hide_me" name="chilifreshReview">
                                             <td></td>
                                                 </div>
                                             </td>
                                         </tr>
-                            
                                         <tr>
                                             <td colspan="5">
                                                 <div style="height:0px;border-top:1px solid #b7b7b7;border-bottom:1px solid #d4d4d4;margin:15px 0px;"></div>
                                 </table>
                             </td>
                         </tr>
+                    [% END %]
                     </tbody>
                 </table>
             </td>
         </tr>
-    </table>  
+    </table>
 </div>
 
 <div>
-    <table id='' style="width:100%;"> 
+    <table id='' style="width:100%;">
         <tbody id=''>
             <tr class="hide_me">
                 <td class='result_table_row' width="100%">
                     <td valign="top">
                         <span class='hide_me' id='result_info_div2'
                             style='font-size: 11px;'>
-                            <span> [% l("Results") %] </span> 
+                            <span> [% l("Results") %] </span>
                             <b id='offset_start2'> </b>
                             <span>&nbsp;- </span>
                             <b id='offset_end2'> </b>
index df39f4f..c24eb35 100644 (file)
@@ -1,12 +1,21 @@
-[%  WRAPPER "default/opac/parts/base.tt2";
+[%  USE CGI;
+    USE POSIX;
+
+    WRAPPER "default/opac/parts/base.tt2";
     INCLUDE "default/opac/parts/topnav.tt2";
-    ctx.page_title = "Search Results" %]
+    ctx.page_title = "Search Results";
+
+    page = CGI.param('page') || 0;
+    query = CGI.param('query');
+    loc = CGI.param('loc');
+    page_count = POSIX.ceil(ctx.hit_count / ctx.page_size);
+%]
     <div id="search-wrapper">
         [% INCLUDE "default/opac/parts/utils.tt2" %]
         [% INCLUDE "default/opac/parts/searchbar.tt2" %]
     </div>
     <div id="content-wrapper">
-        <div id="results_header_bar"><!-- XXX give #results_header_bar its own file -->
+        <div id="results_header_bar">
             <div id="results_header_inner">
                 <div class="results_header_btns">
                     <a href="index.xml"><img alt="Another Search"