line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Whim::Mention; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
111170
|
use Moo; |
|
5
|
|
|
|
|
11734
|
|
|
5
|
|
|
|
|
45
|
|
4
|
5
|
|
|
5
|
|
5015
|
use MooX::ClassAttribute; |
|
5
|
|
|
|
|
50400
|
|
|
5
|
|
|
|
|
51
|
|
5
|
|
|
|
|
|
|
extends 'Web::Mention'; |
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
4454
|
use Web::Microformats2::Parser; |
|
5
|
|
|
|
|
2053211
|
|
|
5
|
|
|
|
|
1802
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'author_photo_hash' => ( |
10
|
|
|
|
|
|
|
is => 'rw', |
11
|
|
|
|
|
|
|
isa => sub { |
12
|
|
|
|
|
|
|
if ( defined $_[0] ) { |
13
|
|
|
|
|
|
|
die "Not a SHA256 hash" unless length $_[0] == 64; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
}, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
class_has 'mf2_parser' => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
default => sub { Web::Microformats2::Parser->new }, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new_from_source { |
24
|
3
|
|
|
3
|
0
|
37986
|
my ( $class, $source, %options ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
|
|
79
|
my $response = $class->ua->get($source); |
27
|
|
|
|
|
|
|
|
28
|
3
|
50
|
|
|
|
41867
|
if ( $response->is_success ) { |
29
|
3
|
|
|
|
|
32
|
my $html; |
30
|
3
|
100
|
|
|
|
11
|
if ( $options{limit_to_content} ) { |
31
|
2
|
|
|
|
|
60
|
my $mf2_doc = $class->mf2_parser->parse( $response->content, |
32
|
|
|
|
|
|
|
( url_context => $source ) ); |
33
|
2
|
|
|
|
|
72817
|
my $entry = $mf2_doc->get_first('entry'); |
34
|
2
|
100
|
|
|
|
495
|
my $content = $entry->get_property('content') if $entry; |
35
|
2
|
100
|
|
|
|
30
|
if ($content) { |
36
|
1
|
|
50
|
|
|
15
|
$html = $content->{html} // ''; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
1
|
|
|
|
|
32
|
die "Content at $source lacks an h-entry microformat " |
40
|
|
|
|
|
|
|
. "with an e-content property.\n"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
1
|
|
|
|
|
11
|
$html = $response->content; |
45
|
|
|
|
|
|
|
} |
46
|
2
|
|
|
|
|
32
|
return $class->new_from_html( |
47
|
|
|
|
|
|
|
source => $source, |
48
|
|
|
|
|
|
|
html => $html, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else { |
52
|
0
|
|
|
|
|
|
die "Could not fetch content from $source: " |
53
|
|
|
|
|
|
|
. $response->status_line . "\n"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Whim::Mention - A code library used by the Whim webmention multitool |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This is a code library used by the C<whim> executable. It doesn't have a |
66
|
|
|
|
|
|
|
public interface! |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SEE ALSO |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L<whim> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 AUTHOR |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Jason McIntosh E<lt>jmac@jmac.orgE<gt> |
75
|
|
|
|
|
|
|
|