From d713c17e29976cdb038ad0fa30b229674738abc8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 26 Apr 2014 02:52:50 +0000 Subject: 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. --- lib/PublicInbox/View.pm | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/View.pm') 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; -- cgit v1.2.3-24-ge0c7