Changeset 2703
- Timestamp:
- 04/07/07 14:27:06 (14 years ago)
- Location:
- TI05-delivery/ows_framework/trunk/ows_server/ows_server
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TI05-delivery/ows_framework/trunk/ows_server/ows_server/config/ndgMiddleware.py
r2688 r2703 31 31 self.globals.icons_A=cf.get('NDG_A_SERVICE','icon') 32 32 self.globals.icons_B=cf.get('NDG_B_SERVICE','icon') 33 self.globals.icons_D=cf.get('DISCOVERY','icon') 34 self.globals.icons_R=cf.get('RELATED','icon') 33 35 34 36 self.globals.discoveryURL=cf.get('SEARCH','discoveryURL') -
TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/discovery.py
r2675 r2703 166 166 c.xml+='Internal sending of mail failed with error [%s]</p>'%message 167 167 return render_response('content') 168 c.xml=renderDiscoverySet(difs,state,self.cf) 169 f=file('debug-dif.xml','w') 170 f.write(c.xml) 171 f.close() 172 return render_response('content') 168 if 0: 169 c.xml=renderDiscoverySet(difs,state,self.cf) 170 f=file('debug-dif.xml','w') 171 f.write(c.xml) 172 f.close() 173 return render_response('content') 174 else: 175 c.state=state 176 c.difs=difs 177 return render_response('results') 178 173 179 except ValueError,e: 174 180 if debug: … … 212 218 def __buildconstraints(self,dateRange,bbox,scope): 213 219 ''' Just build a constraint string ''' 214 constraints=' ('220 constraints='' 215 221 if dateRange is not None: 216 222 constraints+='Including %s to %s; '%('%s,%s,%s'%dateRange[0],'%s,%s,%s'%dateRange[1]) … … 220 226 if scope is not None: 221 227 constraints+='Restricted to %s; '%scope[0] 222 constraints=constraints[:-2] +')'228 constraints=constraints[:-2] 223 229 logger.info(constraints) 224 230 return constraints -
TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/DiscoveryState.py
r2672 r2703 16 16 self.stride=stride 17 17 self.searchString=searchString 18 self.alternatives=None 18 19 def geturl(self,**kw): 19 20 ''' Get a url from the wsgi environment, modified by the keyword arguments offset and stride … … 29 30 url=cgi.escape(url) 30 31 return url 32 def getNext(self): 33 ''' Get the next slice ''' 34 result=[] 35 defStride=10 36 if self.offset+self.stride<self.hits: 37 #there are more to look at 38 r=[self.offset+self.stride,self.stride] 39 if r[0]+r[1]-1>self.hits: r[1]=self.hits+1-r[0] 40 result.append(r) 41 else:result.append([]) 42 if self.offset>1: 43 #there are previous records 44 b=max(self.stride,defStride) 45 r=[self.offset-b,b] 46 if r[0]<1: r[0]=1 47 if r[1]>self.hits: r[1]=self.hits 48 result.append(r) 49 else: result.append([]) 50 return result 51 31 52 def __str__(self): 32 53 return ''' … … 41 62 '''%(self.searchString,self.constraints,self.sessID,self.hits,self.offset,self.stride,self.environ) 42 63 43 import unittest 64 if __name__=="__main__": 65 66 import unittest 67 DummyEnviron={'QUERY_STRING':'start=10&howmany=10','HTTP_HOST':'example.ndg', 68 'PATH_INFO':'/discovery','wsgi.url_scheme':'http','SERVER_PORT':'80'} 44 69 45 class TestCase(unittest.TestCase): 70 class TestCase(unittest.TestCase): 71 72 def testDiscoveryState(self): 73 ''' Test creation of a discovery state variable ''' 74 d=DiscoveryState('123','blah',DummyEnviron,12,'(none)') 75 self.assertEqual(d.geturl(offset='11',stride='20'), 76 'http://example.ndg/discovery?start=11&howmany=20') 77 print d 46 78 47 def testDiscoveryState(self): 48 ''' Test creation of a discovery state variable ''' 49 DummyEnviron={'QUERY_STRING':'start=10&howmany=10','HTTP_HOST':'example.ndg', 50 'PATH_INFO':'/discovery','wsgi.url_scheme':'http','SERVER_PORT':'80'} 51 d=DiscoveryState('123','blah',DummyEnviron,12,'(none)') 52 self.assertEqual(d.geturl(offset='11',stride='20'), 53 'http://example.ndg/discovery?start=11&howmany=20') 54 print d 55 56 57 if __name__=="__main__": 79 def testStrideself(self): 80 ''' Test striding through a dataset ''' 81 82 s=DiscoveryState('123','blah',DummyEnviron,15,'(none)',1,10) 83 res=s.getNext() 84 self.assertEqual([[11,5],[]],res) 85 86 s=DiscoveryState('123','blah',DummyEnviron,15,'(none)',11,5) 87 res=s.getNext() 88 self.assertEqual([[],[1,10]],res) 89 90 s=DiscoveryState('123','blah',DummyEnviron,50,'(none)',11,10) 91 res=s.getNext() 92 self.assertEqual([[21,10],[1,10]],res) 93 94 58 95 unittest.main() 59 60 61 96 62 97 -
TI05-delivery/ows_framework/trunk/ows_server/ows_server/public/layout/ndg2.css
r2688 r2703 143 143 .helptxt {font-size:smaller; background-color:yellow;} 144 144 145 /* Results Page */ 146 147 148 #context { margin: 0 10px 0 10px; border:0; color:#571512;} 149 #synonyms { margin: 0 10px 0 10px; border:0; color:#571512;} 150 .syno {} 151 .resultsBar {text-align:right; margin: 2px 10px 2px 10px; border:0;} 152 153 #resultsTab thead {background-color: #075993; color:#FFFFFF; margin: 0px 10px 0px 10px;} */ 154 #resultsTab th { 155 background-color: #075993; 156 color:#FFFFFF; 157 padding: 3px 10px 3px 10px; 158 } 159 #resultsTab td { 160 color:#333333; 161 /* line-height:1.5; */ 162 padding: 5px 10px 5px 10px; 163 } 164 /* #resultsTab tbody {vertical-align:baseline; } */ 165 166 .ndgem {font-weight:bold} 167 tr.rowlo {background: #eeeeee; 168 border-top:1px; 169 border-bottom:1px; 170 border-bottom-color:#FFFFFF; 171 border-top-color:#000000; 172 } 173 tr.rowhi { 174 border-top:1px; 175 border-bottom:1px; 176 border-bottom-color:#FFFFFF; 177 border-top-color:#000000; 178 } 179 145 180 /* And now the footer */ 146 181 #Footer { color: #999999; background-color: #eeeeee; margin-bottom: 25px; padding-top: 3px; padding-right: 10px; padding-left: 10px; clear: both; border-top: 2px solid #333333; margin-top:10px; font-size:80%; border-bottom: 2px solid #333333;} -
TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/meta.kid
r2694 r2703 48 48 49 49 50 <div py:def="Spatial(bbox )">50 <div py:def="Spatial(bbox,h)"> 51 51 <!-- Currently this only shows the first bounding box --> 52 52 <table py:if="bbox.nboxes==1"><tbody> 53 <tr ><td colspan="2" class="cellhead">Spatial coverage</td></tr>53 <tr py:if="h==1"><td colspan="2" class="cellhead">Spatial coverage</td></tr> 54 54 <tr><td colspan="2" align="center">${bbox.boxes[0][0]}</td></tr> 55 55 <tr><td align="center">${bbox.boxes[0][1]}</td><td align="center">${bbox.boxes[0][2]}</td></tr> … … 63 63 <table cellspacing="0" cellpadding="3" border="0" width="100%"><tbody> 64 64 <tr><td class="linehead" colspan="2"><span class="heading0"> Data Coverage</span> </td></tr> 65 <tr><td><div py:replace="Spatial(bbox )"/></td>65 <tr><td><div py:replace="Spatial(bbox,1)"/></td> 66 66 <td><table><tr><td colspan="2" class="cellhead"> Temporal coverage</td></tr> 67 67 <tr><td> Start Date: ${timcov[0]}</td><td>End Date: ${timcov[1]}</td></tr> … … 92 92 </div> 93 93 94 <!--- Create that little list of service icons on the result page --> 95 <span py:def="serviceIcons(sL)"> 96 <span py:for="s in sL"> 97 <?python 98 t=s.contentType 99 if t=='': t='R' 100 try: 101 icon={'NDG_A_SERVICE':g.icons_A, 102 'NDG_B_SERVICE':g.icons_B, 103 'DISCOVERY':g.icons_D, 104 'R':g.icons_R}[t] 105 except: 106 icon=g.icons_R 107 ?> 108 <span py:replace="linkimage(s.url,icon,s.description)"/> 109 </span> 110 </span> 111 112 <!--- Easy shortening of text for result pages, should use ajax to expand --> 113 <span py:def="abbreviate(text,L,url)"> 114 <?python 115 if len(text)<L: 116 more='' 117 else: 118 if url: 119 more=' <a href="%s">(more)</a>'%url 120 else: more='...' 121 ?> 122 ${text[0:L]}${XML(more)} 123 </span> 124 125 <span py:def="result(i,d)"> 126 <tr class="${i%2 and 'rowhi' or 'rowlo'}"> 127 <td> 128 <span py:if="d.briefCitation!=''"> 129 <span class="ndgem">Citation:</span> ${d.briefCitation}</span> 130 <span class="ndgem"> Title:</span> 131 <span py:replace="abbreviate(d.name,70,0)"/> 132 <br/> 133 <span class="ndgem"> Abstract:</span> 134 <span py:replace="abbreviate(d.abstract,200,d.binding.url)"/> 135 <br/> 136 <span class="ndgem"> Sourced from:</span>${XML(d.centre.url())} 137 <span class="ndgem">Links:</span> 138 <span py:replace="serviceIcons([d.binding])"/> 139 <span py:replace="serviceIcons(d.services)"/> 140 </td><td> 141 <span py:if="d.timeCoverage[0] not in [None,'','Unknown']"> ${d.timeCoverage[0]}</span> 142 </td><td> 143 <span py:if="d.timeCoverage[0] not in [None,'','Unknown']"> ${d.timeCoverage[1]}</span> 144 </td><td> 145 <div py:replace="Spatial(d.bbox,0)"/> 146 </td> 147 </tr> 148 </span> 149 94 150 </html>
Note: See TracChangeset
for help on using the changeset viewer.