line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Livedoor::Wiki::Plugin::Function::Image; |
2
|
11
|
|
|
11
|
|
937
|
use warnings; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
515
|
|
3
|
11
|
|
|
11
|
|
61
|
use strict; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
544
|
|
4
|
11
|
|
|
11
|
|
172
|
use base qw/Text::Livedoor::Wiki::Plugin::Function/; |
|
11
|
|
|
|
|
115
|
|
|
11
|
|
|
|
|
370
|
|
5
|
11
|
|
|
11
|
|
779
|
use Text::Livedoor::Wiki::Utils; |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
75
|
|
6
|
|
|
|
|
|
|
__PACKAGE__->function_name('ref'); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub prepare_args { |
9
|
16
|
|
|
16
|
1
|
24
|
my $class= shift; |
10
|
16
|
|
|
|
|
16
|
my $args = shift; |
11
|
16
|
|
|
|
|
22
|
my $my_args = {}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# no args |
14
|
16
|
100
|
|
|
|
54
|
die 'no args' unless scalar @$args; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# image url |
17
|
15
|
|
|
|
|
23
|
my $image_url = $args->[0]; |
18
|
15
|
100
|
|
|
|
42
|
die 'not image url' unless Text::Livedoor::Wiki::Utils::is_image_url( $image_url ); |
19
|
14
|
|
|
|
|
33
|
$my_args->{url} = $image_url; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# width , heigth , align |
22
|
14
|
|
|
|
|
18
|
my $flg = 0; |
23
|
14
|
|
|
|
|
24
|
for(@$args) { |
24
|
38
|
100
|
|
|
|
223
|
if ( $_ =~ /^\d+$/ ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
25
|
15
|
100
|
|
|
|
38
|
if($flg ==0 ){ |
|
|
100
|
|
|
|
|
|
26
|
8
|
|
|
|
|
15
|
$my_args->{width} = $_; |
27
|
8
|
|
|
|
|
13
|
$flg =1; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
elsif( $flg == 1 ) { |
30
|
6
|
|
|
|
|
10
|
$my_args->{height} = $_; |
31
|
6
|
|
|
|
|
10
|
$flg++; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif( $_ eq '' ) { |
35
|
1
|
50
|
|
|
|
4
|
$flg = 1 if $flg == 0; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif( $_ =~ /^left|right$/i ) { |
38
|
7
|
|
|
|
|
25
|
$my_args->{align} = lc $_; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
elsif( $_ eq 'no_link' ) { |
41
|
1
|
|
|
|
|
3
|
$my_args->{no_link} = 1; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
14
|
|
|
|
|
43
|
return $my_args; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
sub prepare_value { |
47
|
14
|
|
|
14
|
1
|
21
|
my $class= shift; |
48
|
14
|
|
100
|
|
|
50
|
my $value = shift || ''; |
49
|
14
|
|
|
|
|
37
|
return Text::Livedoor::Wiki::Utils::escape( $value ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub process { |
53
|
14
|
|
|
14
|
1
|
18
|
my ( $class, $inline, $data ) = @_; |
54
|
14
|
|
|
|
|
18
|
my $args = $data->{args}; |
55
|
14
|
|
|
|
|
17
|
my $value = $data->{value}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# build attr |
58
|
14
|
100
|
|
|
|
32
|
my $width = exists $args->{width} ? ' width="' . $args->{width} . '"' : ''; |
59
|
14
|
100
|
|
|
|
32
|
my $height = exists $args->{height} ? ' height="' . $args->{height} . '"' : ''; |
60
|
14
|
100
|
|
|
|
28
|
my $alt = length($value) ? ' alt="' . $value . '"' : ''; |
61
|
14
|
100
|
|
|
|
42
|
my $align = exists $args->{align} ? ' align="' . $args->{align} . '"' : ''; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# done |
64
|
14
|
100
|
|
|
|
30
|
if( $args->{no_link} ) { |
65
|
1
|
|
|
|
|
10
|
return sprintf( '' , $data->{args}{url} , $width,$height,$alt,$align ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else { |
68
|
13
|
|
|
|
|
127
|
return sprintf( '' , $data->{args}{url} ,$data->{args}{url} , $width,$height,$alt,$align ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Text::Livedoor::Wiki::Plugin::Function::Image - Image Function Plugin |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DESCRIPTION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
put your picture everywhere! |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SYNOPSIS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
&ref(http://image.profile.livedoor.jp/icon/polocky_60.gif) |
86
|
|
|
|
|
|
|
&ref(http://image.profile.livedoor.jp/icon/polocky_60.gif){hoge hoge"'><} |
87
|
|
|
|
|
|
|
&ref(http://image.profile.livedoor.jp/icon/polocky_60.gif,10,10,left) |
88
|
|
|
|
|
|
|
&ref(http://image.profile.livedoor.jp/icon/polocky_60.gif,left,10,10) |
89
|
|
|
|
|
|
|
&ref(http://image.profile.livedoor.jp/icon/polocky_60.gif,left,10) |
90
|
|
|
|
|
|
|
&ref(http://image.profile.livedoor.jp/icon/polocky_60.gif,10) |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 FUNCTION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 prepare_args |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 prepare_value |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 process |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
polocky |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |