class FormExamplePage(formal.ResourceMixin, rend.Page): """ A base page for the actual examples. The page renders something sensible, including the title example and description. It also include the "example" form in an appropriate place. Each example page is expected to provide the title and description attributes as well as a form_example method that builds and returns a formal.Form instance. """ docFactory = loaders.stan( T.invisible[DOCTYPE, T.html[ T.head[CHARSET, T.title(data=T.directive('title'), render=rend.data), T.link(rel='stylesheet', type='text/css', href=url.root.child('examples.css')), T.link(rel='stylesheet', type='text/css', href=url.root.child('formal.css')), T.script(type='text/javascript', src='js/formal.js'), ], T.body[T.h1(data=T.directive('title'), render=rend.data), T.p(data=T.directive('description'), render=rend.data), T.directive('form example'), ], ], ], ) def data_title(self, ctx, data): return self.title def data_description(self, ctx, data): return self.description
class ResultsPage(athena.LivePage): addSlash = True docFactory = loaders.stan( tags.html[tags.head(render=tags.directive('liveglue'))[ tags.title["IPython Results"], tags.link(rel="stylesheet", type="text/css", href="main.css"), tags.link(rel="stylesheet", type="text/css", href="results.css")], tags.body[tags.h1["IPython Results"], tags.div(render=tags.directive('widgets'))]]) def __init__(self, controller): athena.LivePage.__init__(self) self.controller = controller if not self.children: self.children = {} self.children["main.css"] = static.File( util.sibpath(__file__, 'main.css')) self.children["results.css"] = static.File( util.sibpath(__file__, 'results.css')) def render_widgets(self, ctx, data): w = aw.ResultWidget() w.setFragmentParent(self) n1 = results.notifierFromFunction(w.handleResult) self.controller.addNotifier(n1) c = aw.CommandWidget(self.controller) c.setFragmentParent(self) return ctx.tag[w, tags.br, c]
def render_commonhead(self, ctx, data): # we do not want to blindly append these things to the tag since user- # provided items in the header should have access to this environment, # in particular to jquery; thus, this stuff must be as early as possible. originalChildren = ctx.tag.children[:] ctx.tag.clear() res = ctx.tag[ T.meta(**{"charset": "utf-8"}), T.link(rel="icon", type="image/png", href=base.makeSitePath("/static/img/favicon.png")), T.link(rel="stylesheet", href=base.makeSitePath("/static/css/style.css"), type="text/css"), T.link(rel="stylesheet", href=base.makeSitePath("/formal.css"), type="text/css"), T.link(rel="stylesheet", href=base.makeSitePath("/static/css/gavo_dc.css"), type="text/css"), T.script(src=base.makeSitePath("/static/js/jquery-gavo.js"), type="text/javascript"), T.script(type='text/javascript', src=base.makeSitePath('static/js/formal' + JSEXT)), T.script(type="text/javascript", src=base.makeSitePath("/static/js/gavo" + JSEXT)), T.script(type="text/javascript", src=base.makeSitePath("/static/js/script.js")), originalChildren, ] if base.getConfig("web", "operatorCSS"): res[T.link(rel="stylesheet", type="text/css", href=base.getConfig("web", "operatorCSS"))] return res
def render_css(self, ctx, data): if self.cssorigin: if isinstance(self.cssorigin, str): res= [T.link(type= 'text/css', rel= 'stylesheet', href= self.cssorigin)] else: res= [T.link(type= 'text/css', rel= 'stylesheet', href= s) for s in self.cssorigin] res.append(T.link(type= 'text/css', rel= 'stylesheet', href= _cssblitz)) return res return T.link(type= 'text/css', rel= 'stylesheet', href= _cssblitz)
class ControllerPageAthena(athena.LivePage): """This is broken""" chat = None addSlash = True docFactory = loaders.stan( tags.html[tags.head( render=tags.directive('liveglue') )[tags.link(rel="stylesheet", type="text/css", href="main.css"), tags.link(rel="stylesheet", type="text/css", href="controller.css")], tags.body[tags.h1["IPython Controller"], tags.br, tags.h2[tags.div( render=tags.directive('idwidget')), tags.br, tags.a(href="results")["results"], tags.br, tags.a(href="status")["status"], tags.br, tags.a(href="command")["command"], tags.br, tags.a(href="monitor")["monitor"]], tags.br, tags.div(render=tags.directive('chat'))]]) def __init__(self, controller): athena.LivePage.__init__(self) self.controller = controller if not self.children: self.children = {} self.children["main.css"] = static.File( util.sibpath(__file__, 'main.css')) self.children["controller.css"] = static.File( util.sibpath(__file__, 'controller.css')) def render_idwidget(self, ctx, data): w = aw.IDWidget(self.controller) w.setFragmentParent(self) return ctx.tag[w] def render_chat(self, ctx, data): self.chat = "NO CHAT" if self.chat is None: self.chat = aw.ChatWidget() self.chat.setFragmentParent(self) return ctx.tag[self.chat] def child_results(self, ctx): return ResultsPage(self.controller) def child_status(self, ctx): return StatusPage(self.controller) def child_command(self, ctx): return CommandPage(self.controller) def child_monitor(self, ctx): return MonitorPage(self.controller) def goingLive(self, ctx, client): return self.chat.goingLive(ctx, client)
def render_head_tag(self, ctx, data): ctx.fillSlots('meta_tags', "") ## CSS stylesheets = [] color_option = self._get_color_option(ctx) global_css_includes = self.global_css_includes + ['zoto_%s.css' % color_option] for file in global_css_includes + self.local_css_includes: stylesheets += [T.link(type="text/css", rel="stylesheet", href=self.make_css_path(file)), '\n'] ctx.fillSlots('css_includes', loaders.stan(T.invisible[stylesheets])) ## alternate links - rss, atom, etc. feed_links= [] for feed_url in self.global_feed_includes + self.local_feed_includes: feed_links += [T.link(type="application/%s+xml"%feed_url['type'], rel="alternate", href=feed_url['uri']), '\n'] ctx.fillSlots('feed_includes', loaders.stan(T.invisible[feed_links])) ## Javascript scripts = [] if aztk_config.setup.get('site', 'environment') in ["sandbox", "development"]: for script in self.global_js_includes + self.local_js_includes: if script == "core.js": for script in js.core_js.scripts: scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n'] elif script == "site.js": for script in js.site_js.scripts: scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n'] elif script == "managers.js": for script in js.managers_js.scripts: scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n'] elif script == "mochikit.js": scripts += [ T.script(type="text/javascript", src=self.make_js_path("third_party/MochiKit/MochiKit.js")), '\n', T.script(type="text/javascript", src=self.make_js_path("third_party/MochiKit/DragAndDrop.js")), '\n', T.script(type="text/javascript", src=self.make_js_path("third_party/MochiKit/Sortable.js")), '\n' ] else: scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n'] if self.page_manager_js: scripts += [T.script(type="text/javascript", src=self.make_js_path(self.page_manager_js)), '\n'] ctx.fillSlots('js_includes', loaders.stan(T.invisible[scripts])) else: for script in self.global_js_includes + self.local_js_includes: if script == "mochikit.js": scripts += [T.script(type="text/javascript", src=self.make_js_path("third_party/MochiKit/packed/MochiKit.js")), '\n'] else: scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n'] if self.page_manager_js: scripts += [T.script(type="text/javascript", src=self.make_js_path(self.page_manager_js)), '\n'] ctx.fillSlots('js_includes', loaders.stan(T.invisible[scripts])) return ctx
def render_head(self, ctx, data): if self.db[0] == "FIRSTRUN": return ctx.tag[tags.link(rel="stylesheet", type="text/css", href="/css/login.css")] return ctx.tag[tags.xml( '<meta http-equiv="refresh" content="0;url=auth/"/>')]
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'), ], ], )
class RootPage(rend.Page): """ Main page that lists the examples and makes the example page a child resource. """ docFactory = loaders.stan( T.invisible[ DOCTYPE, T.html[ T.head[ CHARSET, T.title['Forms Examples'], T.link(rel='stylesheet', type='text/css', href=url.root.child('examples.css')), ], T.body[ T.directive('examples'), ], ], ], ) def render_examples(self, ctx, data): for name in examples: cls = reflect.namedAny(name) yield T.div(class_='example')[ T.h1[T.a(href=url.here.child(name))[cls.title]], T.p[cls.description], ] def childFactory(self, ctx, name): if name in examples: cls = reflect.namedAny(name) return cls()
class Root(TransactionalPage): child_webform_css = webform.defaultCSS implements(IInsert) docFactory = loaders.stan(t.html[ t.head[t.title['Imagination'], t.link(rel='stylesheet', type='text/css', href=url.root.child('webform_css'))], t.body[webform.renderForms(), t.ul(render=t.directive("sequence"), data=t.directive("images") )[t.li(pattern="item", render=t.directive("image")), t.li(pattern="empty")["No images yet"]]]]) def data_images(self, ctx, data): return IImages(self.store).getImages(15) def render_image(self, ctx, data): return t.a(href=url.root.child('fs').child(data.hash))[data.title] def insert(self, ctx, title, author, image): img = Image(store=self.store, image=image.value, title=title.decode('utf-8'), author=author.decode('utf-8'), hash=label().decode('utf-8')) def locateChild(self, ctx, segments): if segments[0] == 'fs': data = IImages(self.store).getOne(segments[1].decode('utf-8')) return static.Data(data.image, 'image/jpeg'), () return super(Root, self).locateChild(ctx, segments)
class NewEntry(BaseUI): implements(IInsert) docFactory = loaders.stan( t.html[ t.head[ t.title['Insertion form'], t.link(rel='stylesheet', type='text/css', href=url.root.child('webform_css')), ], t.body[ t.h1['Insertion'], t.invisible(render=t.directive("forms")) ] ]) def render_forms(self, ctx, data): d = iformless.IFormDefaults(ctx).getAllDefaults('insert') d['author'] = 'Anonymous' d['id'] = IBlog(IStore(ctx)).getNextId() return webform.renderForms() def insert(self, ctx, id, title, author, category, content): newPost = Post(store=IStore(ctx), id=int(id), author=unicode(author), title=unicode(title), category=unicode(category), content=unicode(content)) IBlog(IStore(ctx)).addNewPost(newPost) inevow.IRequest(ctx).setComponent(iformless.IRedirectAfterPost, '/thx')
class TestFramework(athena.LivePage): addSlash = True docFactory = loaders.stan([ tags.xml(DOCTYPE_XHTML), tags.html[ tags.head(render=tags.directive('liveglue'))[ tags.link(rel='stylesheet', href='livetest.css'), tags.directive('head')], tags.body[ tags.invisible(render=tags.directive('runner'))]]]) def __init__(self, testSuite): super(TestFramework, self).__init__() self.testSuite = testSuite self.children = { 'livetest.css': static.File(util.resource_filename('nevow.livetrial', 'livetest.css')), } def beforeRender(self, ctx): self.runner = TestRunner(self.testSuite) def render_runner(self, ctx, data): self.runner.setFragmentParent(self) return self.runner def render_head(self, ctx, data): return self.runner.gatherHead()
class Page(rend.Page): addSlash = True child_css = static.File('./css/') child_scripts = static.File('./scripts/') child_images = static.File('./images/') docFactory = loaders.stan( tags.html[tags.head[ tags.title["Tabbed Page Example"], tags.link(rel="stylesheet", href="css/folder-tree-static.css", type="text/css"), tags. script(type="text/javascript", src="scripts/folder-tree-static.js" )['']], tags.body[tags.invisible(render=tags.directive('tree'))]]) def render_tree(self, c, d): Tr = Tree.Tree("r", "Domains") l = Tree.retrieveTree("127.0.0.1", "cn=Manager", "wsthusa", "o=TRYPTOPHAN") flatL = Tree.flattenTree(l, 'o=TRYPTOPHAN') for node in flatL: Tree.addPath(node, Tr) return Tree.StanTree(Tr)
def links(l, path=None): for filename in l: href = filename if path is not None: href = path.child(href) yield tags.link(rel="stylesheet", type="text/css", href=href)
class HistoryPage(rend.Page): def __init__(self, root, ob, rev): self.root = root self.ob = ob self.rev = rev def render_title(self, context, data): return context.tag[u"History of \N{LEFT DOUBLE QUOTATION MARK}" + self.ob.fullName() + u"\N{RIGHT DOUBLE QUOTATION MARK}s docstring"] def render_links(self, context, data): ds = self.root.edits(self.ob) therange = range(len(ds)) rev = therange[self.rev] ul = tags.ul() for i in therange: li = tags.li() if i: li[tags.a(href=url.URL.fromContext( context).sibling('diff').add('ob', self.ob.fullName()).add( 'revA', i - 1).add('revB', i))["(diff)"]] else: li["(diff)"] li[" - "] if i == len(ds) - 1: label = "Latest" else: label = str(i) if i == rev: li[label] else: li[tags.a(href=url.gethere.replace('rev', str(i)))[label]] li[' - ' + ds[i].user + '/' + ds[i].time] ul[li] return context.tag[ul] def render_docstring(self, context, data): docstring = self.root.editsbyob[self.ob][self.rev].newDocstring if docstring is None: docstring = '' return epydoc2stan.doc2html(self.ob, docstring=docstring)[0] def render_linkback(self, context, data): return util.taglink(self.ob, label="Back") docFactory = loaders.stan( tags.html[tags.head[ tags.title(render=tags.directive('title')), tags.link(rel="stylesheet", type="text/css", href='apidocs.css')], tags.body[tags.h1(render=tags.directive('title')), tags.p(render=tags.directive('links')), tags.div(render=tags.directive('docstring')), tags.p(render=tags.directive('linkback'))]])
def error(self, request, msg, code=None): if request.args.get('json'): request.setHeader("content-type", "application/json") d = {'err': msg} if code is not None: d['code'] = code return json.dumps(d) page = t.html[t.head[t.title['KSP Race Into Space server'], t.link(rel='stylesheet', href='main.css')], t.body[t.h1["Error"], t.h2[msg]]] request.setHeader("content-type", "text/html") return flatten(page)
class MonitorPage(athena.LivePage): addSlash = True docFactory = loaders.stan( tags.html[tags.head(render=tags.directive('liveglue'))[ tags.title["IPython Monitor"], tags.link(rel="stylesheet", type="text/css", href="main.css"), tags.link(rel="stylesheet", type="text/css", href="monitor.css")], tags.body[tags.h1["IPython Monitor"], tags.div(render=tags.directive('widgets'))]]) def __init__(self, controller): athena.LivePage.__init__(self) self.controller = controller if not self.children: self.children = {} self.children["main.css"] = static.File( util.sibpath(__file__, 'main.css')) self.children["monitor.css"] = static.File( util.sibpath(__file__, 'monitor.css')) def render_widgets(self, ctx, data): f = aw.CommandWidget(self.controller) f.setFragmentParent(self) g = aw.StatusWidget(self.controller) g.setFragmentParent(self) h = aw.ResultWidget() h.setFragmentParent(self) n1 = results.notifierFromFunction(h.handleResult) self.controller.addNotifier(n1) n2 = results.notifierFromFunction(g.refreshStatus) f.addNotifier(n2) reactor.callLater(1, g.refreshStatus) build = tags.table(id="monitor")[tags.tr[tags.td(valign="top")[g], tags.td(valign="top")[h, tags.br, f]]] return ctx.tag[build]
class tabbedPaneGlue: _css = util.resource_filename('nevow.taglibrary', "tabbedPane.css") _js = util.resource_filename('nevow', "js/Nevow/TagLibrary/TabbedPane.js") fileCSS = static.File(_css, 'text/css') fileJS = static.File(_js, 'text/javascript') fileGlue = (t.link(rel='stylesheet', type='text/css', href='/tabbedPane.css'), t.script(type='text/javascript', src='/tabbedPane.js')) inlineCSS = t.style(type_='text/css')[t.xml(file(_css).read())] inlineJS = t.inlineJS(file(_js).read()) inlineGlue = inlineJS, inlineCSS
class progressBarGlue: _css = util.resource_filename('nevow.taglibrary', "progressBar.css") _js = util.resource_filename('nevow.taglibrary', "progressBar.js") fileCSS = static.Data(_css, 'text/css') fileJS = static.Data(_js, 'text/javascript') fileGlue = ( t.link(rel='stylesheet', type_='text/css', href='/progressBar.css'), t.script(type_='text/javascript', src='/progressBar.js') ) inlineCSS = t.style(type_='text/css')[ t.xml(file(_css).read()) ] inlineJS = t.inlineJS(file(_js).read()) inlineGlue = inlineJS, inlineCSS
class CommandPage(athena.LivePage): addSlash = True docFactory = loaders.stan( tags.html[tags.head(render=tags.directive('liveglue'))[ tags.title["IPython Command"], tags.link(rel="stylesheet", type="text/css", href="main.css"), tags.link(rel="stylesheet", type="text/css", href="command.css")], tags.body[tags.h1["IPython Command"], tags.div(render=tags.directive('widget'))]]) def __init__(self, controller): athena.LivePage.__init__(self) self.controller = controller if not self.children: self.children = {} self.children["main.css"] = static.File( util.sibpath(__file__, 'main.css')) self.children["command.css"] = static.File( util.sibpath(__file__, 'command.css')) def render_widget(self, ctx, data): w = aw.CommandWidget(self.controller) w.setFragmentParent(self) return ctx.tag[w]
class Tester(livepage.LivePage): addSlash = True child_css = static.File(os.path.join(resourceDirectory, 'livetest.css')) child_scripts = static.File(os.path.join(resourceDirectory, 'livetest.js')) child_postscripts = static.File( os.path.join(resourceDirectory, 'livetest-postscripts.js')) docFactory = loaders.stan(tags.html[ tags.head[tags.script(src="scripts"), tags.link(rel="stylesheet", type="text/css", href="css")], tags.body[tags.table(id="testprogress")[ tags.tr[tags.th["Tests"], tags.th["Pass"], tags.th["Fail"]], tags. tr[tags.td(id="test-status")["Running"], tags.td(id="test-passes", _class="test-passes")[entities.nbsp], tags.td(id="test-failures", _class="test-failures")[entities. nbsp]]], tags. table(id="testresults", render=tags.directive('table') )[tags. tr(pattern="item", render=tags.directive('test'))[ tags.td[tags.slot('action')], tags.td[tags.slot('target')], tags.td[tags.slot('parameter')]]], tags.iframe(id="testframe", src="asdf"), tags.script(src="postscripts"), livepage.glue]]) def render_table(self, ctx, suite): self.testId = 0 driver = Driver(suite) handle = livepage.IClientHandle(ctx) driver.notifyWhenTestsComplete().addCallback(self.testsComplete, handle) driver.setHandle(handle) driver.nextTest() return rend.sequence(ctx, suite) def render_test(self, ctx, test): ctx.tag(id=("test-", self.testId)) action, target, parameter = test ctx.fillSlots('action', action) ctx.fillSlots('target', str(target)) ctx.fillSlots('parameter', parameter) self.testId += 1 return ctx.tag def testsComplete(self, results, handle): handle.set('test-status', 'Complete')
class tabbedPaneGlue: """ Record which holds information about the Javascript & CSS requirements of L{TabbedPane} and L{TabbedPaneFragment}. @type stylesheetPath: C{str} @ivar stylesheetPath: Filesystem path of the tabbed pane stylesheet. @type javascriptPath: C{str} @ivar javascriptPath: Filesystem path of the tabbed pane Javascript module. @type fileCSS: L{static.File} @ivar fileCSS: Resource which serves L{stylesheetPath}. @type fileJS: L{static.File} @ivar fileJS: Resource which serves L{javascriptPath}. @type fileGlue: Stan @ivar fileGlue: Stan which, when placed in the <head> of an HTML document, will include the required CSS & Javascript. @type inlineCSS: L{t.style} @ivar inlineCSS: <style> tag containing the tabbedpane CSS inline. @type inlineJS: L{t.script} @ivar inlineJS: <script> tag containing the tabbedpane Javascript inline. @type inlineGlue: Stan @ivar inlineGlue: A tuple of L{inlineCSS} and L{inlineJS}. """ stylesheetPath = util.resource_filename('nevow', 'css/Nevow/TagLibrary/TabbedPane.css') javascriptPath = util.resource_filename('nevow', 'js/Nevow/TagLibrary/TabbedPane.js') fileCSS = static.File(stylesheetPath, 'text/css') fileJS = static.File(javascriptPath, 'text/javascript') fileGlue = ( t.link(rel='stylesheet', type='text/css', href='/tabbedPane.css'), t.script(type='text/javascript', src='/tabbedPane.js') ) inlineCSS = t.style(type_='text/css')[ t.xml(file(stylesheetPath).read()) ] inlineJS = t.inlineJS(file(javascriptPath).read()) inlineGlue = inlineJS, inlineCSS
def render_GET(self, request): self.flatten_args(request) try: self.validate(**request.args) except Failed as e: return self.error(request, e.msg, e.code) except Exception as e: return self.error(request, repr(e)) if request.args.get('json'): try: d = self.data(**request.args) request.setHeader("content-type", "application/json") return json.dumps(d) except Exception as e: return self.error(request, repr(e)) page = t.html[t.head[t.title['KSP Race Into Space server'], t.link(rel='stylesheet', href='main.css')], t.body[self.content(**request.args)]] request.setHeader("content-type", "text/html") return flatten(page)
class FormPage(rend.Page): addSlash = True child_webform_css = webform.defaultCSS # We need this to implement IMyForm foo = 5 docFactory = loaders.stan( tags.html[tags.head[ tags.link(rel='stylesheet', type='text/css', href=url.here.child('webform_css')), ], tags.body[ "Hello! Here is a form:", # We want to render the "default" configurable. # This is located in Page.configurable_() and is going to be # 'self' (which, as you see above, implements IMyForm). webform.renderForms(), ], ], )
def head(self, request, website): """ Provide content to include in the head of the document. If you only need to provide a stylesheet, see L{stylesheetLocation}. Otherwise, override this. @type request: L{inevow.IRequest} provider @param request: The request object for which this is a response. @param website: The site-wide L{xmantissa.website.WebSite} instance. Primarily of interest for its C{rootURL} method. @return: Anything providing or adaptable to L{nevow.inevow.IRenderer}, or C{None} to include nothing. """ stylesheet = self.stylesheetLocation if stylesheet is not None: root = website.rootURL(request) for segment in stylesheet: root = root.child(segment) return tags.link(rel='stylesheet', type='text/css', href=root)
class NotebookPage(athena.LivePage): addSlash = True docFactory = loaders.stan( tags.html[tags.head( render=tags.directive('liveglue') )[tags.title["IPython Notebook"], tags.link(href="notebook.css", rel="stylesheet", type="text/css"), ], tags.body(render=tags.directive('widget'))]) def __init__(self, controller): athena.LivePage.__init__(self) self.controller = controller if self.children is None: self.children = {} self.children["notebook.css"] = static.File( util.sibpath(__file__, 'notebook.css')) def render_widget(self, ctx, data): w = aw.NotebookWidget(self.controller) w.setFragmentParent(self) return ctx.tag[w]
class RecentChangesPage(page.Element): def __init__(self, root, url): self.root = root self.url = url @page.renderer def changes(self, request, tag): item = tag.patternGenerator('item') for d in reversed(self.root._edits): tag[util.fillSlots(item, diff=self.diff(d), hist=self.hist(d), object=util.taglink(d.obj), time=d.time, user=d.user)] return tag def diff(self, data): return tags.a(href=self.url.sibling('diff').add( 'ob', data.obj.fullName()).add('revA', data.rev - 1).add('revB', data.rev))["(diff)"] def hist(self, data): return tags.a(href=self.url.sibling('history').add( 'ob', data.obj.fullName()).add('rev', data.rev))["(hist)"] docFactory = loaders.stan(tags.html[ tags.head[ tags.title["Recent Changes"], tags.link(rel="stylesheet", type="text/css", href='apidocs.css')], tags.body[tags.h1["Recent Changes"], tags.p[ "See ", tags.a( href="bigDiff")["a diff containing all changes made online"]], tags.ul(render=tags.directive("changes"))[tags.li( pattern="item")[tags.slot("diff"), " - ", tags.slot("hist"), " - ", tags.slot("object"), " - ", tags.slot("time"), " - ", tags.slot("user"), ]]]])
class Tester(livepage.LivePage): addSlash = True child_css = static.File(util.resource_filename('nevow', 'livetest.css')) child_scripts = static.File(util.resource_filename('nevow', 'livetest.js')) child_postscripts = static.File(util.resource_filename('nevow', 'livetest-postscripts.js')) docFactory = loaders.stan(tags.html[ tags.head[ tags.script(src="scripts"), tags.link(rel="stylesheet", type="text/css", href="css")], tags.body[ tags.table(id="testprogress")[ tags.tr[ tags.th["Tests"], tags.th["Pass"], tags.th["Fail"]], tags.tr[ tags.td(id="test-status")["Running"], tags.td(id="test-passes", _class="test-passes")[entities.nbsp], tags.td(id="test-failures", _class="test-failures")[entities.nbsp]]], tags.table(id="testresults", render=tags.directive('sequence'))[ tags.tr(pattern="item", render=tags.directive('test'))[ tags.td(title=tags.slot('action'))[tags.slot('action')], tags.td(title=tags.slot('target'))[tags.slot('target')], tags.td(title=tags.slot('parameter'))[tags.slot('parameter')]]], tags.iframe(id="testframe", src="asdf"), tags.script(src="postscripts"), livepage.glue]]) def beforeRender(self, ctx): self.testId = 0 def render_test(self, ctx, test): ctx.tag(id=("test-", self.testId)) action, target, parameter = test ctx.fillSlots('action', action) ctx.fillSlots('target', str(target)) ctx.fillSlots('parameter', str(parameter)) self.testId += 1 return ctx.tag def goingLive(self, ctx, handle): Driver(handle, self.original)
class Root(rend.Page): """Render a custom and normal form for an ISomething. """ addSlash = True child_webform_css = webform.defaultCSS def render_normalForm(self, ctx, data): return webform.renderForms() def render_customForm(self, ctx, data): return webform.renderForms()[FORM_LAYOUT] def doSomething(self, ctx, **kwargs): print('***** doSomething called with:', kwargs) docFactory = loaders.stan( T.html[T.head[T.title['Example :: Custom Form Layout'], T.link(rel='stylesheet', type='text/css', href=url.here.child("webform_css")), ], T.body[T.h1['Custom'], render_customForm, T.h1['Default'], render_normalForm, ]])
_tp_style_fn = _locateFile("tabbedPane-style.css") _tp_layout_fn = _locateFile("tabbedPane-layout.css") _tp_JS = _locateFile("tabbedPane.js") tabbedPaneStyle = t.style(type_="text/css")[open(_tp_style_fn).read()] tabbedPaneLayout = t.style(type_="text/css")[open(_tp_layout_fn).read()] tabbedPaneJS = t.inlineJS(open(_tp_JS).read()) tabbedPaneHeadInline = t.invisible[tabbedPaneStyle, tabbedPaneLayout, tabbedPaneJS] tabbedPaneStyleFile = static.File(_tp_style_fn, "text/css") tabbedPaneLayoutFile = static.File(_tp_layout_fn, "text/css") tabbedPaneJSFile = static.File(_tp_JS, "text/javascript") tabbedPaneHeadFiles = t.invisible[ t.link(rel="stylesheet", type="text/css", href="/tabbedPane-style.css"), t.link(rel="stylesheet", type="text/css", href="/tabbedPane-layout.css"), t.script(type="text/javascript", src="/tabbedPane.js"), ] class TabbedPane(object): def tabbedPane(self, ctx, data): tab_names = [element[0] for element in data] return t.invisible[ t.div(class_="tabbedPane")[ t.ul(class_="tabs")[[t.li(id_="tab-" + name.replace(" ", "_"))[name] for name in tab_names]], [t.div(id_="page-" + name.replace(" ", "_"))[fragment] for name, fragment in data], ], t.inlineJS(
class Page(rend.Page): docFactory = loaders.stan(T.html[ T.head[T.link(rel='stylesheet', href=urlparse. urljoin(CONF.get('target', 'baseurl' ), CONF.get('stylesheet', 'filename')), type='text/css'), T.title[T.directive('title')]], T.body[T.div(id='main')[T.directive('main')]]]) def render_stylesheet(self, context, data): return open('main.css').read() def render_title(self, context, data): if data.title: tit = data.title else: tit = data.name return '%s - %s' % (tit, CONF.get('project', 'name')) def render_bottom(self, context, data): yield 'Copyright 2006 %s' % CONF.get('copyright', 'holder') def render_main(self, context, data): for part in 'top', 'middle', 'bottom': yield T.div(id=part)[T.directive(part)] def render_middle(self, context, data): yield T.div(render=T.directive('trail'), data=data.get_ancestry()) yield T.h1(class_='main-heading')[data.title] yield T.div(render=T.directive('items'), data=data.get_subdirs()) yield T.div(render=T.directive('rst')) yield T.div(render=T.directive('items'), data=data.get_items()) def render_items(self, context, items): return self.render_menu(context, items) def render_main_menu(self, context, items): return self.render_menu(context, items, class_='main-menu') def render_subdirs(self, context, items): return self.render_menu(context, items) def render_rst(self, context, data): if data.body: return loaders.htmlstr(data.body) else: return '' def render_top(self, context, data): yield T.div(id='banner', )[CONF.get('project', 'name')] yield T.div(id='logo', )['"%s"' % CONF.get('project', 'motto')] def _menuitems(): yield data.home for i in data.home.get_items(): yield i yield T.div(render=T.directive('main_menu'), data=_menuitems()) def render_trail(self, context, items): trail = [] for item in items: trail.append( T.span(class_='trail')[T.a(href=item.get_url())[item.title]]) trail.append('>') if len(trail) <= 2: return '' else: trail.pop() return T.div(class_='trail')['You are:', trail] def render_menu(self, context, items, class_='menu'): def _menu(items, class_): for item in items: yield T.li(class_=class_)[T.a(href=item.get_url(), class_=class_)[item.title]] return T.ul(class_=class_)[_menu(items, class_)]
_tp_layout_fn = _locateFile("tabbedPane-layout.css") _tp_JS = _locateFile("tabbedPane.js") tabbedPaneStyle = t.style(type_='text/css')[open(_tp_style_fn).read()] tabbedPaneLayout = t.style(type_='text/css')[open(_tp_layout_fn).read()] tabbedPaneJS = t.inlineJS(open(_tp_JS).read()) tabbedPaneHeadInline = t.invisible[tabbedPaneStyle, tabbedPaneLayout, tabbedPaneJS, ] tabbedPaneStyleFile = static.File(_tp_style_fn, 'text/css') tabbedPaneLayoutFile = static.File(_tp_layout_fn, 'text/css') tabbedPaneJSFile = static.File(_tp_JS, 'text/javascript') tabbedPaneHeadFiles = t.invisible[ t.link(rel='stylesheet', type='text/css', href='/tabbedPane-style.css'), t.link(rel='stylesheet', type='text/css', href='/tabbedPane-layout.css'), t.script(type='text/javascript', src='/tabbedPane.js'), ] class TabbedPane(object): def tabbedPane(self, ctx, data): tab_names = [element[0] for element in data] return t.invisible[t.div(class_='tabbedPane')[t.ul(class_='tabs')[[ t.li(id_="tab-" + name.replace(' ', '_'))[name] for name in tab_names ]], [ t.div(id_="page-" + name.replace(' ', '_'))[fragment] for name, fragment in data ]],
def styleSheetLink(href): return tags.link(rel='stylesheet', type='text/css', href=href)
def render_Head (self, ctx, data): css = T.link (rel="stylesheet", type="text/css", href='/css/qsos-listing.css') favicon = T.link (rel="icon", type="image/png", href='/css/favicon.ico') return T.head [ T.title [ self.renderTitle ], css , favicon]
def render_invertstyles(self, ctx, data): i = isInverted(ctx) if i is True: return T.link(rel="stylesheet", type="text/css", href="/skin/css/styles-inverted.css") else: return ""
def render_css(self, ctx, data): return [T.link(type='text/css', rel='stylesheet', href= self.mycss)]
tabbedPaneJS = t.inlineJS( open(_tp_JS).read() ) tabbedPaneHeadInline = t.invisible[ tabbedPaneStyle, tabbedPaneLayout, tabbedPaneJS, ] tabbedPaneStyleFile = static.File(_tp_style_fn, 'text/css') tabbedPaneLayoutFile = static.File(_tp_layout_fn, 'text/css') tabbedPaneJSFile = static.File(_tp_JS, 'text/javascript') tabbedPaneHeadFiles = t.invisible[ t.link(rel='stylesheet', type='text/css', href='/tabbedPane-style.css'), t.link(rel='stylesheet', type='text/css', href='/tabbedPane-layout.css'), t.script(type='text/javascript', src='/tabbedPane.js'), ] class TabbedPane(object): def tabbedPane(self, ctx, data): tab_names = [element[0] for element in data] return t.invisible[ t.div(class_='tabbedPane')[ t.ul(class_='tabs')[ [t.li(id_="tab-"+name.replace(' ', '_'))[name] for name in tab_names] ], [t.div(id_="page-"+name.replace(' ', '_'))[fragment] for name, fragment in data] ],
def render_invertstyles(self,ctx,data): i = isInverted(ctx) if i is True: return T.link(rel='stylesheet',type='text/css',href='/skin/css/styles-inverted.css') else: return ''
def render_album_style(self, ctx, segments): return ctx.tag[T.link(type="text/css", href="/%s/albums/%s/album.css" % (self.username, self.album_id), rel="stylesheet")]
def links(l): for filename in l: yield tags.link(rel="stylesheet", type="text/css", href=filename)