line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Livedoor::Wiki::Plugin::Function::Youtube; |
2
|
11
|
|
|
11
|
|
66
|
use warnings; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
354
|
|
3
|
11
|
|
|
11
|
|
57
|
use strict; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
346
|
|
4
|
11
|
|
|
11
|
|
65
|
use Text::Livedoor::Wiki::Utils; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
103
|
|
5
|
11
|
|
|
11
|
|
305
|
use base qw/Text::Livedoor::Wiki::Plugin::Function/; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
2223
|
|
6
|
|
|
|
|
|
|
__PACKAGE__->function_name('youtube'); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub prepare_args { |
9
|
7
|
|
|
7
|
1
|
13
|
my $class= shift; |
10
|
7
|
|
|
|
|
11
|
my $args = shift; |
11
|
|
|
|
|
|
|
# no args |
12
|
7
|
100
|
|
|
|
46
|
die 'no arg' unless scalar @$args ; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# no code |
15
|
6
|
|
|
|
|
395
|
my $url = $args->[0]; |
16
|
6
|
|
|
|
|
36
|
my ( $code ) = $url =~ /v=([^&]+)/; |
17
|
6
|
100
|
|
|
|
36
|
die 'no code found' unless $code ; |
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
|
|
29
|
return { code => $code }; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
sub prepare_value { |
22
|
5
|
|
|
5
|
1
|
10
|
my $class = shift; |
23
|
5
|
|
|
|
|
9
|
my $value = shift; |
24
|
5
|
|
|
|
|
10
|
my $width = 340 ; |
25
|
5
|
|
|
|
|
6
|
my $height = 280 ; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# do not need space |
28
|
5
|
|
100
|
|
|
32
|
$value ||= ''; |
29
|
5
|
|
|
|
|
13
|
$value =~ s/\s//g; |
30
|
|
|
|
|
|
|
|
31
|
5
|
|
|
|
|
36
|
($width , $height ) |
32
|
|
|
|
|
|
|
= Text::Livedoor::Wiki::Utils::get_width_height( $value , { width => $width , height => $height }) ; |
33
|
|
|
|
|
|
|
|
34
|
5
|
|
|
|
|
29
|
return { width => $width , height => $height }; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
sub process { |
37
|
4
|
|
|
4
|
1
|
9
|
my ( $class, $inline, $data ) = @_; |
38
|
4
|
|
|
|
|
11
|
my $code = $data->{args}{code}; |
39
|
4
|
|
|
|
|
8
|
my $width = $data->{value}{width}; |
40
|
4
|
|
|
|
|
8
|
my $height= $data->{value}{height}; |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
25
|
my $html= <<"END_YOUTUBE_TMPL"; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
type="application/x-shockwave-flash" wmode="transparent" |
49
|
|
|
|
|
|
|
width="$width" height="$height"> |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
END_YOUTUBE_TMPL |
52
|
|
|
|
|
|
|
|
53
|
4
|
|
|
|
|
20
|
$html =~ s/\n$//; |
54
|
4
|
|
|
|
|
28
|
return $html; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# XXX only docomo wark the video. |
58
|
|
|
|
|
|
|
sub process_mobile { |
59
|
1
|
|
|
1
|
1
|
2
|
my ( $class, $inline, $data ) = @_; |
60
|
1
|
|
|
|
|
3
|
my $code = $data->{args}{code}; |
61
|
1
|
|
|
|
|
11
|
return qq||; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Text::Livedoor::Wiki::Plugin::Function::Youtube - Youtube Function Plugin |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
do you want to see youtube? |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SYNOPSIS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
&youtube(http://jp.youtube.com/watch?v=fEiL5yyNfco) |
77
|
|
|
|
|
|
|
&youtube(http://jp.youtube.com/watch?v=fEiL5yyNfco){100,50} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 FUNCTION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 prepare_args |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 prepare_value |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 process |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 process_mobile |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
polocky |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |