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,AWL,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 AF2A11FA0B for ; Sat, 18 Apr 2020 03:38:54 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 6/8] wwwatomstream: move {emit_header} field to $self Date: Sat, 18 Apr 2020 03:38:51 +0000 Message-Id: <20200418033853.9798-7-e@yhbt.net> In-Reply-To: <20200418033853.9798-1-e@yhbt.net> References: <20200418033853.9798-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: There's no need to pollute the cross-package $ctx with it. --- Documentation/mknews.perl | 2 +- lib/PublicInbox/WwwAtomStream.pm | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Documentation/mknews.perl b/Documentation/mknews.perl index adb83832..a9dede00 100755 --- a/Documentation/mknews.perl +++ b/Documentation/mknews.perl @@ -127,7 +127,7 @@ sub atom_start { require PublicInbox::WwwAtomStream; # WwwAtomStream stats this dir for mtime my $astream = PublicInbox::WwwAtomStream->new($ctx); - delete $ctx->{emit_header}; + delete $astream->{emit_header}; my $ibx = $ctx->{-inbox}; my $title = PublicInbox::WwwAtomStream::title_tag($ibx->description); my $updated = PublicInbox::WwwAtomStream::feed_updated(gmtime($mtime)); diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm index aa917ed8..c3fbb1a7 100644 --- a/lib/PublicInbox/WwwAtomStream.pm +++ b/lib/PublicInbox/WwwAtomStream.pm @@ -20,9 +20,8 @@ sub close {} sub new { my ($class, $ctx, $cb) = @_; - $ctx->{emit_header} = 1; $ctx->{feed_base_url} = $ctx->{-inbox}->base_url($ctx->{env}); - bless { cb => $cb || \&close, ctx => $ctx }, $class; + bless { cb => $cb || \&close, ctx => $ctx, emit_header => 1 }, $class; } sub response { @@ -130,7 +129,7 @@ sub feed_entry { $email = ascii_html($email); my $s = ''; - if (delete $ctx->{emit_header}) { + if (delete $self->{emit_header}) { $s .= atom_header($ctx, $title); } $s .= "$name$email" .