Exemplo n.º 1
0
    def expand_macro(self, formatter, name, content):
        interwikis = []
        for k in sorted(self.keys()):
            prefix, url, title = self[k]
            interwikis.append({
                'prefix':
                prefix,
                'url':
                url,
                'title':
                title,
                'rc_url':
                self._expand_or_append(url, ['RecentChanges']),
                'description':
                url if title == prefix else title
            })

        return tag.table(
            tag.tr(tag.th(tag.em(_("Prefix"))), tag.th(tag.em(_("Site")))), [
                tag.tr(
                    tag.td(tag.a(w['prefix'], href=w['rc_url'])),
                    tag.td(tag.a(w['description'], href=w['url'])))
                for w in interwikis
            ],
            class_="wiki interwiki")
Exemplo n.º 2
0
    def expand_macro(self, formatter, name, content):
        intertracs = {}
        for key, value in self.config.options("intertrac"):
            idx = key.rfind(".")  # rsplit only in 2.4
            if idx > 0:  # 0 itself doesn't help much: .xxx = ...
                prefix, attribute = key[:idx], key[idx + 1 :]
                intertrac = intertracs.setdefault(prefix, {})
                intertrac[attribute] = value
            else:
                intertracs[key] = value  # alias
        if "trac" not in intertracs:
            intertracs["trac"] = {"title": _("The Trac Project"), "url": "http://trac.edgewall.org"}

        def generate_prefix(prefix):
            intertrac = intertracs[prefix]
            if isinstance(intertrac, basestring):
                yield tag.tr(tag.td(tag.b(prefix)), tag.td("Alias for ", tag.b(intertrac)))
            else:
                url = intertrac.get("url", "")
                if url:
                    title = intertrac.get("title", url)
                    yield tag.tr(tag.td(tag.a(tag.b(prefix), href=url + "/timeline")), tag.td(tag.a(title, href=url)))

        return tag.table(class_="wiki intertrac")(
            tag.tr(tag.th(tag.em("Prefix")), tag.th(tag.em("Trac Site"))),
            [generate_prefix(p) for p in sorted(intertracs.keys())],
        )
Exemplo n.º 3
0
    def browser(self, req, stream, data):

        if not data.has_key('path'):
            # this probably means that there is an upstream error
            return stream

        # mark up the title (disabled)
        #stream |= Transformer('//title/text()').substitute('/', data['svn_base_url'] + '/')

        # provide a link to the svn repository
        #stream |= Transformer("//div[@id='content']/h1").after(tag.a(self.link_text, href=self.url(data['path']), title=self.link_title))

        # if a directory, provide links to the children files
        if data['dir']:
            offset = 2 # table header, index of 0 (python) versus 1 (xpath)
            if data['path'] != '/':                
                offset += 1 # parent directory row

            xpath_prefix = "//table[@id='dirlist']"
            # add the table header
            xpath = xpath_prefix + "//th[contains(@class, '%s')]" % self.element_class
            stream |= Transformer(xpath).after(tag.th('Url', **{'class': "url"}))

            if 'up' in data['chrome']['links']:
                stream |= Transformer(xpath_prefix + "//td[@colspan='5']").attr('colspan', None)

            # add table cells
            stream = self.dir_entries(req, stream, data, xpath_prefix)

        # Repository Index
	xpath_prefix = "//table[@id='repoindex']"
        # add the table header
        xpath = xpath_prefix + "//th[contains(@class, '%s')]" % self.element_class
        stream |= Transformer(xpath).after(tag.th('Url', **{'class': "url"}))
	
	if 'up' in data['chrome']['links']:
            stream |= Transformer(xpath_prefix + "//td[@colspan='5']").attr('colspan', None)

        # add table cells
        stream = self.dir_entries(req, stream, data, xpath_prefix)


        # MAIN HEADER
	xpath_prefix = "//h1"
        # add the table header
        xpath = xpath_prefix + "//a[contains(@class, '%s')]" % self.header_element_class
        #mainlink = data['path']
        # Cut first from last path_links element
	firstlink = data['path_links'][0]['href'].rsplit('?', 1)[0]
        mainlink = data['path_links'][-1]['href'].split(firstlink)[-1]
        mainlink = self.svn_base_url + mainlink.rsplit('?', 1)[0]
        stream |= Transformer(xpath).after(tag.a(self.link_text, href=mainlink, title=SVNMULTIURLs.link_title))

        #for dat in data:
        #    self.log.debug('data: %s : %s',dat,data[dat])
	#self.log.debug('data: 0 : %s',data['path_links'][0]['href'])
	#self.log.debug('data: 1 : %s',data['path_links'][-1]['href'])
	

        return stream
Exemplo n.º 4
0
    def expand_macro(self, formatter, name, content):
        intertracs = {}
        for key, value in self.intertrac_section.options():
            idx = key.rfind('.')
            if idx > 0:  # 0 itself doesn't help much: .xxx = ...
                prefix, attribute = key[:idx], key[idx + 1:]
                intertrac = intertracs.setdefault(prefix, {})
                intertrac[attribute] = value
            else:
                intertracs[key] = value  # alias
        if 'trac' not in intertracs:
            intertracs['trac'] = {
                'title': _('The Trac Project'),
                'url': 'http://trac.edgewall.org'
            }

        def generate_prefix(prefix):
            intertrac = intertracs[prefix]
            if isinstance(intertrac, basestring):
                yield tag.tr(tag.td(tag.b(prefix)),
                             tag.td('Alias for ', tag.b(intertrac)))
            else:
                url = intertrac.get('url', '')
                if url:
                    title = intertrac.get('title', url)
                    yield tag.tr(
                        tag.td(tag.a(tag.b(prefix), href=url + '/timeline')),
                        tag.td(tag.a(title, href=url)))

        return tag.table(class_="wiki intertrac")(
            tag.tr(tag.th(tag.em('Prefix')), tag.th(tag.em('Trac Site'))),
            [generate_prefix(p) for p in sorted(intertracs.keys())])
Exemplo n.º 5
0
    def expand_macro(self, formatter, name, content):
        intertracs = {}
        for key, value in self.intertrac_section.options():
            idx = key.rfind('.')
            if idx > 0: # 0 itself doesn't help much: .xxx = ...
                prefix, attribute = key[:idx], key[idx+1:]
                intertrac = intertracs.setdefault(prefix, {})
                intertrac[attribute] = value
            else:
                intertracs[key] = value # alias
        if 'trac' not in intertracs:
            intertracs['trac'] = {'title': _('The Trac Project'),
                                  'url': 'http://trac.edgewall.org'}

        def generate_prefix(prefix):
            intertrac = intertracs[prefix]
            if isinstance(intertrac, basestring):
                yield tag.tr(tag.td(tag.b(prefix)),
                             tag.td('Alias for ', tag.b(intertrac)))
            else:
                url = intertrac.get('url', '')
                if url:
                    title = intertrac.get('title', url)
                    yield tag.tr(tag.td(tag.a(tag.b(prefix),
                                              href=url + '/timeline')),
                                 tag.td(tag.a(title, href=url)))

        return tag.table(class_="wiki intertrac")(
            tag.tr(tag.th(tag.em('Prefix')), tag.th(tag.em('Trac Site'))),
            [generate_prefix(p) for p in sorted(intertracs.keys())])
Exemplo n.º 6
0
        def fn(stream):
            for kind, data, pos in stream:
                if kind is END and data.localname == 'body':
                    first_time = req._tracdeveloper_hdlr.buf \
                                 and req._tracdeveloper_hdlr.buf[0].created

                    elm = tag.div(tag.table(
                        tag.thead(
                            tag.tr(
                                tag.th('Time'),
                                tag.th('Module'),
                                tag.th('Level'),
                                tag.th('Message'),
                            )),
                        class_='listing')([
                            tag.tr(
                                tag.td(int((r.created - first_time) * 1000)),
                                tag.td(r.module),
                                tag.td(r.levelname),
                                tag.td(r.getMessage()),
                                class_=(i % 2 and 'even' or 'odd'),
                            )
                            for i, r in enumerate(req._tracdeveloper_hdlr.buf)
                        ]),
                                  id='tracdeveloper-log')
                    for evt in elm.generate():
                        yield evt
                    del elm
                    req._tracdeveloper_hdlr.formatter = None
                    del req._tracdeveloper_hdlr.buf[:]
                    self.log.removeHandler(req._tracdeveloper_hdlr)
                    del req._tracdeveloper_hdlr
                yield kind, data, pos
Exemplo n.º 7
0
    def annotate_row(self, context, row, lineno, line, data):
        "add column with Lint data to annotation"
        if data == None:
            row.append(tag.th())
            return
        row_data = data.get(lineno, None)
        if row_data == None:
            row.append(tag.th(class_='covered'))
            return

        self.log.debug('problems in line no %d:' % lineno)
        categories = ''
        problems = []
        for item in row_data:
            categories += item['category'] and item['category'][0] or '-'
            self.log.debug('  %s' % item)
            problems.append('%(category)s: %(tag)s in report %(rid)d' % item)
        problems = '\n'.join(problems)
        self.itemid += 1
        row.append(
            tag.th(tag.a(categories, href='#Lint%d' % self.itemid),
                   class_='uncovered',
                   title=problems,
                   id_='Lint%d' % self.itemid))
        self.log.debug('%s' % row)
Exemplo n.º 8
0
def remove_header(stream, field):
    """ Removes the display from the ticket properties """
    stream = stream | \
        Transformer('//th[@id="h_%s"]' % field).replace(tag.th(id="h_%s" % field))
    stream = stream | \
        Transformer('//td[@headers="h_%s"]' % field).replace(tag.th(id="h_%s" % field))
    return stream
Exemplo n.º 9
0
    def expand_macro(self, formatter, name, content):
        from trac.mimeview.api import Mimeview
        mime_map = Mimeview(self.env).mime_map
        mime_type_filter = ''
        args, kw = parse_args(content)
        if args:
            mime_type_filter = args.pop(0).strip().rstrip('*')

        mime_types = {}
        for key, mime_type in mime_map.iteritems():
            if (not mime_type_filter or
                mime_type.startswith(mime_type_filter)) and key != mime_type:
                mime_types.setdefault(mime_type, []).append(key)

        return tag.div(class_='mimetypes')(
            tag.table(class_='wiki')(
                tag.thead(tag.tr(
                    tag.th(_("MIME Types")),  # always use plural
                    tag.th(tag.a("WikiProcessors",
                                 href=formatter.context.href.wiki(
                                     'WikiProcessors'))))),
                tag.tbody(
                    tag.tr(tag.th(tag.tt(mime_type),
                                  style="text-align: left"),
                           tag.td(tag.code(
                               ' '.join(sorted(mime_types[mime_type])))))
                    for mime_type in sorted(mime_types.keys()))))
Exemplo n.º 10
0
    def expand_macro(self, formatter, name, content):
        intertracs = {}
        for key, value in self.config.options('intertrac'):
            idx = key.rfind('.') # rsplit only in 2.4
            if idx > 0: # 0 itself doesn't help much: .xxx = ...
                prefix, attribute = key[:idx], key[idx+1:]
                intertrac = intertracs.setdefault(prefix, {})
                intertrac[attribute] = value
            else:
                intertracs[key] = value # alias

        def generate_prefix(prefix):
            intertrac = intertracs[prefix]
            if isinstance(intertrac, basestring):
                yield tag.tr(tag.td(tag.b(prefix)),
                             tag.td('Alias for ', tag.b(intertrac)))
            else:
                url = intertrac.get('url', '')
                if url:
                    title = intertrac.get('title', url)
                    yield tag.tr(tag.td(tag.a(tag.b(prefix),
                                              href=url + '/timeline')),
                                 tag.td(tag.a(title, href=url)))

        return tag.table(class_="wiki intertrac")(
            tag.tr(tag.th(tag.em('Prefix')), tag.th(tag.em('Trac Site'))),
            [generate_prefix(p) for p in sorted(intertracs.keys())])
Exemplo n.º 11
0
def remove_header(stream, field):
    """ Removes the display from the ticket properties """
    stream = stream | \
        Transformer('//th[@id="h_%s"]' % field).replace(tag.th(id="h_%s" % field))
    stream = stream | \
        Transformer('//td[@headers="h_%s"]' % field).replace(tag.th(id="h_%s" % field))
    return stream
Exemplo n.º 12
0
 def fn(stream):
     for kind, data, pos in stream:
         if kind is END and data.localname == 'body':
             first_time = req._tracdeveloper_hdlr.buf \
                          and req._tracdeveloper_hdlr.buf[0].created
             
             elm = tag.div(tag.table(tag.thead(tag.tr(
                 tag.th('Time'),
                 tag.th('Module'),
                 tag.th('Level'),
                 tag.th('Message'),
             )), class_='listing')([
                 tag.tr(
                     tag.td(int((r.created - first_time) * 1000)),
                     tag.td(r.module),
                     tag.td(r.levelname),
                     tag.td(r.getMessage()),
                     class_=(i%2 and 'even' or 'odd'),
                 )
                 for i, r in enumerate(req._tracdeveloper_hdlr.buf)
             ]), id='tracdeveloper-log')
             for evt in elm.generate():
                 yield evt
             del elm
             req._tracdeveloper_hdlr.formatter = None
             del req._tracdeveloper_hdlr.buf[:]
             self.log.removeHandler(req._tracdeveloper_hdlr)
             del req._tracdeveloper_hdlr
         yield kind, data, pos
Exemplo n.º 13
0
def render_refs_box(self, req, ids, order = 'year', desc = 1, headhref=False,
    path=[],args=[],page=None,max=None ):
    # Check parameters
    if not ids:
        return []     
    
    columns = self.env.config.get('zotero', 'columns','firstCreator, year, publicationTitle, title' )
    columns = columns.split(',')
    columns = [c.strip() for c in columns]
   
    model = ZoteroModelProvider(self.env)
    if page:
        page = (page-1)*max
    data = model.get_item_columns_by_iids(ids,columns, order, desc = desc, offset=page,limit=max)
    
    apath = args_path(args)
    
    heads = []
    for idx, column in enumerate(columns):
        label = column
        if zotero_fields_mapping_name.has_key(column):
            label = zotero_fields_mapping_name[column]['label']
        if headhref and path:
            head = []
            th_class = ''
            th_href = req.href(path, order=column)+apath
            if order == column:
                if desc:
                    th_class = 'desc'
                else:
                    th_class = 'asc'
                    th_href = req.href(path, order=column, desc = str(1))+apath
            head = tag.th(tag.a(label, href = th_href),class_= th_class)
            heads.append(head)
        else:
            heads.append(tag.th(label))
    body = []
    for idx, item in enumerate(data):
        item_class = 'even'
        if idx % 2 == 1:
            item_class = 'odd'
        item_td = []
        for idx, col in enumerate(columns):
            col_td = []
            if not col or item[idx+1] == 'None':
                col_td = tag.td()
            elif col == 'title':
                col_td = tag.td(tag.a(item[idx+1], 
                    href = req.href.zotero('item',str(item[0]))))
            else:   
                col_td = tag.td(item[idx+1])
            item_td.append(col_td)
        item_tr = tag.tr( item_td,class_=item_class)
        body.append(item_tr)
    return tag.table( tag.thead( heads ), tag.tbody(body),
        class_="listing dirlist", id="dirlist")
Exemplo n.º 14
0
 def expand_macro(self, formatter, name, arguments):
     self.mc.options(arguments)
     extras = self.mc.extras()
     extra = ''
     if 'extra' in extras:
         extra = extras['extra']
     return tag.div(
         tag.h3('[[%s(%s)]]' % ( name, arguments )),
         tag.table(
           tag.tr(
             tag.th('Name'), tag.th('Value'), tag.th('Qualified'),
             tag.th('Default?'), tag.th('Macroarg?'), tag.th('Extra?'),
             tag.th('Known?'), tag.th('Default'), tag.th('Documentation')
           ),
           self._show_option('text', self.mo_text,
                             TracMacroConfigExample.mo_text),
           self._show_option('bool', self.mo_bool,
                             TracMacroConfigExample.mo_bool),
           self._show_option('int', self.mo_int,
                             TracMacroConfigExample.mo_int),
           self._show_option('list', self.mo_list,
                             TracMacroConfigExample.mo_list),
           self._show_option('nodtext', self.mo_nodtext,
                             TracMacroConfigExample.mo_nodtext),
           self._show_option('nodbool', self.mo_nodbool,
                             TracMacroConfigExample.mo_nodbool),
           self._show_option('nodint', self.mo_nodint,
                             TracMacroConfigExample.mo_nodint),
           self._show_option('nodlist', self.mo_nodlist,
                             TracMacroConfigExample.mo_nodlist),
           self._show_extra('extra', extra),
           border=1, cellpadding=1, cellspacing=0
         )
     )
Exemplo n.º 15
0
 def expand_macro(self, formatter, name, arguments):
     self.mc.options(arguments)
     extras = self.mc.extras()
     extra = ''
     if 'extra' in extras:
         extra = extras['extra']
     return tag.div(
         tag.h3('[[%s(%s)]]' % (name, arguments)),
         tag.table(tag.tr(tag.th('Name'), tag.th('Value'),
                          tag.th('Qualified'), tag.th('Default?'),
                          tag.th('Macroarg?'), tag.th('Extra?'),
                          tag.th('Known?'), tag.th('Default'),
                          tag.th('Documentation')),
                   self._show_option('text', self.mo_text,
                                     TracMacroConfigExample.mo_text),
                   self._show_option('bool', self.mo_bool,
                                     TracMacroConfigExample.mo_bool),
                   self._show_option('int', self.mo_int,
                                     TracMacroConfigExample.mo_int),
                   self._show_option('list', self.mo_list,
                                     TracMacroConfigExample.mo_list),
                   self._show_option('nodtext', self.mo_nodtext,
                                     TracMacroConfigExample.mo_nodtext),
                   self._show_option('nodbool', self.mo_nodbool,
                                     TracMacroConfigExample.mo_nodbool),
                   self._show_option('nodint', self.mo_nodint,
                                     TracMacroConfigExample.mo_nodint),
                   self._show_option('nodlist', self.mo_nodlist,
                                     TracMacroConfigExample.mo_nodlist),
                   self._show_extra('extra', extra),
                   border=1,
                   cellpadding=1,
                   cellspacing=0))
Exemplo n.º 16
0
 def annotate_row(self, context, row, lineno, line, data):
     htmlImageString = '<img src="' + self.imagePath + '">'
     #make line number light gray
     if(lineno <= self.lineEnd and lineno >= self.lineStart):
         #if there is a comment on this line
         if(self.comments.has_key(lineno)):
             #if there is more than 0 comments
             if(self.comments[lineno] > 0):
                 return row.append(tag.th(id='L%s' % lineno)(tag.a(tag.img(src='%s' % self.imagePath) + ' ' + str(lineno), href='javascript:getComments(%s, %s)' % (lineno, self.fileID))))
         return row.append(tag.th(id='L%s' % lineno)(tag.a(lineno, href='javascript:addComment(%s, %s, -1)' % (lineno, self.fileID))))
     return row.append(tag.th(id='L%s' % lineno)(tag.font(lineno, color='#CCCCCC')))
Exemplo n.º 17
0
 def annotate_row(self, context, row, lineno, line, data):
     from genshi.builder import tag
     lineno -= 1 # 0-based index for data
     if lineno >= len(data):
         row.append(tag.th())
         return
     row_data = data[lineno]
     if row_data == '-':
         row.append(tag.th())
     elif row_data == '0':
         row.append(tag.th(row_data, class_='uncovered'))
     else:
         row.append(tag.th(row_data, class_='covered'))
Exemplo n.º 18
0
    def filter_stream(self, req, method, filename, stream, data):
        """
        Returns changed stream for `prefs_general.html` template with notification
        opt-out preference option.

        `req` is the current request object, `method` is the Genshi render
        method (xml, xhtml or text), `filename` is the filename of the template
        to be rendered, `stream` is the event stream and `data` is the data for
        the current template.
        """

        if filename == 'prefs_general.html' and req.authname != 'anonymous':
            stream |= Transformer('.//table').append(
                tag.tr(
                    tag.th(
                        tag.label('Ticket notifications opt-out:', **{'for': 'ticket-notification-optout'}),
                    ),
                    tag.td(
                        tag.input(type="hidden", name="ticket-notification-optout_cb", value=""),
                        tag.input(type="checkbox", id="ticket-notification-optout", name="ticket-notification-optout", checked=req.session.get('ticket-notification-optout') or None),
                    ),
                    **{'class': 'field'}
                ),
            )
        return stream
Exemplo n.º 19
0
    def browser(self, req, stream, data):

        if not data.has_key('path'):
            # this probably means that there is an upstream error
            return stream

        # mark up the title (disabled)
        # stream |= Transformer('//title/text()').substitute('/', data['svn_base_url'] + '/')

        # provide a link to the svn repository
        stream |= Transformer("//div[@id='content']/h1").after(tag.a(self.link_text, href=self.url(data['path']), title=self.link_title))

        # if a directory, provide links to the children files
        if data['dir']:
            offset = 2 # table header, index of 0 (python) versus 1 (xpath)
            if data['path'] != '/':                
                offset += 1 # parent directory row

            xpath_prefix = "//table[@id='dirlist']"
            # add the table header
            xpath = xpath_prefix + "//th[contains(@class, '%s')]" % self.element_class
            stream |= Transformer(xpath).after(tag.th('URL', **{'class': "url"}))

            if 'up' in data['chrome']['links']:
                stream |= Transformer(xpath_prefix + "//td[@colspan='5']").attr('colspan', None)

            # add table cells
            stream = self.dir_entries(req, stream, data, xpath_prefix)
        return stream
Exemplo n.º 20
0
 def render(self, context, mimetype, content, filename=None, url=None):
     content = content.read()
     content = re.split('\r[\n]', content) 
     if not content:
         return None
     head = content[0]
     if not head:
         return None
     head = re.split(',', head)
     
     if not head:
         return None
     thead = tag.thead(tag.tr([tag.th(h) for h in head]))
     content = content[1:]
     if not content:
         return None
     tbody = []
     for r in content:
         if r:
             r = re.split(',', r)
             if r:
                 tbody.append(tag.tr([tag.td(c) for c in r ]))
     
     return tag.table(thead,tag.tbody(tbody), 
         class_="wiki")
Exemplo n.º 21
0
    def filter_stream(self, req, method, filename, stream, data):
        """
        Adds project total count information in project summary block::

            Downloads: 288

        """
        # TODO: Make interface for the project summary box and implement it here

        # Filter only the summary table wiki macro
        if filename != 'multiproject_summary.html':
            return stream

        # Load project and followers info
        project = Project.get(self.env)
        count = ProjectDownloadEntry.total_download_count(project.id)

        if count == 0:
            return stream

        # Add following information into project summary block
        trans = Transformer('//div[@class="summary"]/table').append(
            tag.tr(
                tag.th('Downloads:'),
                tag.td(count)
            )
        )

        return stream | trans
 def _make_graph(self, req, repos, info):
     # Generate graph data
     graph = {}
     threads, vertices, columns = \
         make_log_graph(repos, (item['rev'] for item in info))
     graph.update(threads=threads, vertices=vertices, columns=columns,
                  colors=self.graph_colors,
                  line_width=0.04, dot_radius=0.1)
     add_script(req, 'revisiongraph/js/excanvas.js')
     add_script(req, 'revisiongraph/js/log_graph.js')
     add_script_data(req, {'graph': graph})
     
     script = Markup("//<![CDATA[") + """
     jQuery(document).ready(function($) {
       $('th.trac-graph, td.trac-graph').show();
       var canvas = $('""" + Markup("<canvas>") + """').css({width: '%dem',
                                       height: '%dem'})
                                 .appendTo('td.trac-graph')[0];
       canvas.width = $(canvas).width();
       canvas.height = $(canvas).height();
       if (typeof(G_vmlCanvasManager) != 'undefined')
         canvas = G_vmlCanvasManager.initElement(canvas);
       $.paintLogGraph(graph, canvas);
     });
     """ % (graph['columns'] * 2, len(info) * 2) + Markup("//]]>")
     
     th = tag.th('Graph', class_='trac-graph')
     td = tag.td(class_='trac-graph', rowspan='%d' % len(info))
     
     script_filter = Transformer('//head').append(tag.script(script, type="text/javascript"))
     table_filter = Transformer('//table[@class="listing chglist"]').attr('class', 'listing chglist trac-graph')
     th_filter = Transformer('//table/thead/tr/th[@class="diff"]').before(th)
     td_filter = Transformer('//table/tbody/tr[1]/td[@class="diff"]').before(td)
     
     return [script_filter, table_filter, th_filter, td_filter]
Exemplo n.º 23
0
def render_table(items, colspec, render_item):
    try:
        columns = max(int(colspec), 1)
    except:
        columns = 3

    nbsp = Markup('&nbsp;')
    hdr = [tag.th('Markup', nbsp), tag.th(nbsp, 'Display')]
    def render_def(s):
        rendered = s and render_item(s) or None
        return [tag.td(s), tag.td(rendered)] 
    
    return tag.table(tag.tr((hdr + [tag.th(nbsp)]) * (columns-1) + hdr),
                     [tag.tr([render_def(s) + [tag.td(nbsp)]
                              for s in row[:-1]] + render_def(row[-1]))
                      for row in group(sorted(items), columns)],
                     class_="wiki")
Exemplo n.º 24
0
def generate_home(self, req):
    
    model = ZoteroModelProvider(self.env)
    
    title = tag.h1( 'Tops' )
    authors_top = model.count_by_author_top()
    authors = []
    for creatorID, firstName, lastName in authors_top:
        authors.append(tag.a( lastName + ' ' + firstName, 
                href = req.href.zotero('qjump', author = creatorID) ) )
        authors.append(tag.span(' | '))
    authors = tag.tr(tag.th( tag.b('Authors:'), 
        tag.td( authors, 
                tag.a('more...', href = req.href.zotero('cloud', t = 'author' ) ) ),
        valign="top", style="text-align: right; width: 15%;"))
    
    publisher_top = model.count_by_publisher_top()
    publisher = []
    for p in publisher_top:
        publisher.append(tag.a( p, 
                href = req.href.zotero('qjump', publisher = p) ) )
        publisher.append(tag.br())
    publisher = tag.tr(tag.th( tag.b('Publishers:'), 
            tag.td(publisher, 
                   tag.a('more...', href = req.href.zotero('cloud', t = 'publisher' ))),
            valign="top", style="text-align: right; width: 15%;"))
    
    year_top = model.count_by_year_top()
    years = []
    for y in year_top:
        years.append(tag.a( y, 
                href = req.href.zotero('qjump', year = y) ) )
        years.append(tag.span(' | '))
    years = tag.tr(tag.th( tag.b('Years:'), 
            tag.td(years, 
                   tag.a('more...', href = req.href.zotero('cloud', t = 'year' ))),
            valign="top", style="text-align: right; width: 15%;"))
    # For recently add
    recent_ids = model.get_recents()
    recents_title = tag.div( tag.br(), tag.br(),tag.h1('Recent Changes'))
    recents = render_refs_box(self, req, recent_ids )
    home = tag.div( title, 
        tag.table(authors, years, publisher, border="0", cellpadding="2", cellspacing="2"),
        recents_title, recents)
    
    return home
