File: Ticket.pm

package info (click to toggle)
libtext-trac-perl 0.24-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 712 kB
  • sloc: perl: 1,462; makefile: 10
file content (27 lines) | stat: -rwxr-xr-x 574 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
26
27
package Text::Trac::LinkResolver::Ticket;

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

our $VERSION = '0.24';

sub init {
	my $self = shift;
	$self->{pattern} = '!?(?<!&)\#\d+';
}

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

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

	my $url = $c->{trac_ticket_url} || $c->trac_url . 'ticket/';
	$url .= $rev;
	return sprintf '<a %s href="%s">%s</a>', ( $c->{class} ? q{class="ticket"} : '' ), $url, $label;
}

1;