Skip Menu |

This queue is for tickets about the Text-Trac CPAN distribution.

Report information
The Basics
Id: 34805
Status: resolved
Priority: 0/
Queue: Text-Trac

People
Owner: Nobody in particular
Requestors: clsung [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Trac link for Comments
Hi, I'd like to add one more file lib/Text/Trac/LinkResolver/Comment.pm to handle 'comment:ticket:<ticketId>:<commentId>' package Text::Trac::LinkResolver::Comment; use strict; use base qw( Text::Trac::LinkResolver ); sub init { my $self = shift; $self->{pattern} = '!?(?<!&)comment:ticket:\d+:\d+'; } sub format_link { my ( $self, $match, $target, $label ) = @_; return $match if $self->_is_disabled; my $c = $self->{context}; $label ||= $match; my ( $rev,$commentId ) = ( $match =~ m/(\d+):(\d+)/ ); my $url = $c->{trac_ticket_url} || $c->trac_url . 'ticket/'; $url .= $rev; $url .= "#$commentId"; return sprintf '<a class="ticket" href="%s">%s</a>', $url, $label; } 1; And here is the test I append in t/03-trac-links.t ### comment link test 1 --- input comment:ticket:1:8 --- expected <p> <a class="ticket" href="http://trac.mizzy.org/public/ticket/1#8">comment:ticket:1:8</a> </p>
在 2008-04-09 22:37:47 星期三 時,CLSUNG 寫到: Show quoted text
> Hi, I'd like to add one more file lib/Text/Trac/LinkResolver/Comment.pm > to handle 'comment:ticket:<ticketId>:<commentId>' > > > package Text::Trac::LinkResolver::Comment; > > use strict; > use base qw( Text::Trac::LinkResolver ); > > sub init { > my $self = shift; > $self->{pattern} = '!?(?<!&)comment:ticket:\d+:\d+'; > } > > sub format_link { > my ( $self, $match, $target, $label ) = @_; > return $match if $self->_is_disabled; > > my $c = $self->{context}; > $label ||= $match; > my ( $rev,$commentId ) = ( $match =~ m/(\d+):(\d+)/ ); > > my $url = $c->{trac_ticket_url} || $c->trac_url . 'ticket/'; > $url .= $rev; > $url .= "#$commentId"; > return sprintf '<a class="ticket" href="%s">%s</a>', $url, $label; > } > > 1; > > > And here is the test I append in t/03-trac-links.t > > ### comment link test 1 > --- input > comment:ticket:1:8 > --- expected > <p> > <a class="ticket" > href="http://trac.mizzy.org/public/ticket/1#8">comment:ticket:1:8</a> > </p>
sorry about typo, $url .= "#$commentId"; should be $url .= "#comment:$commentId";
Thanks for your patch.I applied it and released Text-Trac 0.12.