Changeset 949
- Timestamp:
- 17/05/06 21:35:32 (15 years ago)
- Location:
- TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/DIF.py
r940 r949 46 46 47 47 #load up information about temporal extent 48 self.timeCoverage= 'Start Date:%s Stop Date:%s (%s)'%(48 self.timeCoverage=( 49 49 wrapGetText(self.elem,'Temporal_Coverage/Start_Date'), 50 50 wrapGetText(self.elem,'Temporal_Coverage/Stop_Date'), … … 78 78 79 79 f=file('../../exampleD/spade.xml') 80 difxml=f.read() 81 D=DIF(cleanup(difxml)) 80 g=file('../../exampleD/ucar.xml') 81 dif1xml=f.read() 82 dif2xml=g.read() 83 D=DIF(cleanup(dif1xml)) 84 G=DIF(cleanup(dif2xml)) 82 85 y='''<?xml version="1.0" encoding="UTF-8"?> 83 86 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> … … 87 90 <title>%s</title> 88 91 <LINK media="all, screen" href="../layout/style.css" type="text/css" rel="stylesheet"/> 89 </head> '''%D.name+D.toHTML() 92 </head> '''%D.name+D.toHTML()+G.toHTML() 90 93 f.close() 91 94 f=file('output.html','wb') -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/geoUtilities.py
r938 r949 21 21 22 22 try: 23 self.box=[float(i) for i in [North, South,West, East]]23 self.box=[float(i) for i in [North, West, East, South]] 24 24 except: 25 25 self.box=None … … 29 29 html='''<p> 30 30 Limit North: %s <br/> 31 Limit South: %s <br/> 32 Limit West: %s <br/> 33 Limit East: %s <br/> 31 Limit West: %s Limit East: %s <br/> 32 Limit South: %s <br/> 34 33 </p>'''%self.box 35 34 else: 36 35 html='No bounding box available' 37 36 return html 37 def toHTMLbox(self): 38 print self.box 39 if self.box is not None: 40 html='''<table><tbody><tr><td colspan="2" align="center">%s</td></tr> 41 <tr><td>%s</td?><td>%s</td></tr> 42 <tr><td colspan="2" align="center">%s</td></tr></tbody></table>'''%tuple(self.box) 43 else: 44 html='' 45 return html -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/renderDiscoveryResponses.py
r940 r949 5 5 def render(difSet,summary=0,services=0,spatial=0,temporal=0,linkto='NDG_B_SERVICE'): 6 6 '''Takes a set of xml DIFS from a discovery search and renders a list of responses as a table, 7 with layout depending on a set of keywords: 8 ''' 9 columns=['name','centre'] 7 with layout depending on a set of keywords''' 8 # List of methods which deal with the actual row content ... 9 columns=['Dataset','Repository'] 10 11 def row(rowList,bgcolor='#EEEEEE'): 12 h='<tr bgcolor="%s">'%bgcolor 13 for item in rowList: 14 print item 15 if type(item)==type((1,2)): 16 h+='<td colspan="%s">%s</td>'%(item[1],item[0]) 17 else:h+='<td>%s</td>'%item 18 h+='</tr>' 19 return h 20 21 def spatialBox(elem): 22 return elem.bbox.toHTMLbox() 23 24 def temporalRange(elem): 25 return '' 26 27 def serviceList(elem): 28 return '' 29 10 30 #next three lines not yet used in anger 11 if spatial: columns.insert(-1,'Spatial') 12 if temporal: columns.insert(-1,'Temporal') 31 if spatial: columns.insert(-1,'Location') 32 if temporal: 33 #two columns for temporal but put a column header across both columns 34 header='''<table><tr><td colspan="2">Temporal Coverage</td></tr><tr> 35 <td>Start Date</td><td> End Date</td></tr></table>''' 36 columns.insert(-1,(header,2)) 13 37 if services: columns.insert(-1,'Services') 14 html='<table><tbody>' 15 i=1#next three lines not yet used in anger 16 if spatial: columns.insert(-1,'Spatial') 17 if temporal: columns.insert(-1,'Temporal') 18 if services: columns.insert(-1,'Services') 38 html='<table><tbody>'+row(columns,bgcolor="#FDFFCC") 39 40 i=1 19 41 for item in difSet: 20 42 d=DIF(item) 21 43 bgc={1:'#FFFFFF',-1:'#EEEEEE'}[i] 22 44 i=-1*i 23 html+='<tr bgcolor=%s><td>%s</td><td>%s</td></tr>'%( 24 bgc,d.name[0:60],d.centre.tohtml()) 45 rlist=[d.name[0:60],d.centre.toHTML()] 46 if summary: 47 rlist[0]='Name: '+rlist[0] 48 rlist[0]+='</br>Summary: %s'%d.abstract[0:200] 49 rlist[0]+='<br/>+' 50 if spatial: rlist.insert(-1,spatialBox(d)) 51 if temporal: 52 rlist.insert(-1,d.timeCoverage[0]) 53 rlist.insert(-1,d.timeCoverage[1]) 54 if services: rlist.insert(-1,serviceList(d)) 55 56 html+=row(rlist,bgcolor=bgc) 57 25 58 html+='</tbody></table>' 26 59 return html … … 33 66 for result in results: 34 67 difs.append(cleanup(result)) 35 html=render(difs) 36 print html 68 html=render(difs,summary=1,spatial=1,temporal=1) 69 f=file('output.html','wb') 70 f.write(html) 37 71 ws.release() -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/stubB.py
r938 r949 50 50 if t is not None: 51 51 try: 52 self.timeCoverage= [float(i.text) for i in t]52 self.timeCoverage=(float(i.text) for i in t) 53 53 except: 54 self.timeCoverage='No time information' 54 self.timeCoverage=('',) 55 55 56 else: 56 57 t=self.elem.find('dgDataSummary/dgDataCoverage/dgTemporalCoverage/DateSingle') 57 58 try: 58 self.timeCoverage= t.text59 self.timeCoverage=(t.text,) 59 60 except: 60 self.timeCoverage='No time information' 61 self.timeCoverage=('',) 62 61 63 62 64
Note: See TracChangeset
for help on using the changeset viewer.