]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: reduce parameters for html_footer
authorEric Wong <e@yhbt.net>
Sat, 25 Jan 2020 04:44:53 +0000 (04:44 +0000)
committerEric Wong <e@yhbt.net>
Mon, 27 Jan 2020 02:59:09 +0000 (02:59 +0000)
Put more logic into html_footer and less in its only caller so
we can control the buffering and string creation.

lib/PublicInbox/View.pm

index 040604b08b926552aa797725e3960bebeeacb0ee..0eb20ae0d7f7f8bc2d1ba103ae70ee151614f72a 100644 (file)
@@ -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 {