From 1397205077a2b2d196f6c469a15a4a4721f1d15f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 4 Apr 2014 01:42:41 +0000 Subject: view: update IRP and MID links We'll go with .html and .txt suffixes on MIDs to benefit static hosting setups. --- lib/PublicInbox/View.pm | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 125fcd62..08849a92 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -60,6 +60,15 @@ sub add_filename_line { "$pad " . escapeHTML($fn) . " $pad\n"; } +sub trim_message_id { + my ($mid) = @_; + $mid =~ tr/<>//d; + my $html = escapeHTML($mid); + my $href = escapeHTML(escape($mid)); + + ($html, $href); +} + sub headers_to_html_header { my ($simple) = @_; @@ -79,15 +88,18 @@ sub headers_to_html_header { } } - foreach my $h (qw(Message-ID In-Reply-To)) { - my $v = $simple->header($h); - defined $v or next; - $v =~ tr/<>//d; - my $html = escapeHTML($v); - my $href = escapeHTML(escape($v)); - $rv .= "$h: $html\n"; + my $mid = $simple->header('Message-ID'); + if (defined $mid) { + my ($html, $href) = trim_message_id($mid); + $rv .= "Message-ID: $html "; + $rv .= "(raw message)\n"; } + my $irp = $simple->header('In-Reply-To'); + if (defined $irp) { + my ($html, $href) = trim_message_id($irp); + $rv .= "In-Reply-To: $html\n"; + } $rv .= "\n"; return ("". -- cgit v1.2.3-24-ge0c7