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-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 4E5871F8DF for ; Sun, 5 Jul 2020 23:28:01 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 05/43] wwwtext: switch to html_oneshot Date: Sun, 5 Jul 2020 23:27:21 +0000 Message-Id: <20200705232759.3161-6-e@yhbt.net> In-Reply-To: <20200705232759.3161-1-e@yhbt.net> References: <20200705232759.3161-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: No point in streaming a tiny response via ->getline, but we may stream to a gzipped buffer, later. --- lib/PublicInbox/WwwText.pm | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/PublicInbox/WwwText.pm b/lib/PublicInbox/WwwText.pm index 508005fba..ea50428e3 100644 --- a/lib/PublicInbox/WwwText.pm +++ b/lib/PublicInbox/WwwText.pm @@ -64,25 +64,18 @@ sub get_text { # Follow git commit message conventions, # first line is the Subject/title my ($title) = ($txt =~ /\A([^\n]*)/s); - $ctx->{txt} = \$txt; $ctx->{-title_html} = ascii_html($title); my $nslash = ($key =~ tr!/!/!); $ctx->{-upfx} = '../../../' . ('../' x $nslash); - PublicInbox::WwwStream->response($ctx, $code, \&_do_linkify); -} - -sub _do_linkify { - my ($nr, $ctx) = @_; - return unless $nr == 1; my $l = PublicInbox::Linkify->new; - my $txt = delete $ctx->{txt}; - $l->linkify_1($$txt); + $l->linkify_1($txt); if ($hl) { - $hl->do_hl_text($txt); + $hl->do_hl_text(\$txt); } else { - $$txt = ascii_html($$txt); + $txt = ascii_html($txt); } - '
' . $l->linkify_2($$txt) . '
'; + $txt = '
' . $l->linkify_2($txt) . '
'; + PublicInbox::WwwStream::html_oneshot($ctx, $code, \$txt); } sub _srch_prefix ($$) {