]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: show References: header, too
authorEric Wong <e@80x24.org>
Sat, 26 Apr 2014 02:52:50 +0000 (02:52 +0000)
committerEric Wong <e@80x24.org>
Sat, 26 Apr 2014 03:05:02 +0000 (03:05 +0000)
Some mail user agents use this header, and Mail::Thread uses
it, too, so show it if possible, but only if it's not redundant
to In-Reply-To.

lib/PublicInbox/View.pm

index e43872037ebc493d1c488b14ee1b91b8031f9299..b2f2a7fd5851a404965a6b3ace5ffb8d1c318efc 100644 (file)
@@ -172,12 +172,22 @@ sub headers_to_html_header {
 
        my $irp = $header_obj->header_raw('In-Reply-To');
        if (defined $irp) {
-               $irp = PublicInbox::Hval->new_msgid($irp);
-               my $html = $irp->as_html;
-               my $href = $irp->as_href;
+               my $v = PublicInbox::Hval->new_msgid(my $tmp = $irp);
+               my $html = $v->as_html;
+               my $href = $v->as_href;
                $rv .= "In-Reply-To: &lt;";
                $rv .= "<a href=\"$href.html\">$html</a>&gt;\n";
        }
+
+       my $refs = $header_obj->header_raw('References');
+       if ($refs) {
+               $refs =~ s/\s*\Q$irp\E\s*// if (defined $irp);
+               my @refs = ($refs =~ /<([^>]+)>/g);
+               if (@refs) {
+                       $rv .= 'References: '. linkify_refs(@refs) . "\n";
+               }
+       }
+
        $rv .= "\n";
 
        ("<html><head><title>".  join(' - ', @title) .
@@ -213,4 +223,13 @@ sub html_footer {
        '<a href="' . ascii_html($href) . '">reply</a>';
 }
 
+sub linkify_refs {
+       join(' ', map {
+               my $v = PublicInbox::Hval->new_msgid($_);
+               my $html = $v->as_html;
+               my $href = $v->as_href;
+               "&lt;<a href=\"$href.html\">$html</a>&gt;";
+       } @_);
+}
+
 1;