line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hatena::Star::Mobile; |
2
|
2
|
|
|
2
|
|
74875
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
79
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
78
|
|
4
|
2
|
|
|
2
|
|
1786
|
use URI::Escape; |
|
2
|
|
|
|
|
3364
|
|
|
2
|
|
|
|
|
153
|
|
5
|
2
|
|
|
2
|
|
11801
|
use LWP::UserAgent; |
|
2
|
|
|
|
|
209129
|
|
|
2
|
|
|
|
|
224
|
|
6
|
2
|
|
|
2
|
|
36
|
use HTTP::Request; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
77
|
|
7
|
2
|
|
|
2
|
|
2284
|
use JSON::Syck; |
|
2
|
|
|
|
|
23854
|
|
|
2
|
|
|
|
|
8577
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $add_template = |
12
|
|
|
|
|
|
|
'' . |
13
|
|
|
|
|
|
|
''; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get_star_entries { |
16
|
1
|
|
|
1
|
0
|
22
|
my $class = shift; |
17
|
1
|
|
|
|
|
10
|
my %args = @_; |
18
|
1
|
50
|
|
|
|
5
|
my $entries = $args{entries} or return; |
19
|
1
|
|
50
|
|
|
4
|
my $hatena_domain = $args{hatena_domain} || 'hatena.com'; |
20
|
1
|
|
|
|
|
9
|
my $sbase = sprintf('http://s.%s/', $hatena_domain); |
21
|
1
|
|
|
|
|
2
|
my $suri = $sbase . 'entries.json?'; |
22
|
1
|
50
|
|
|
|
7
|
if ($args{sid}) { |
23
|
1
|
|
|
|
|
4
|
$suri .= sprintf('sid=%s&', $args{sid}); |
24
|
|
|
|
|
|
|
} |
25
|
1
|
|
|
|
|
3
|
my $count = 0; |
26
|
1
|
|
|
|
|
2
|
for my $e (@$entries) { |
27
|
3
|
50
|
|
|
|
10
|
next unless $e->{uri}; |
28
|
3
|
|
|
|
|
19
|
$suri .= 'uri=' . URI::Escape::uri_escape($e->{uri}) . '&'; |
29
|
3
|
|
|
|
|
115
|
$count++; |
30
|
|
|
|
|
|
|
} |
31
|
1
|
|
|
|
|
3
|
my $sentries = []; |
32
|
1
|
50
|
|
|
|
3
|
if ($count) { |
33
|
1
|
|
|
|
|
11
|
my $ua = LWP::UserAgent->new; |
34
|
1
|
|
|
|
|
4118
|
my $req = HTTP::Request->new(GET => $suri); |
35
|
1
|
|
|
|
|
9496
|
my $res = $ua->request($req); |
36
|
1
|
50
|
|
|
|
1090326
|
$res->is_success or return; |
37
|
1
|
|
|
|
|
24
|
my $data = JSON::Syck::Load($res->content); |
38
|
1
|
|
|
|
|
385
|
$sentries = $data->{entries}; |
39
|
|
|
|
|
|
|
} |
40
|
1
|
|
|
|
|
5
|
for my $se (@$sentries) { |
41
|
2
|
50
|
33
|
|
|
17
|
next unless ($se && $se->{uri}); |
42
|
2
|
|
50
|
|
|
36
|
my $html = sprintf( |
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
43
|
|
|
|
|
|
|
$add_template, |
44
|
|
|
|
|
|
|
$sbase, $args{sid} || '', $args{rks} || '', |
45
|
|
|
|
|
|
|
URI::Escape::uri_escape($se->{uri}), |
46
|
|
|
|
|
|
|
URI::Escape::uri_escape($args{location} || ''), |
47
|
|
|
|
|
|
|
$args{color} || 'de' |
48
|
|
|
|
|
|
|
); |
49
|
2
|
|
|
|
|
162
|
for my $s (@{$se->{stars}}) { |
|
2
|
|
|
|
|
6
|
|
50
|
12
|
100
|
|
|
|
30
|
if (ref $s eq 'HASH') { |
51
|
11
|
|
|
|
|
41
|
$html .= sprintf('', |
52
|
|
|
|
|
|
|
$sbase, $s->{name}); |
53
|
|
|
|
|
|
|
} else { |
54
|
1
|
|
|
|
|
4
|
$html .= sprintf('%d',$s); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
2
|
|
|
|
|
8
|
$se->{star_html} = $html; |
58
|
|
|
|
|
|
|
} |
59
|
1
|
|
|
|
|
9
|
return $sentries; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |