def render_footnotes(self, ctx, data): """renders the footnotes as a definition list. """ return T.dl(class_="footnotes")[[ T.xml(note.getContent(targetFormat="html")) for note in sorted(self.footnotes, key=lambda n: n.tag) ]]
def render_footnotes(self, ctx, data): """renders the footnotes as a definition list. """ if self.serManager.notes: yield T.hr(class_="footsep") yield T.dl(class_="footnotes")[[ T.xml(note.getContent(targetFormat="html", macroPackage=self.serManager.table.tableDef)) for tag, note in sorted(self.serManager.notes.items())]]
def render_status(self, context, data): try: obj = context.locate(inevow.IHand) except KeyError: return context.tag.clear() if not isinstance(obj, MassPasswordChangeStatus): return context.tag.clear()[obj] dl = tags.dl(compact="compact") context.tag.clear()[dl] for success, x in obj.deferlist: if success: entry, pwd = x dl[tags.dt[entry.dn], tags.dd[pwd]] else: context.tag[_('Failed: '), x.getErrorMessage()] return context.tag
class ChatWidget(athena.LiveElement): """This is broken""" jsClass = u'ControllerModule.ChatWidget' docFactory = loaders.stan([tags.div(render=tags.directive('liveElement'))[ tags.div(id="topic"), tags.div(id="content")[ tags.div(pattern="message")[ classTag(tags.span, 'timestamp')[tags.slot(name='timestamp')], classTag(tags.span, 'userid')[tags.slot(name='userid')], classTag(tags.span, 'message')[tags.slot(name='message')], ]], tags.dl(id="userlist")[tags.dt["Userlist"], tags.dd(pattern="user")[ # tags.attr(name="id")["user-list-", tags.slot(name="user-id")], # tags.slot(name="user-id") tags.xml(""" <nevow:attr name="id">user-list-<nevow:slot name="user-id" /></nevow:attr> """),tags.slot(name="user-id") ]], tags.form(name="inputForm", onsubmit=""" var w = Nevow.Athena.Widget(this); w.callRemote('sendInput', this.inputLine.value);""")[ tags.input(name="inputLine"), tags.input(type="submit", value="say") ], tags.form(name="nickForm", onsubmit=""" var w = Nevow.Athena.Widget(this); w.callRemote('changeNick', this.nick.value);""")[ tags.input(name="nick"), tags.input(type="submit", value="change nick") ], tags.form(name="topicForm", onsubmit=""" var w = Nevow.Athena.Widget(this); w.callRemote('changeTopic', this.topic.value);""")[ tags.input(name="topic"), tags.input(type="submit", value="change topic") ], # tags.span(id="bottom") ]]) messagePattern = inevow.IQ(docFactory).patternGenerator('message') userPattern = inevow.IQ(docFactory).patternGenerator('user') def __init__(self): self.clients = [] self.events = [] def goingLive(self, ctx, client): client.notifyOnClose().addBoth(self.userLeft, client) client.userId = "newuser" client.send( assign(document.nickForm.nick.value, client.userId)) addUserlistEntry = append('userlist', self.userPattern.fillSlots('user-id', client.userId)), eol self.sendEvent( client, addUserlistEntry, self.content(client, 'has joined.')) ## Catch the user up with the previous events client.send([(event, eol) for source, event in self.events]) self.clients.append(client) def userLeft(self, _, client): self.clients.remove(client) self.sendEvent( client, js.removeNode('user-list-%s' % (client.userId, )), eol, self.content(client, 'has left.')) def sendEvent(self, source, *event): self.events.append((source, event)) for target in self.clients: if target is not source: target.send(event) return event def content(self, sender, message): return append( 'content', self.messagePattern.fillSlots( 'timestamp', time.strftime("%H:%M %d/%m/%y") ).fillSlots( 'userid', sender.userId ).fillSlots( 'message', message)), eol, js.scrollDown() def handle_sendInput(self, ctx, inputLine): sender = livepage.IClientHandle(ctx) return self.sendEvent(sender, self.content(sender, inputLine)), eol, js.focusInput() def handle_changeNick(self, ctx, nick): changer = livepage.IClientHandle(ctx) rv = self.sendEvent( changer, set('user-list-%s' % (changer.userId, ), nick), eol, js.changeId('user-list-%s' % (changer.userId, ), 'user-list-%s' % (nick, )), eol, self.content(changer, 'changed nick to %r.' % (nick, ))) changer.userId = nick return rv
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