line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Livedoor::Wiki::Plugin::Inline::URL; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
53
|
use warnings; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
269
|
|
4
|
10
|
|
|
10
|
|
55
|
use strict; |
|
10
|
|
|
|
|
14
|
|
|
10
|
|
|
|
|
284
|
|
5
|
10
|
|
|
10
|
|
45
|
use base qw(Text::Livedoor::Wiki::Plugin::Inline); |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
250
|
|
6
|
10
|
|
|
10
|
|
796
|
use Text::Livedoor::Wiki::Utils; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
84
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->regex( q{((?:http|https|ftp):\/\/[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+)}); |
9
|
|
|
|
|
|
|
__PACKAGE__->n_args(2); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub process { |
12
|
12
|
|
|
12
|
1
|
21
|
my ( $class, $inline, $url ) = @_; |
13
|
12
|
100
|
|
|
|
38
|
return qq|| if Text::Livedoor::Wiki::Utils::is_image_url( $url ); |
14
|
11
|
|
|
|
|
31
|
my $label = $class->_cut( $url ); |
15
|
11
|
|
|
|
|
53
|
return qq{$label}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _cut { |
20
|
11
|
|
|
11
|
|
15
|
my $class= shift; |
21
|
11
|
|
|
|
|
14
|
my $url = shift; |
22
|
11
|
100
|
|
|
|
25
|
if ( length $url > 50 ) { |
23
|
2
|
|
|
|
|
8
|
return substr($url , 0 , 50 ) . '...'; |
24
|
|
|
|
|
|
|
} |
25
|
9
|
|
|
|
|
16
|
return $url; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Text::Livedoor::Wiki::Plugin::Inline::URL - URL Inline Plugin |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
make URL linkable. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
http://wiki.livedoor.com |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 FUNCTION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 process |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 AUTHOR |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
polocky |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |