def applyTable(self, page): headings, rows = self.getTable() headings.append(('', '')) mrows = self.jsData(headings, rows) newRows = self.formatTable(headings, rows) return [ tags.xml(""" <script type="text/javascript"> function editElm%(name)s(index){ var exRows = %(rows)s; var heads = %(headings)s; getElement('add%(name)s-editIndexNode').value=index; var c = 0; forEach(heads, function(el){ try { var input = getElement('add%(name)s-'+el); if (input.nodeName == "INPUT"){ if (input.type == "checkbox"){ var newVal = exRows[index][c].toLowerCase(); input.checked = (newVal == "yes") || (newVal == "true"); } else { input.value = exRows[index][c]; } } else if (input.nodeName == "SELECT") { var inc = 0 forEach(input.options, function(opt){ if (opt.value == exRows[index][c]){ input.selectedIndex = inc; } inc ++; }); }; } catch (dc) {}; // Ignore colums which are unparsable - look at PPP config for why ;) %(extra)s c++; }); hideElement('addHead%(name)s'); showElement('editHead%(name)s'); } </script> """ % { 'name': self.name, 'rows': mrows, 'headings': map(lambda _:_[1].encode('ascii', 'replace') ,headings[:-1]), 'extra': self.extraJs() }), dataTable(map(lambda _:_[0] ,headings), newRows, sortable = True), tags.br, tags.h3(id='addHead%s' % self.name)["Add %s" % self.description], tags.h3(id='editHead%s' % self.name, style='display: none;')["Edit %s" % self.description], tags.directive('form add%s' % self.name) ]
class FormPage(rend.Page): addSlash = True child_webform_css = webform.defaultCSS def render_hand(self, ctx, data): hand = inevow.IHand(ctx, None) if hand is not None: return ctx.tag[hand] return '' docFactory = loaders.stan( tags.html[ tags.head[ tags.link(rel='stylesheet', type='text/css', href=url.here.child('webform_css')), ], tags.body[ tags.h3(render=render_hand, style="color: red; font-size: xx-large"), "Hello! Here is a form:", # We want to render forms defined by the Implementation instance. # When we pass the Implementation instance to FormPage below, # rend.Page sets it as the .original attribute. To tell webform to render # forms described by this object, we use the configurable name "original". webform.renderForms('original'), ], ], )
def render_webconsole_environments(self): return [ tags.h3()['Web console Environments'], tags.table()[ tags.tr()[ tags.th()['Port'], tags.td()[lumen.config['webport']], ], ], ]
def data_trusted_roots(self, ctx, data): """ Template function to display a list of user roots. """ result = yield self.user.getTrustedRoots() output = [tags.h3()['trusted roots'], tags.ul(_class="url-list")[[ tags.li()[item['url']] for item in result ]] ] returnValue(output)
def data_identities(self, ctx, data): """ Template function to display a list of user identities. """ result = yield self.user.getIdentities() output = [tags.h3()['identities'], tags.ul(_class="url-list")[[ tags.li()[item['url']] for item in result ]] ] returnValue(output)
def render_logs(self): if lumen.config['logpath']: logFilePath = os.path.abspath(lumen.config['logpath']) logFile = open(logFilePath) return [ tags.h3()['Logs'], tags.pre(style='border:1px solid #ccc; padding: 0.5em; overflow:auto')[ self.tail_logs(logFile) ], ] else: return []
def render_bayeux_environments(self): return [ tags.h3()['Bayeux Environmerts'], tags.table()[ tags.tr()[ tags.th()['Port'], tags.td()[lumen.config['port']], ], tags.tr()[ tags.th()['Engine'], tags.td()[lumen.config['engine']], ] ], ]
class LoggedIn(rend.Page): """The resource that is returned when you login""" addSlash = True docFactory = loaders.stan( tags.html[tags.head[tags.title["Logged In"]], tags.body[tags.h3(render=tags.directive("welcome")), tags.a(href=guard.LOGOUT_AVATAR)["Logout"]]]) def render_welcome(self, context, data): return context.tag["Hello, %s!" % data] def logout(self): ## self.original is the page's main data -- the object that was passed in to the constructor, and ## the object that is initially passed as the 'data' parameter to renderers print "%s logged out!" % self.original
def data_trusted_roots(self, ctx, data): """ Template function to display a checkbox list of user roots. """ result = yield self.user.getTrustedRoots() output = [tags.h3()['trusted roots'], tags.ul(_class="url-list")[[ tags.li()[[ tags.input(type='checkbox', name='root-%s' % item['id'], value='1'), item['url'], ]] for item in result ]] ] returnValue(output)
def data_identities(self, ctx, data): """ Template function to display a checkbox list of user identities. """ result = yield self.user.getIdentities() output = [tags.h3()['identities'], tags.ul(_class="url-list")[[ tags.li()[[ tags.input(type='checkbox', name='identity-%s' % item['id'], value='1'), item['url'], ]] for item in result ]] ] returnValue(output)
class TypeAheadFieldFragment(athena.LiveFragment): docFactory = loaders.stan( T.span(render=T.directive('liveFragment'))[ '\n', T.input(type="text", _class="typehere"), '\n', T.h3(_class="description"), ]) def loadDescription(self, typed): if typed == '': return None, '--' matches = [] for key in animals: if key.startswith(typed): matches.append(key) if len(matches) == 1: return matches[0], animals[matches[0]] elif len(matches) > 1: return None, "(Multiple found)" else: return None, '--' athena.expose(loadDescription)
def render_content(self, context, data): return [ tags.h3()['APNS'], tags.h4()['Applications'], ]
def render_photoinformation(self,ctx,data): p = self.photo priceoptions = [] for optiondata in p.options: data={} for d in optiondata['cats']: data[d['cat']] = d['value'] priceoptions.append( {'name':optiondata['code'],'description':data['description'],'price':'%3.2f'%float(optiondata['price'])} ) if p.date is not None: d = p.date.day if 4 <= d <= 20 or 24 <= d <= 30: suffix = "th" else: suffix = ["st", "nd", "rd"][d % 10 - 1] m = p.date.strftime('%B') y = p.date.strftime('%Y') day = '%s%s %s %s'%(d,suffix,m,y) else: day = '-' if p.location is not None: location = p.location else: location = '-' if p.lens is not None: lens = p.lens else: lens = '-' if hasattr(p,'speed') and p.speed is not None: speed = p.speed else: speed = '-' if hasattr(p,'aperture') and p.aperture is not None: aperture = p.aperture else: aperture = '-' if p.tiltswing is not None: tiltswing = p.tiltswing else: tiltswing = '-' if p.risefall is not None: risefall = p.risefall else: risefall = '-' if p.ndfilters is not None: ndfilters = p.ndfilters else: ndfilters = '-' if p.otherfilters is not None: otherfilters = p.otherfilters else: otherfilters = '-' hidecategorylist = ['flags'] recorddata = [ ('date', day), ('location', location), ('lens', lens), ('speed', speed), ('aperture', aperture), ('tilt/swing', tiltswing), ('rise/fall', risefall), ('nd filters', ndfilters), ('other filters', otherfilters), ('keywords',','.join( [ ':'.join(k.split('.')[1:]) for k in p.categories if k.split('.')[0] not in hidecategorylist] )), ] pricedl = T.dl() for option in priceoptions: pricedl[ T.dt[option['name']] ] pricedl[ T.dd[T.p[T.form(action='/basket',id='addtobasket',method='POST')[ T.input(type='hidden',name='id',value='%s.%s'%(self.photo.id,option['name'])),T.input(type='hidden',name='command',value='add'),T.input(type='submit',value='add') ],option['description']],T.p[T.xml('£'),option['price']]] ] recorddl = T.dl() for key,value in recorddata: recorddl[ T.dt[key] ] recorddl[ T.dd[value] ] html = [ T.invisible[ p.description ], T.div(class_="purchase clearfix")[ T.h3(onclick="$('.purchase').BlindToggleVertically(500, null, 'easeout');$('#price a').toggleClass('over');return false;")['purchase options'], pricedl, ], T.div(class_="record clearfix")[ T.h3(onclick="$('.record').BlindToggleVertically(500, null, 'easeout');$('#info a').toggleClass('over');return false;")['photographic record'], recorddl, ], ] return html