コード例 #1
0
ファイル: __init__.py プロジェクト: nyuhuhuu/trachacks
    def expand_macro(self, formatter, name, content):
        env = formatter.env
        req = formatter.req
        if not 'VOTE_VIEW' in req.perm:
            return
        # Simplify function calls.
        format_author = partial(Chrome(self.env).format_author, req)
        if not content:
            args = []
            compact = None
            kw = {}
            top = 5
        else:
            args, kw = parse_args(content)
            compact = 'compact' in args and True
            top = as_int(kw.get('top'), 5, min=0)

        if name == 'LastVoted':
            lst = tag.ul()
            for i in self.get_votes(req, top=top):
                resource = Resource(i[0], i[1])
                # Anotate who and when.
                voted = ('by %s at %s'
                         % (format_author(i[3]),
                            format_datetime(to_datetime(i[4]))))
                lst(tag.li(tag.a(
                    get_resource_description(env, resource, compact and
                                             'compact' or 'default'),
                    href=get_resource_url(env, resource, formatter.href),
                    title=(compact and '%+i %s' % (i[2], voted) or None)),
                    (not compact and Markup(' %s %s' % (tag.b('%+i' % i[2]),
                                                        voted)) or '')))
            return lst

        elif name == 'TopVoted':
            realm = kw.get('realm')
            lst = tag.ul()
            for i in self.get_top_voted(req, realm=realm, top=top):
                if 'up-only' in args and i[2] < 1:
                    break
                resource = Resource(i[0], i[1])
                lst(tag.li(tag.a(
                    get_resource_description(env, resource, compact and
                                             'compact' or 'default'),
                    href=get_resource_url(env, resource, formatter.href),
                    title=(compact and '%+i' % i[2] or None)),
                    (not compact and ' (%+i)' % i[2] or '')))
            return lst

        elif name == 'VoteList':
            lst = tag.ul()
            resource = resource_from_path(env, req.path_info)
            for i in self.get_votes(req, resource, top=top):
                vote = ('at %s' % format_datetime(to_datetime(i[4])))
                lst(tag.li(
                    compact and format_author(i[3]) or
                    Markup(u'%s by %s %s' % (tag.b('%+i' % i[2]),
                                             tag(format_author(i[3])), vote)),
                    title=(compact and '%+i %s' % (i[2], vote) or None)))
            return lst
コード例 #2
0
ファイル: api.py プロジェクト: t2y/trac
    def test_resource_changeset(self):
        res = Resource('changeset', '42')
        self.assertEqual('Changeset 42', get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/changeset/42',
                         get_resource_url(self.env, res, self.env.href))

        repo = Resource('repository', 'repo')
        res = Resource('changeset', '42', parent=repo)
        self.assertEqual('Changeset 42 in repo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/changeset/42/repo',
                         get_resource_url(self.env, res, self.env.href))
コード例 #3
0
ファイル: api.py プロジェクト: t2y/trac
    def test_resource_repository(self):
        res = Resource('repository', 'testrepo')
        self.assertEqual('Repository testrepo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/testrepo',
                         get_resource_url(self.env, res, self.env.href))

        res = Resource('repository', '')  # default repository
        self.assertEqual('Default repository',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser',
                         get_resource_url(self.env, res, self.env.href))
コード例 #4
0
ファイル: api.py プロジェクト: exocad/exotrac
    def test_resource_repository(self):
        res = Resource('repository', 'testrepo')
        self.assertEqual('Repository testrepo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/testrepo',
                         get_resource_url(self.env, res, self.env.href))

        res = Resource('repository', '')  # default repository
        self.assertEqual('Default repository',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser',
                         get_resource_url(self.env, res, self.env.href))
コード例 #5
0
ファイル: api.py プロジェクト: exocad/exotrac
    def test_resource_changeset(self):
        res = Resource('changeset', '42')
        self.assertEqual('Changeset 42', get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/changeset/42',
                         get_resource_url(self.env, res, self.env.href))

        repo = Resource('repository', 'repo')
        res = Resource('changeset', '42', parent=repo)
        self.assertEqual('Changeset 42 in repo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/changeset/42/repo',
                         get_resource_url(self.env, res, self.env.href))
コード例 #6
0
    def filter_stream(self, req, method, filename, stream, data):

        if req.path_info.startswith('/wiki/'):
            if data and data.has_key('page') and hasattr(
                    data['page'], 'resource'):
                title = data['title']
                filter = Transformer('//div[@id="pagepath"]')
                filter = filter.empty()
                filter = filter.append(
                    tag.a('wiki:',
                          href=req.href.wiki(),
                          class_='pathentry first'))

                resource = data['page'].resource
                relation_system = ResourceRelationSystem(self.env)
                tree = relation_system.get_cached_tree(req)
                add_stylesheet(req, 'wikimenu/css/superfish.css')
                add_script(req, 'wikimenu/js/jquery.bgiframe.min.js')
                add_script(req, 'wikimenu/js/superfish.js')
                add_script(req, 'wikimenu/js/popup.js')
                resources = []
                for res in relation_system.get_ancestors(resource, tree=tree):
                    resources.append(res)
                for res in reversed(resources):
                    label = get_resource_description(self.env, res)
                    if res.realm == 'wiki':
                        if res.id and WikiSystem(self.env).has_page(res.id):

                            menu = tag.ul()

                            for res_child in relation_system.get_children(res):
                                child_label = get_resource_description(
                                    self.env, res_child)
                                if res_child.realm == 'wiki':
                                    if res_child.id and WikiSystem(
                                            self.env).has_page(res_child.id):
                                        anc = tag.a(
                                            child_label,
                                            href=req.href.wiki(child_label))
                                        menu.append(tag.li(anc))

                            filter = filter.append(
                                tag.ul(tag.li(
                                    tag.a(label, href=req.href.wiki(label)),
                                    menu),
                                       class_='wiki_menu'))
                            if title != label:
                                filter = filter.append(
                                    tag.span(' / ', class_='pathentry sep'))
                remove_tran = '//a[@title="View ' + title + '"]'
                return stream | filter
        return stream
コード例 #7
0
ファイル: web_ui.py プロジェクト: pombredanne/trachacks
 def _do_view(self, env, req, form):
     data = {}
     form_id = form.resource.id
     data['page_title'] = get_resource_description(env, form.resource,
                                                   href=req.href)
     data['title'] = get_resource_shortname(env, form.resource)
     # prime list with current state
     subcontext, author, time = self.get_tracform_meta(form_id)[3:6]
     if not subcontext == '':
         data['subcontext'] = subcontext
     state = self.get_tracform_state(form_id)
     data['fields'] = self._render_fields(form_id, state)
     history = [{'author': author, 'time': time,
                 'old_state': state}]
     # add recorded old_state
     records = self.get_tracform_history(form_id)
     for author, time, old_state in records:
         history.append({'author': author, 'time': time,
                         'old_state': old_state})
     data['history'] = parse_history(history)
     # show reset button in case of existing data and proper permission
     data['allow_reset'] = req.perm(form.resource) \
                           .has_permission('FORM_RESET') and form.has_data
     add_stylesheet(req, 'tracforms/tracforms.css')
     return 'form.html', data, None
コード例 #8
0
ファイル: api.py プロジェクト: okamototk/kanonconductor
 def get_resource_description(self, resource, format="default", context=None, **kwargs):
     page = WikiPage(self.env, resource.id)
     if page.exists:
         return get_resource_description(self.env, page.resource, format, **kwargs)
     rid = to_unicode(resource.id)
     if format in ("compact", "default"):
         return rid
     else:
         return u"tag:%s" % rid
コード例 #9
0
    def test_global_neighborhood_report(self):
        target = resource.Neighborhood("global", None).child(self.resource)

        self.assertEquals("[global:] report:1", resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] report:1", resource.get_resource_name(self.env, target))
        self.assertEquals("[global:] report:1", resource.get_resource_shortname(self.env, target))
        self.assertEquals("[global:] report:1 at version None", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/report/1", resource.get_resource_url(self.env, target, self.env.href)
        )
コード例 #10
0
ファイル: api.py プロジェクト: kzhamaji/TracTagsPlugin
 def describe_tagged_resource(self, req, resource):
     """Returns a short description of a taggable resource."""
     provider = self._get_provider(resource.realm)
     try:
         return provider.describe_tagged_resource(req, resource)
     except (AttributeError, NotImplementedError):
         # Fallback to resource provider method.
         self.env.log.info('ITagProvider %r does not implement '
                           'describe_tagged_resource()' % provider)
         return get_resource_description(self.env, resource, 'summary')
コード例 #11
0
ファイル: api.py プロジェクト: jier38/TracSite
 def describe_tagged_resource(self, req, resource):
     """Returns a short description of a taggable resource."""
     provider = self._get_provider(resource.realm)
     try:
         return provider.describe_tagged_resource(req, resource)
     except (AttributeError, NotImplementedError):
         # Fallback to resource provider method.
         self.env.log.info('ITagProvider %r does not implement '
                           'describe_tagged_resource()' % provider)
         return get_resource_description(self.env, resource, 'summary')
コード例 #12
0
ファイル: wiki.py プロジェクト: nyuhuhuu/trachacks
 def filter_stream(self, req, method, filename, stream, data):
     
     if req.path_info.startswith('/wiki/'):
         if data and data.has_key('page') and hasattr(data['page'], 'resource'):
             title = data['title']
             filter = Transformer('//div[@id="pagepath"]')
             filter = filter.empty()
             filter = filter.append( tag.a( 'wiki:', href = req.href.wiki(), class_ = 'pathentry first' ) )
            
             resource = data['page'].resource
             relation_system = ResourceRelationSystem(self.env)
             tree = relation_system.get_cached_tree(req)    
             add_stylesheet(req, 'wikimenu/css/superfish.css')
             add_script(req, 'wikimenu/js/jquery.bgiframe.min.js')
             add_script(req, 'wikimenu/js/superfish.js')
             add_script(req, 'wikimenu/js/popup.js')
             resources = []
             for res in relation_system.get_ancestors(resource, tree=tree):
                 resources.append(res)
             for res in reversed( resources ):
                 label = get_resource_description(self.env, res)
                 if res.realm=='wiki':
                     if res.id and WikiSystem(self.env).has_page(res.id):
                         
                         menu = tag.ul( )
                                                     
                         for res_child in relation_system.get_children(res):
                             child_label = get_resource_description(self.env, res_child)
                             if res_child.realm=='wiki':
                                 if res_child.id and WikiSystem(self.env).has_page(res_child.id):
                                     anc = tag.a(child_label, href = req.href.wiki(child_label))
                                     menu.append(tag.li( anc ))
                                     
                         
                         filter = filter.append( tag.ul( tag.li( 
                             tag.a(label, href=req.href.wiki(label) ),
                                 menu ), class_= 'wiki_menu' ) )
                         if title != label:
                             filter = filter.append( tag.span( ' / ', 
                                     class_ = 'pathentry sep' ) )
             remove_tran = '//a[@title="View ' + title + '"]'
             return stream | filter
     return stream
コード例 #13
0
    def test_product_neighborhood_report(self):
        target = resource.Neighborhood("product", u"xü").child(self.resource)

        self.assertEquals(u"[product:xü] report:1", resource.get_resource_description(self.env, target))
        self.assertEquals(u"[product:xü] report:1", resource.get_resource_name(self.env, target))
        self.assertEquals(u"[product:xü] report:1", resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"[product:xü] report:1 at version None", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/products/x%C3%BC/report/1",
            resource.get_resource_url(self.env, target, self.env.href),
        )
コード例 #14
0
    def test_global_neighborhood_milestone(self):
        target = resource.Neighborhood("global", None).child(self.resource)

        self.assertEquals("[global:] Milestone milestone1", resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] Milestone milestone1", resource.get_resource_name(self.env, target))
        self.assertEquals("milestone1", resource.get_resource_shortname(self.env, target))
        self.assertEquals("[global:] Milestone milestone1", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/milestone/milestone1",
            resource.get_resource_url(self.env, target, self.env.href),
        )
コード例 #15
0
    def test_global_neighborhood_wiki(self):
        target = resource.Neighborhood("global", None).child(self.resource)

        self.assertEquals("TestPage", resource.get_resource_description(self.env, target))
        self.assertEquals("TestPage", resource.get_resource_name(self.env, target))
        self.assertEquals("TestPage", resource.get_resource_shortname(self.env, target))
        self.assertEquals("TestPage", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/wiki/TestPage?version=2",
            resource.get_resource_url(self.env, target, self.env.href),
        )
コード例 #16
0
    def test_product_neighborhood_wiki(self):
        target = resource.Neighborhood("product", u"xü").child(self.resource)

        self.assertEquals(u"TestPage", resource.get_resource_description(self.env, target))
        self.assertEquals(u"TestPage", resource.get_resource_name(self.env, target))
        self.assertEquals(u"TestPage", resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"TestPage", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/products/x%C3%BC/wiki/TestPage?version=2",
            resource.get_resource_url(self.env, target, self.env.href),
        )
コード例 #17
0
ファイル: api.py プロジェクト: nyuhuhuu/trachacks
 def get_resource_description(self, resource, format='default', context=None,
                              **kwargs):
     page = WikiPage(self.env, resource.id)
     if page.exists:
         return get_resource_description(self.env, page.resource, format,
                                         **kwargs)
     rid = to_unicode(resource.id)
     if format in ('compact', 'default'):
         return rid
     else:
         return u'tag:%s' % rid
コード例 #18
0
ファイル: api.py プロジェクト: exocad/exotrac
    def test_resource_source(self):
        res = Resource('source', '/trunk/src')
        self.assertEqual('path /trunk/src',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/trunk/src',
                         get_resource_url(self.env, res, self.env.href))

        repo = Resource('repository', 'repo')
        res = Resource('source', '/trunk/src', parent=repo)
        self.assertEqual('path /trunk/src in repo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/repo/trunk/src',
                         get_resource_url(self.env, res, self.env.href))

        repo = Resource('repository', 'repo')
        res = Resource('source', '/trunk/src', version=42, parent=repo)
        self.assertEqual('path /trunk/src@42 in repo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/repo/trunk/src?rev=42',
                         get_resource_url(self.env, res, self.env.href))
コード例 #19
0
ファイル: api.py プロジェクト: t2y/trac
    def test_resource_source(self):
        res = Resource('source', '/trunk/src')
        self.assertEqual('path /trunk/src',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/trunk/src',
                         get_resource_url(self.env, res, self.env.href))

        repo = Resource('repository', 'repo')
        res = Resource('source', '/trunk/src', parent=repo)
        self.assertEqual('path /trunk/src in repo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/repo/trunk/src',
                         get_resource_url(self.env, res, self.env.href))

        repo = Resource('repository', 'repo')
        res = Resource('source', '/trunk/src', version=42, parent=repo)
        self.assertEqual('path /trunk/src@42 in repo',
                         get_resource_description(self.env, res))
        self.assertEqual('/trac.cgi/browser/repo/trunk/src?rev=42',
                         get_resource_url(self.env, res, self.env.href))
コード例 #20
0
 def get_resource_description(self, resource, format='default',
                              context=None, **kwargs):
     if self.wiki_page_link:
         page = WikiPage(self.env, resource.id)
         if page.exists:
             return get_resource_description(self.env, page.resource,
                                             format, **kwargs)
     rid = to_unicode(resource.id)
     if format in ('compact', 'default'):
         return rid
     else:
         return u'tag:%s' % rid
コード例 #21
0
    def test_global_neighborhood_ticket(self):
        nbh = resource.Neighborhood("global", None)
        data = dict(summary="Ticket summary", description="Ticket description", type="enhancement", status="new")
        target = nbh.child("ticket", self._new_ticket(self.global_env, data))

        self.assertEquals("[global:] Ticket #1", resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] Ticket #1", resource.get_resource_name(self.env, target))
        self.assertEquals("[global:] #1", resource.get_resource_shortname(self.env, target))
        self.assertEquals("enhancement: Ticket summary (new)", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/ticket/1", resource.get_resource_url(self.env, target, self.env.href)
        )
コード例 #22
0
    def test_product_neighborhood_ticket(self):
        nbh = resource.Neighborhood("product", u"xü")
        data = dict(summary="Ticket summary", description="Ticket description", type="task", status="accepted")
        target = nbh.child("ticket", self._new_ticket(self.env1, data))

        self.assertEquals(u"[product:xü] Ticket #1", resource.get_resource_description(self.env, target))
        self.assertEquals(u"[product:xü] Ticket #1", resource.get_resource_name(self.env, target))
        self.assertEquals(u"[product:xü] #1", resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"task: Ticket summary (accepted)", resource.get_resource_summary(self.env, target))
        self.assertEquals(
            "http://example.org/trac.cgi/products/x%C3%BC/ticket/1",
            resource.get_resource_url(self.env, target, self.env.href),
        )
コード例 #23
0
ファイル: resource.py プロジェクト: tsanov/bloodhound
    def test_global_neighborhood_wiki(self):
        target = resource.Neighborhood('global', None).child(self.resource)

        self.assertEquals("TestPage",
                          resource.get_resource_description(self.env, target))
        self.assertEquals("TestPage",
                          resource.get_resource_name(self.env, target))
        self.assertEquals("TestPage",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals("TestPage",
                          resource.get_resource_summary(self.env, target))
        self.assertEquals(
            'http://example.org/trac.cgi/wiki/TestPage?version=2',
            resource.get_resource_url(self.env, target, self.env.href))
コード例 #24
0
ファイル: resource.py プロジェクト: tsanov/bloodhound
    def test_product_neighborhood_report(self):
        target = resource.Neighborhood('product', u'xü').child(self.resource)

        self.assertEquals(u"[product:xü] report:1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals(u"[product:xü] report:1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals(u"[product:xü] report:1",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"[product:xü] report:1 at version None",
                          resource.get_resource_summary(self.env, target))
        self.assertEquals(
            'http://example.org/trac.cgi/products/x%C3%BC/report/1',
            resource.get_resource_url(self.env, target, self.env.href))
コード例 #25
0
ファイル: resource.py プロジェクト: tsanov/bloodhound
    def test_product_neighborhood_wiki(self):
        target = resource.Neighborhood('product', u'xü').child(self.resource)

        self.assertEquals(u"TestPage",
                          resource.get_resource_description(self.env, target))
        self.assertEquals(u"TestPage",
                          resource.get_resource_name(self.env, target))
        self.assertEquals(u"TestPage",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"TestPage",
                          resource.get_resource_summary(self.env, target))
        self.assertEquals(
            'http://example.org/trac.cgi/products/x%C3%BC/wiki/TestPage?version=2',
            resource.get_resource_url(self.env, target, self.env.href))
コード例 #26
0
ファイル: resource.py プロジェクト: mohsadki/dargest
    def test_product_neighborhood_attachments(self):
        target = resource.Neighborhood('product', u'xü').child(self.resource)

        self.assertEquals(u"[product:xü] Attachment 'foo.txt' in [product:xü] Ticket #1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals(u"[product:xü] Attachment 'foo.txt' in [product:xü] Ticket #1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals(u"[product:xü] foo.txt ([product:xü] Ticket #1)",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals('Product Bar',
                          resource.get_resource_summary(self.env, target))
        self.assertEquals('http://example.org/trac.cgi/products/x%C3%BC/attachment/ticket/1/foo.txt',
                          resource.get_resource_url(self.env,
                                                    target, self.env.href))
コード例 #27
0
ファイル: resource.py プロジェクト: mohsadki/dargest
    def test_product_neighborhood_milestone(self):
        target = resource.Neighborhood('product', u'xü').child(self.resource)

        self.assertEquals(u"[product:xü] Milestone milestone1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals(u"[product:xü] Milestone milestone1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals(u"milestone1",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"[product:xü] Milestone milestone1",
                          resource.get_resource_summary(self.env, target))
        self.assertEquals('http://example.org/trac.cgi/products/x%C3%BC/milestone/milestone1',
                          resource.get_resource_url(self.env,
                                                    target, self.env.href))
コード例 #28
0
ファイル: resource.py プロジェクト: mohsadki/dargest
    def test_global_neighborhood_attachments(self):
        target = resource.Neighborhood('global', None).child(self.resource)

        self.assertEquals("[global:] Attachment 'foo.txt' in [global:] Ticket #1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] Attachment 'foo.txt' in [global:] Ticket #1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals("[global:] foo.txt ([global:] Ticket #1)",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals('Global Bar',
                          resource.get_resource_summary(self.env, target))
        self.assertEquals('http://example.org/trac.cgi/attachment/ticket/1/foo.txt',
                          resource.get_resource_url(self.env,
                                                    target, self.env.href))
コード例 #29
0
ファイル: timeline.py プロジェクト: nagyistoce/trac-downloads
 def render_timeline_event(self, context, field, event):
     # Decompose event data.
     id = event[3]
     # Return apropriate content.
     resource = Resource("downloads", id)
     if field == "url":
         if context.req.perm.has_permission("DOWNLOADS_VIEW", resource):
             return get_resource_url(self.env, resource, context.req.href)
         else:
             return "#"
     elif field == "title":
         return tag("New download ", tag.em(get_resource_name(self.env, resource)), " created")
     elif field == "description":
         return get_resource_description(self.env, resource, "summary")
コード例 #30
0
 def render_timeline_event(self, context, field, event):
     # Decompose event data.
     id = event[3]
     # Return apropriate content.
     resource = Resource('downloads', id)
     if field == 'url':
         if context.req.perm.has_permission('DOWNLOADS_VIEW', resource):
             return get_resource_url(self.env, resource, context.req.href)
         else:
             return '#'
     elif field == 'title':
         return tag('New download ', tag.em(get_resource_name(self.env, resource)), ' created')
     elif field == 'description':
         return get_resource_description(self.env, resource, 'summary')
コード例 #31
0
ファイル: resource.py プロジェクト: tsanov/bloodhound
    def test_global_neighborhood_report(self):
        target = resource.Neighborhood('global', None).child(self.resource)

        self.assertEquals("[global:] report:1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] report:1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals("[global:] report:1",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals('[global:] report:1 at version None',
                          resource.get_resource_summary(self.env, target))
        self.assertEquals(
            'http://example.org/trac.cgi/report/1',
            resource.get_resource_url(self.env, target, self.env.href))
コード例 #32
0
ファイル: resource.py プロジェクト: tsanov/bloodhound
    def test_global_neighborhood_milestone(self):
        target = resource.Neighborhood('global', None).child(self.resource)

        self.assertEquals("[global:] Milestone milestone1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] Milestone milestone1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals("milestone1",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals("[global:] Milestone milestone1",
                          resource.get_resource_summary(self.env, target))
        self.assertEquals(
            'http://example.org/trac.cgi/milestone/milestone1',
            resource.get_resource_url(self.env, target, self.env.href))
コード例 #33
0
ファイル: resource.py プロジェクト: tsanov/bloodhound
    def test_product_neighborhood_attachments(self):
        target = resource.Neighborhood('product', u'xü').child(self.resource)

        self.assertEquals(
            u"[product:xü] Attachment 'foo.txt' in [product:xü] Ticket #1",
            resource.get_resource_description(self.env, target))
        self.assertEquals(
            u"[product:xü] Attachment 'foo.txt' in [product:xü] Ticket #1",
            resource.get_resource_name(self.env, target))
        self.assertEquals(u"[product:xü] foo.txt ([product:xü] Ticket #1)",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals('Product Bar',
                          resource.get_resource_summary(self.env, target))
        self.assertEquals(
            'http://example.org/trac.cgi/products/x%C3%BC/attachment/ticket/1/foo.txt',
            resource.get_resource_url(self.env, target, self.env.href))
コード例 #34
0
ファイル: timeline.py プロジェクト: nyuhuhuu/trachacks
    def render_timeline_event(self, context, field, event):
        # Decompose event data.
        id = event[3]

        # Return apropriate content.
        resource = Resource('downloads', id)
        if field == 'url':
           if context.req.perm.has_permission('DOWNLOADS_VIEW', resource):
               return get_resource_url(self.env, resource, context.req.href)
           else:
               return '#'
        elif field == 'title':
           return tag('New download ', tag.em(get_resource_name(self.env,
             resource)), ' created')
        elif field == 'description':
           return get_resource_description(self.env, resource, 'summary')
コード例 #35
0
ファイル: resource.py プロジェクト: tsanov/bloodhound
    def test_global_neighborhood_attachments(self):
        target = resource.Neighborhood('global', None).child(self.resource)

        self.assertEquals(
            "[global:] Attachment 'foo.txt' in [global:] Ticket #1",
            resource.get_resource_description(self.env, target))
        self.assertEquals(
            "[global:] Attachment 'foo.txt' in [global:] Ticket #1",
            resource.get_resource_name(self.env, target))
        self.assertEquals("[global:] foo.txt ([global:] Ticket #1)",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals('Global Bar',
                          resource.get_resource_summary(self.env, target))
        self.assertEquals(
            'http://example.org/trac.cgi/attachment/ticket/1/foo.txt',
            resource.get_resource_url(self.env, target, self.env.href))
コード例 #36
0
ファイル: resource.py プロジェクト: mohsadki/dargest
    def test_global_neighborhood_ticket(self):
        nbh = resource.Neighborhood('global', None)
        data = dict(summary='Ticket summary', description='Ticket description',
                    type='enhancement', status='new')
        target = nbh.child('ticket', self._new_ticket(self.global_env, data))

        self.assertEquals("[global:] Ticket #1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] Ticket #1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals("[global:] #1",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals('enhancement: Ticket summary (new)',
                          resource.get_resource_summary(self.env, target))
        self.assertEquals('http://example.org/trac.cgi/ticket/1',
                          resource.get_resource_url(self.env,
                                                    target, self.env.href))
コード例 #37
0
ファイル: resource.py プロジェクト: mohsadki/dargest
    def test_product_neighborhood_ticket(self):
        nbh = resource.Neighborhood('product', u'xü')
        data = dict(summary='Ticket summary', description='Ticket description',
                    type='task', status='accepted')
        target = nbh.child('ticket', self._new_ticket(self.env1, data))

        self.assertEquals(u"[product:xü] Ticket #1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals(u"[product:xü] Ticket #1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals(u"[product:xü] #1",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"task: Ticket summary (accepted)",
                          resource.get_resource_summary(self.env, target))
        self.assertEquals('http://example.org/trac.cgi/products/x%C3%BC/ticket/1',
                          resource.get_resource_url(self.env,
                                                    target, self.env.href))
コード例 #38
0
ファイル: resource.py プロジェクト: tsanov/bloodhound
    def test_global_neighborhood_ticket(self):
        nbh = resource.Neighborhood('global', None)
        data = dict(summary='Ticket summary',
                    description='Ticket description',
                    type='enhancement',
                    status='new')
        target = nbh.child('ticket', self._new_ticket(self.global_env, data))

        self.assertEquals("[global:] Ticket #1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals("[global:] Ticket #1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals("[global:] #1",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals('enhancement: Ticket summary (new)',
                          resource.get_resource_summary(self.env, target))
        self.assertEquals(
            'http://example.org/trac.cgi/ticket/1',
            resource.get_resource_url(self.env, target, self.env.href))
コード例 #39
0
ファイル: resource.py プロジェクト: tsanov/bloodhound
    def test_product_neighborhood_ticket(self):
        nbh = resource.Neighborhood('product', u'xü')
        data = dict(summary='Ticket summary',
                    description='Ticket description',
                    type='task',
                    status='accepted')
        target = nbh.child('ticket', self._new_ticket(self.env1, data))

        self.assertEquals(u"[product:xü] Ticket #1",
                          resource.get_resource_description(self.env, target))
        self.assertEquals(u"[product:xü] Ticket #1",
                          resource.get_resource_name(self.env, target))
        self.assertEquals(u"[product:xü] #1",
                          resource.get_resource_shortname(self.env, target))
        self.assertEquals(u"task: Ticket summary (accepted)",
                          resource.get_resource_summary(self.env, target))
        self.assertEquals(
            'http://example.org/trac.cgi/products/x%C3%BC/ticket/1',
            resource.get_resource_url(self.env, target, self.env.href))
コード例 #40
0
ファイル: web_ui.py プロジェクト: pombredanne/trachacks
    def get_search_results(self, req, terms, filters):
        if not 'form' in filters:
            return
        env = self.env
        results = self.search_tracforms(env, terms)

        for id, realm, parent, subctxt, state, author, updated_on in results:
            # DEVEL: support for handling form revisions not implemented yet
            #form = Form(env, realm, parent, subctxt, id, version)
            form = Form(env, realm, parent, subctxt, id)
            if 'FORM_VIEW' in req.perm(form):
                form = form.resource
                # build a more human-readable form values representation,
                # especially with unicode character escapes removed
                state = _render_values(state)
                yield (get_resource_url(env, form, req.href),
                       get_resource_description(env, form),
                       to_datetime(updated_on), author,
                       shorten_result(state, terms))
コード例 #41
0
ファイル: web_ui.py プロジェクト: pombredanne/trachacks
 def _do_switch(self, env, req, form):
     data = {}
     data['page_title'] = get_resource_description(env, form.resource,
                                                   href=req.href)
     data['title'] = get_resource_shortname(env, form.resource)
     data['siblings'] = []
     for sibling in form.siblings:
         form_id = tag.strong(tag.a(_("Form %(form_id)s",
                                      form_id=sibling[0]),
                                      href=req.href.form(sibling[0])))
         if sibling[1] == '':
             data['siblings'].append(form_id)
         else:
             # TRANSLATOR: Form list entry for form select page
             data['siblings'].append(tag_(
                           "%(form_id)s (subcontext = '%(subcontext)s')",
                           form_id=form_id, subcontext = sibling[1]))
     add_stylesheet(req, 'tracforms/tracforms.css')
     return 'switch.html', data, None
コード例 #42
0
ファイル: __init__.py プロジェクト: lkraav/trachacks
    def _format_name(self, req, url):
        linkname = url
        name = ""
        missing = False

        path_info = url
        query_string = ''
        idx = path_info.find('?')
        if idx >= 0:
            path_info, query_string = path_info[:idx], path_info[idx:]
        href = req.href(path_info) + query_string

        args = arg_list_to_args(parse_arg_list(query_string.lstrip('?')))
        version = args.get('version', False)

        path = path_info.strip('/').split('/')
        realm = path[0]
        class_ = realm
        if len(path) > 1:
            resource = Resource(realm, path[1])
            if resource:
                if realm == 'ticket':
                    linkname = get_resource_shortname(self.env, resource)
                    try:
                        name = get_resource_summary(self.env, resource)
                    except ResourceNotFound:
                        missing = True
                    else:
                        from trac.ticket.model import Ticket
                        class_ = Ticket(self.env, resource.id)['status'] + \
                            ' ' + class_
                elif realm == 'milestone':
                    linkname = get_resource_name(self.env, resource)
                elif realm == 'wiki':
                    resource = Resource(realm, '/'.join(path[1:]), version)
                    linkname = get_resource_shortname(self.env, resource)
                    if version:
                        linkname += '@' + version
                elif realm == 'report':
                    linkname = "{%s}" % path[1]
                    name = self._format_report_name(path[1])
                elif realm == 'changeset':
                    rev = path[1]
                    parent = Resource('source', '/'.join(path[2:]))
                    resource = Resource(realm, rev, False, parent)
                    linkname = "[%s]" % rev
                    name = get_resource_description(self.env, resource)
                elif realm == 'browser':
                    parent = Resource('source', path[1])
                    resource = Resource('source', '/'.join(path[2:]), False, parent)
                    linkname = get_resource_description(self.env, resource)
                    name = get_resource_summary(self.env, resource)
                elif realm == 'attachment':
                    # Assume a file and check existence
                    parent = Resource(path[1], '/'.join(path[2:-1]))
                    resource = Resource(realm, path[-1], parent=parent)
                    linkname = get_resource_name(self.env, resource)
                    if not resource_exists(self.env, resource):
                        # Assume an attachment list page and check existence
                        parent = Resource(path[1], '/'.join(path[2:]))
                        if resource_exists(self.env, parent):
                            resource = Resource(realm, parent=parent)
                            linkname = get_resource_name(self.env, resource)
                            if not query_string:
                                # Trailing slash needed for Trac < 1.0, t:#10280
                                href += '/'
                        else:
                            # Assume it's a missing attachment
                            missing = True
                else:
                    linkname = get_resource_shortname(self.env, resource)
                    name = get_resource_summary(self.env, resource)
        elif len(path) == 1 and path[0] and path[0] != 'wiki':
            linkname = path[0].capitalize()
        else:
            class_ = 'wiki'
            linkname = 'WikiStart'

        if missing:
            href = None
            class_ = 'missing ' + realm

        return {
            'class_': class_,
            'href': href,
            'linkname': linkname,
            'name': name,
            'delete': req.href.bookmark('delete_in_page', url),
        }
コード例 #43
0
    def _format_name(self, req, url):
        linkname = url
        name = ""
        missing = False

        path_info = url
        query_string = ''
        idx = path_info.find('?')
        if idx >= 0:
            path_info, query_string = path_info[:idx], path_info[idx:]
        href = req.href(path_info) + query_string

        args = arg_list_to_args(parse_arg_list(query_string.lstrip('?')))
        version = args.get('version', False)

        path = path_info.strip('/').split('/')
        realm = path[0]
        class_ = realm
        if len(path) > 1:
            resource = Resource(realm, path[1])
            if resource:
                if realm == 'ticket':
                    linkname = get_resource_shortname(self.env, resource)
                    try:
                        name = get_resource_summary(self.env, resource)
                    except ResourceNotFound:
                        missing = True
                    else:
                        from trac.ticket.model import Ticket
                        class_ = Ticket(self.env, resource.id)['status'] + \
                            ' ' + class_
                elif realm == 'milestone':
                    linkname = get_resource_name(self.env, resource)
                elif realm == 'wiki':
                    resource = Resource(realm, '/'.join(path[1:]), version)
                    linkname = get_resource_shortname(self.env, resource)
                    if version:
                        linkname += '@' + version
                elif realm == 'report':
                    linkname = "{%s}" % path[1]
                    name = self._format_report_name(path[1])
                elif realm == 'changeset':
                    rev = path[1]
                    parent = Resource('source', '/'.join(path[2:]))
                    resource = Resource(realm, rev, False, parent)
                    linkname = "[%s]" % rev
                    name = get_resource_description(self.env, resource)
                elif realm == 'browser':
                    rm = RepositoryManager(self.env)
                    reponame, repos, path = rm.get_repository_by_path('/'.join(
                        path[1:]))
                    parent = Resource('source', reponame)
                    resource = Resource('source', path, False, parent)
                    linkname = get_resource_description(self.env, resource)
                    name = get_resource_summary(self.env, resource)
                elif realm == 'attachment':
                    # Assume a file and check existence
                    parent = Resource(path[1], '/'.join(path[2:-1]))
                    resource = Resource(realm, path[-1], parent=parent)
                    linkname = get_resource_name(self.env, resource)
                    if not resource_exists(self.env, resource):
                        # Assume an attachment list page and check existence
                        parent = Resource(path[1], '/'.join(path[2:]))
                        if resource_exists(self.env, parent):
                            resource = Resource(realm, parent=parent)
                            linkname = get_resource_name(self.env, resource)
                            if not query_string:
                                # Trailing slash needed for Trac < 1.0, t:#10280
                                href += '/'
                        else:
                            # Assume it's a missing attachment
                            missing = True
                else:
                    linkname = get_resource_shortname(self.env, resource)
                    name = get_resource_summary(self.env, resource)
        elif len(path) == 1 and path[0] and path[0] != 'wiki':
            linkname = path[0].capitalize()
        else:
            class_ = 'wiki'
            linkname = 'WikiStart'

        if missing:
            href = None
            class_ = 'missing ' + realm

        return {
            'class_': class_,
            'href': href,
            'linkname': linkname,
            'name': name,
            'delete': req.href.bookmark('delete_in_page', url),
        }
コード例 #44
0
ファイル: api.py プロジェクト: tsanov/bloodhound
 def test_resource_repository(self):
     res = Resource('repository', 'testrepo')
     self.assertEqual('Repository testrepo',
                      get_resource_description(self.env, res))
     self.assertEqual('/trac.cgi/products/tp1/browser/testrepo',
                      get_resource_url(self.env, res, self.env.href))
コード例 #45
0
ファイル: macros.py プロジェクト: pombredanne/trachacks
    def expand_macro(self, formatter, name, content):
        env = self.env
        req = formatter.req
        args, kw = parse_args(content)

        # Use macro arguments (most likely wiki macro calls).
        realms = 'realm' in kw and kw['realm'].split('|') or []
        tag_system = TagSystem(env)
        all_realms = [p.get_taggable_realm() for p in tag_system.tag_providers]
        self.all_realms = all_realms
        self.realms = realms

        if name == 'TagCloud':
            args.append(' or '.join(['realm:%s' % r for r in realms]))
            all_tags = tag_system.get_all_tags(req, ' '.join(args))
            mincount = 'mincount' in kw and kw['mincount'] or None
            return self.render_cloud(req,
                                     all_tags,
                                     caseless_sort=self.caseless_sort,
                                     mincount=mincount)
        elif name == 'ListTagged':
            if _OBSOLETE_ARGS_RE.search(content):
                data = {'warning': 'obsolete_args'}
            else:
                data = {'warning': None}
            context = formatter.context
            # Use TagsQuery arguments (most likely wiki macro calls).
            cols = 'cols' in kw and kw['cols'] or self.default_cols
            format = 'format' in kw and kw['format'] or self.default_format
            query = args and args[0].strip() or None
            if query and not realms:
                # First read query arguments (most likely a web-UI call).
                for realm in all_realms:
                    if re.search('(^|\W)realm:%s(\W|$)' % (realm), query):
                        realms = realms and realms.append(realm) or [realm]
            if not realms:
                # Apply ListTagged defaults to macro call w/o realm.
                realms = list(set(all_realms) - set(self.exclude_realms))
            if not realms:
                return ''
            else:
                self.query = query
                self.realms = realms
            query = '(%s) (%s)' % (query or '', ' or '.join(
                ['realm:%s' % (r) for r in realms]))
            env.log.debug('LISTTAGGED_QUERY: ' + query)
            query_result = tag_system.query(req, query)
            if not query_result:
                return ''

            def _link(resource):
                if resource.realm == 'tag':
                    # Keep realm selection in tag links.
                    return builder.a(resource.id,
                                     href=self.get_href(req, tag=resource))
                elif resource.realm == 'ticket':
                    # Return resource link including ticket status dependend
                    #   class to allow for common Trac ticket link style.
                    ticket = Ticket(env, resource.id)
                    return builder.a('#%s' % ticket.id,
                                     class_=ticket['status'],
                                     href=formatter.href.ticket(ticket.id),
                                     title=shorten_line(ticket['summary']))
                return render_resource_link(env, context, resource, 'compact')

            if format == 'table':
                cols = [
                    col for col in cols.split('|')
                    if col in self.supported_cols
                ]
                # Use available translations from Trac core.
                try:
                    labels = TicketSystem(env).get_ticket_field_labels()
                    labels['id'] = _('Id')
                except AttributeError:
                    # Trac 0.11 neither has the attribute nor uses i18n.
                    labels = {'id': 'Id', 'description': 'Description'}
                labels['realm'] = _('Realm')
                labels['tags'] = _('Tags')
                headers = [{'label': labels.get(col)} for col in cols]
                data.update({'cols': cols, 'headers': headers})

            results = sorted(query_result, key=lambda r: \
                             embedded_numbers(to_unicode(r[0].id)))
            results = self._paginate(req, results)
            rows = []
            for resource, tags in results:
                desc = tag_system.describe_tagged_resource(req, resource)
                tags = sorted(tags)
                if tags:
                    rendered_tags = [
                        _link(Resource('tag', tag)) for tag in tags
                    ]
                    if 'oldlist' == format:
                        resource_link = _link(resource)
                    else:
                        desc = desc or \
                               get_resource_description(env, resource,
                                                        context=context)
                        resource_link = builder.a(desc,
                                                  href=get_resource_url(
                                                      env, resource,
                                                      context.href))
                        if 'table' == format:
                            cells = []
                            for col in cols:
                                if col == 'id':
                                    cells.append(_link(resource))
                                # Don't duplicate links to resource in both.
                                elif col == 'description' and 'id' in cols:
                                    cells.append(desc)
                                elif col == 'description':
                                    cells.append(resource_link)
                                elif col == 'realm':
                                    cells.append(resource.realm)
                                elif col == 'tags':
                                    cells.append(
                                        builder([(tag, ' ')
                                                 for tag in rendered_tags]))
                            rows.append({'cells': cells})
                            continue
                rows.append({
                    'desc': desc,
                    'rendered_tags': None,
                    'resource_link': _link(resource)
                })
            data.update({
                'format': format,
                'paginator': results,
                'results': rows,
                'tags_url': req.href('tags')
            })

            # Work around a bug in trac/templates/layout.html, that causes a
            # TypeError for the wiki macro call, if we use add_link() alone.
            add_stylesheet(req, 'common/css/search.css')

            return Chrome(env).render_template(req, 'listtagged_results.html',
                                               data, 'text/html', True)
コード例 #46
0
ファイル: api.py プロジェクト: thimalk/bloodhound
 def test_resource_repository(self):
     res = Resource('repository', 'testrepo')
     self.assertEqual('Repository testrepo',
                      get_resource_description(self.env, res))
     self.assertEqual('/trac.cgi/products/tp1/browser/testrepo',
                      get_resource_url(self.env, res, self.env.href))
コード例 #47
0
    def expand_macro(self, formatter, name, content):
        env = formatter.env
        req = formatter.req
        if not 'VOTE_VIEW' in req.perm:
            return
        # Simplify function calls.
        format_author = partial(Chrome(self.env).format_author, req)
        if not content:
            args = []
            compact = None
            kw = {}
            top = 5
        else:
            args, kw = parse_args(content)
            compact = 'compact' in args and True
            top = as_int(kw.get('top'), 5, min=0)

        if name == 'LastVoted':
            lst = tag.ul()
            for i in self.get_votes(req, top=top):
                resource = Resource(i[0], i[1])
                # Anotate who and when.
                voted = (
                    'by %s at %s' %
                    (format_author(i[3]), format_datetime(to_datetime(i[4]))))
                lst(
                    tag.li(
                        tag.a(get_resource_description(
                            env, resource, compact and 'compact' or 'default'),
                              href=get_resource_url(env, resource,
                                                    formatter.href),
                              title=(compact and '%+i %s' % (i[2], voted)
                                     or None)),
                        (not compact and Markup(' %s %s' %
                                                (tag.b('%+i' % i[2]), voted))
                         or '')))
            return lst

        elif name == 'TopVoted':
            realm = kw.get('realm')
            lst = tag.ul()
            for i in self.get_top_voted(req, realm=realm, top=top):
                if 'up-only' in args and i[2] < 1:
                    break
                resource = Resource(i[0], i[1])
                lst(
                    tag.li(
                        tag.a(get_resource_description(
                            env, resource, compact and 'compact' or 'default'),
                              href=get_resource_url(env, resource,
                                                    formatter.href),
                              title=(compact and '%+i' % i[2] or None)),
                        (not compact and ' (%+i)' % i[2] or '')))
            return lst

        elif name == 'VoteList':
            lst = tag.ul()
            resource = resource_from_path(env, req.path_info)
            for i in self.get_votes(req, resource, top=top):
                vote = ('at %s' % format_datetime(to_datetime(i[4])))
                lst(
                    tag.li(compact and format_author(i[3]) or Markup(
                        u'%s by %s %s' %
                        (tag.b('%+i' % i[2]), tag(format_author(i[3])), vote)),
                           title=(compact and '%+i %s' % (i[2], vote)
                                  or None)))
            return lst
コード例 #48
0
ファイル: macros.py プロジェクト: nyuhuhuu/trachacks
    def expand_macro(self, formatter, name, content):
        env = self.env
        req = formatter.req
        args, kw = parse_args(content)

        # Use macro arguments (most likely wiki macro calls).
        realms = 'realm' in kw and kw['realm'].split('|') or []
        tag_system = TagSystem(env)
        all_realms = [p.get_taggable_realm()
                      for p in tag_system.tag_providers]
        self.all_realms = all_realms
        self.realms = realms

        if name == 'TagCloud':
            args.append(' or '.join(['realm:%s' % r for r in realms]))
            all_tags = tag_system.get_all_tags(req, ' '.join(args))
            mincount = 'mincount' in kw and kw['mincount'] or None
            return self.render_cloud(req, all_tags,
                                     caseless_sort=self.caseless_sort,
                                     mincount=mincount)
        elif name == 'ListTagged':
            if _OBSOLETE_ARGS_RE.search(content):
                data = {'warning': 'obsolete_args'}
            else:
                data = {'warning': None}
            context=formatter.context
            # Use TagsQuery arguments (most likely wiki macro calls).
            cols = 'cols' in kw and kw['cols'] or self.default_cols
            format = 'format' in kw and kw['format'] or self.default_format
            query = args and args[0].strip() or None
            if query and not realms:
                # First read query arguments (most likely a web-UI call).
                for realm in all_realms:
                    if re.search('(^|\W)realm:%s(\W|$)' % (realm), query):
                        realms = realms and realms.append(realm) or [realm]
            if not realms:
                # Apply ListTagged defaults to macro call w/o realm.
                realms = list(set(all_realms)-set(self.exclude_realms))
            if not realms:
                return ''
            else:
                self.query = query
                self.realms = realms
            query = '(%s) (%s)' % (query or '', ' or '.join(['realm:%s' % (r)
                                                             for r in realms]))
            env.log.debug('LISTTAGGED_QUERY: ' + query)
            query_result = tag_system.query(req, query)
            if not query_result:
                return ''

            def _link(resource):
                if resource.realm == 'tag':
                    # Keep realm selection in tag links.
                    return builder.a(resource.id,
                                     href=self.get_href(req, tag=resource))
                elif resource.realm == 'ticket':
                    # Return resource link including ticket status dependend
                    #   class to allow for common Trac ticket link style.
                    ticket = Ticket(env, resource.id)
                    return builder.a('#%s' % ticket.id,
                                     class_=ticket['status'],
                                     href=formatter.href.ticket(ticket.id),
                                     title=shorten_line(ticket['summary']))
                return render_resource_link(env, context, resource, 'compact')

            if format == 'table':
                cols = [col for col in cols.split('|')
                        if col in self.supported_cols]
                # Use available translations from Trac core.
                try:
                    labels = TicketSystem(env).get_ticket_field_labels()
                    labels['id'] = _('Id')
                except AttributeError:
                    # Trac 0.11 neither has the attribute nor uses i18n.
                    labels = {'id': 'Id', 'description': 'Description'}
                labels['realm'] = _('Realm')
                labels['tags'] = _('Tags')
                headers = [{'label': labels.get(col)}
                           for col in cols]
                data.update({'cols': cols,
                             'headers': headers})

            results = sorted(query_result, key=lambda r: \
                             embedded_numbers(to_unicode(r[0].id)))
            results = self._paginate(req, results)
            rows = []
            for resource, tags in results:
                desc = tag_system.describe_tagged_resource(req, resource)
                tags = sorted(tags)
                if tags:
                    rendered_tags = [_link(Resource('tag', tag))
                                     for tag in tags]
                    if 'oldlist' == format:
                        resource_link = _link(resource)
                    else:
                        desc = desc or \
                               get_resource_description(env, resource,
                                                        context=context)
                        resource_link = builder.a(desc, href=get_resource_url(
                                                  env, resource, context.href))
                        if 'table' == format:
                            cells = []
                            for col in cols:
                                if col == 'id':
                                    cells.append(_link(resource))
                                # Don't duplicate links to resource in both.
                                elif col == 'description' and 'id' in cols:
                                    cells.append(desc)
                                elif col == 'description':
                                    cells.append(resource_link)
                                elif col == 'realm':
                                    cells.append(resource.realm)
                                elif col == 'tags':
                                    cells.append(
                                        builder([(tag, ' ')
                                                 for tag in rendered_tags]))
                            rows.append({'cells': cells})
                            continue
                rows.append({'desc': desc,
                             'rendered_tags': None,
                             'resource_link': _link(resource)})
            data.update({'format': format,
                         'paginator': results,
                         'results': rows,
                         'tags_url': req.href('tags')})

            # Work around a bug in trac/templates/layout.html, that causes a
            # TypeError for the wiki macro call, if we use add_link() alone.
            add_stylesheet(req, 'common/css/search.css')

            return Chrome(env).render_template(
                req, 'listtagged_results.html', data, 'text/html', True)