| 1 | package Text::Livedoor::Wiki::Plugin::Inline::URL; | ||||||||||
| 2 | |||||||||||
| 3 | 10 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 10 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 10 | ▶ | use base qw(Text::Livedoor::Wiki::Plugin::Inline); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 10 | ▶ | use Text::Livedoor::Wiki::Utils; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 10 | __PACKAGE__->regex( q{((?:http|https|ftp):\/\/[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+)}); | |||||||||
| 9 | 10 | __PACKAGE__->n_args(2); | |||||||||
| 10 | |||||||||||
| 11 | 12 | ▶ | sub process { | ||||||||
|
Subroutine
process: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 12 | 12 | my ( $class, $inline, $url ) = @_; | |||||||||
| 13 | 12 | ▶ | return qq|<a href="$url"><img src="$url" border="0"/></a>| if Text::Livedoor::Wiki::Utils::is_image_url( $url ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 11 | my $label = $class->_cut( $url ); | |||||||||
| 15 | 11 | return qq{<a href="$url" class=\"outlink\">$label</a>}; | |||||||||
| 16 | |||||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 11 | ▶ | sub _cut { | ||||||||
|
Subroutine
_cut: called CC=2 SCAR=6.9
| |||||||||||
| 20 | 11 | my $class= shift; | |||||||||
| 21 | 11 | my $url = shift; | |||||||||
| 22 | 11 | ▶ | if ( length $url > 50 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 2 | return substr($url , 0 , 50 ) . '...'; | |||||||||
| 24 | } | ||||||||||
| 25 | 9 | return $url; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 10 | 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 | ||||||||||