diff options
author | Eric Wong <e@80x24.org> | 2016-04-15 20:50:56 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-04-15 20:50:56 +0000 |
commit | fdf9b900b8c35cb4259dbdf56400d44db61e7a9e (patch) | |
tree | 418244247703b6087aa12597feffad85394e8612 /lib | |
parent | 474a987a2ba9183ceb9e143aeccdc49c7cb5f382 (diff) | |
download | public-inbox-fdf9b900b8c35cb4259dbdf56400d44db61e7a9e.tar.gz |
Quote-folding was a major design mistake pre-1.0. Since this project is still in its infancy and unlikely to be in wide use at the moment, redirect the /f/ endpoints back to the plain message.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/View.pm | 27 | ||||
-rw-r--r-- | lib/PublicInbox/WWW.pm | 38 |
2 files changed, 29 insertions, 36 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 2bf7cd50..ac44d442 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -22,13 +22,13 @@ my $enc_utf8 = find_encoding('UTF-8'); # public functions: sub msg_html { - my ($ctx, $mime, $full_pfx, $footer) = @_; + my ($ctx, $mime, $footer) = @_; $footer = defined($footer) ? "\n$footer" : ''; my $hdr = $mime->header_obj; - headers_to_html_header($hdr, $full_pfx, $ctx) . - multipart_text_as_html($mime, $full_pfx) . + headers_to_html_header($hdr, $ctx) . + multipart_text_as_html($mime) . '</pre><hr /><pre>' . - html_footer($hdr, 1, $full_pfx, $ctx) . + html_footer($hdr, 1, $ctx) . $footer . '</pre></body></html>'; } @@ -72,11 +72,10 @@ sub msg_reply { } sub feed_entry { - my ($class, $mime, $full_pfx) = @_; + my ($class, $mime) = @_; # no <head> here for <style>... - PublicInbox::Hval::PRE . - multipart_text_as_html($mime, $full_pfx) . '</pre>'; + PublicInbox::Hval::PRE . multipart_text_as_html($mime) . '</pre>'; } sub in_reply_to { @@ -138,7 +137,7 @@ sub index_entry { index_walk($fh, $_[0], $enc, \$part_nr); }); $mime->body_set(''); - $rv = "\n" . html_footer($hdr, 0, undef, $ctx, $mhref); + $rv = "\n" . html_footer($hdr, 0, $ctx, $mhref); if (defined $irt) { unless (defined $parent_anchor) { @@ -246,7 +245,7 @@ sub enc_for { } sub multipart_text_as_html { - my ($mime, $full_pfx, $srch) = @_; + my ($mime) = @_; my $rv = ""; my $part_nr = 0; my $enc = enc_for($mime->header("Content-Type")); @@ -335,11 +334,11 @@ sub add_text_body { } sub headers_to_html_header { - my ($hdr, $full_pfx, $ctx) = @_; + my ($hdr, $ctx) = @_; my $srch = $ctx->{srch} if $ctx; my $atom = ''; my $rv = ''; - my $upfx = $full_pfx ? '' : '../'; + my $upfx = ''; if ($srch) { $atom = qq{<link\nrel=alternate\ntitle="Atom feed"\n} . @@ -494,11 +493,11 @@ sub mailto_arg_link { } sub html_footer { - my ($hdr, $standalone, $full_pfx, $ctx, $mhref) = @_; + my ($hdr, $standalone, $ctx, $mhref) = @_; my $srch = $ctx->{srch} if $ctx; - my $upfx = $full_pfx ? '../' : '../../'; - my $tpfx = $full_pfx ? '' : '../'; + my $upfx = '../'; + my $tpfx = ''; my $idx = $standalone ? " <a\nhref=\"$upfx\">index</a>" : ''; my $irt = ''; diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index bb54aaa6..ce00e345 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -22,7 +22,7 @@ require PublicInbox::Git; use PublicInbox::GitHTTPBackend; our $LISTNAME_RE = qr!\A/([\w\.\-]+)!; our $MID_RE = qr!([^/]+)!; -our $END_RE = qr!(f/|T/|t/|R/|t\.mbox(?:\.gz)?|t\.atom|raw|)!; +our $END_RE = qr!(T/|t/|R/|t\.mbox(?:\.gz)?|t\.atom|raw|)!; sub new { my ($class, $pi_config) = @_; @@ -72,11 +72,14 @@ sub call { msg_page($self, $ctx, $1, $2, $3); # in case people leave off the trailing slash: - } elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/(f|T|t|R)\z!o) { + } elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/(T|t|R)\z!o) { my ($listname, $mid, $suffix) = ($1, $2, $3); $suffix .= $suffix =~ /\A[tT]\z/ ? '/#u' : '/'; r301($ctx, $listname, $mid, $suffix); + } elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/f/?\z!o) { + r301($ctx, $1, $2); + # convenience redirects order matters } elsif ($path_info =~ m!$LISTNAME_RE/([^/]{2,})\z!o) { r301($ctx, $1, $2); @@ -202,21 +205,7 @@ sub get_mid_html { my $mime = Email::MIME->new($x); searcher($ctx); [ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ], - [ PublicInbox::View::msg_html($ctx, $mime, 'f/', $foot) ] ]; -} - -# /$LISTNAME/$MESSAGE_ID/f/ -> HTML content (fullquotes) -sub get_full_html { - my ($ctx) = @_; - my $x = mid2blob($ctx) or return r404($ctx); - - require PublicInbox::View; - my $foot = footer($ctx); - require Email::MIME; - my $mime = Email::MIME->new($x); - searcher($ctx); - [ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ], - [ PublicInbox::View::msg_html($ctx, $mime, undef, $foot)] ]; + [ PublicInbox::View::msg_html($ctx, $mime, $foot) ] ]; } # /$LISTNAME/$MESSAGE_ID/R/ -> HTML content (fullquotes) @@ -354,7 +343,7 @@ sub legacy_redirects { r301($ctx, $1, $2, 'raw'); } elsif ($path_info =~ m!$LISTNAME_RE/f/(\S+)/\z!o) { - r301($ctx, $1, $2, 'f/'); + r301($ctx, $1, $2); # thread display } elsif ($path_info =~ m!$LISTNAME_RE/t/(\S+)/\z!o) { @@ -371,7 +360,7 @@ sub legacy_redirects { r301($ctx, $1, $2, 't/#u'); } elsif ($path_info =~ m!$LISTNAME_RE/f/(\S+)\.html\z!o) { - r301($ctx, $1, $2, 'f/'); + r301($ctx, $1, $2); } elsif ($path_info =~ m!$LISTNAME_RE/(?:m|f)/(\S+)\.txt\z!o) { r301($ctx, $1, $2, 'raw'); @@ -385,7 +374,7 @@ sub legacy_redirects { } elsif ($path_info =~ m!$LISTNAME_RE/t/(\S+)\z!o) { r301($ctx, $1, $2, 't/#u'); } elsif ($path_info =~ m!$LISTNAME_RE/f/(\S+)\z!o) { - r301($ctx, $1, $2, 'f/'); + r301($ctx, $1, $2); # some Message-IDs have slashes in them and the HTTP server # may try to be clever and unescape them :< @@ -393,8 +382,10 @@ sub legacy_redirects { msg_page($self, $ctx, $1, $2, $3); # in case people leave off the trailing slash: - } elsif ($path_info =~ m!$LISTNAME_RE/(\S+/\S+)/(f|T|t)\z!o) { + } elsif ($path_info =~ m!$LISTNAME_RE/(\S+/\S+)/(T|t)\z!o) { r301($ctx, $1, $2, $3 eq 't' ? 't/#u' : $3); + } elsif ($path_info =~ m!$LISTNAME_RE/(\S+/\S+)/f\z!o) { + r301($ctx, $1, $2); } else { $self->news_www->call($ctx->{cgi}->{env}); } @@ -426,7 +417,10 @@ sub msg_page { 't.mbox.gz' eq $e and return get_thread_mbox($ctx, '.gz'); '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); + + # legacy, but no redirect for compatibility: + 'f/' eq $e and return get_mid_html($ctx); + 'R/' eq $e and return get_reply_html($ctx); r404($ctx); } |