line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::URLFor; |
2
|
2
|
|
|
2
|
|
77481
|
use strict; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
74
|
|
3
|
|
|
|
|
|
|
use Module::Pluggable |
4
|
2
|
|
|
|
|
14
|
sub_name => '_plugins', |
5
|
|
|
|
|
|
|
instantiate => 'new', |
6
|
2
|
|
|
2
|
|
1022
|
; |
|
2
|
|
|
|
|
22325
|
|
7
|
2
|
|
|
2
|
|
1283
|
use Moo 2; |
|
2
|
|
|
|
|
18479
|
|
|
2
|
|
|
|
|
11
|
|
8
|
2
|
|
|
2
|
|
3797
|
use Filter::signatures; |
|
2
|
|
|
|
|
51056
|
|
|
2
|
|
|
|
|
13
|
|
9
|
2
|
|
|
2
|
|
79
|
no warnings 'experimental::signatures'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
69
|
|
10
|
2
|
|
|
2
|
|
11
|
use feature 'signatures'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
543
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Mail::URLFor - Create deep links into mail clients |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $links = Mail::URLFor->new(); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $messageid = 'mail.abcdef.123456@example.com'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $urls = $links->urls_for($messageid); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
for my $client (keys %$urls) { |
27
|
|
|
|
|
|
|
print "$client: $urls->{$client}\n"; |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Output: |
31
|
|
|
|
|
|
|
# Thunderlink: thunderlink://messageid=mail.abcdef.123456%40example.com |
32
|
|
|
|
|
|
|
# OSX: message:%3Cmail.abcdef.123456@example.com%3E |
33
|
|
|
|
|
|
|
# RFC2392: mid:mail.abcdef.123456@example.com |
34
|
|
|
|
|
|
|
# Gmail: https://mail.google.com/mail/#search/rfc822msgid%3Amail.abcdef.123456%40example.com |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This module allows you to create (clickable) URLs to emails that |
40
|
|
|
|
|
|
|
will open in the respective (native) client or Gmail. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This is useful if you have a web application but still want to connect |
43
|
|
|
|
|
|
|
an object on the web page with an email in a local mail client. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
our @default_links; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 C<< Mail::URLFor->new >> |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Only link to mails on Gmail |
54
|
|
|
|
|
|
|
my $links = Mail::URLFor->new( |
55
|
|
|
|
|
|
|
clients => [Mail::URLFor::Plugin::Gmail->new], |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head3 Options |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=over 4 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item B |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Arrayref of the classes (or instances) of mail clients to |
65
|
|
|
|
|
|
|
render links for. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Defaults to all C<::Plugin> classes. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=back |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has clients => ( |
74
|
|
|
|
|
|
|
is => 'ro', |
75
|
|
|
|
|
|
|
default => sub {[ $_[0]->_plugins() ]}, |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 C<< ->url_for( $rfc822messageid, $client = 'Gmail' ) >> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $url = $links->url_for( '1234.abc@example.com', 'Gmail' ); |
81
|
|
|
|
|
|
|
print "See mail" |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Renders the URL using the moniker of the plugin. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Returns something that should mostly be treated as an opaque string. |
86
|
|
|
|
|
|
|
Returns C, if the moniker is unknown. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Currently, the returned string is always |
89
|
|
|
|
|
|
|
percent-encoded already, but this may change in the future. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
4
|
|
|
4
|
1
|
4035
|
sub url_for( $self, $rfc822messageid, $client = 'Gmail' ) { |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
7
|
|
94
|
4
|
|
|
|
|
8
|
$self->urls_for( $rfc822messageid )->{$client} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 C<< ->urls_for( $rfc822messageid ) >> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $urls = $links->urls_for( '1234.abc@example.com' ); |
100
|
|
|
|
|
|
|
print $urls->{'Gmail'}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
5
|
|
|
5
|
1
|
884
|
sub urls_for( $self, $rfc822messageid, @clients ) { |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
8
|
|
105
|
5
|
50
|
|
|
|
12
|
if( ! @clients) { |
106
|
5
|
|
|
|
|
9
|
@clients = @{ $self->clients }; |
|
5
|
|
|
|
|
17
|
|
107
|
|
|
|
|
|
|
}; |
108
|
|
|
|
|
|
|
+{ |
109
|
5
|
|
|
|
|
12
|
map { $_->moniker => $_->render( $rfc822messageid )} @clients |
|
20
|
|
|
|
|
620
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__END__ |