line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Bloglines::Blogroll; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
29242
|
use 5.008006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
46
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
|
|
7
|
use fields qw( |
8
|
|
|
|
|
|
|
user_name |
9
|
|
|
|
|
|
|
folder |
10
|
|
|
|
|
|
|
url |
11
|
|
|
|
|
|
|
uri |
12
|
|
|
|
|
|
|
html |
13
|
|
|
|
|
|
|
blogroll_hash |
14
|
|
|
|
|
|
|
blogroll_html |
15
|
|
|
|
|
|
|
page |
16
|
|
|
|
|
|
|
http_proxy |
17
|
|
|
|
|
|
|
ftp_proxy |
18
|
1
|
|
|
1
|
|
874
|
); |
|
1
|
|
|
|
|
1844
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
121
|
use vars qw($VERSION %FIELDS $AUTOLOAD); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
86
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
BEGIN { |
23
|
1
|
|
|
1
|
|
21
|
$VERSION = '0.02'; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
1035
|
use LWP::Simple qw($ua get); |
|
1
|
|
|
|
|
721218
|
|
|
1
|
|
|
|
|
10
|
|
27
|
1
|
|
|
1
|
|
232
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
12659
|
use Data::Dumper; |
|
1
|
|
|
|
|
7438
|
|
|
1
|
|
|
|
|
1158
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
my $_def_values = { |
33
|
|
|
|
|
|
|
url => 'rpc.bloglines.com', |
34
|
|
|
|
|
|
|
uri => 'blogroll', |
35
|
|
|
|
|
|
|
html => 1, |
36
|
|
|
|
|
|
|
http_proxy => $ENV{http_proxy}, |
37
|
|
|
|
|
|
|
ftp_proxy => $ENV{ftp_proxy}, |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
|
9
|
sub _get_defaults { %$_def_values } |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
44
|
1
|
|
|
1
|
1
|
14
|
my $class = shift; |
45
|
1
|
|
|
|
|
2
|
my $self = {}; |
46
|
1
|
|
|
|
|
3
|
bless $self, $class; |
47
|
1
|
|
|
|
|
7
|
$self->_init(@_); |
48
|
1
|
|
|
|
|
4
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _init { |
52
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
53
|
1
|
|
|
|
|
5
|
my %pars = @_; |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
6
|
my %_defaults = $self->_get_defaults; |
56
|
1
|
|
|
|
|
6
|
for(keys %FIELDS) { |
57
|
10
|
100
|
|
|
|
36
|
$self->{$_} = exists $pars{$_} ? $pars{$_} : $_defaults{$_}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub retrieve_blogroll { |
63
|
1
|
|
|
1
|
1
|
868
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
14
|
$ua->proxy('http', $self->http_proxy); |
66
|
1
|
|
|
|
|
148
|
$ua->proxy('ftp', $self->ftp_proxy); |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
470
|
$self->page(get($self->_get_url)); |
69
|
0
|
|
|
|
|
0
|
$self->_parse_blogroll(); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub get_blogroll_as_html { |
73
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
0
|
my $blogroll_hash = $self->blogroll_hash; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
my $blogroll_html; |
78
|
0
|
|
|
|
|
0
|
for(keys %{$blogroll_hash}) { |
|
0
|
|
|
|
|
0
|
|
79
|
0
|
|
|
|
|
0
|
$blogroll_html .= "$_\n"; |
80
|
0
|
|
|
|
|
0
|
$blogroll_html .= " |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
0
|
for my $item (@{$blogroll_hash->{$_}}) { |
|
0
|
|
|
|
|
0
|
|
83
|
0
|
0
|
0
|
|
|
0
|
$blogroll_html .= "$item->{item_title}\n" |
84
|
|
|
|
|
|
|
if $item->{item_url} && $item->{item_title}; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
$blogroll_html .= '' |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
0
|
$self->blogroll_html($blogroll_html); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub page { |
94
|
1
|
|
|
1
|
1
|
93518
|
my $self = shift; |
95
|
1
|
50
|
|
|
|
6
|
if(@_) { |
96
|
1
|
|
|
|
|
3
|
my $page = shift; |
97
|
1
|
50
|
|
|
|
5
|
if(!$page) { |
|
|
0
|
|
|
|
|
|
98
|
1
|
|
|
|
|
499
|
croak "Cannot retireve a blogroll: \n\tproxy url is |
99
|
|
|
|
|
|
|
[$ENV{http_proxy}]\n\turl is [".$self->get_url."]"; |
100
|
|
|
|
|
|
|
} elsif($page =~ /The user name you are using to access this blogroll is incorrect/i) { |
101
|
0
|
|
|
|
|
0
|
croak "User name [".$self->user_name."] is not correct!"; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
0
|
$self->{page} = $page; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
0
|
return $self->{page}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _parse_blogroll { |
111
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
0
|
my($folder, $item_title, $item_url, %list); |
114
|
0
|
|
|
|
|
0
|
for(split/\n/, $self->page) { |
115
|
0
|
0
|
|
|
|
0
|
if(/blogrollfolder/) { |
|
|
0
|
|
|
|
|
|
116
|
0
|
|
|
|
|
0
|
($folder) = m#(?:.+)>(.+?)<#; |
117
|
|
|
|
|
|
|
} elsif(/blogrollitem/) { |
118
|
0
|
|
|
|
|
0
|
($item_url, $item_title) = m#href="(.+?)">(.+?)<#; |
119
|
0
|
|
|
|
|
0
|
push @{ $list{$folder} }, {item_title => $item_title, item_url => $item_url}; |
|
0
|
|
|
|
|
0
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
0
|
$self->blogroll_hash(\%list); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub _get_url { |
127
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
128
|
|
|
|
|
|
|
|
129
|
1
|
50
|
|
|
|
8
|
croak "User name is not specified!" unless $self->user_name; |
130
|
|
|
|
|
|
|
|
131
|
1
|
|
|
|
|
8
|
my $url = 'http://'.$self->url.'/'.$self->uri.'?id='.$self->user_name; |
132
|
1
|
50
|
|
|
|
8
|
$url .= '&folder='.$self->folder if $self->folder; |
133
|
1
|
|
|
|
|
7
|
$url .= '&html='.$self->html; |
134
|
|
|
|
|
|
|
|
135
|
1
|
|
|
|
|
11
|
return $url; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub get_blogroll_hash { |
139
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
140
|
0
|
|
|
|
|
0
|
my $folder = shift; |
141
|
|
|
|
|
|
|
|
142
|
0
|
0
|
0
|
|
|
0
|
return $self->{blogroll_hash}{$folder} if $self->{blogroll_hash} && $folder; |
143
|
0
|
|
|
|
|
0
|
return $self->{blogroll_hash} |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub get_list_folders { |
147
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
148
|
0
|
0
|
|
|
|
0
|
if($self->{blogroll_hash}) { |
149
|
0
|
|
|
|
|
0
|
return [ keys %{ $self->{blogroll_hash} } ] |
|
0
|
|
|
|
|
0
|
|
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub AUTOLOAD { |
154
|
9
|
|
|
9
|
|
17
|
my $self = shift; |
155
|
9
|
|
|
|
|
57
|
my($class, $attr) = $AUTOLOAD =~ /(.+)::(.+)/; |
156
|
|
|
|
|
|
|
|
157
|
9
|
100
|
|
|
|
27
|
if(exists $FIELDS{$attr}) { |
158
|
8
|
50
|
|
|
|
20
|
$self->{$attr} = shift() if @_; |
159
|
8
|
|
|
|
|
52
|
return $self->{$attr}; |
160
|
|
|
|
|
|
|
} else { |
161
|
1
|
|
|
|
|
359
|
croak "Method [$attr] is not found in the class [$class]!"; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub DESTROY { |
166
|
1
|
|
|
1
|
|
634
|
my $self = shift; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
1; |
170
|
|
|
|
|
|
|
__END__ |