From: Eric Wong Date: Sat, 26 Apr 2014 02:52:50 +0000 (+0000) Subject: view: show References: header, too X-Git-Tag: v1.0.0~1203 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=d713c17e29976cdb038ad0fa30b229674738abc8;p=public-inbox.git view: show References: header, too 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. --- diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index e4387203..b2f2a7fd 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -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: <"; $rv .= "$html>\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"; ("". 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; + "<<a href=\"$href.html\">$html</a>>"; + } @_); +} + 1;