File: Attachment.pm

package info (click to toggle)
libtext-trac-perl 0.16-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 364 kB
  • ctags: 257
  • sloc: perl: 2,971; makefile: 2
file content (26 lines) | stat: -rwxr-xr-x 602 bytes parent folder | download
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
26
package Text::Trac::LinkResolver::Attachment;

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

our $VERSION = '0.16';

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 ( $type, $name, $file ) = ( $match =~ m/attachment:([^:]+):([^:]+):([^:\]\s]+)/ );
    my $url = $c->{trac_attachment_url} || $c->trac_url . "attachment/";
    $url .= "$type/$name/$file";

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

1;