about summary refs log tree commit homepage
path: root/lib/PublicInbox/View.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-04-26 02:29:22 +0000
committerEric Wong <e@80x24.org>2014-04-26 02:29:22 +0000
commit665fa99b39fe439e34c4e3042df1dfbb2bf1e956 (patch)
treeee543ba9993ce0982742deedf9916009a97b42b9 /lib/PublicInbox/View.pm
parente022d3377fd2c50fd9931bf96394728958a90bf3 (diff)
downloadpublic-inbox-665fa99b39fe439e34c4e3042df1dfbb2bf1e956.tar.gz
This may not work with most mail user agents, however.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r--lib/PublicInbox/View.pm31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 0a8ab549..e4387203 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -21,6 +21,8 @@ sub as_html {
 
         headers_to_html_header($mime, $full_pfx) .
                 multipart_text_as_html($mime, $full_pfx) .
+                '</pre><hr /><pre>' .
+                html_footer($mime) .
                 '</pre></body></html>';
 }
 
@@ -182,4 +184,33 @@ sub headers_to_html_header {
          '</title></head><body><pre style="white-space:pre-wrap">' .  $rv);
 }
 
+sub html_footer {
+        my ($mime) = @_;
+        my %cc; # everyone else
+        my $to; # this is the From address
+
+        foreach my $h (qw(From To Cc)) {
+                my $v = $mime->header($h);
+                defined($v) && length($v) or next;
+                my @addrs = Email::Address->parse($v);
+                foreach my $recip (@addrs) {
+                        my $address = $recip->address;
+                        my $dst = lc($address);
+                        $cc{$dst} ||= $address;
+                        $to ||= $dst;
+                }
+        }
+
+        my $subj = $mime->header('Subject') || '';
+        $subj = "Re: $subj" unless $subj =~ /\bRe:/;
+        my $irp = uri_escape($mime->header_obj->header_raw('Message-ID') || '');
+        delete $cc{$to};
+        $to = uri_escape($to);
+
+        my $cc = uri_escape(join(',', values %cc));
+        my $href = "mailto:$to?In-Reply-To=$irp&Cc=${cc}&Subject=$subj";
+
+        '<a href="' . ascii_html($href) . '">reply</a>';
+}
+
 1;