File: Source.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 (25 lines) | stat: -rw-r--r-- 555 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
24
25
package Text::Trac::LinkResolver::Source;

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

sub init {
    my $self = shift;
}

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

    my $c = $self->{context};
    $label ||= $match;
    my ( $file, $rev ) = ( $target =~ m/([^#]+)(?:#(\d+))?/ );

    my $url = $c->{trac_source_url} || $c->trac_url . "browser/";
    $url .= $file;
    $url .= "?rev=$rev" if $rev;

    return sprintf '<a class="source" href="%s">%s</a>', $url, $label;
}

1;