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.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE 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 352D21F627 for ; Sat, 10 Sep 2022 08:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662797934; bh=DZ8cVznSyWb++M8cWCASMGN7IywYDSMWE+BM8qtVf60=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VPKcbK9NHuqUB4M7Y9BIKJ93rVpWEpQViUGpwyFZBFaogiL8CSYIiHkw+PEyMqMfZ pbNN5Icwa/FfB/Cd25bSHzbJtwzH2umkm2qeKRrnD2NCqtztbYyK2vgrB81ThOG0Zq d3BqKRuk4cZLJm2uBmWg2jbnW6yXoVce9t7dynYg= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 14/38] view: remove multipart_text_as_html Date: Sat, 10 Sep 2022 08:17:05 +0000 Message-Id: <20220910081729.2011934-15-e@80x24.org> In-Reply-To: <20220910081729.2011934-1-e@80x24.org> References: <20220910081729.2011934-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It seems like a pointless wrapper function that's not saving us a whole lot. Drop some direct {obuf} manipulation while we're at it. --- lib/PublicInbox/View.pm | 15 ++++----------- lib/PublicInbox/WwwAtomStream.pm | 5 ++--- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 37b484ae..0b67d92f 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -39,8 +39,8 @@ sub msg_page_i { $ctx->{mhref} = ($ctx->{nr} || $ctx->{smsg}) ? "../${\mid_href($smsg->{mid})}/" : ''; if (_msg_page_prepare_obuf($eml, $ctx)) { - multipart_text_as_html($eml, $ctx); - ${$ctx->{obuf}} .= '
'; + $eml->each_part(\&add_text_body, $ctx, 1); + $ctx->zmore('
'); } html_footer($ctx, $ctx->{first_hdr}) if !$ctx->{smsg}; delete($ctx->{obuf}) // \''; @@ -57,8 +57,8 @@ sub no_over_html ($) { $ctx->{mhref} = ''; PublicInbox::WwwStream::init($ctx); if (_msg_page_prepare_obuf($eml, $ctx)) { # sets {-title_html} - multipart_text_as_html($eml, $ctx); - ${$ctx->{obuf}} .= '
'; + $eml->each_part(\&add_text_body, $ctx, 1); + $ctx->zmore('
'); } html_footer($ctx, $eml); $ctx->html_done; @@ -506,13 +506,6 @@ sub thread_html_i { # PublicInbox::WwwStream::getline callback } } -sub multipart_text_as_html { - # ($mime, $ctx) = @_; # each_part may do "$_[0] = undef" - - # scan through all parts, looking for displayable text - $_[0]->each_part(\&add_text_body, $_[1], 1); -} - sub submsg_hdr ($$) { my ($ctx, $eml) = @_; my $obfs_ibx = $ctx->{-obfs_ibx}; diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm index 906b292a..09c79a8a 100644 --- a/lib/PublicInbox/WwwAtomStream.pm +++ b/lib/PublicInbox/WwwAtomStream.pm @@ -157,9 +157,8 @@ sub feed_entry { $ctx->{obuf} = \$s; $ctx->{mhref} = $href; $ctx->{changed_href} = "${href}#related"; - PublicInbox::View::multipart_text_as_html($eml, $ctx); - delete $ctx->{obuf}; - $s .= ''; + $eml->each_part(\&PublicInbox::View::add_text_body, $ctx, 1); + ''; } sub feed_updated {