On Jan 28, 1:45 am, Torbjörn Svensson
<[email protected]> wrote:
> Hi Scott!
>
> Quoting sbamford <[email protected]>:
>
> > And also, is my plugin at the moment going to be doing what I want
> > it to be doing (assuming I have wiki formatting turned on for the
> > field)?
>
> For documentation, I have no real answer except that you would
> probably want to take a look at genshi. I think you want something
> like this, but please note that this is written from my head with
> your example as input.
>
> Good luck!
> Torbj rn Svensson
>
> class InterLinksPlugin(Component):
>    implements(ITemplateStreamFilter)
>
>    fname = 'reviewno'
>
>    # ITemplateStreamFilter methods
>    def filter_stream(self, req, method, filename, stream, data):
>      # this is shamelessly stollen from MasterTickets and modified
>      # for one field only
>
>      # We try all at the same time to maybe catch also changed or
>      # processed templates
>      if data and filename in ["report_view.html", "query_results.html",
>                               "ticket.html", "query.html"]:
>        # For ticket.html
>        if 'fields' in data and isinstance(data['fields'], list):
>          for field in data['fields']:
>            if field['name'] == self.fname and data['ticket'][self.fname]:
>              field['rendered'] = self._make_link(data['ticket'][self.fname])
>      return stream
>
>    def _make_link(self, val):
>      items = [tag.a('%d' % i, href='http://reviews.sw/r%d'% i),
>               title='Review %d' % i) for i in re.findall(r'\d+', val)]
>      if items:
>        return tag(items)
>      return None
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.

Hi Torbjörn

That code of yours works really well, thanks a lot!

Scott

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-users?hl=en.

Reply via email to