Example #1
0
 def renderInlineException(self, context, reason):
     from nevow import failure
     formatted = failure.formatFailure(reason)
     desc = str(reason)
     return flat.serialize([
         stan.xml("""<div style="border: 1px dashed red; color: red; clear: both" onclick="this.childNodes[1].style.display = this.childNodes[1].style.display == 'none' ? 'block': 'none'">"""),
         desc,
         stan.xml('<div style="display: none">'),
         formatted,
         stan.xml('</div></div>')
     ], context)
Example #2
0
 def renderInlineException(self, context, reason):
     from nevow import failure
     formatted = failure.formatFailure(reason)
     desc = str(reason)
     return flat.serialize([
         stan.xml(
             """<div style="border: 1px dashed red; color: red; clear: both" onclick="this.childNodes[1].style.display = this.childNodes[1].style.display == 'none' ? 'block': 'none'">"""
         ), desc,
         stan.xml('<div style="display: none">'), formatted,
         stan.xml('</div></div>')
     ], context)
Example #3
0
 def render(self, ctx, data):
     """
     Returns an xul string for viewing this pane.
     The xul is stored in a tuple inside the methods of this class
     then new lines are added when we actually return it
     """
     log.debug("render")
     xul = (u'<!-- start outline pane -->',
             '    <tree id="outlineTree"',
             '          hidecolumnpicker="true" ',
             '          onselect="outlineClick()" ',
             '          context="outlineMenu" flex="1"',
             '          ondraggesture="treeDragGesture(event)"',
             '          ondragenter="treeDragEnter(event)"',
             '          ondragover="treeDragOver(event)"',
             '          ondragexit="treeDragExit(event)"',
             '          ondragdrop="treeDragDrop(event)"',
             '          ondblclick="eval(document.getElementById('
             """'btnRename').getAttribute('oncommand'))">""",
             '        <treecols>',
             '            <treecol id="sectionCol" primary="true" '+
             'label="%s" flex="1"/>' % _(u"Outline"),
             '        </treecols>',
             '        <treechildren>',)
     xul += self.__renderNode(self.package.root, 12)
     xul += ('       </treechildren>',
             '    </tree>',
             '<!-- end outline pane -->')
     return stan.xml('\n'.join(xul))
Example #4
0
	def pageContent(self,ctx,data):
		content = ctx.locate(IWikiContent)
		return T.div(style="margin:4px;")[
			content and 
				stan.xml(format(content)) or
				"This page does not yet exist."
			]
Example #5
0
    def render_results(self, ctx, data):
        if data is None:
            return ctx.tag

        success, query, db, total = data

        if not success:
            ctx.tag[T.h1[u'Failed to process query %s' % query]]
            ctx.tag[T.pre[str(db)]]

            return ctx.tag
        
        ctx.tag[T.h1[u'%d/%d results for query "%s"' % (
            len(db.entries), total, query)]]

        # Cite the records
        formatter = citation(db)

        cited = T.ul[[T.li[stan.xml(generate(formatter(record)))]
                      for record in db.entries.itervalues()]]

        ctx.tag[cited]

        # Display the raw BibTeX too
        res = StringIO()
        w.write(res, db.entries, db)

        res = res.getvalue().decode('utf-8')
        ctx.tag[T.pre[res]]
    
        return ctx.tag
Example #6
0
 def render(self, ctx, data):
     """
     Returns an xul string for viewing this pane.
     The xul is stored in a tuple inside the methods of this class
     then new lines are added when we actually return it
     """
     # Now do the rendering
     log.debug("render")
     xul = (u'<!-- start outline pane -->',
             '    <tree id="outlineTree"',
             '          hidecolumnpicker="true" ',
             '          onselect="outlineClick()" ',
             '          context="outlineMenu" flex="1"',
             '          ondraggesture="treeDragGesture(event)"',
             '          ondragenter="treeDragEnter(event)"',
             '          ondragover="treeDragOver(event)"',
             '          ondragexit="treeDragExit(event)"',
             '          ondragdrop="treeDragDrop(event)"',
             '          ondblclick="eval(document.getElementById('
             """'btnRename').getAttribute('oncommand'))">""",
             '        <treecols>',
             '            <treecol id="sectionCol" primary="true" '+
             'label="%s" flex="1"/>' % _(u"Outline"),
             '        </treecols>',
             '        <treechildren>',)
     xul += self.__renderNode(self.package.root, 12)
     xul += ('       </treechildren>',
             '    </tree>',
             '<!-- end outline pane -->')
     return stan.xml('\n'.join(xul))
Example #7
0
    def render(self, ctx, data):
        """
        Returns an html string for viewing this pane
        """
        # Create a scecial server side func that the
        # Idevice editor js can call
        #addHandler = handler(self.handleAddIdevice,
        #                     identifier='outlinePane.handleAddIdevice')
        # The below call stores the handler so we can call it
        # as a server
        #addHandler(ctx, data)

        # Now do the rendering
        log.debug("Render")

        html = u"<!-- IDevice Pane Start -->\n"
        html += u"<listbox id=\"ideviceList\" flex=\"1\" "
        html += u"style=\"background-color: #FFF;\">\n"

        prototypes = self.prototypes.values()

        def sortfunc(pt1, pt2):
            """Used to sort prototypes by title"""
            return cmp(pt1.title, pt2.title)

        prototypes.sort(sortfunc)
        for prototype in prototypes:
            if prototype._title.lower() not in G.application.config.hiddeniDevices \
            and prototype._title.lower() \
            not in G.application.config.deprecatediDevices:
                html += self.__renderPrototype(prototype)

        html += u"</listbox>\n"
        html += u"<!-- IDevice Pane End -->\n"
        return stan.xml(html.encode('utf8'))
Example #8
0
    def render(self, ctx, data):
        """
        Returns an html string for viewing this pane
        """
        # Create a scecial server side func that the 
        # Idevice editor js can call
        #addHandler = handler(self.handleAddIdevice,
        #                     identifier='outlinePane.handleAddIdevice')
        # The below call stores the handler so we can call it
        # as a server 
        #addHandler(ctx, data) 

        # Now do the rendering
        log.debug("Render")

        html  = u"<!-- IDevice Pane Start -->\n"
        html += u"<listbox id=\"ideviceList\" flex=\"1\" "
        html += u"style=\"background-color: #FFF;\">\n"

        prototypes = self.prototypes.values()
        def sortfunc(pt1, pt2):
            """Used to sort prototypes by title"""
            return cmp(pt1.title, pt2.title)
        prototypes.sort(sortfunc)
        for prototype in prototypes:
            if prototype._title.lower() not in G.application.config.hiddeniDevices \
            and prototype._title.lower() \
            not in G.application.config.deprecatediDevices:
                html += self.__renderPrototype(prototype)

        html += u"</listbox>\n"
        html += u"<!-- IDevice Pane End -->\n"
        return stan.xml(html.encode('utf8'))
Example #9
0
	def beforeRender(self, ctx):
		formDefs = iformless.IFormDefaults(ctx).getAllDefaults('updateWiki')
		content = IWikiContent(ctx)
		formDefs['new'] = "0"
		if content:
			formDefs['text'] = stan.xml(content)
		else:
			formDefs['new'] = "1"
Example #10
0
 def beforeRender(self, ctx):
     formDefs = iformless.IFormDefaults(ctx).getAllDefaults('updateWiki')
     content = IWikiContent(ctx)
     formDefs['new'] = "0"
     if content:
         formDefs['text'] = stan.xml(content)
     else:
         formDefs['new'] = "1"
Example #11
0
 def startDTD(self, name, publicId, systemId):
     if self.ignoreDocType:
         return
     # Check for broken startDTD
     if bad_startdtd_args:
         systemId, publicId = publicId, systemId
     doctype = '<!DOCTYPE %s\n  PUBLIC "%s"\n  "%s">\n' % (name, publicId, systemId)
     self.current.append(xml(doctype))
Example #12
0
def urlToChild(request, *ar, **kw):
    u = url.URL.fromRequest(request)
    for segment in ar:
        u = u.child(stan.xml(segment))
    if request.method == 'POST':
        u = u.clear()
    for k,v in kw.items():
        u = u.replace(k, v)
    return u
