about summary refs log tree commit homepage
path: root/lib/PublicInbox/View.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-09-10 08:16:54 +0000
committerEric Wong <e@80x24.org>2022-09-10 19:50:26 +0000
commit0eec12d630c1bac6f5a7850f37a7d67ecdbadf7e (patch)
tree9171a8dc1b5ed70916c012a51dc2e40696566086 /lib/PublicInbox/View.pm
parent133c9c61c0fe7e0e2d8d00e9935b3433b806ddc7 (diff)
downloadpublic-inbox-0eec12d630c1bac6f5a7850f37a7d67ecdbadf7e.tar.gz
We can rely on deflate to compress large thread skeletons on
single message pages.  Subsequent commits will compress bodies,
as well.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r--lib/PublicInbox/View.pm42
1 files changed, 18 insertions, 24 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 446e6bb8..033af283 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -38,14 +38,12 @@ sub msg_page_i {
                                 : $ctx->gone('over');
                 $ctx->{mhref} = ($ctx->{nr} || $ctx->{smsg}) ?
                                 "../${\mid_href($smsg->{mid})}/" : '';
-                my $obuf = _msg_page_prepare_obuf($eml, $ctx);
-                if (length($$obuf)) {
+                if (_msg_page_prepare_obuf($eml, $ctx)) {
                         multipart_text_as_html($eml, $ctx);
-                        $$obuf .= '</pre><hr>';
+                        ${$ctx->{obuf}} .= '</pre><hr>';
                 }
-                delete $ctx->{obuf};
-                $$obuf .= html_footer($ctx, $ctx->{first_hdr}) if !$ctx->{smsg};
-                $$obuf;
+                html_footer($ctx, $ctx->{first_hdr}) if !$ctx->{smsg};
+                delete($ctx->{obuf}) // \'';
         } else { # called by WwwStream::async_next or getline
                 $ctx->{smsg}; # may be undef
         }
@@ -58,14 +56,12 @@ sub no_over_html ($) {
         my $eml = PublicInbox::Eml->new($bref);
         $ctx->{mhref} = '';
         PublicInbox::WwwStream::init($ctx);
-        my $obuf = _msg_page_prepare_obuf($eml, $ctx);
-        if (length($$obuf)) {
+        if (_msg_page_prepare_obuf($eml, $ctx)) { # sets {-title_html}
                 multipart_text_as_html($eml, $ctx);
-                $$obuf .= '</pre><hr>';
+                ${$ctx->{obuf}} .= '</pre><hr>';
         }
-        delete $ctx->{obuf};
-        eval { $$obuf .= html_footer($ctx, $eml) };
-        html_oneshot($ctx, 200, $$obuf);
+        html_footer($ctx, $eml);
+        $ctx->html_done(200);
 }
 
 # public functions: (unstable)
@@ -669,7 +665,7 @@ sub _msg_page_prepare_obuf {
         if ($nr) { # unlikely
                 if ($ctx->{chash} eq content_hash($eml)) {
                         warn "W: BUG? @$mids not deduplicated properly\n";
-                        return \$rv;
+                        return;
                 }
                 $rv .=
 "<pre>WARNING: multiple messages have this Message-ID\n</pre><pre>";
@@ -746,7 +742,7 @@ sub _msg_page_prepare_obuf {
         }
         _parent_headers($ctx, $eml);
         $rv .= "\n";
-        \$rv;
+        1;
 }
 
 sub SKEL_EXPAND () {
@@ -827,13 +823,11 @@ EOM
         }
 }
 
-# returns a string buffer
+# appends to obuf
 sub html_footer {
         my ($ctx, $hdr) = @_;
         my $upfx = '../';
-        my $skel;
-        my $rv = '<pre>';
-        my $related;
+        my ($related, $skel);
         my $qry = delete $ctx->{-qry};
         if ($qry && $ctx->{ibx}->isrch) {
                 my $q = ''; # search for either ancestor or descendent patches
@@ -896,15 +890,15 @@ EOF
                 } elsif ($u) { # unlikely
                         $parent = " <a\nhref=\"$u\"\nrel=prev>parent</a>";
                 }
-                $rv .= "$next $prev$parent ";
+                ${$ctx->{obuf}} .= "<pre>$next $prev$parent ";
         } else { # unindexed inboxes w/o over
+                ${$ctx->{obuf}} .= '<pre>';
                 $skel = qq( <a\nhref="$upfx">latest</a>);
         }
-        $rv .= qq(<a\nhref="#R">reply</a>);
-        $rv .= $skel;
-        $rv .= '</pre>';
-        $rv .= $related // '';
-        $rv .= msg_reply($ctx, $hdr);
+        ${$ctx->{obuf}} .= qq(<a\nhref="#R">reply</a>);
+        # $skel may be big for big threads, don't append it to obuf
+        $skel .= '</pre>' . ($related // '');
+        $ctx->zmore($skel .= msg_reply($ctx, $hdr)); # flushes obuf
 }
 
 sub linkify_ref_no_over {