From 62a77b55c9fadec1b4b1ba061e99f4a18d8a14bc Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 23 Feb 2016 06:52:09 +0000 Subject: www: support $MESSAGE_ID/R/ endpoint for replies Setting the "In-Reply-To:" header via mailto: links is not well-supported and should probably not be encouraged unless the client situation improves. So instead, teach users more widely-supported ways of setting the In-Reply-To: header to ensure proper threading of replies. --- lib/PublicInbox/WWW.pm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/WWW.pm') diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index 77910f67..1f28df20 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -21,7 +21,7 @@ require PublicInbox::Git; use PublicInbox::GitHTTPBackend; our $LISTNAME_RE = qr!\A/([\w\.\-]+)!; our $MID_RE = qr!([^/]+)!; -our $END_RE = qr!(f/|T/|t/|t\.mbox(?:\.gz)?|t\.atom|raw|)!; +our $END_RE = qr!(f/|T/|t/|R/|t\.mbox(?:\.gz)?|t\.atom|raw|)!; our $pi_config; sub run { @@ -58,7 +58,7 @@ sub run { msg_page($ctx, $1, $2, $3); # in case people leave off the trailing slash: - } elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/(f|T|t)\z!o) { + } elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/(f|T|t|R)\z!o) { my ($listname, $mid, $suffix) = ($1, $2, $3); $suffix .= $suffix =~ /\A[tT]\z/ ? '/#u' : '/'; r301($ctx, $listname, $mid, $suffix); @@ -200,6 +200,19 @@ sub get_full_html { [ PublicInbox::View::msg_html($ctx, $mime, undef, $foot)] ]; } +# /$LISTNAME/$MESSAGE_ID/R/ -> HTML content (fullquotes) +sub get_reply_html { + my ($ctx) = @_; + my $x = mid2blob($ctx) or return r404($ctx); + + require PublicInbox::View; + my $foot = footer($ctx); + require Email::MIME; + my $hdr = Email::MIME->new($x)->header_obj; + [ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ], + [ PublicInbox::View::msg_reply($ctx, $hdr, $foot)] ]; +} + # /$LISTNAME/$MESSAGE_ID/t/ sub get_thread { my ($ctx, $flat) = @_; @@ -407,6 +420,7 @@ sub msg_page { 'T/' eq $e and return get_thread($ctx, 1); 'raw' eq $e and return get_mid_txt($ctx); 'f/' eq $e and return get_full_html($ctx); + 'R/' eq $e and return get_reply_html($ctx); } r404($ctx); } -- cgit v1.2.3-24-ge0c7