Example #13
0
def urlToChild(ctx, *ar, **kw):
    u = url.URL.fromContext(ctx)
    for segment in ar:
        u = u.child(stan.xml(segment))
    if inevow.IRequest(ctx).method == 'POST':
        u = u.clear()
    for k, v in kw.items():
        u = u.replace(k, v)

    return u
Example #14
0
def urlToChild(ctx, *ar, **kw):
    u = url.URL.fromContext(ctx)
    for segment in ar:
        u = u.child(stan.xml(segment))
    if inevow.IRequest(ctx).method == 'POST':
        u = u.clear()
    for k,v in kw.items():
        u = u.replace(k, v)

    return u
Example #15
0
def urlToChild(request, *ar, **kw):
    u = url.URL.fromRequest(request)
    for segment in ar:
        u = u.child(stan.xml(segment))
    if request.method == 'POST':
        u = u.clear()
    for k, v in kw.items():
        u = u.replace(k, v)

    return u
Example #16
0
 def render_recentProjects(self, ctx, data):
     """
     Fills in the list of recent projects menu
     """
     result = ['<menupopup id="recent-projects-popup">\n']
     for num, path in enumerate(self.config.recentProjects):
         result.append('  <menuitem label="%(num)s. %(path)s"'
                       ' accesskey="%(num)s"'
                       ' oncommand="fileOpenRecent(\'%(num)s\')"/>' %
                       {'num': num + 1, 'path': escape(path)})
     result.append('</menupopup>')
     return stan.xml('\n'.join(result))
Example #17
0
 def render(self, ctx, data):
     """
     Returns an XUL string for viewing this pane
     """
     log.debug("render")
     xul  = u"<!-- Styles Pane Start -->\n"
     xul += u"<menupopup>\n"
     for style in self.config.styles:
         xul += u"  <menuitem label=\""+style+"\" "
         xul += u"onclick=\"submitLink('ChangeStyle', '"+style+"', 1);\"/>\n"
     xul += u"</menupopup>\n"
     xul += u"<!-- Styles Pane End -->\n"
     return stan.xml(xul)
Example #18
0
 def render_debugInfo(self, ctx, data):
     """Renders debug info to the top
     of the screen if logging is set to debug level
     """
     if log.getEffectiveLevel() == logging.DEBUG:
         request = inevow.IRequest(ctx)
         return stan.xml(('<hbox id="header">\n'
                          '    <label>%s</label>\n'
                          '    <label>%s</label>\n'
                          '</hbox>\n' %
                          (request.prepath, self.package.name)))
     else:
         return ''
Example #19
0
def urlToChild(ctx, *ar, **kw):
    req = inevow.IRequest(ctx)
    host = req.getHeader('host')
    if host is None:
        raise ValueError("Host field is undefined in HTTP request");
    u = url.URL.fromContext(ctx)
    for segment in ar:
        u = u.child(stan.xml(segment))
    if req.method == 'POST':
        u = u.clear()
    for k,v in list(kw.items()):
        u = u.replace(k, v)

    return u
Example #20
0
 def render(self, ctx, data):
     """
     Returns an XUL string for viewing this pane
     """
     log.debug("render")
     xul  = u"<!-- Styles Pane Start -->\n"
     xul += u"<menupopup>\n"
     printableStyles = [(x.capitalize(), x) for x in self.config.styles]
     for printableStyle, style in printableStyles:
         xul += u"  <menuitem label=\""+printableStyle+"\" "
         xul += u"oncommand=\"submitLink('ChangeStyle', '"+style+"', 1);\"/>\n"
     xul += u"</menupopup>\n"
     xul += u"<!-- Styles Pane End -->\n"
     return stan.xml(xul)
Example #21
0
 def render_debugInfo(self, ctx, data):
     """Renders debug info to the to
     of the screen if logging is set to debug level
     """
     if log.getEffectiveLevel() == logging.DEBUG:
         # TODO: Needs to be updated by xmlhttp or xmlrpc
         request = inevow.IRequest(ctx)
         return stan.xml(('<hbox id="header">\n'
                          '    <label>%s</label>\n'
                          '    <label>%s</label>\n'
                          '</hbox>\n' %
                          ([escape(x) for x in request.prepath],
                           escape(self.package.name))))
     else:
         return ''
Example #22
0
 def render_recentProjects(self, ctx, data):
     """
     Fills in the list of recent projects menu
     """
     result = ['<menupopup id="recent-projects-popup">\n']
     for num, path in enumerate(self.config.recentProjects):
         result.append(
             '  <menuitem label="%(num)s. %(path)s"'
             ' accesskey="%(num)s"'
             " oncommand=\"fileOpenRecent('%(num)s')\"/>" % {"num": num + 1, "path": escape(path)}
         )
     result.append("  <menuseparator/>")
     result.append('  <menuitem label="%s"' ' oncommand="fileRecentClear()"/>' % _("Clear Recent Projects List"))
     result.append("</menupopup>")
     return stan.xml("\n".join(result))
 def render_debugInfo(self, ctx, data):
     """Renders debug info to the to
     of the screen if logging is set to debug level
     """
     if log.getEffectiveLevel() == logging.DEBUG:
         # TODO: Needs to be updated by xmlhttp or xmlrpc
         request = inevow.IRequest(ctx)
         return stan.xml(
             ('<hbox id="header">\n'
              '    <label>%s</label>\n'
              '    <label>%s</label>\n'
              '</hbox>\n' %
              ([escape(x)
                for x in request.prepath], escape(self.package.name))))
     else:
         return ''
Example #24
0
 def test_basicPythonTypes(self):
     tag = proto(data=5)[
         "A string; ",
         "A unicode string; ",
         5, " (An integer) ",
         1.0, " (A float) ",
         1, " (A long) ",
         True, " (A bool) ",
         ["A ", "List; "],
         stan.xml("<xml /> Some xml; "),
         lambda data: "A function"
     ]
     if self.hasBools:
         self.assertEqual(self.render(tag), "<hello>A string; A unicode string; 5 (An integer) 1.0 (A float) 1 (A long) True (A bool) A List; <xml /> Some xml; A function</hello>")
     else:
         self.assertEqual(self.render(tag), "<hello>A string; A unicode string; 5 (An integer) 1.0 (A float) 1 (A long) 1 (A bool) A List; <xml /> Some xml; A function</hello>")
Example #25
0
 def test_basicPythonTypes(self):
     tag = proto(data=5)[
         "A string; ",
         u"A unicode string; ",
         5, " (An integer) ",
         1.0, " (A float) ",
         1L, " (A long) ",
         True, " (A bool) ",
         ["A ", "List; "],
         stan.xml("<xml /> Some xml; "),
         lambda data: "A function"
     ]
     if self.hasBools:
         self.assertEquals(self.render(tag), "<hello>A string; A unicode string; 5 (An integer) 1.0 (A float) 1 (A long) True (A bool) A List; <xml /> Some xml; A function</hello>")
     else:
         self.assertEquals(self.render(tag), "<hello>A string; A unicode string; 5 (An integer) 1.0 (A float) 1 (A long) 1 (A bool) A List; <xml /> Some xml; A function</hello>")
 def render_recentProjects(self, ctx, data):
     """
     Fills in the list of recent projects menu
     """
     result = ['<menupopup id="recent-projects-popup">\n']
     for num, path in enumerate(self.config.recentProjects):
         result.append('  <menuitem label="%(num)s. %(path)s"'
                       ' accesskey="%(num)s"'
                       ' oncommand="fileOpenRecent(\'%(num)s\')"/>' % {
                           'num': num + 1,
                           'path': escape(path)
                       })
     result.append('  <menuseparator/>')
     result.append('  <menuitem label="%s"'
                   ' oncommand="fileRecentClear()"/>' %
                   _('Clear Recent Projects List'))
     result.append('</menupopup>')
     return stan.xml('\n'.join(result))
