line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# $Id: MrWiggles.pm,v 1.1 2006/01/10 10:51:59 nicolaw Exp $ |
4
|
|
|
|
|
|
|
# WWW::Comic::Plugin::MrWiggles - Rehabilitating Mr. Wiggles plugin for WWW::Comic |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright 2006 Nicola Worthington |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
9
|
|
|
|
|
|
|
# you may not use this file except in compliance with the License. |
10
|
|
|
|
|
|
|
# You may obtain a copy of the License at |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software |
15
|
|
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
16
|
|
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17
|
|
|
|
|
|
|
# See the License for the specific language governing permissions and |
18
|
|
|
|
|
|
|
# limitations under the License. |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
############################################################ |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package WWW::Comic::Plugin::MrWiggles; |
23
|
|
|
|
|
|
|
# vim:ts=4:sw=4:tw=78 |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
2
|
|
8851
|
use strict; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
80
|
|
26
|
2
|
|
|
2
|
|
11
|
use Carp qw(carp croak); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
127
|
|
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
|
10
|
use vars qw($VERSION @ISA %COMICS); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1168
|
|
29
|
|
|
|
|
|
|
$VERSION = sprintf('%d.%02d', q$Revision: 1.1 $ =~ /(\d+)/g); |
30
|
|
|
|
|
|
|
@ISA = qw(WWW::Comic::Plugin); |
31
|
|
|
|
|
|
|
%COMICS = ( mrwiggles => 'Rehabilitating Mr. Wiggles' ); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new { |
34
|
1
|
|
|
1
|
1
|
23
|
my $class = shift; |
35
|
1
|
|
|
|
|
3
|
my $self = { homepage => 'http://www.neilswaab.com/comics/wiggles/' }; |
36
|
1
|
|
|
|
|
5
|
bless $self, $class; |
37
|
1
|
|
|
|
|
5
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub strip_url { |
41
|
9
|
|
|
9
|
1
|
21
|
my $self = shift; |
42
|
9
|
|
|
|
|
31
|
my %param = @_; |
43
|
|
|
|
|
|
|
|
44
|
9
|
|
66
|
|
|
67
|
$self->{ua} ||= $self->_new_agent(); |
45
|
9
|
|
|
|
|
44
|
my $url = "$self->{homepage}/wiggles_current.html"; |
46
|
9
|
50
|
33
|
|
|
109
|
if (exists $param{id} && $param{id} =~ /^[0-9]+$/) { |
47
|
0
|
|
|
|
|
0
|
$url = "$self->{homepage}rehab$param{id}.html"; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
9
|
|
|
|
|
53
|
my $response = $self->{ua}->get($url); |
51
|
9
|
50
|
|
|
|
13379935
|
if ($response->is_success) { |
|
|
50
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
my $html = $response->content; |
53
|
0
|
0
|
|
|
|
0
|
if ($html =~ m#
|
54
|
|
|
|
|
|
|
(/comics/wiggles/)?images/rehab[0-9]+\.(gif|jpe?g|png))"#imsx) { |
55
|
0
|
|
|
|
|
0
|
my $url = $1; |
56
|
0
|
0
|
|
|
|
0
|
$url = "$self->{homepage}$1" unless $url =~ /^https?:\/\//i; |
57
|
0
|
|
|
|
|
0
|
return $url; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} elsif ($^W) { |
61
|
0
|
|
|
|
|
0
|
carp($response->status_line); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
9
|
|
|
|
|
869
|
return undef; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=pod |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
WWW::Comic::Plugin::MrWiggles - MrWiggles plugin for WWW::Comic |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SYNOPSIS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
See L. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 VERSION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$Id: MrWiggles.pm,v 1.1 2006/01/10 10:51:59 nicolaw Exp $ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Nicola Worthington |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
L |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Copyright 2006 Nicola Worthington. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This software is licensed under The Apache Software License, Version 2.0. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
L |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|