Exemplo n.º 25
0
    def expand_macro(self, formatter, name, content):
        content = content.strip() if content else ''
        name_filter = content.strip('*')
        items = {}
        for subscriber in NotificationSystem(self.env).subscribers:
            name = subscriber.__class__.__name__
            if not name_filter or name.startswith(name_filter):
                items[name] = subscriber.description()

        return tag.div(class_='trac-subscriberlist')(tag.table(class_='wiki')(
            tag.thead(tag.tr(tag.th(_("Subscriber")),
                             tag.th(_("Description")))),
            tag.tbody(
                tag.tr(tag.td(tag.code(name)),
                       tag.td(items[name]),
                       class_='odd' if idx % 2 else 'even')
                for idx, name in enumerate(sorted(items.keys())))))
Exemplo n.º 26
0
    def expand_macro(self, formatter, name, content):
        content = content.strip() if content else ''
        name_filter = content.strip('*')
        items = {}
        for subscriber in NotificationSystem(self.env).subscribers:
            name = subscriber.__class__.__name__
            if not name_filter or name.startswith(name_filter):
                items[name] = subscriber.description()

        return tag.div(class_='trac-subscriberlist')(
            tag.table(class_='wiki')(
                tag.thead(tag.tr(
                    tag.th(_("Subscriber")),
                    tag.th(_("Description")))),
                tag.tbody(
                    tag.tr(tag.td(tag.code(name)),
                           tag.td(items[name]),
                           class_='odd' if idx % 2 else 'even')
                    for idx, name in enumerate(sorted(items.keys())))))
Exemplo n.º 27
0
  def expand_macro(self, formatter, name, content, args):

    title = 'Color Scheme'
    classes = 'colormacro' 

    if args and 'title' in args:
      title = args['title']

    if args and 'class' in args:
      classes  += ' ' + args['class']


    tbody = []
    have_comment = False
    colors = self._parse_arguments(content)

    for color in colors:
      if len(color['title']) > 0:
        have_comment = True
      ## Create row
      tbody.append(
        [
          tag.td()(tag.strong(color['title'])),
          tag.td(
              style='background-color:' + color['orig']
            )(
              tag.div(style='color: black')(color['hex']),
              tag.div(style='color: white')(color['hex'])
          ),
          tag.td(
              style='background-color:' + color['orig']
            )(
              tag.div(style='color: black')(color['rgbp']),
              tag.div(style='color: white')(color['rgbp'])
          ),
        ]
      )
      ## end for loop

    if len(tbody) > 0:
      colcount = len(tbody[0])
      if not have_comment:
        colcount -= 1
      
      table = tag.table(class_=classes)
      table()(tag.thead()(tag.th(colspan='%d' % colcount)(title)))
      ## Attach row in table.
      if have_comment:
        table()(tag.tbody(class_='colorlist')([tag.tr(row) for row in tbody]))
      else:
        table()(tag.tbody(class_='colorlist')([tag.tr(row[1:]) for row in tbody]))

      return table;
    else:
      return tag.div(class_='colormacro')('Nothing to display')
Exemplo n.º 28
0
 def annotate_row(self, context, row, lineno, line, data):
     htmlImageString = '<img src="' + self.imagePath + '">'
     #make line number light gray
     if (lineno <= self.lineEnd and lineno >= self.lineStart):
         #if there is a comment on this line
         if (self.comments.has_key(lineno)):
             #if there is more than 0 comments
             if (self.comments[lineno] > 0):
                 return row.append(
                     tag.th(id='L%s' % lineno)(
                         tag.a(tag.img(src='%s' % self.imagePath) + ' ' +
                               str(lineno),
                               href='javascript:getComments(%s, %s)' %
                               (lineno, self.fileID))))
         return row.append(
             tag.th(id='L%s' % lineno)(
                 tag.a(lineno,
                       href='javascript:addComment(%s, %s, -1)' %
                       (lineno, self.fileID))))
     return row.append(
         tag.th(id='L%s' % lineno)(tag.font(lineno, color='#CCCCCC')))
Exemplo n.º 29
0
    def annotate_row(self, context, row, lineno, line, data):
        file_name = context.file_name
        if file_name[0] == '/':
            file_name = file_name[1:]

        rev = make_rev_str(context.rev)

        lineno = context.startline + lineno - 1
        
        row.append(tag.th(id='L%s' % lineno)(
            tag.a(lineno, href='../browser/%s%s#L%s' % (file_name, rev, lineno))
        ))
Exemplo n.º 30
0
    def expand_macro(self, formatter, name, content):
        evs = EarnValueSystem(self.env)
        kwargs = self._parse_arg(content)
        users = evs.get_users(formatter.req, kwargs.get('users', 'authenticated'))
        format = kwargs.get('format', 'table')
        start_time = self._parse_date(kwargs.get('start'), 0)
        end_time = self._parse_date(kwargs.get('end'), None)

        if format == 'plain':
            ev = dict([(u, evs.get_user_ev(u, start_time, end_time)) for u in users])
            tags = []
            for k, v in ev.items():
                tags.append(tag.span(k + ': ' + str(v)))
                tags.append(tag.br)
            return tag.p(*tags)

        elif format == 'table':
            evc = evs.get_users_ev_detail(users, start_time, end_time)
            rows = [tag.tr(
                tag.td(ev['action_name']),
                tag.td(ev['value']),
                tag.td(ev['fullname']),
                tag.td(ev['time']),
                tag.td(ev['summary'])
            ) for evcs in evc.values() for ev in evcs ]
            return tag.div(
                tag.table(tag.thead(
                    tag.tr(
                        tag.th('Action'),
                        tag.th('Value'),
                        tag.th('User'),
                        tag.th('Date'),
                        tag.th('Summary'), class_='trac-columns')
                ),
                tag.tbody(
                    *rows
                ), class_='listing tickets')
            )

        return None
