blob: e1f299d3b39c8474fabb9bbe07b8a838bf214062 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
% layout 'mainlayout';
% my $mail_fmt = begin
% my ($category, $value) = @_;
% if (ref $value eq 'ARRAY' && $value->@*) {
<dt> <%= uc l $category %> </dt>
% for ($value->@*) {
<dd>
%= $_->{display_name} ? qq("$_->{display_name}" <$_->{address}>) : "$_->{address}"
</dd>
% }
% }
% end
% my $format_mail = begin
% my ($msg) = @_;
% my $body = $msg->{body};
% my $content_type = to_mime_type $msg->{head}{mime};
<div clas="jwm-mail">
<dl class="jwm-mail-header">
<dt> <%= uc l 'subject' %> </dt>
<dd> <%= $msg->{head}{subject} %> </dd>
%= $mail_fmt->(from => $msg->{head}{from})
%= $mail_fmt->(to => $msg->{head}{to})
%= $mail_fmt->(cc => $msg->{head}{cc})
%= $mail_fmt->(bcc => $msg->{head}{bcc})
<dt> <%= uc l 'date' %> </dt>
<dd> <%= $msg->{head}{date} %> </dd>
<dt> <%= uc l 'content-type' %> </dt>
<dd> <%= $content_type %> </dd>
</dl>
% if ($content_type eq 'multipart/alternative') {
% my $end;
% for (reverse $body->{parts}->@*) {
% if (!$end) {
<div class="jwm-mail-body <%= to_mime_type($_->{head}) eq 'text/plain' ? 'jwm-mail-body-text-plain' : '' %>" >
% my $x = mime_render(to_mime_type($_->{head}), $_->{body});
%== $x;
</div>
% $end = 1 if $x;
% }
% else {
<details class="jwm-mail-body <%= to_mime_type($_->{head}) eq 'text/plain' ? 'jwm-mail-body-text-plain' : '' %>" >
<summary>
%= to_mime_type $_->{head}
</summary>
%== mime_render(to_mime_type($_->{head}), $_->{body})
</details>
% }
% }
% }
% elsif ($msg->{head}{mime}{content_maintype} eq 'multipart') {
% for ($body->{parts}->@*) {
% if ( !$_->{head}{content_disposition}
% || lc $_->{head}{content_disposition} eq 'none'
% || lc $_->{head}{content_disposition} eq 'inline') {
<div class="jwm-mail-body <%= to_mime_type($_->{head}) eq 'text/plain' ? 'jwm-mail-body-text-plain' : '' %>" >
%== mime_render(to_mime_type($_->{head}), $_->{body}) // "Can not render mime-part of type <code>$_->{head}{content_maintype}/$_->{head}{content_subtype}</code>."
</div>
% }
% elsif (lc $_->{head}{content_disposition} eq 'attachment') {
<p>
Attachment <%= $_->{head}{filename} %> of type
%= to_mime_type $_->{head}
</p>
% }
% else {
% die "unknown Content-Disposition '$_->{head}{content_disposition}'"
% }
% }
% }
% elsif ($msg->{head}{mime}{content_maintype} eq 'message') {
% die "not implemented" unless $msg->{head}{mime}{content_subtype} eq 'rfc822';
<p>not implemented</p>
% }
% else {
<div class="jwm-mail-body <%= $content_type eq 'text/plain' ? 'jwm-mail-body-text-plain' : '' %>" >
%== mime_render($content_type, $body) // $content_type
</div>
% }
</div>
% end
<div class="jwm-base">
<h1>Read Mail</h1>
%= $format_mail->($msg)
<nav>
<a href="javascript:history.back()" class="pure-button">
%= l 'back'
</a>
</nav>
</div>
|