Example #27
0
 def render(self, ctx, data):
     """
     Returns an html string for viewing this pane
     """
     log.debug("Render")
     html  = u"<!-- IDevice Pane Start -->\n"
     html += u"<listbox id=\"ideviceList\" flex=\"1\" "
     html += u"style=\"background-color: #FFF;\">\n"
     prototypes = self.prototypes.values()
     def sortfunc(pt1, pt2):
         """Used to sort prototypes by title"""
         return cmp(pt1.title, pt2.title)
     prototypes.sort(sortfunc)
     for prototype in prototypes:
         html += self.__renderPrototype(prototype)
     html += u"</listbox>\n"
     html += u"<!-- IDevice Pane End -->\n"
     return stan.xml(html.encode('utf8'))
Example #28
0
    def render(self, ctx, data):
        """
        Returns an XUL string for viewing this pane
        """
        log.debug("render")
        # Render the start tags
        xul  = u"<!-- Styles Pane Start -->\n"
        xul += u"<menupopup>\n"

        # Render each style individually
        printableStyles = [(x.capitalize(), x) for x in self.config.styles]
        for printableStyle, style in sorted(printableStyles, key=lambda x: x[0]):
            xul += u"  <menuitem label=\""+printableStyle+"\" "
            xul += u"oncommand=\"submitLink('ChangeStyle', '"+style+"', 1);\"/>\n"

        # Render the end tags
        xul += u"</menupopup>\n"
        xul += u"<!-- Styles Pane End -->\n"
        return stan.xml(xul)
    def render(self, ctx, data):
        """
        Returns an XUL string for viewing this pane
        """
        log.debug("render")
        # Render the start tags
        xul  = u"<!-- Styles Pane Start -->\n"
        xul += u"<menupopup>\n"

        # Render each style individually
        printableStyles = [(x.capitalize(), x) for x in self.config.styles]
        for printableStyle, style in printableStyles:
            xul += u"  <menuitem label=\""+printableStyle+"\" "
            xul += u"oncommand=\"submitLink('ChangeStyle', '"+style+"', 1);\"/>\n"

        # Render the end tags
        xul += u"</menupopup>\n"
        xul += u"<!-- Styles Pane End -->\n"
        return stan.xml(xul)
Example #30
0
    def render(self, ctx, data):
        """
        Returns an XUL string for viewing this pane
        """
        log.debug("render")
        # Render the start tags
        xul  = u"<!-- Styles Pane Start -->\n"
        xul += u"<menupopup>\n"

        # Render each style individually
        for style in self.config.styles:
            name = style[style.find("/") + 1:]
            xul += u"  <menuitem label=\"" + name.capitalize() + "\" "
            xul += u"oncommand=\"submitLink('ChangeStyle', '" + style +\
                    "', 1);\"/>\n"

        # Render the end tags
        xul += u"<menuseparator/>"
        xul += u"<menuitem label=\"Add Style\" oncommand=\"addStyle()\"/>"
        xul += u"</menupopup>\n"
        xul += u"<!-- Styles Pane End -->\n"
        return stan.xml(xul)
Example #31
0
def describe_build(branch, build):
    """Return a nevow HTML description of a build"""
    change_report_dir = CHANGE_REPORT_DIRECTORY % (branch, build)
    if os.path.isdir(change_report_dir):
        content = os.listdir(change_report_dir)
        for stuff in content:
            if 'diff' in stuff or stuff.endswith('.error'):
                continue
            filename = os.path.join(change_report_dir, stuff)
            try:
                content = file(filename, 'r').read()
            except IOError:
                continue
            bod_start = content.find('<body>')
            bod_end = content.find('</body>')
            if bod_start  != -1 and bod_end != -1:
                return [xml(content[bod_start+6:bod_end])]
            else:
                return [space_span()['could not find body in ', filename]]
        return [space_span()[em['could not find build description in ', 
                             change_report_dir]]]
    else: 
        return [space_span()['could not find ', change_report_dir]]
Example #32
0
 def startCDATA(self):
     self.inCDATA = True
     self.current.append(xml('<![CDATA['))
Example #33
0
def inlineJS(s):
    return script(type="text/javascript")[xml('\n//<![CDATA[\n%s\n//]]>\n' % s)]
Example #34
0
def MicroDomCommentSerializer(original, context):
    return xml("<!--%s-->" % original.data)
Example #35
0
def MicroDomEntityReferenceSerializer(original, context):
    return xml(original.nodeValue)
Example #36
0
def MicroDomCommentSerializer(original, context):
    return xml("<!--%s-->" % original.data)
Example #37
0
 def processingInstruction(self, target, data):
     self.current.append(xml("<?%s %s?>\n" % (target, data)))
Example #38
0
 def skippedEntity(self, name):
     self.current.append(xml("&%s;"%name))
Example #39
0
 def comment(self, content):
     if self.ignoreComment:
         return
     self.current.append( (xml('<!--'),xml(content),xml('-->')) )
Example #40
0
    def render(self, ctx, data):
        """
        Returns an html string for viewing this pane
        """
        # Create a scecial server side func that the
        # Idevice editor js can call
        #addHandler = handler(self.handleAddIdevice,
        #                     identifier='outlinePane.handleAddIdevice')
        # The below call stores the handler so we can call it
        # as a server
        #addHandler(ctx, data)

        # Now do the rendering
        log.debug("Render")

        ## A dict with idevices groups
        groups = {
            Idevice.Didactics: u"",
            Idevice.Content: u"",
            Idevice.Media: u"",
            Idevice.Test: u"",
            Idevice.Communication: u""
        }
        # idevices not in any group
        unknown = u""

        prototypes = self.prototypes.values()

        def sortfunc(pt1, pt2):
            """Used to sort prototypes by title"""
            return cmp(pt1.title, pt2.title)

        prototypes.sort(sortfunc)
        for prototype in prototypes:
            if prototype._title.lower() not in\
                G.application.config.hiddeniDevices \
                    and prototype._title.lower() \
                        not in G.application.config.deprecatediDevices:
                if prototype.group in groups:
                    groups[prototype.group] \
                        += self.__renderPrototype(prototype)
                else:
                    unknown += self.__renderPrototype(prototype)
        # used to perserve the group order
        groupkeys = groups.keys()
        if unknown != u"":
            groupkeys += [Idevice.Unknown]
            groups[Idevice.Unknown] = unknown
        html = u"<!-- IDevice Pane Start -->\n"
        html += u'<tree id="iDeviceTree" hidecolumnpicker="true"'
        html += u' context="iDevice Menu" flex="1"'
        html += u' ondblclick="AddIdeviceBySelection()">\n'
        html += u'<treecols id="-1">\n'
        html += u'  <treecol primary="true" style="font-weight: bold" ' + \
                 'label="%s" flex="1" />\n' % _("IDevices")
        html += u'</treecols>\n'
        html += u'<treechildren>\n'
        for group in groupkeys:
            html += u'  <treeitem id="-1" container="true" open="true">'
            html += u'    <treerow>\n'
            html += u'    <treecell label="%s"/>\n' % _(group)
            html += u'     </treerow>\n'
            html += u'     <treechildren>\n'
            html += groups[group]
            html += u"      </treechildren>\n"
            html += u"    </treeitem>\n"
        html += u"  </treechildren>"
        html += u"</tree>\n"
        html += u"<!-- IDevice Pane End -->\n"
        return stan.xml(html.encode('utf8'))
Example #41
0
 def pageContent(self, ctx, data):
     content = ctx.locate(IWikiContent)
     return T.div(style="margin:4px;")[content and stan.xml(format(content))
                                       or "This page does not yet exist."]
Example #42
0
 def testXmlMissing(self):
     self.assertRaises(stan.NodeNotFound,
                       IQ(stan.xml('<html>hello</html>')).patternGenerator,
                       'foo')
Example #43
0
 def characters(self, ch):
     # CDATA characters should be passed through as is.
     if self.inCDATA:
         ch = xml(ch)
     self.current.append(ch)
Example #44
0
 def testXmlMissing(self):
     self.assertRaises(stan.NodeNotFound, IQ(stan.xml('<html>hello</html>')).patternGenerator, 'foo')
Example #45
0
 def endCDATA(self):
     self.inCDATA = False
     self.current.append(xml(']]>'))
Example #46
0
def MicroDomEntityReferenceSerializer(original, context):
    return xml(original.nodeValue)