Changeset 2528
- Timestamp:
- 30/05/07 16:44:15 (14 years ago)
- Location:
- TI07-MOLES/trunk/PythonCode/wsgi
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TI07-MOLES/trunk/PythonCode/wsgi/DiscoveryGUI.py
r2522 r2528 138 138 else: 139 139 self.standardInterface() 140 141 def message(self,message): 142 ''' Layout a message to the user ''' 143 self.html='<div class="message"><p>%s</p></div>'%message 140 144 141 145 … … 145 149 by the DiscoveryTemplate GUI, and are: All, Authors, Parameters ''' 146 150 151 self.oneLineSearch() 147 152 start,howmany=int(start),int(howmany) # url arguments need conversion ... 148 153 … … 159 164 state=self.__setState(id,searchString,hits,start,howmany) 160 165 if hits==0: 161 self.html+= '<p> No records found </p>'166 self.html+=self.message('No records found') 162 167 else: 163 168 try: … … 173 178 errors.append((result[0],str(e))) 174 179 if results==[]: 175 self.html+= '<p>No results for "%s"!</p>'%searchString180 self.html+=self.message('No results for "%s"!</p>'%searchString) 176 181 elif difs==[]: 177 self.html+= '<p>No usable results for "%s"!'%searchString182 self.html+=self.message('No usable results for "%s"!'%searchString) 178 183 else: 179 184 if errors<>[]: … … 189 194 self.html+=' (unfortunately %s hits matched unformattable documents from %s, an internal error has been logged):</p>'%(len(errors),dp) 190 195 mailError('b.n.lawrence@rl.ac.uk','DIF errors',str(errors),server=self.mailServer) 191 self.html+=renderDiscoverySet(difs,state,config=self.config, 192 summary=1,spatial=1,temporal=1,services=1) 196 self.html+=renderDiscoverySet(difs,state,self.config) 193 197 except ValueError,e: 194 198 if debug: … … 197 201 self.html='<p> Error retrieving documents for %s hits is [%s]</p>'%(hits,e) 198 202 199 self.standardInterface() 200 return 203 #self.standardInterface() 204 return 205 201 206 202 207 def standardInterface(self): … … 242 247 return 243 248 244 249 def oneLineSearch(self): 250 try: 251 discoveryURL=self.config.get('SEARCH','discoveryURL') 252 except: 253 self.message='Error, invalid configuration for search interface' 254 self.html='' 255 return 256 self.html+=DiscoveryTemplate.searchTextOneLine%locals() 257 258 -
TI07-MOLES/trunk/PythonCode/wsgi/DiscoveryTemplate.py
r1934 r2528 151 151 </div>''' 152 152 153 searchTextOneLine=''' 154 <div class="searchOneLine"><form action="%(discoveryURL)s"> 155 New Search: 156 <input type="text" size="60" name="searchString"><input type="hidden" value="0" name="advanced"> 157 (Target: <select name="textTarget"> 158 <option value="Authors">Authors</option> 159 <option value="All" selected="selected">All</option> 160 <option value="Params">Parameters</option> </select>) </form> 161 </div>''' -
TI07-MOLES/trunk/PythonCode/wsgi/layout/ndg.css
r2522 r2528 51 51 52 52 53 tr.rbgWhite {BACKGROUND-COLOR: #FFFFFF; BORDER-BOTTOM: thin solid black;}54 tr.rbgGrey {BACKGROUND-COLOR: #F0F0F0; BORDER-BOTTOM: thin solid black;}55 tr.rbgBeige {BACKGROUND-COLOR: #FDFFCC; BORDER-BOTTOM: thin solid black;}56 tr.separated{border-bottom:thin solid black;}57 53 58 #Header {color: black; background-color: white; text-align: center; margin-bottom: 10px; padding-top: 3px; padding-right: 10px; padding-left: 10px; padding-bottom: 10px; clear: both; border-bottom: 2px solid red; font-size: medium; font-weight:bold;}59 54 60 #ListOfResults {color: black;} 55 #Header {color: black; background-color: white; text-align: center; margin-bottom: 10px; padding-top: 3px; padding-right: 10px; padding-left: 10px; padding-bottom: 10px; clear: both; border-bottom: 2px solid wheat; font-size: medium; font-weight:bold;} 56 57 61 58 62 59 a img {border: none;} … … 65 62 66 63 #simpleSearch {text-align: center; margin-top: 10px; margin-bottom: 10 px;} 64 div.AdvancedSearch{margin-top: 10px; margin-bottom: 10 px;} 67 65 68 div.AdvancedSearch{margin-top: 10px; margin-bottom: 10 px;} 66 /* Result Set Controls */ 67 68 #ListOfResults {color: black;} 69 69 70 div.stridePosition{margin-top: 2px; margin-bottom: 2px; background-color: wheat;} 70 div.error{margin-top:2px; margin-bottom: 2px; background-color:tomato; 71 padding-left:10px; padding-right:10px;} 71 div.message {margin-top: 2px; margin-bottom: 2px; background-color: wheat;} 72 div.error{margin-top:2px; margin-bottom: 2px; background-color:tomato; padding-left:10px; padding-right:10px;} 73 div.searchOneLine{margin-top: 2px; margin-bottom: 2px; background-color: wheat; text-align:right;} 74 tr.rbgWhite {BACKGROUND-COLOR: #FFFFFF;} 75 /* *tr.rbgGrey {BACKGROUND-COLOR: #F0F0F0;} */ 76 tr.rbgGrey {BACKGROUND-COLOR: #EEEEE0; } 77 tr.rbgBeige {BACKGROUND-COLOR: #FDFFCC; } 78 /* end of result set controls */ 72 79 73 80 div.searchMethod {margin-top: 7px; margin-bottom: 8px;} … … 83 90 padding-top:1px; padding-left: 4px; padding-right: 4px; text-decoration:none; color:black;} 84 91 85 #Footer { color: #999999; background-color: #f4f4f4; text-align: center; margin-bottom: 25px; padding-top: 3px; padding-right: 10px; padding-left: 10px; height: 49px; clear: both; border-top: 2px solid red; margin-top:10px;}92 #Footer { color: #999999; background-color: #f4f4f4; text-align: center; margin-bottom: 25px; padding-top: 3px; padding-right: 10px; padding-left: 10px; height: 49px; clear: both; border-top: 2px solid wheat; margin-top:10px;} 86 93 87 94 -
TI07-MOLES/trunk/PythonCode/wsgi/ndgDiscovery.config
r2522 r2528 74 74 badc.nerc.ac.uk: glue.badc.rl.ac.uk 75 75 npm.ac.uk: wwwdev.npm.ac.uk/rsdas/projects/ndg 76 grid.bodc.nerc.ac.uk: glue.badc.rl.ac.uk 76 #grid.bodc.nerc.ac.uk: glue.badc.rl.ac.uk 77 grid.bodc.nerc.ac.uk: localhost:8001 77 78 ndg.noc.soton.ac.uk: ndg.noc.soton.ac.uk:8001 78 79 icon: %(layout)s/B.gif -
TI07-MOLES/trunk/PythonCode/wsgi/ndgLog.py
r2490 r2528 50 50 '''Default error handling WSGI application.''' 51 51 start_response(HTTPMSG, [('Content-type', 'text/plain')], 52 exc_info=sys.exc_info()) 52 exc_info=sys.exc_info()) 53 # sys.exc_info()) 53 54 return [ERRORMSG] 54 55 -
TI07-MOLES/trunk/PythonCode/wsgi/renderDiscoverySet.py
r2487 r2528 49 49 50 50 51 def renderDiscoverySet(difSet,state,config,summary=0,services=0,spatial=0,temporal=0, 52 linkto='NDG_B_SERVICE',selector=None): 51 def renderDiscoverySet(difSet,state,config, linkto='NDG_B_SERVICE',selector=None): 53 52 '''Takes a set of xml DIFS from a discovery search (difSet) and renders a 54 list of responses as a table, with layout depending on a set of keywords: 55 summary (boolean) - show the abstract, 56 services (boolean) - show the service list, 57 spatial (boolean) - show the bounding box, 58 temporal (boolean) - show the date range, 53 list of responses as a table. The argument is 59 54 linkto (string) - clicking on the select widget should add the url for 60 55 this service to the selected list … … 67 62 # List of methods which deal with the actual row content ... 68 63 # 69 70 def row(rowList,bgcolor='rbgWhite'): 71 h='<tr class="%s">'%bgcolor 72 for item in rowList: 73 if type(item)==type((1,2)): 74 h+='<td colspan="%s">%s</td>'%(item[1],item[0]) 75 else:h+='<td>%s</td>'%item 76 h+='</tr>' 77 return h#span(h,bgcolor) 78 64 def doubleheader(args): 65 return '''<table><tbody><tr><td colspan="2" align="center">%s</td></tr> 66 <tr><td align="center">%s</td><td align="center">%s</td></tr></tbody></table>'''%args 67 def row(rowlist,rclass='rbgWhite'): 68 print rowlist 69 r= '''<tr class="%s"><td width="70%%">%s</td><td width="12%%" align="center">%s</td> 70 '''%(rclass,rowlist[0],rowlist[1]) 71 ll=len(rowlist) 72 print 'BBB[',rowlist[2:],']' 73 74 if ll==3: 75 r+='<td align="center" colspan="2" width="12%%">%s</td></tr>'%rowlist[2] 76 elif ll==4: 77 r+='<td align="center">%s</td><td align="center">%s</td></tr>'%tuple(rowlist[2:]) 78 else: 79 raise 'Coding error in renderDiscovery' 80 print 'ok' 81 return r 82 79 83 def spatialBox(elem): 80 84 return elem.bbox.toHTMLbox() … … 107 111 # ################################## 108 112 109 # depending on keyword options, provide column headings 110 # 113 # previous versions of this code had options, but let's simplify this a lot ... 111 114 112 columns=['Dataset',] 113 if spatial: columns.append('Location') 114 if temporal: 115 #two columns for temporal but put a column header across both columns 116 header='''<table><tbody><tr><td colspan="2" align="center">Time Coverage</td></tr><tr> 117 <td align="center">Start</td><td align="center"> End</td></tr></tbody></table>''' 118 columns.append((header,2)) 119 html='<table><tbody>'+row(columns,bgcolor="rbgBeige") 115 spatial=doubleheader(('Spatial Coverage','(-ve:W,S;','+ve:N,E)')) 116 temporal=doubleheader(('Temporal Coverage','Start','End')) 117 columns=['Dataset',spatial,temporal] 118 html='<table><tbody>'+row(columns,rclass="rbgBeige") 120 119 121 120 # ok, now let's cycle through the hits 122 121 i=1 123 122 for item in difSet: 124 #print item.entryID125 123 d=item # we used to do the diffing here ... but we don't anymore 126 124 bgc={1:'rbgWhite',-1:'rbgGrey'}[i] 127 125 i=-1*i 128 if debug: print 'Rendering ',d.entryID129 126 if d.tree is None: 130 html+='<tr class="%s"><td colspan=" %s"> Unparseable record </td></tr>'%(bgc,len(columns))127 html+='<tr class="%s"><td colspan="4"> Unparseable record </td></tr>'%bgc 131 128 else: 132 129 ndg,slist=serviceList(d) 133 130 rlist=['',] 134 if summary: 135 if d.briefCitation <>'': 136 rlist[0]='%s: %s'%(span('Citation','ndgem'),d.briefCitation) 137 else: 138 rlist[0]='%s: %s'%(span('Title','ndgem'),abbreviate(d.name,60)) 139 rlist[0]+='<br/>%s: %s'%(span('Summary','ndgem'),abbreviate(d.abstract,200)) 140 if d.binding is not None: rlist[0]+=' '+hyperlink('(more)',d.binding.url) 131 if d.briefCitation <>'': 132 rlist[0]='%s: %s'%(span('Citation','ndgem'),d.briefCitation) 133 else: 134 rlist[0]='%s: %s'%(span('Title','ndgem'),abbreviate(d.name,60)) 135 rlist[0]+='<br/>%s: %s'%(span('Summary','ndgem'),abbreviate(d.abstract,200)) 136 if d.binding is not None: rlist[0]+=' '+hyperlink('(more)',d.binding.url) 141 137 rlist[0]+='<br/>%s: %s.'%(span('Repository','ndgem'),d.centre.url()) 142 if not summary and d.binding is not None: 143 rlist[0]+=' '+hyperlink('(more)',d.binding.url) 144 if services:rlist[0]+=slist 138 rlist[0]+=slist 145 139 if ndg and selector !=None: 146 140 rlist[0]+=', '+selector.target(d.entryID,name=d.abbreviation) 147 if spatial: rlist.append(spatialBox(d)) 148 if temporal: 149 rlist.append(htmlTime(d.timeCoverage[0])) 150 rlist.append(htmlTime(d.timeCoverage[1])) 151 html+=row(rlist,bgcolor=bgc) 152 print 'Completed rendering ',d.entryID 141 rlist.append(spatialBox(d)) 142 rlist.append(htmlTime(d.timeCoverage[0])) 143 rlist.append(htmlTime(d.timeCoverage[1])) 144 html+=row(rlist,rclass=bgc) 153 145 154 146 html+='</tbody></table>'
Note: See TracChangeset
for help on using the changeset viewer.