Example #1
0
    def _process_view(self, req, stream, method, tags):
        stage = 1
        div_count = 1

        def tag_data():
            engine = TagEngine(self.env)
            for t in tags:
                href, title = engine.get_tag_link(t)
                yield t, href, title

        elm = tag.ul(tags and tag.lh('Tags'), [
            tag.li(tag.a(t, href=href, title=title), ' ')
            for t, href, title in tag_data()
        ],
                     class_='tags')

        for kind, data, pos in stream:
            yield kind, data, pos
            if stage == 1 and \
               kind is START and \
               data[0].localname == 'div' and \
               'wikipage' in data[1].get('class', ''):
                stage = 2
            elif stage == 2:
                if kind is START and data[0].localname == 'div':
                    div_count += 1
                elif kind is END and data.localname == 'div':
                    div_count -= 1

                if not div_count:
                    for e in elm.generate():
                        yield e
                    stage = None
Example #2
0
    def filter_stream(self, req, method, filename, stream, data):
        crumbs = self._get_crumbs(req.session)
        if not crumbs:
            return stream

        add_stylesheet(req, 'breadcrumbs/css/breadcrumbs.css')
        li = []

        href = req.href(req.base_path)

        for crumb in crumbs:
            realm, resource = crumb.split('/', 1)
            name = resource.replace('_', ' ')

            if realm == "ticket":
                name = "#" + resource
            elif realm != "wiki":
                name = "%s:%s" % (realm, name)

            link = req.href(realm, resource)

            li.append(tag.li(tag.a(
                title=name,
                href=link,
            )(name)))

        insert = tag.ul(class_="nav", id="breadcrumbs")(tag.lh("Breadcrumbs:"),
                                                        li)

        return stream | Transformer('//div[@id="metanav"]/ul').after(insert)
Example #3
0
 def _process_view(self, req, stream, method, tags):
     stage = 1
     div_count = 1
     
     def tag_data():
         engine = TagEngine(self.env)
         for t in tags:
             href, title = engine.get_tag_link(t)
             yield t, href, title
     
     elm = tag.ul(tags and tag.lh('Tags'),
                  [tag.li(tag.a(t, href=href, title=title), ' ') for t, href, title in tag_data()],
                  class_='tags')
                  
     for kind, data, pos in stream:
         yield kind, data, pos
         if stage == 1 and \
            kind is START and \
            data[0].localname == 'div' and \
            'wikipage' in data[1].get('class', ''):
             stage = 2
         elif stage == 2:
             if kind is START and data[0].localname == 'div':
                 div_count += 1
             elif kind is END and data.localname == 'div':
                 div_count -= 1
                 
             if not div_count:
                 for e in elm.generate():
                     yield e
                 stage = None
Example #4
0
    def filter_stream(self, req, method, filename, stream, data):
        crumbs = self._get_crumbs(req.session)
        if not crumbs:
            return stream
            
        add_stylesheet(req, 'breadcrumbs/css/breadcrumbs.css')
        li = []

        href = req.href(req.base_path)
        
        for crumb in crumbs:
            realm, resource = crumb.split('/', 1)
            name = resource.replace('_', ' ')

            if realm == "ticket":
                name = "#" + resource
            elif realm != "wiki":
                name = "%s:%s" % (realm, name)

            link = req.href(realm, resource)
            
            li.append(
                tag.li(
                    tag.a(title=name, href=link,
                    )(name)
                )
            )
            
        insert = tag.ul(class_="nav", id="breadcrumbs")(tag.lh("Breadcrumbs:"), li)

        return stream | Transformer('//div[@id="metanav"]/ul').after(insert)
        
Example #5
0
    def _wiki_view(self, req, stream):
        tags = self._page_tags(req)
        if not tags:
            return stream
        engine = TagEngine(self.env)
        add_stylesheet(req, 'tags/css/tractags.css')
        li = []
        for tag in tags:
            href, title = engine.get_tag_link(tag)
            li.append(T.li(T.a(title=title, href=href)(tag), ' '))

        insert = T.ul(class_='tags')(T.lh('Tags'), li)

        return stream | Transformer('//div[@class="buttons"]').before(insert)
Example #6
0
    def _wiki_view(self, req, stream):
        tags = self._page_tags(req)
        if not tags:
            return stream
        engine = TagEngine(self.env)
        add_stylesheet(req, 'tags/css/tractags.css')
        li = []
        for tag in tags:
            href, title = engine.get_tag_link(tag)
            li.append(T.li(T.a(title=title, href=href)(tag), ' '))

        insert = T.ul(class_='tags')(T.lh('Tags'), li)

        return stream | Transformer('//div[@class="buttons"]').before(insert)