line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Whim::Controller::Display; |
2
|
2
|
|
|
2
|
|
4206
|
use Mojo::Base 'Mojolicious::Controller'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
3
|
2
|
|
|
2
|
|
395
|
use Whim::Mention; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
60
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
14
|
use Readonly; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1099
|
|
6
|
|
|
|
|
|
|
Readonly my $BAD_REQUEST => 400; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub display { |
9
|
1
|
|
|
1
|
0
|
8316
|
my $self = shift; |
10
|
|
|
|
|
|
|
|
11
|
1
|
50
|
|
|
|
5
|
return unless $self->_get_wms; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
|
|
9
|
$self->render('webmentions'); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub summarize { |
17
|
1
|
|
|
1
|
0
|
34814
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
1
|
50
|
|
|
|
6
|
return unless $self->_get_wms; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
8
|
$self->render('summary'); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _get_wms { |
25
|
2
|
|
|
2
|
|
6
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
16
|
my $url = $self->param('url'); |
28
|
|
|
|
|
|
|
|
29
|
2
|
50
|
|
|
|
736
|
unless ($url) { |
30
|
0
|
|
|
|
|
0
|
$self->render( |
31
|
|
|
|
|
|
|
status => $BAD_REQUEST, |
32
|
|
|
|
|
|
|
text => 'No "url" parameter found.', |
33
|
|
|
|
|
|
|
); |
34
|
0
|
|
|
|
|
0
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Grab all webmentions, then sort them into a hash-of-lists, keyed on type. |
38
|
2
|
|
|
|
|
22
|
my @webmentions = $self->whim->fetch_webmentions( { target => $url } ); |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
12
|
my %webmentions; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Initialize %webmentions with an empty list for each webmention type that |
43
|
|
|
|
|
|
|
# Web::Mention supports (plus one or two extras, perhaps) |
44
|
2
|
|
|
|
|
9
|
foreach (qw( mention reply like repost quotation rsvp bookmark )) { |
45
|
14
|
|
|
|
|
37
|
$webmentions{$_} = []; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
7
|
for my $wm (@webmentions) { |
49
|
2
|
50
|
|
|
|
60
|
unless ( $webmentions{ $wm->type } ) { |
50
|
0
|
|
|
|
|
0
|
die "Unknown webmention type: " . $wm->type; |
51
|
|
|
|
|
|
|
} |
52
|
2
|
|
|
|
|
59
|
push $webmentions{ $wm->type }->@*, $wm; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
24
|
$self->stash->{webmentions} = \%webmentions; |
56
|
2
|
|
|
|
|
25
|
$self->stash->{webmention_count} = scalar @webmentions; |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
21
|
return 1; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |