File: Log.pm

package info (click to toggle)
libtext-trac-perl 0.12-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 320 kB
  • ctags: 234
  • sloc: perl: 2,742; makefile: 40
file content (23 lines) | stat: -rw-r--r-- 577 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package Text::Trac::LinkResolver::Log;

use strict;
use base qw( Text::Trac::LinkResolver );

sub init {
    my $self = shift;
    $self->{pattern} = '!?\[\d+:\d+\]|(?:\b|!)r\d+:\d+\b';
}

sub format_link {
    my ( $self, $match, $target, $label ) = @_;
    return $match if $self->_is_disabled;

    my $c = $self->{context};
    $label ||= $match;
    my ( $from, $to ) = ( $match =~ m/(\d+):(\d+)/ );

    my $url = $c->{trac_log_url} || $c->trac_url . "log/";
    return sprintf '<a class="source" href="%s?rev=%s&amp;stop_rev=%s">%s</a>', $url, $to, $from, $label;
}

1;