Changeset 5306 for MILK


Ignore:
Timestamp:
19/05/09 13:20:29 (10 years ago)
Author:
cbyrom
Message:

Add new template method, 'semanticSearch' to do the asynchronous
loading of alternative search options - and replace the previous
template code with this in both results pages. Fix a couple of issues
with the PagerState? object to ensure start/last page stride is set
correctly.

Location:
MILK/trunk/milk_server/milk_server
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • MILK/trunk/milk_server/milk_server/controllers/browse/discovery.py

    r5303 r5306  
    335335        # NB, this is used in the semantic search function of results.kid and short_results.kid 
    336336        c.querystring = request.environ['QUERY_STRING'] 
     337        c.altSearchURL = '%s?%s'%(h.url_for(action='semantic'), 
     338                                  request.environ['QUERY_STRING']) 
    337339 
    338340        difs = [] 
  • MILK/trunk/milk_server/milk_server/models/DiscoveryState.py

    r5305 r5306  
    104104    ''' 
    105105     
    106     def __init__(self, hits, environ, offset=1, stride=10): 
     106    def __init__(self, hits, environ, offset=1, stride=10, defaultStride = 10): 
    107107        ''' 
    108108        Initialise PagerState object 
     
    112112        - i.e. the array number of the topmost record displayed. Default = 1 
    113113        @keyword stride: Number of records currently visible.  Default = 10 
     114        @keyword defaultStride: Standard number of records to display on a page. 
     115        Default = 10  
    114116        ''' 
    115117        self.hits = hits 
     
    124126        self.lastPageURL = None 
    125127         
     128        self.defaultStride = defaultStride 
     129         
    126130        n, p = self.getNext() 
    127131        start, end = "", "" 
     
    129133            self.previousPageURL = getURL(environ, offset = p[0], stride = p[1]) 
    130134            self.previousNumber = p[1] 
    131             self.startPageURL = getURL(environ, offset = 1) 
     135            self.startPageURL = getURL(environ, offset = 1, stride = self.defaultStride) 
    132136        if n: 
    133137            self.nextPageURL = getURL(environ, offset = n[0], stride = n[1]) 
    134138            self.nextNumber = n[1] 
    135             off = self.hits - 10 
    136             if off < 0: 
    137                 off = 0 
    138             self.lastPageURL = getURL(environ, offset = off) 
     139            off = self.hits - self.defaultStride + 1 
     140            if off < 1: 
     141                off = 1 
     142            self.lastPageURL = getURL(environ, offset = off, stride = self.defaultStride) 
    139143             
    140144        self.upperRange = self.offset + self.stride - 1 
     
    149153        ''' 
    150154        result=[] 
    151         defStride=10 
    152155        if self.offset+self.stride < self.hits: 
    153156            #there are more to look at 
     
    161164        if self.offset > 1: 
    162165            #there are previous records 
    163             b = max(self.stride, defStride) 
     166            b = max(self.stride, self.defaultStride) 
    164167            r = [self.offset-b,b] 
    165168            if r[0] < 1:  
  • MILK/trunk/milk_server/milk_server/public/js/queueDeployments.js

    r4558 r5306  
    22// incremental loading of the deployments data - so this can be loaded after 
    33// the rest of the atom data is displayed 
    4 // NB, for the load of info to work, the user must set a placeholder element 
     4// NB, for the load of info to work, the following script tags needs to be added 
     5// to the calling template: 
     6//      <script type="text/javascript" src="$g.server/js/yui/build/yui/yui-min.js" /> 
     7//      <script type="text/javascript" src="$g.server/js/queueDeployments.js"/> 
     8// 
     9// Additionally, the user must set a placeholder element 
    510// in the page which contains the url to do the callback to.  Also, one must set 
    611// placeholderNames, dataTypes and urls as script array values (to allow multiple queues 
     
    1015// dataTypes = array of names of types of data to lookup - to display correct 'loading' message 
    1116// urls = array of urls to use in the callbacks 
    12 // - see implementation in atom_editor.html for example 
     17// - see implementation in atom_editor.html for example. 
    1318// 
    1419// C Byrom, Tessella Dec 08 
  • MILK/trunk/milk_server/milk_server/public/layout/style/ndg2.css

    r5175 r5306  
    8888} 
    8989 
     90#altSearchPlaceholder 
     91{ 
     92        color:#571512; 
     93        font-family:Verdana, Arial, Helvetica, sans-serif; 
     94        line-height:1.0; 
     95        font-size:small; 
     96        width:100%; 
     97        margin: 5px 1000px 5px 10px; 
     98} 
     99#altSearchPlaceholder .yui-module .linehead 
     100{ 
     101        display: none; 
     102        background-color:  white; 
     103        font-size:small; 
     104} 
    90105.searchBar {margin-top: 2px; background-color:  #f0f0f0; } /* Change this color and you need to change the color in the pagetab current */ 
    91106.searchBar table {padding-left:10px; padding-bottom:0px; margin:0px;font-weight:bold;} 
  • MILK/trunk/milk_server/milk_server/templates/browse/results.kid

    r5305 r5306  
    33    <head> 
    44    <replace py:replace="pagehead()"/> 
     5    <script type="text/javascript"> 
     6                var placeholderNames = ['altSearchPlaceholder']; 
     7                var dataTypes = ['alternative searches']; 
     8                var urls = ['$c.altSearchURL']; 
     9        </script> 
     10        <script type="text/javascript" src="$g.server/js/yui/build/yui/yui-min.js" /> 
     11        <script type="text/javascript" src="$g.server/js/queueDeployments.js"/> 
    512    </head> 
    613    <body> 
     
    1118        <div id="results"> 
    1219            <div id="context"> 
    13                 ${c.state.hits} results for "${c.state.searchString}" (${XML(c.state.constraints)})</div> 
    14             <div id="SemanticSearchBox"><div id="SemanticSearchResults"> 
    15                 <div py:if="c.state.searchString!=''"> 
    16                 Not found what you are looking for? Try ${XML(h.link_to_remote("alternative searches",dict(update="SemanticSearchBox", 
    17                         url='%s?%s'%(h.url_for(action='semantic'),c.querystring))))}. 
    18                 </div></div> 
     20                ${c.state.hits} results for "${c.state.searchString}" (${XML(c.state.constraints)}) 
    1921            </div> 
     22                <div py:replace="semanticSearch()"/> 
    2023                <div py:replace="pageControl(c.state, c.discoveryUrl)"/> 
    2124            <div py:if="c.state.hits != 0" id="resultsTab"> 
  • MILK/trunk/milk_server/milk_server/templates/browse/short_results.kid

    r5305 r5306  
    33    <head> 
    44    <replace py:replace="pagehead()"/> 
     5    <script type="text/javascript"> 
     6                var placeholderNames = ['altSearchPlaceholder']; 
     7                var dataTypes = ['alternative searches']; 
     8                var urls = ['$c.altSearchURL']; 
     9        </script> 
     10        <script type="text/javascript" src="$g.server/js/yui/build/yui/yui-min.js" /> 
     11        <script type="text/javascript" src="$g.server/js/queueDeployments.js"/> 
    512    </head> 
    613    <body> 
     
    1623            <div id="context"> 
    1724                ${c.state.hits} results for ${c.state.searchString} (${XML(c.state.constraints)})</div> 
    18             <div id="SemanticSearchBox"/> 
     25                <div py:replace="semanticSearch()"/> 
    1926            <div class="resultsBar">  
    20                  <div class="resultsLeft"> 
    21                     ${XML(h.link_to_remote("Semantic Search",dict(update="SemanticSearchBox", 
    22                             url='%s?%s'%(h.url_for(action='semantic'),c.querystring))))} 
    23                     <span py:replace="helpIcon('semser_help')"/> 
    24                  </div> 
    2527                        <div py:replace="pageControl(c.state, c.discoveryUrl)"/> 
    26                 <div id="semser_help" class="hidden"> 
    27                     <div class="helptxt"><p> 
    28                     The semantic search option allows you to see how many hits a search using your current parameters would return if you 
    29                     used a slightly different vocabulary in your search term. 
    30                     </p></div> 
    31                 </div> 
    3228            </div> 
    3329            <div id="resultsTab"> 
  • MILK/trunk/milk_server/milk_server/templates/ndgPage.kid

    r5305 r5306  
    1919        <div id="logo"><img src="$g.LeftLogo" alt="$g.LeftAlt" /></div> 
    2020    </div> 
     21 
     22 
     23    <div py:def="semanticSearch()" id="context"> 
     24    <!-- NB, to use this method, you need to add the queueDeployments script to the calling 
     25    page - see queueDeployments.js for more details --> 
     26    <table> 
     27    <tr> 
     28    <td width="15%">Alternative searches<span py:replace="helpIcon('semser_help')"/>:</td> 
     29    <td> 
     30                <div id="altSearchPlaceholder" /> 
     31        </td> 
     32        </tr> 
     33        </table> 
     34    <div id="semser_help" class="hidden"> 
     35        <div class="helptxt"><p> 
     36        The semantic search option allows you to see how many hits a search using your current parameters would return if you 
     37        used a slightly different vocabulary in your search term. 
     38        </p></div> 
     39    </div> 
     40        </div> 
    2141 
    2242    <div py:def="pageControl(state, discoveryURL)" class="resultsBar"> 
Note: See TracChangeset for help on using the changeset viewer.