From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C97601FD47 for ; Sat, 25 Jan 2020 04:45:11 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 05/22] view: reduce parameters for html_footer Date: Sat, 25 Jan 2020 04:44:53 +0000 Message-Id: <20200125044510.13769-6-e@yhbt.net> In-Reply-To: <20200125044510.13769-1-e@yhbt.net> References: <20200125044510.13769-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 0a6903f1..02dd86da 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}); - '
' . html_footer($hdr, 1, $ctx) .
-			'
' . 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 ? " index" : ''; - my $irt = ''; - if ($skel && $ibx->over) { + my $skel = " index"; + my $rv = '
';
+	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 = " parent";
 		}
-		$irt = "$next $prev$parent ";
-	} else {
-		$irt = '';
+		$rv .= "$next $prev$parent ";
 	}
-	$rhref ||= '#R';
-	$irt .= qq(reply);
-	$irt .= $skel;
+	$rv .= qq(reply);
+	$rv .= $skel;
+	$rv .= '
'; + $rv .= msg_reply($ctx, $hdr); } sub linkify_ref_no_over {