line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::xkcd; |
2
|
|
|
|
|
|
|
# ABSTRACT: WWW::xkcd plugin for Template::Toolkit |
3
|
|
|
|
|
|
|
$Template::Plugin::xkcd::VERSION = '0.004'; |
4
|
2
|
|
|
2
|
|
47883
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
44
|
|
5
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
42
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
708
|
use parent 'Template::Plugin'; |
|
2
|
|
|
|
|
420
|
|
|
2
|
|
|
|
|
9
|
|
8
|
2
|
|
|
2
|
|
5245
|
use WWW::xkcd; |
|
2
|
|
|
|
|
120691
|
|
|
2
|
|
|
|
|
273
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
2
|
|
|
2
|
1
|
48
|
my $class = shift; |
12
|
2
|
|
|
|
|
4
|
my $context = shift; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
|
|
7
|
my $self = bless { |
15
|
|
|
|
|
|
|
'xkcd' => WWW::xkcd->new, |
16
|
|
|
|
|
|
|
}, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub comic { |
20
|
2
|
|
|
2
|
1
|
587
|
my $self = shift; |
21
|
2
|
|
|
|
|
2
|
my $num = shift; |
22
|
2
|
50
|
|
|
|
17
|
my $meta = $self->{'xkcd'}->fetch_metadata( $num ? $num : () ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# return HTML |
25
|
0
|
|
0
|
|
|
|
my $img = $meta->{'img'} || ''; |
26
|
0
|
|
0
|
|
|
|
my $alt = $meta->{'alt'} || ''; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
return qq{}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |