line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::URLFor; |
2
|
2
|
|
|
2
|
|
76592
|
use strict; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
74
|
|
3
|
|
|
|
|
|
|
use Module::Pluggable |
4
|
2
|
|
|
|
|
13
|
sub_name => '_plugins', |
5
|
|
|
|
|
|
|
instantiate => 'new', |
6
|
2
|
|
|
2
|
|
1022
|
; |
|
2
|
|
|
|
|
21927
|
|
7
|
2
|
|
|
2
|
|
1656
|
use Moo 2; |
|
2
|
|
|
|
|
18352
|
|
|
2
|
|
|
|
|
12
|
|
8
|
2
|
|
|
2
|
|
3853
|
use Filter::signatures; |
|
2
|
|
|
|
|
50884
|
|
|
2
|
|
|
|
|
12
|
|
9
|
2
|
|
|
2
|
|
75
|
no warnings 'experimental::signatures'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
67
|
|
10
|
2
|
|
|
2
|
|
11
|
use feature 'signatures'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
575
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
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
|
|
|
|
|
|
|
=head1 ONLINE DEMO |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
There is an online demo of the functionality at L . |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Paste a valid message id into the input field and click on the appropriate link |
41
|
|
|
|
|
|
|
to open the email in that mail client if the mail exists in that mail client. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This module allows you to create (clickable) URLs to emails that |
46
|
|
|
|
|
|
|
will open in the respective (native) client or Gmail. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This is useful if you have a web application but still want to connect |
49
|
|
|
|
|
|
|
an object on the web page with an email in a local mail client. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
our @default_links; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 C<< Mail::URLFor->new >> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Only link to mails on Gmail |
60
|
|
|
|
|
|
|
my $links = Mail::URLFor->new( |
61
|
|
|
|
|
|
|
clients => [Mail::URLFor::Plugin::Gmail->new], |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head3 Options |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=over 4 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item B |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Arrayref of the classes (or instances) of mail clients to |
71
|
|
|
|
|
|
|
render links for. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Defaults to all C<::Plugin> classes. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
has clients => ( |
80
|
|
|
|
|
|
|
is => 'ro', |
81
|
|
|
|
|
|
|
default => sub {[ $_[0]->_plugins() ]}, |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 C<< ->url_for( $rfc822messageid, $client = 'Gmail' ) >> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $url = $links->url_for( '1234.abc@example.com', 'Gmail' ); |
87
|
|
|
|
|
|
|
print "See mail" |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Renders the URL using the moniker of the plugin. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns something that should mostly be treated as an opaque string. |
92
|
|
|
|
|
|
|
Returns C, if the moniker is unknown. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Currently, the returned string is always |
95
|
|
|
|
|
|
|
percent-encoded already, but this may change in the future. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
4
|
|
|
4
|
1
|
4026
|
sub url_for( $self, $rfc822messageid, $client = 'Gmail' ) { |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
6
|
|
100
|
4
|
|
|
|
|
9
|
$self->urls_for( $rfc822messageid )->{$client} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 C<< ->urls_for( $rfc822messageid ) >> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $urls = $links->urls_for( '1234.abc@example.com' ); |
106
|
|
|
|
|
|
|
print $urls->{'Gmail'}; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
5
|
|
|
5
|
1
|
798
|
sub urls_for( $self, $rfc822messageid, @clients ) { |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
7
|
|
111
|
5
|
50
|
|
|
|
15
|
if( ! @clients) { |
112
|
5
|
|
|
|
|
8
|
@clients = @{ $self->clients }; |
|
5
|
|
|
|
|
17
|
|
113
|
|
|
|
|
|
|
}; |
114
|
|
|
|
|
|
|
+{ |
115
|
5
|
|
|
|
|
11
|
map { $_->moniker => $_->render( $rfc822messageid )} @clients |
|
20
|
|
|
|
|
581
|
|
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |