root/lang/perl/Text-Trac/trunk/lib/Text/Trac/LinkResolver/Changeset.pm @ 6066

Revision 6066, 0.6 kB (checked in by mizzy, 6 years ago)

lang/perl/Text-Trac: initial import.

Line 
1package Text::Trac::LinkResolver::Changeset;
2
3use strict;
4use base qw( Text::Trac::LinkResolver );
5
6sub init {
7    my $self = shift;
8    $self->{pattern} = '!?\[\d+\]|(?:\b|!)r\d+\b(?!:\d)';
9}
10
11sub format_link {
12    my ( $self, $match, $target, $label ) = @_;
13    return $match if $self->_is_disabled;
14
15    my $c = $self->{context};
16    $label ||= $match;
17    my ( $rev ) = ( $match =~ m/(\d+)/ );
18
19    my $url = $c->{trac_changeset_url} || $c->trac_url . "changeset/";
20    $url .= $rev;
21    return sprintf '<a class="changeset" href="%s">%s</a>', $url, $label;
22}
23
241;
Note: See TracBrowser for help on using the browser.