Exemplo n.º 31
0
    def annotate(self, row, lineno):
        if lineno > len(self.annotations):
            row.append(tag.th())
            return
        rev = self.annotations[lineno-1]
        chgset = self.changesets[lineno-1]
        path = self.paths.get(rev, None)
        # Note: path will be None if copy/rename is not supported
        # by get_history

        # -- compute anchor and style once per revision
        if rev not in self.chgset_data:
            chgset_href = \
                self.context.href.changeset(rev, self.repos.reponame or None,
                                            path)
            short_author = chgset.author.split(' ', 1)[0]
            title = shorten_line('%s: %s' % (short_author, chgset.message))
            anchor = tag.a('[%s]' % self.repos.short_rev(rev), # shortname
                           title=title, href=chgset_href)
            color = self.colorize_age(self.timerange.relative(chgset.date))
            style = 'background-color: rgb(%d, %d, %d);' % color
            self.chgset_data[rev] = (anchor, style)
        else:
            anchor, style = self.chgset_data[rev]

        if self.prev_chgset != chgset:
            self.prev_style = style
        # optimize away the path if there's no copy/rename info
        if not path or path == self.path:
            path = ''
        # -- produce blame column, eventually with an anchor
        style = self.prev_style
        if lineno < len(self.changesets) and self.changesets[lineno] == chgset:
            style += ' border-bottom: none;'
        blame_col = tag.th(style=style, class_='blame r%s' % rev)
        if self.prev_chgset != chgset:
            blame_col.append(anchor)
            self.prev_chgset = chgset
        row.append(blame_col)
Exemplo n.º 32
0
    def expand_macro(self, formatter, name, content):
        interwikis = []
        for k in sorted(self.keys()):
            prefix, url, title = self[k]
            interwikis.append(
                {
                    "prefix": prefix,
                    "url": url,
                    "title": title,
                    "rc_url": self._expand_or_append(url, ["RecentChanges"]),
                    "description": url if title == prefix else title,
                }
            )

        return tag.table(
            tag.tr(tag.th(tag.em("Prefix")), tag.th(tag.em("Site"))),
            [
                tag.tr(tag.td(tag.a(w["prefix"], href=w["rc_url"])), tag.td(tag.a(w["description"], href=w["url"])))
                for w in interwikis
            ],
            class_="wiki interwiki",
        )
Exemplo n.º 33
0
    def annotate_row(self, context, row, lineno, line, data):
        file_name = context.file_name
        if file_name[0] == '/':
            file_name = file_name[1:]

        rev = make_rev_str(context.rev)

        lineno = context.startline + lineno - 1

        row.append(
            tag.th(id='L%s' % lineno)(tag.a(lineno,
                                            href='../browser/%s%s#L%s' %
                                            (file_name, rev, lineno))))
Exemplo n.º 34
0
    def filter_stream(self, req, method, filename, stream, data):
        if filename in ('browser.html', 'dir_entries.html'):
            if 'path' not in data:
                # Probably an upstream error
                return stream
            # provide a link to the svn repository at the top of the Browse Source listing
            if self.env.is_component_enabled('contextmenu.contextmenu.SubversionLink'):
                content = SubversionLink(self.env).get_content(req, data['path'], stream, data)
                if content:
                    stream |= Transformer('//div[@id="content"]/h1').after(content)
            # No dir entries; we're showing a file
            if not data['dir']:
                return stream
            # FIXME: The idx is only good for finding rows, not generating element ids.
            # Xhr rows are only using dir_entries.html, not browser.html.
            # The xhr-added rows' ids are added using js (see expand_dir.js)
            add_stylesheet(req, 'contextmenu/contextmenu.css')
            add_script(req, 'contextmenu/contextmenu.js')
            if 'up' in data['chrome']['links']:
                # Start appending stuff on 2nd tbody row when we have a parent dir link
                row_index = 2
                # Remove colspan and insert an empty cell for checkbox column
                stream |= Transformer('//table[@id="dirlist"]//td[@colspan="5"]').attr('colspan', None).before(tag.td())
            else:
                # First row = //tr[1]
                row_index = 1

            for idx, entry in enumerate(data['dir']['entries']):
                menu = tag.div(tag.span(Markup('&#9662;'), style='color: #bbb'),
                               tag.div(class_='ctx-foldable', style='display:none'),
                               id='ctx%s' % idx, class_='context-menu')
                for provider in sorted(self.context_menu_providers, key=lambda x: x.get_order(req)):
                    content = provider.get_content(req, entry, stream, data)
                    if content:
                        menu.children[1].append(tag.div(content))
                ## XHR rows don't have a tbody in the stream
                if data['xhr']:
                    path_prefix = ''
                else:
                    path_prefix = '//table[@id="dirlist"]//tbody'
                # Add the menu
                stream |= Transformer('%s//tr[%d]//td[@class="name"]' % (path_prefix, idx + row_index)).prepend(menu)
                if provider.get_draw_separator(req):
                    menu.children[1].append(tag.div(class_='separator'))
                # Add td+checkbox
                cb = tag.td(tag.input(type='checkbox', id="cb%s" % idx, class_='fileselect'))
                stream |= Transformer('%s//tr[%d]//td[@class="name"]' % (path_prefix, idx + row_index)).before(cb)

            stream |= Transformer('//th[1]').before(tag.th())

        return stream
Exemplo n.º 35
0
    def annotate_row(self, context, row, lineno, line, data):
        "add column with Lint data to annotation"
        if data == None:
            row.append(tag.th())
            return
        row_data = data.get(lineno, None)
        if row_data == None:
            row.append(tag.th(class_='covered'))
            return

        self.log.debug('problems in line no %d:' % lineno)
        categories = ''
        problems = []
        for item in row_data:
            categories += item['category'] and item['category'][0] or '-'
            self.log.debug('  %s' % item)
            problems.append('%(category)s: %(tag)s in report %(rid)d' % item)
        problems = '\n'.join(problems)
        self.itemid += 1
        row.append(tag.th(tag.a(categories, href='#Lint%d' % self.itemid),
                          class_='uncovered', title=problems,
                          id_='Lint%d' % self.itemid))
        self.log.debug('%s' % row)
Exemplo n.º 36
0
    def _contruct_tickets_table(self, req, ticket, childtickets, priorities):
        # trac.ini : Which columns to display in child ticket listing?
        columns = self.config.getlist('childtickets', 'parent.%s.table_headers' % ticket['type'], default=['summary','owner'])

        tablediv = tag.div()
        tablediv.append(tag.label(tag.input(type="checkbox", id="cb_show_closed"),
                                  "show closed tickets"))

        for tkt_types, type_tickets in groupby(childtickets, lambda t: t['type']):
            tablediv.append(tag.h2("Type: %s" % tkt_types, class_="report-result"))
            tablediv.append(
                    tag.table(
                        tag.thead(
                            tag.tr(
                                tag.th("Ticket",class_="id"),
                                [ tag.th(s.title(),class_=s) for s in columns ])
                            ),
                        tag.tbody([ self._table_row(req,tkt,columns,priorities) for tkt in type_tickets]),
                        class_="listing tickets",
                        )
                    )

        return tablediv
        def table_header(self):
		# use genshi to build header row, also use th for table headings
		# (note, we don't start the table here, as all genshi objects have to be self-contained)
		return tag.thead(tag.tr(tag.th('Ticket'),
			      tag.th('Summary'),
			      tag.th('Modified'),
			      tag.th('Owner'),
			      tag.th('Component'),
			      tag.th('Status')))
Exemplo n.º 38
0
  def expand_macro(self, formatter, name, content, args):
    title = 'Color Gradient'
    classes = 'colorgradient';

    if args and 'title' in args:
      title = args['title']

    if args and 'class' in args:
      classes  += ' ' + args['class']

    colors = self._parse_arguments(content)

    lastcolor = {}
    tbody = []

    for color in colors:
      if 'orig' in lastcolor:
        tbody.append(self._create_gradient(lastcolor, color))
        
      tbody.append([
        tag.td(
          style='background-color:' + color['orig']
        )(
          tag.div(style='color: black')(color['hex']),
          tag.div(style='color: white')(color['hex'])
        ),
        tag.td(
          style='background-color:' + color['orig']
        )(
          tag.div(style='color: black')(color['rgbp']),
          tag.div(style='color: white')(color['rgbp'])
        )
      ])

      lastcolor = color

    ## end for loop

    if len(tbody) > 0:
      
      table = tag.table(class_=classes)
      table()(tag.thead()(tag.th(colspan="2")(title)))
     
      table()(tag.tbody(class_='colorgradient')([tag.tr()(td) for td in tbody]))

      return table;
    else:
      return tag.div(class_='colorgradient')('Nothing to display')
Exemplo n.º 39
0
    def filter_stream(self, req, method, filename, stream, data):
        if 'TICKET_ADMIN' in req.perm and req.path_info.startswith('/admin/ticket/components'):
            if data.get('components'):
                filter = Transformer('//form[@id="addcomponent"]/fieldset/div[@class="buttons"]')
                stream = stream | filter.before(tag.div("Default CC:",
                                                tag.br(),
                                                tag.input(type='text', name='defaultcc'),
                                                class_='field'))

                default_ccs = DefaultCC.select(self.env)

                stream = stream | Transformer('//table[@id="complist"]/thead/tr') \
                    .append(tag.th('Default CC'))

                filter = Transformer('//table[@id="complist"]/tbody')
                default_comp = self.config.get('ticket', 'default_component')
                for comp in data.get('components'):
                    if comp.name == default_comp:
                        default_tag = tag.input(type='radio', name='default', value=comp.name, checked='checked')
                    else:
                        default_tag = tag.input(type='radio', name='default', value=comp.name)

                    if comp.name in default_ccs:
                        default_cc = default_ccs[comp.name]
                    else:
                        default_cc = ''

                    filter = filter.append(tag.tr(tag.td(tag.input(type='checkbox', name='sel', value=comp.name), class_='sel'),
                                                  tag.td(tag.a(comp.name, href=req.href.admin('ticket', 'components') + '/' + comp.name), class_='name'),
                                                  tag.td(comp.owner, class_='owner'),
                                                  tag.td(default_tag, class_='default'),
                                                  tag.td(default_cc, class_='defaultcc')))
                return stream | filter

            elif data.get('component'):
                cc = DefaultCC(self.env, data.get('component').name)
                filter = Transformer('//form[@id="modcomp"]/fieldset/div[@class="buttons"]')
                filter = filter.before(tag.div("Default CC:",
                                               tag.br(),
                                               tag.input(type='text', name='defaultcc', value=cc.cc),
                                               class_='field')) \
                                               .before(tag.input(type='hidden', name='old_name', value=cc.name))
                return stream | filter

        return stream
Exemplo n.º 40
0
    def filter_stream(self, req, method, filename, stream, data):
        if 'TICKET_ADMIN' in req.perm:
            if req.path_info == '/admin/ticket/components' or req.path_info == '/admin/ticket/components/':
                components = data.get('components')
                # 'components' will be None if component with specified name already exists.
                if not components:
                    return stream
                
                default_ccs = DefaultCC.select(self.env)

                stream = stream | Transformer('//table[@id="complist"]/thead/tr') \
                    .append(tag.th('Default CC'))

                filter = Transformer('//table[@id="complist"]/tbody')
                default_comp = self.config.get('ticket', 'default_component')
                for comp in components:
                    if default_comp == comp.name:
                        default_tag = tag.input(type='radio', name='default', value=comp.name, checked='checked')
                    else:
                        default_tag = tag.input(type='radio', name='default', value=comp.name)

                    if comp.name in default_ccs:
                        default_cc = default_ccs[comp.name]
                    else:
                        default_cc = ''

                    filter = filter.append(tag.tr(tag.td(tag.input(type='checkbox', name='sel', value=comp.name), class_='sel'),
                                                  tag.td(tag.a(comp.name, href=req.href.admin('ticket', 'components') + '/' + comp.name), class_='name'),
                                                  tag.td(comp.owner, class_='owner'),
                                                  tag.td(default_tag, class_='default'),
                                                  tag.td(default_cc, class_='defaultcc')))
                return stream | filter

            elif req.path_info.startswith('/admin/ticket/components/') and data.get('component'):
                cc = DefaultCC(self.env, data.get('component').name)
                filter = Transformer('//form[@id="modcomp"]/fieldset/div[@class="buttons"]')
                filter = filter.before(tag.div("Default CC:",
                                               tag.br(),
                                               tag.input(type="text", name="defaultcc", value=cc.cc),
                                               class_="field")) \
                                               .before(tag.input(type='hidden', name='old_name', value=cc.name))
                return stream | filter

        return stream
Exemplo n.º 41
0
    def filter_stream(self, req, method, filename, stream, data):
        if 'TICKET_ADMIN' in req.perm and \
                req.path_info.startswith('/admin/ticket/components'):
            if data.get('component'):
                cc = DefaultCC(self.env, data.get('component').name)
                filter = Transformer('//form[@id="modcomp"]/fieldset'
                                     '/div[@class="field"][2]')
                filter = filter.after(tag.div("Default CC:",
                                              tag.br(),
                                              tag.input(type='text',
                                                        name='defaultcc',
                                                        value=cc.cc),
                                              class_='field')) \
                               .before(tag.input(type='hidden',
                                                 name='old_name',
                                                 value=cc.name))
                return stream | filter
            else:
                filter = Transformer('//form[@id="addcomponent"]'
                                     '/fieldset/div[@class="buttons"]')
                stream |= filter.before(tag.div("Default CC:",
                                                tag.br(),
                                                tag.input(type='text',
                                                          name='defaultcc'),
                                                class_='field'))

                default_ccs = DefaultCC.select(self.env)

                stream |= Transformer('//table[@id="complist"]/thead/tr') \
                          .append(tag.th('Default CC'))

                for i, comp in enumerate(data.get('components')):
                    if comp.name in default_ccs:
                        default_cc = default_ccs[comp.name]
                    else:
                        default_cc = ''
                    filter = Transformer('//table[@id="complist"]'
                                         '/tbody/tr[%d]' % (i + 1))
                    stream |= filter.append(tag.td(default_cc,
                                                   class_='defaultcc'))
                return stream

        return stream
Exemplo n.º 42
0
    def filter_stream(self, req, method, filename, stream, data):
        if 'TICKET_ADMIN' in req.perm and \
                req.path_info.startswith('/admin/ticket/components'):
            if data.get('component'):
                cc = DefaultCC(self.env, data.get('component').name)
                filter = Transformer('//form[@class="mod"]/fieldset'
                                     '/div[@class="field"][2]')
                filter = filter.after(tag.div("Default CC:",
                                              tag.br(),
                                              tag.input(type='text',
                                                        name='defaultcc',
                                                        value=cc.cc),
                                              class_='field')) \
                               .before(tag.input(type='hidden',
                                                 name='old_name',
                                                 value=cc.name))
                return stream | filter
            else:
                filter = Transformer('//form[@id="addcomponent"]'
                                     '/fieldset/div[@class="buttons"]')
                stream |= filter.before(
                    tag.div("Default CC:",
                            tag.br(),
                            tag.input(type='text', name='defaultcc'),
                            class_='field'))

                default_ccs = DefaultCC.select(self.env)

                stream |= Transformer('//table[@id="complist"]/thead'
                                      '/tr/th[3]') \
                          .after(tag.th('Default CC'))

                components = data.get('components')
                if components:
                    func = self._inject_default_cc_cols(
                        default_ccs, components)
                    stream |= Transformer('//table[@id="complist"]'
                                          '/tbody/tr').apply(func)
                return stream

        return stream
Exemplo n.º 43
0
    def filter_stream(self, req, method, filename, stream, data):

        # Tickets will be modified to show the child tickets as a list under the 'Description' section.
        if filename == 'ticket.html':

            # Add our own styles for the ticket lists.
            add_stylesheet(req, 'ct/css/childtickets.css')

            # Get the ticket info.
            ticket = data.get('ticket')

            # Modify ticket.html with sub-ticket table, create button, etc...
            # As follows:
            # - If ticket has no child tickets and child tickets are NOT allowed then skip.
            # - If ticket has child tickets and child tickets are NOT allowed (ie. rules changed or ticket type changed after children were assigned),
            #   print list of tickets but do not allow any tickets to be created.
            # - If child tickets are allowed then print list of child tickets or 'No Child Tickets' if non are currently assigned.
            # 
            if ticket and ticket.exists:

                # The additional section on the ticket is built up of (potentially) three parts: header, ticket table, buttons. These
                # are all 'wrapped up' in a 'div' with the 'attachments' id (we'll just pinch this to make look and feel consistent with any
                # future changes!)
                filter = Transformer('//div[@id="ticket"]')
                snippet = tag.div()

                # Are there any child tickets to display?
                childtickets = [ Ticket(self.env,n) for n in self.childtickets.get(ticket.id,[]) ]

                # (tempish) fix for #8612 : force sorting by ticket id
                childtickets = sorted(childtickets, key=lambda t: t.id)

                # Are child tickets allowed?
                childtickets_allowed = self.config.getbool('childtickets', 'parent.%s.allow_child_tickets' % ticket['type'])

                # If there are no childtickets and the ticket should not have any child tickets, we can simply drop out here.
                if not childtickets_allowed and not childtickets:
                    return stream

                # Our 'main' display consists of two divs.
                buttondiv = tag.div()
                tablediv = tag.div()

                # Test if the ticket has children: If so, then list in pretty table.
                if childtickets:

                    # trac.ini : Which columns to display in child ticket listing?
                    columns = self.config.getlist('childtickets', 'parent.%s.table_headers' % ticket['type'], default=['summary','owner'])

                    tablediv = tag.div(
                                tag.table(
                                    tag.thead(
                                        tag.tr(
                                            tag.th("Ticket",class_="id"),
                                            [ tag.th(s.title(),class_=s) for s in columns ])
                                        ),
                                    tag.tbody([ self._table_row(req,tkt,columns) for tkt in childtickets ]),
                                    class_="listing tickets",
                                    ),
                                tag.br(),
                                )

                # trac.ini : child tickets are allowed - Set up 'create new ticket' buttons.
                if childtickets_allowed:

                    # Can user create a new ticket? If not, just display title (ie. no 'create' button).
                    if 'TICKET_CREATE' in req.perm(ticket.resource):

                        # Always pass these fields
                        default_child_fields = (
                                tag.input(type="hidden", name="parent", value='#'+str(ticket.id)),
                                )

                        #Pass extra fields defined in inherit parameter of parent
                        inherited_child_fields = [
                                tag.input(type="hidden",name="%s"%field,value=ticket[field]) for field in self.config.getlist('childtickets','parent.%s.inherit' % ticket['type'])
                                ]

                        # If child types are restricted then create a set of buttons for the allowed types (This will override 'default_child_type).
                        restrict_child_types = self.config.getlist('childtickets','parent.%s.restrict_child_type' % ticket['type'],default=[])

                        if not restrict_child_types:
                            # trac.ini : Default 'type' of child tickets?
                            default_child_type = self.config.get('childtickets', 'parent.%s.default_child_type' % ticket['type'], default=self.config.get('ticket','default_type'))

                            # ... create a default submit button
                            if ticket['status'] == 'closed':
                                submit_button_fields = (
                                        tag.input(type="submit",disabled="disabled",name="childticket",value="New Child Ticket",title="Create a child ticket"),
                                        tag.input(type="hidden", name="type", value=default_child_type),
                                        )
                            else:
                                submit_button_fields = (
                                        tag.input(type="submit",name="childticket",value="New Child Ticket",title="Create a child ticket"),
                                        tag.input(type="hidden",name="type",value=default_child_type),
                                        )
                        else:
                            if ticket['status'] == 'closed':
                                submit_button_fields = [ tag.input(type="submit",disabled="disabled",name="type",value="%s" % ticket_type,title="Create a %s child ticket" % ticket_type) for ticket_type in restrict_child_types ]
                            else:
                                submit_button_fields = [ tag.input(type="submit",name="type",value="%s" % ticket_type,title="Create a %s child ticket" % ticket_type) for ticket_type in restrict_child_types ]
                        buttondiv = tag.form(
                                    tag.div( default_child_fields, inherited_child_fields, submit_button_fields),
                                    method="get", action=req.href.newticket(),
                                    )

                snippet.append(tag.h2("Child Tickets",class_="foldable"))
                snippet.append(tag.div(tablediv, buttondiv, id="childtickets"))

                return stream | filter.after(snippet)

        return stream