Changeset 711
- Timestamp:
- 04/24/06 16:58:28 (3 years ago)
- Files:
-
- tracistanplugin/0.10/example/aftracistan/aftracistan/htdocs/css/aftracistan.css (modified) (33 diffs)
- tracistanplugin/0.10/example/aftracistan/aftracistan/status.py (modified) (4 diffs)
- tracistanplugin/0.10/example/aftracistan/aftracistan/templates/index.stan (modified) (4 diffs)
- tracistanplugin/0.10/stan/stansupport.py (modified) (10 diffs)
- tracistanplugin/0.10/stan/templates/tracmain.stan (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tracistanplugin/0.10/example/aftracistan/aftracistan/htdocs/css/aftracistan.css
r694 r711 3 3 Version: 1.1, November 28, 2005 */ 4 4 5 body{5 #divbody { 6 6 background:#e0e0e0 url(../img/bodybg.gif) repeat-x; 7 color:#505050;8 font:76% Georgia,Verdana,Tahoma,Arial,sans-serif;9 7 margin:0; 10 8 padding:0; … … 12 10 } 13 11 14 p{12 #divbody p{ 15 13 line-height:1.5em; 16 14 margin:0 0 15px; 17 } 18 19 a{ 15 color:#505050 ! important; 16 font:76% Georgia,Verdana,Tahoma,Arial,sans-serif ! important; 17 } 18 19 #divbody a{ 20 20 color:#fa9035; 21 21 font-weight:700; … … 23 23 } 24 24 25 a:hover{25 #divbody a:hover{ 26 26 color:#d04a10; 27 27 } 28 28 29 hr{29 #divbody hr{ 30 30 height:1px; 31 31 margin:10px 0; … … 33 33 } 34 34 35 dt{35 #divbody dt{ 36 36 font-weight:700; 37 37 } 38 38 39 dd{39 #divbody dd{ 40 40 margin:1px 0 12px 15px; 41 41 } 42 42 43 # container{43 #divbody #container{ 44 44 background:#c0c0c0 url(../img/bodybg.gif) repeat-x; 45 45 margin:0 auto; … … 48 48 } 49 49 50 # sitename{50 #divbody #sitename{ 51 51 background:url(../img/leaves.jpg) top center no-repeat; 52 52 color:#ffffff; … … 57 57 } 58 58 59 # sitename h1{59 #divbody #sitename h1{ 60 60 font-size:2.2em; 61 61 margin:0; … … 63 63 } 64 64 65 # sitename span{65 #divbody #sitename span{ 66 66 font-size:1.6em; 67 67 letter-spacing:-1px; … … 69 69 } 70 70 71 # nav{71 #divbody #nav{ 72 72 background:url(../img/greypx.gif) bottom left repeat-x; 73 73 float:left; … … 75 75 } 76 76 77 # nav ul{77 #divbody #nav ul{ 78 78 list-style:none; 79 79 margin:0; … … 81 81 } 82 82 83 # nav a{83 #divbody #nav a{ 84 84 background:url(../img/tabs.gif) no-repeat 100% 0; 85 85 color:#808080; … … 91 91 } 92 92 93 # nav a:hover{94 color:#505050; 95 } 96 97 # nav li{93 #divbody #nav a:hover{ 94 color:#505050; 95 } 96 97 #divbody #nav li{ 98 98 background:url(../img/tabs.gif) no-repeat 0 0; 99 99 float:left; … … 102 102 } 103 103 104 # nav #current{104 #divbody #nav #current{ 105 105 background:url(../img/tabs.gif) no-repeat 0 -41px; 106 106 } 107 107 108 # nav #current a{108 #divbody #nav #current a{ 109 109 background:url(../img/tabs.gif) no-repeat 100% -41px; 110 110 color:#303030; … … 112 112 } 113 113 114 # wrap1{114 #divbody #wrap1{ 115 115 background:#ffffff url(../img/innerbg.gif) repeat-y; 116 116 border-bottom:1px solid #808080; … … 122 122 } 123 123 124 # wrap2{124 #divbody #wrap2{ 125 125 background:url(../img/header.jpg) top left no-repeat; 126 126 padding:10px; … … 128 128 } 129 129 130 # header{130 #divbody #header{ 131 131 height:30px; 132 132 position:relative; … … 134 134 } 135 135 136 # header h1{136 #divbody #header h1{ 137 137 float:left; 138 138 font-size:1.4em; … … 141 141 } 142 142 143 # topbox{143 #divbody #topbox{ 144 144 color:#808080; 145 145 margin:0 0 4px; … … 147 147 } 148 148 149 # topbox a{149 #divbody #topbox a{ 150 150 color:#d04a10; 151 151 } 152 152 153 # topbox a:hover{153 #divbody #topbox a:hover{ 154 154 text-decoration:underline; 155 155 } 156 156 157 # leftside{157 #divbody #leftside{ 158 158 float:left; 159 159 margin:-15px 0 0; … … 161 161 } 162 162 163 # leftside h1{163 #divbody #leftside h1{ 164 164 font-size:1.4em; 165 165 font-weight:400; 166 166 } 167 167 168 # rightside{168 #divbody #rightside{ 169 169 float:right; 170 170 margin:40px 15px 20px 0; … … 172 172 } 173 173 174 # rightside h1{174 #divbody #rightside h1{ 175 175 font-size:1.4em; 176 176 font-weight:400; … … 178 178 } 179 179 180 # rightside p{180 #divbody #rightside p{ 181 181 font-size:0.9em; 182 182 margin:2px 0 12px 10px; 183 183 } 184 184 185 # rightside img{185 #divbody #rightside img{ 186 186 border:1px solid #fa9035; 187 187 margin:10px 0 5px 5px; … … 189 189 } 190 190 191 # content{191 #divbody #content{ 192 192 margin:45px 160px 0 180px; 193 193 } 194 194 195 # contentalt{195 #divbody #contentalt{ 196 196 margin:45px 15px 0 180px; 197 197 } … … 199 199 #content p,#contentalt p{ 200 200 margin:8px 0 0 10px; 201 color:#505050 ! important; 202 font:76% Georgia,Verdana,Tahoma,Arial,sans-serif ! important; 201 203 } 202 204 … … 207 209 margin:15px 0 10px; 208 210 padding:0; 211 color:#505050 ! important; 212 font: Georgia,Verdana,Tahoma,Arial,sans-serif ! important; 209 213 } 210 214 … … 215 219 margin:20px 0 10px; 216 220 padding:0; 217 } 218 219 #content img,#contentalt img{ 221 color:#505050 ! important; 222 font: Georgia,Verdana,Tahoma,Arial,sans-serif ! important; 223 } 224 225 #divbody #content img,#divbody #contentalt img{ 220 226 border:1px solid #fa9035; 221 227 float:left; … … 223 229 } 224 230 225 # footer{231 #divbody #footer{ 226 232 clear:both; 227 233 color:#a0a0a0; … … 234 240 } 235 241 236 # footer a{242 #divbody #footer a{ 237 243 color:#a0a0a0; 238 244 font-weight:400; 239 245 } 240 246 241 # footer a:hover{247 #divbody #footer a:hover{ 242 248 color:#a0a0a0; 243 249 text-decoration:underline; 244 250 } 245 251 246 .menublock{252 #divbody .menublock{ 247 253 margin-bottom:10px; 248 254 } 249 255 250 .nav{256 #divbody .nav{ 251 257 color:#d04a10; 252 258 display:block; … … 260 266 } 261 267 262 .nav:hover{268 #divbody .nav:hover{ 263 269 border:1px solid #fa9035; 264 270 color:#505050; … … 266 272 } 267 273 268 .sub{274 #divbody .sub{ 269 275 font-size:0.9em; 270 276 margin-left:20px; … … 273 279 } 274 280 275 .sub:hover{281 #divbody .sub:hover{ 276 282 border:1px solid #fa9035; 277 283 color:#505050; … … 279 285 } 280 286 281 .intro{287 #divbody .intro{ 282 288 font-weight:700; 283 289 } 284 290 285 .active{291 #divbody .active{ 286 292 border:1px solid #fa9035; 287 293 padding:1px 1px 1px 9px; 288 294 } 289 295 290 .box{296 #divbody .box{ 291 297 background:#f8f8f8 url(../img/boxbg.gif) top left repeat-y; 292 298 border:1px solid #d0d4d4; … … 297 303 } 298 304 299 .photo{305 #divbody .photo{ 300 306 margin:5px auto 15px; 301 307 padding:5px; 302 308 } 303 309 304 .smallcaps{310 #divbody .smallcaps{ 305 311 font-variant:small-caps; 306 312 } 307 313 308 .mini{314 #divbody .mini{ 309 315 color:#a0a0a0; 310 316 font-size:0.75em; … … 314 320 } 315 321 316 .small{322 #divbody .small{ 317 323 font-size:0.85em; 318 324 } 319 325 320 .large{326 #divbody .large{ 321 327 font-size:1.4em; 322 328 } 323 329 324 .soft{330 #divbody .soft{ 325 331 color:#808080; 326 332 } 327 333 328 .normal{329 font-weight:400; 330 } 331 332 .sharp{334 #divbody .normal{ 335 font-weight:400; 336 } 337 338 #divbody .sharp{ 333 339 color:#101010; 334 340 } 335 341 336 .center{342 #divbody .center{ 337 343 text-align:center; 338 344 } 339 345 340 .hide{346 #divbody .hide{ 341 347 display:none; 342 348 } tracistanplugin/0.10/example/aftracistan/aftracistan/status.py
r697 r711 6 6 import os.path 7 7 from pkg_resources import resource_filename 8 from tracistan import IStanRequestHandler 8 from tracistan import IStanRequestHandler, IStanRenderer 9 from nevow import tags as T 9 10 10 11 __all__ = ['StatusPage'] … … 18 19 19 20 def match_request(self, req): 20 self.log.info(str(req.args)) 21 return req.path_info == '/status' 21 return req.path_info == '/aftracistan' 22 22 23 23 def process_request(self, req): … … 25 25 req.standata.update({ 'name': 'Pacopablo', 26 26 'message' : 'Hello vatos!', 27 'title' : 'Pyrus', 27 'title' : 'Aftracistan', 28 'tidy' : True, 29 'nav' : [{ 'link_name' : 'Front page', 30 'link_id' : 'current', 31 'link_url' : 'index.html', }, 32 { 'link_name' : 'Alternative layout', 33 'link_id' : None, 34 'link_url' : 'alternative.html', }, 35 { 'link_name' : 'Photo layout', 36 'link_id' : None, 37 'link_url' : 'photos.html', }, 38 { 'link_name' : 'Styles', 39 'link_id' : None, 40 'link_url' : 'styles.html', }, 41 { 'link_name' : 'Empty', 42 'link_id' : None, 43 'link_url' : 'empty.html', }, 44 ] 28 45 }) 29 46 return ('index.stan', None) … … 51 68 52 69 70 class StatusRenderers(Component): 71 implements(IStanRenderer) 72 73 def get_renderers(self): 74 """Map methods to method names""" 75 return { 76 'render_nav_row' : self._render_nav_row, 77 } 78 79 def _render_nav_row(self, context, data): 80 return context.tag(id=data['link_id'])[T.a (href=data['link_url']) [ data['link_name'] ]] tracistanplugin/0.10/example/aftracistan/aftracistan/templates/index.stan
r696 r711 1 1 inherits (template='tracmain.stan') [ 2 2 override (slot='pagebody') [ 3 div (id="divbody" ) [ 3 4 div (id="container") [ 4 5 a (id="top"), … … 17 18 ], 18 19 div (id="nav") [ 19 ul [ 20 li (id="current") [ 21 a (href="index.html") [ 'Front page' ] 22 ], 23 li [ 24 a (href="alternative.html") [ 'Alternative layout' ] 25 ], 26 li [ 27 a (href="photo.html") [ 'Photo layout' ] 28 ], 29 li [ 30 a (href="styles.html") [ 'Styles' ] 31 ], 32 li [ 33 a (href="empty.html") [ 'Empty' ] 34 ], 20 ul (render=render.sequence, data=vars.nav) [ 21 li (pattern='item', render=render_nav_row) 35 22 ], 36 23 p (_class="hide") [ … … 103 90 div (id="content") [ 104 91 h1 [ 'Welcome to "falling leaves"...' ], 105 img (src="chrome/ pyrus/img/gravatar-leaf.jpg", height="80",92 img (src="chrome/aftracistan/img/gravatar-leaf.jpg", height="80", 106 93 width="80", alt="Gravatar example"), 107 94 p (_class="intro") [ '...also known as "andreas06", yet another open source ' … … 138 125 ] 139 126 ] 127 ] 140 128 ] tracistanplugin/0.10/stan/stansupport.py
r697 r711 95 95 96 96 def _inherits_tag (self, template, locals, globals): 97 self.log.debug("called _inherits_tag")98 97 filename = self.find_template(template) 99 self.__superTemplate = eval(file(filename, 'rU' ).read(),98 self.__superTemplate = eval(file(filename, 'rU').read(), 100 99 locals, globals) 101 100 return T.invisible 102 101 103 102 def _replace_tag (self, slot): 104 self.log.debug("called _replace_tag")105 self.log.debug("slot: %s" % str(slot))106 107 103 return T.invisible(slot=slot) 108 104 109 105 def _include_tag (self, template, locals, globals): 110 self.log.debug("called _include_tag")111 106 try: 112 107 filename = self.find_template(template) … … 146 141 filename = self.find_template(template) 147 142 143 pretty = False 144 if info.has_key('tidy'): 145 pretty = info['tidy'] 146 148 147 ns = {} 149 148 150 if format.startswith('tidy.'):151 pretty, format = format.split('.')152 else:153 pretty = False154 149 if format == 'html': 155 150 ns.update(__import__('nevow.tags', ns, ns, ['__all__']).__dict__) … … 189 184 for c in self.__template.children]) 190 185 191 from pprint import PrettyPrinter192 ppstream = StringIO()193 pp = PrettyPrinter(stream=ppstream)194 pp.pprint(parts)195 self.log.debug("parts: %s" % ppstream.getvalue())196 186 for slot, fragment in parts.items(): 197 187 self.__superTemplate.fillSlots(slot, fragment) 198 from pprint import PrettyPrinter199 ppstream = StringIO()200 pp = PrettyPrinter(stream=ppstream)201 pp.pprint(self.__superTemplate)202 self.log.debug("__superTemplate: %s" % ppstream.getvalue())203 188 output = flatten(self.__superTemplate) 204 189 else: … … 221 206 def get_renderers(self): 222 207 """Map methods to method names""" 223 self.log.debug("called get_renderers") 224 return {'tracPageTitle' : self._pageTitle, 225 'tracNoRobots' : self._robots, 226 'tracLinks' : self._links, 227 'tracScript' : self._scripts, 228 'tracProjectLogo' : self._project_logo, 208 return { 229 209 'includeCS' : self._include_cs, 230 210 } 231 211 232 def _pageTitle(self, context, data):233 self.log.debug("called _pageTitle")234 self.log.debug("data: %s" % str(type(data)))235 if data.project.name_encoded:236 t = [data.title or '',237 ' - ',238 data.project.name_encoded,239 ' - Trac',]240 else:241 t = ['Trac: ',242 data.project.name_encoded,]243 return context.tag[''.join(t)]244 245 def _robots(self, context, data):246 self.log.debug("called _robots")247 if data.html.norobots:248 return context.tag(name="ROBOTS", content="NOINDEX, NOFOLLOW")249 250 def _links(self, context, data):251 self.log.debug("called _links")252 return ''253 254 def _scripts(self, context, data):255 self.log.debug("called _scripts")256 return ''257 258 212 def _include_cs(self, context, data): 259 self.log.debug("called _include_cs") 260 return '<!-- THis is cs stuff -->' 261 262 def _project_logo(self, context, data): 263 self.log.debug("called _project_logo") 264 href = data.chrome.logo.link 265 logosrc = data.chrome.logo.src 266 logowidth = data.chrome.logo.width 267 logoheight = data.chrome.logo.height 268 logoalt = data.chome.logo.alt 269 if logosrc: 270 image = T.img(src=logosrc, width=logowidth, height=logoheight, 271 alt=logoalt) 272 print 'logosrc present: %s' % str(image) 273 return context.tag [T.a(id="logo", href=href)[image], T.hr] 274 else: 275 image = data.project.name_encoded 276 if image: 277 return context.tag[T.h1 [ T.a(id="logo", href=href)[image] ]] 278 return "" 213 hdf = data['hdf'] 214 template = data['template'] 215 return T.xml(hdf.render(template)) 216 279 217 280 218 class TracIStan(Component): … … 292 230 293 231 """ 294 # abstract = True295 232 implements(IRequestHandler, ITemplateProvider) 296 233 stanreqhandlers = ExtensionPoint(IStanRequestHandler) … … 301 238 # IRequestHandler methods 302 239 def match_request(self, req): 303 self.log.debug('IStanRequestHandlers:')304 [self.log.debug(' Stan Request Handler : %s' % type(x).__name__)305 for x in self.stanreqhandlers]306 240 for handler in self.stanreqhandlers: 307 241 if handler.match_request(req): … … 319 253 hdf = getattr(req, 'hdf', None) 320 254 if hdf: 321 req.standata .update(self._convert_hdf_to_data(hdf))255 req.standata['hdf'] = hdf 322 256 template, content_type = chosen_handler.process_request(req) 323 257 content_type = content_type or 'text/html' … … 340 274 outstream.close() 341 275 else: 276 ct = content_type.split('/')[0] 342 277 data = self._render(req.standata, template) 343 278 … … 358 293 return self.stantheman.render(data, template=template) 359 294 360 def _convert_hdf_to_data(self, hdf):361 """Converts an HDFWrapper to a dictionary362 363 """364 def reformat_data(data):365 """Check to see if the keys are sequential numbers and reformats366 into a list367 368 """369 try:370 keys = [int(k) for k in data.keys()]371 keys.sort()372 datalist = [data[str(k)] for k in keys]373 return datalist374 except ValueError:375 return data376 377 def hdf_tree_walk(node):378 d = {}379 while node:380 name = node.name() or ''381 value = node.value()382 if (value or not node.child()) and name:383 d[name] = value.strip()384 if node.child() and name:385 data = hdf_tree_walk(node.child())386 data = reformat_data(data)387 if data:388 d[name] = data389 node = node.next()390 return d391 392 return hdf_tree_walk(hdf.hdf.child())393 394 295 # ITemplateProvider 395 296 def get_templates_dirs(self): … … 412 313 413 314 """ 414 # return [('blog', resource_filename(__name__, 'htdocs'))]415 315 return [] 416 316 tracistanplugin/0.10/stan/templates/tracmain.stan
r696 r711 1 html [ 2 include(template='tracheader.stan'), 3 body [ 4 include(template='tracnav.stan'), 5 # slot('pagebody'), 6 include(template='tracfooter.stan'), 7 ] 1 invisible [ 2 invisible(render=includeCS, data={'hdf':vars.hdf, 'template':"header.cs"}), 3 slot('pagebody'), 4 invisible(render=includeCS, data={'hdf':vars.hdf, 'template':"footer.cs"}), 8 5 ]
