line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Urlizetrunc; |
2
|
2
|
|
|
2
|
|
789
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
46
|
|
3
|
2
|
|
|
2
|
|
8
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
4
|
2
|
|
|
2
|
|
39
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
56
|
|
5
|
2
|
|
|
2
|
|
9
|
use parent 'DTL::Fast::Filter::Urlize'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{urlizetrunc} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#@Override |
10
|
|
|
|
|
|
|
sub parse_parameters |
11
|
|
|
|
|
|
|
{ |
12
|
9
|
|
|
9
|
0
|
13
|
my $self = shift; |
13
|
|
|
|
|
|
|
die $self->get_parse_error("no max size specified") |
14
|
9
|
50
|
|
|
|
15
|
if (not scalar @{$self->{parameter}}); |
|
9
|
|
|
|
|
25
|
|
15
|
9
|
|
|
|
|
16
|
$self->{maxsize} = $self->{parameter}->[0]; |
16
|
9
|
|
|
|
|
23
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#@Override |
20
|
|
|
|
|
|
|
sub filter |
21
|
|
|
|
|
|
|
{ |
22
|
9
|
|
|
9
|
0
|
21
|
my ($self, $filter_manager, $value, $context ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
9
|
|
|
|
|
26
|
$self->{size} = $self->{maxsize}->render($context); |
25
|
9
|
|
|
|
|
29
|
return $self->SUPER::filter($filter_manager, $value, $context); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#@Override |
29
|
|
|
|
|
|
|
sub normalize_text |
30
|
|
|
|
|
|
|
{ |
31
|
10
|
|
|
10
|
0
|
22
|
my ($self, $text) = @_; |
32
|
|
|
|
|
|
|
|
33
|
10
|
50
|
|
|
|
34
|
if (length $text > $self->{size}) |
34
|
|
|
|
|
|
|
{ |
35
|
10
|
|
|
|
|
24
|
$text = substr $text, 0, $self->{size}; |
36
|
10
|
|
|
|
|
43
|
$text =~ s/\s*$/.../s; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
10
|
|
|
|
|
132
|
return $text; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |