diff options
author | Eric Wong <e@80x24.org> | 2014-04-04 01:42:41 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2014-04-05 06:55:35 +0000 |
commit | 1397205077a2b2d196f6c469a15a4a4721f1d15f (patch) | |
tree | b8d5aa3c4cfa6370cae24c9e3fa94436d5bd983b /lib/PublicInbox/View.pm | |
parent | 71abf270f5b11f147be839a9b057e106d0f8509f (diff) | |
download | public-inbox-1397205077a2b2d196f6c469a15a4a4721f1d15f.tar.gz |
We'll go with .html and .txt suffixes on MIDs to benefit static hosting setups.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r-- | lib/PublicInbox/View.pm | 26 |
1 files changed, 19 insertions, 7 deletions
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: <a href=\"$href\">$html</a>\n"; + my $mid = $simple->header('Message-ID'); + if (defined $mid) { + my ($html, $href) = trim_message_id($mid); + $rv .= "Message-ID: <a href=$href.html>$html</a> "; + $rv .= "(<a href=$href.txt>raw message</a>)\n"; } + my $irp = $simple->header('In-Reply-To'); + if (defined $irp) { + my ($html, $href) = trim_message_id($irp); + $rv .= "In-Reply-To: <a href=$href.html>$html</a>\n"; + } $rv .= "\n"; return ("<html><head><title>". |