about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-01-25 04:44:53 +0000
committerEric Wong <e@yhbt.net>2020-01-27 02:59:09 +0000
commit0d41983a642b4dccb90d04c4e2c5e2602885444c (patch)
tree575973cf4c101286de682f8ff10659292fdecf87 /lib
parentd4cb7fb06031435cd25f5e000bf9c0e4b8b30177 (diff)
downloadpublic-inbox-0d41983a642b4dccb90d04c4e2c5e2602885444c.tar.gz
Put more logic into html_footer and less in its only caller so
we can control the buffering and string creation.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/View.pm35
1 files changed, 15 insertions, 20 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 040604b0..0eb20ae0 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -40,11 +40,7 @@ sub msg_html_i {
                 # fake an EOF if generating the footer fails;
                 # we want to at least show the message if something
                 # here crashes:
-                eval {
-                        my $hdr = delete($ctx->{hdr});
-                        '<pre>' . html_footer($hdr, 1, $ctx) .
-                        '</pre>' . msg_reply($ctx, $hdr)
-                };
+                eval { html_footer($ctx) };
         } else {
                 undef
         }
@@ -113,7 +109,7 @@ sub msg_html_more {
 }
 
 # /$INBOX/$MESSAGE_ID/#R
-sub msg_reply {
+sub msg_reply ($$) {
         my ($ctx, $hdr) = @_;
         my $se_url =
          'https://kernel.org/pub/software/scm/git/docs/git-send-email.html';
@@ -800,17 +796,17 @@ sub _parent_headers {
         $rv;
 }
 
+# returns a string buffer via ->getline
 sub html_footer {
-        my ($hdr, $standalone, $ctx, $rhref) = @_;
-
-        my $ibx = $ctx->{-inbox} if $ctx;
+        my ($ctx) = @_;
+        my $ibx = $ctx->{-inbox};
+        my $hdr = delete $ctx->{hdr};
         my $upfx = '../';
-        my $tpfx = '';
-        my $skel = $standalone ? " <a\nhref=\"$upfx\">index</a>" : '';
-        my $irt = '';
-        if ($skel && $ibx->over) {
+        my $skel = " <a\nhref=\"$upfx\">index</a>";
+        my $rv = '<pre>';
+        if ($ibx->over) {
                 $skel .= "\n";
-                thread_skel(\$skel, $ctx, $hdr, $tpfx);
+                thread_skel(\$skel, $ctx, $hdr, '');
                 my ($next, $prev);
                 my $parent = '       ';
                 $next = $prev = '    ';
@@ -839,13 +835,12 @@ sub html_footer {
                 } elsif ($u) { # unlikely
                         $parent = " <a\nhref=\"$u\"\nrel=prev>parent</a>";
                 }
-                $irt = "$next $prev$parent ";
-        } else {
-                $irt = '';
+                $rv .= "$next $prev$parent ";
         }
-        $rhref ||= '#R';
-        $irt .= qq(<a\nhref="$rhref">reply</a>);
-        $irt .= $skel;
+        $rv .= qq(<a\nhref="#R">reply</a>);
+        $rv .= $skel;
+        $rv .= '</pre>';
+        $rv .= msg_reply($ctx, $hdr);
 }
 
 sub linkify_ref_no_over {