* [PATCH 1/6] treewide: replace {-inbox} with {ibx} for consistency
2020-12-08 21:21 7% [PATCH 0/6] minor internal consistency things Eric Wong
@ 2020-12-08 21:21 2% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-12-08 21:21 UTC (permalink / raw)
To: meta
{ibx} is shorter and is the most prevalent abbreviation
in indexing and IMAP code, and the `$ibx' local variable
is already prevalent throughout.
In general, the codebase favors removal of vowels in variable
and field names to denote non-references (because references are
"lighter" than non-references).
So update WWW and Filter users to use the same code since
it reduces confusion and may allow easier code sharing.
---
Documentation/mknews.perl | 4 ++--
lib/PublicInbox/ExtMsg.pm | 10 +++++-----
lib/PublicInbox/Feed.pm | 6 +++---
lib/PublicInbox/Filter/RubyLang.pm | 2 +-
lib/PublicInbox/GzipFilter.pm | 4 ++--
lib/PublicInbox/InboxWritable.pm | 2 +-
lib/PublicInbox/Mbox.pm | 30 +++++++++++++++---------------
lib/PublicInbox/MboxGz.pm | 4 ++--
lib/PublicInbox/SearchThread.pm | 4 ++--
lib/PublicInbox/SearchView.pm | 14 +++++++-------
lib/PublicInbox/View.pm | 22 +++++++++++-----------
lib/PublicInbox/ViewVCS.pm | 2 +-
lib/PublicInbox/WWW.pm | 24 ++++++++++++------------
lib/PublicInbox/WwwAltId.pm | 2 +-
lib/PublicInbox/WwwAtomStream.pm | 10 +++++-----
lib/PublicInbox/WwwAttach.pm | 10 +++++-----
lib/PublicInbox/WwwStream.pm | 10 +++++-----
lib/PublicInbox/WwwText.pm | 8 ++++----
t/feed.t | 6 +++---
t/filter_rubylang.t | 2 +-
xt/cmp-msgview.t | 2 +-
xt/perf-msgview.t | 2 +-
xt/perf-threading.t | 2 +-
23 files changed, 91 insertions(+), 91 deletions(-)
diff --git a/Documentation/mknews.perl b/Documentation/mknews.perl
index 510a4e18..d87c2609 100755
--- a/Documentation/mknews.perl
+++ b/Documentation/mknews.perl
@@ -43,7 +43,7 @@ if ($dst eq 'NEWS') {
);
$ibx->{-primary_address} = $addr;
my $ctx = {
- -inbox => $ibx,
+ ibx => $ibx,
-upfx => "$base_url/",
-hr => 1,
};
@@ -131,7 +131,7 @@ sub atom_start {
# WwwAtomStream stats this dir for mtime
my $astream = PublicInbox::WwwAtomStream->new($ctx);
delete $astream->{emit_header};
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $title = PublicInbox::WwwAtomStream::title_tag($ibx->description);
my $updated = PublicInbox::WwwAtomStream::feed_updated($mtime);
print $out <<EOF or die;
diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm
index 2a579c1b..43acfb53 100644
--- a/lib/PublicInbox/ExtMsg.pm
+++ b/lib/PublicInbox/ExtMsg.pm
@@ -76,7 +76,7 @@ sub search_partial ($$) {
sub ext_msg_i {
my ($other, $ctx) = @_;
- return if $other->{name} eq $ctx->{-inbox}->{name} || !$other->base_url;
+ return if $other->{name} eq $ctx->{ibx}->{name} || !$other->base_url;
my $mm = $other->mm or return;
@@ -107,7 +107,7 @@ sub ext_msg_ALL ($) {
my ($ctx) = @_;
my $ALL = $ctx->{www}->{pi_config}->ALL or return;
my $by_eidx_key = $ctx->{www}->{pi_config}->{-by_eidx_key};
- my $cur_key = $ctx->{-inbox}->eidx_key;
+ my $cur_key = $ctx->{ibx}->eidx_key;
my %seen = ($cur_key => 1);
my ($id, $prev);
while (my $x = $ALL->over->next_by_mid($ctx->{mid}, \$id, \$prev)) {
@@ -123,7 +123,7 @@ sub ext_msg_ALL ($) {
return exact($ctx) if $ctx->{found};
# fall back to partial MID matching
- for my $ibxish ($ctx->{-inbox}, $ALL) {
+ for my $ibxish ($ctx->{ibx}, $ALL) {
my $mids = search_partial($ibxish, $ctx->{mid}) or next;
push @{$ctx->{partial}}, [ $ibxish, $mids ];
last if ($ctx->{n_partial} += scalar(@$mids)) >= PARTIAL_MAX;
@@ -169,7 +169,7 @@ sub finalize_exact {
# fall back to partial MID matching
my $mid = $ctx->{mid};
- my $cur = $ctx->{-inbox};
+ my $cur = $ctx->{ibx};
my $mids = search_partial($cur, $mid);
if ($mids) {
$ctx->{n_partial} = scalar(@$mids);
@@ -200,7 +200,7 @@ sub partial_response ($) {
my $es = $n_partial == 1 ? '' : 'es';
$n_partial .= '+' if ($n_partial == PARTIAL_MAX);
$s .= "\n$n_partial partial match$es found:\n\n";
- my $cur_name = $ctx->{-inbox}->{name};
+ my $cur_name = $ctx->{ibx}->{name};
foreach my $pair (@{$ctx->{partial}}) {
my ($ibx, $res) = @$pair;
my $env = $ctx->{env} if $ibx->{name} eq $cur_name;
diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 805076f0..4dd584d3 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -24,7 +24,7 @@ sub generate {
sub generate_thread_atom {
my ($ctx) = @_;
- my $msgs = $ctx->{msgs} = $ctx->{-inbox}->over->get_thread($ctx->{mid});
+ my $msgs = $ctx->{msgs} = $ctx->{ibx}->over->get_thread($ctx->{mid});
return _no_thread() unless @$msgs;
PublicInbox::WwwAtomStream->response($ctx, 200, \&generate_i);
}
@@ -34,7 +34,7 @@ sub generate_html_index {
# if the 'r' query parameter is given, it is a legacy permalink
# which we must continue supporting:
my $qp = $ctx->{qp};
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
if ($qp && !$qp->{r} && $ibx->over) {
return PublicInbox::View::index_topics($ctx);
}
@@ -79,7 +79,7 @@ sub _no_thread () {
sub recent_msgs {
my ($ctx) = @_;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $max = $ibx->{feedmax};
return PublicInbox::View::paginate_recent($ctx, $max) if $ibx->over;
diff --git a/lib/PublicInbox/Filter/RubyLang.pm b/lib/PublicInbox/Filter/RubyLang.pm
index 06e4ea75..62cf5d20 100644
--- a/lib/PublicInbox/Filter/RubyLang.pm
+++ b/lib/PublicInbox/Filter/RubyLang.pm
@@ -16,7 +16,7 @@ sub new {
my ($class, %opts) = @_;
my $altid = delete $opts{-altid};
my $self = $class->SUPER::new(%opts);
- my $ibx = $self->{-inbox};
+ my $ibx = $self->{ibx};
# altid = serial:ruby-core:file=msgmap.sqlite3
if (!$altid && $ibx && $ibx->{altid}) {
$altid ||= $ibx->{altid}->[0];
diff --git a/lib/PublicInbox/GzipFilter.pm b/lib/PublicInbox/GzipFilter.pm
index 20030433..5f701673 100644
--- a/lib/PublicInbox/GzipFilter.pm
+++ b/lib/PublicInbox/GzipFilter.pm
@@ -169,7 +169,7 @@ sub async_blob_cb { # git->cat_async callback
if (!defined($oid)) {
# it's possible to have TOCTOU if an admin runs
# public-inbox-(edit|purge), just move onto the next message
- warn "E: $smsg->{blob} missing in $self->{-inbox}->{inboxdir}\n";
+ warn "E: $smsg->{blob} missing in $self->{ibx}->{inboxdir}\n";
return $http->next_step($self->can('async_next'));
}
$smsg->{blob} eq $oid or bail($self, "BUG: $smsg->{blob} != $oid");
@@ -180,7 +180,7 @@ sub async_blob_cb { # git->cat_async callback
sub smsg_blob {
my ($self, $smsg) = @_;
- git_async_cat($self->{-inbox}->git, $smsg->{blob},
+ git_async_cat($self->{ibx}->git, $smsg->{blob},
\&async_blob_cb, $self);
}
diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm
index e97c7e2d..49809045 100644
--- a/lib/PublicInbox/InboxWritable.pm
+++ b/lib/PublicInbox/InboxWritable.pm
@@ -102,7 +102,7 @@ sub filter {
$im->done;
}
- my @args = (-inbox => $self);
+ my @args = (ibx => $self);
# basic line splitting, only
# Perhaps we can have proper quote splitting one day...
($f, @args) = split(/\s+/, $f) if $f =~ /\s+/;
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index 0df31e7f..64de8c72 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -17,7 +17,7 @@ use PublicInbox::Eml;
sub getline {
my ($ctx) = @_; # ctx
my $smsg = $ctx->{smsg} or return;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $eml = $ibx->smsg_eml($smsg) or return;
my $n = $ctx->{smsg} = $ibx->over->next_by_mid(@{$ctx->{next_arg}});
$ctx->zmore(msg_hdr($ctx, $eml, $smsg->{mid}));
@@ -44,7 +44,7 @@ sub async_eml { # for async_blob_cb
my ($ctx, $eml) = @_;
my $smsg = delete $ctx->{smsg};
# next message
- $ctx->{smsg} = $ctx->{-inbox}->over->next_by_mid(@{$ctx->{next_arg}});
+ $ctx->{smsg} = $ctx->{ibx}->over->next_by_mid(@{$ctx->{next_arg}});
$ctx->zmore(msg_hdr($ctx, $eml, $smsg->{mid}));
$ctx->{http_out}->write($ctx->translate(msg_body($eml)));
@@ -56,7 +56,7 @@ sub res_hdr ($$) {
$fn =~ s/^re:\s+//i;
$fn = to_filename($fn) // 'no-subject';
my @hdr = ('Content-Type');
- if ($ctx->{-inbox}->{obfuscate}) {
+ if ($ctx->{ibx}->{obfuscate}) {
# obfuscation is stupid, but maybe scrapers are, too...
push @hdr, 'application/mbox';
$fn .= '.mbox';
@@ -71,7 +71,7 @@ sub res_hdr ($$) {
# for rare cases where v1 inboxes aren't indexed w/ ->over at all
sub no_over_raw ($) {
my ($ctx) = @_;
- my $mref = $ctx->{-inbox}->msg_by_mid($ctx->{mid}) or return;
+ my $mref = $ctx->{ibx}->msg_by_mid($ctx->{mid}) or return;
my $eml = PublicInbox::Eml->new($mref);
[ 200, res_hdr($ctx, $eml->header_str('Subject')),
[ msg_hdr($ctx, $eml, $ctx->{mid}) . msg_body($eml) ] ]
@@ -80,8 +80,8 @@ sub no_over_raw ($) {
# /$INBOX/$MESSAGE_ID/raw
sub emit_raw {
my ($ctx) = @_;
- $ctx->{base_url} = $ctx->{-inbox}->base_url($ctx->{env});
- my $over = $ctx->{-inbox}->over or return no_over_raw($ctx);
+ $ctx->{base_url} = $ctx->{ibx}->base_url($ctx->{env});
+ my $over = $ctx->{ibx}->over or return no_over_raw($ctx);
my ($id, $prev);
my $mip = $ctx->{next_arg} = [ $ctx->{mid}, \$id, \$prev ];
my $smsg = $ctx->{smsg} = $over->next_by_mid(@$mip) or return;
@@ -99,7 +99,7 @@ sub msg_hdr ($$;$) {
foreach my $d (qw(Lines Bytes Content-Length Status)) {
$header_obj->header_set($d);
}
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $base = $ctx->{base_url};
$mid = $ctx->{mid} unless defined $mid;
$mid = mid_escape($mid);
@@ -190,7 +190,7 @@ sub all_ids_cb {
sub mbox_all_ids {
my ($ctx) = @_;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $prev = 0;
my $mm = $ctx->{mm} = $ibx->mm;
my $ids = $mm->ids_after(\$prev) or return
@@ -205,20 +205,20 @@ sub mbox_all_ids {
sub gone ($$) {
my ($ctx, $what) = @_;
- warn "W: `$ctx->{-inbox}->{inboxdir}' $what went away unexpectedly\n";
+ warn "W: `$ctx->{ibx}->{inboxdir}' $what went away unexpectedly\n";
undef;
}
sub results_cb {
my ($ctx) = @_;
- my $over = $ctx->{-inbox}->over or return gone($ctx, 'over');
+ my $over = $ctx->{ibx}->over or return gone($ctx, 'over');
while (1) {
while (defined(my $num = shift(@{$ctx->{ids}}))) {
my $smsg = $over->get_art($num) or next;
return $smsg;
}
# refill result set
- my $srch = $ctx->{-inbox}->isrch or return gone($ctx, 'search');
+ my $srch = $ctx->{ibx}->isrch or return gone($ctx, 'search');
my $mset = $srch->mset($ctx->{query}, $ctx->{qopts});
my $size = $mset->size or return;
$ctx->{qopts}->{offset} += $size;
@@ -229,7 +229,7 @@ sub results_cb {
sub results_thread_cb {
my ($ctx) = @_;
- my $over = $ctx->{-inbox}->over or return gone($ctx, 'over');
+ my $over = $ctx->{ibx}->over or return gone($ctx, 'over');
while (1) {
while (defined(my $num = shift(@{$ctx->{xids}}))) {
my $smsg = $over->get_art($num) or next;
@@ -240,7 +240,7 @@ sub results_thread_cb {
next if $over->expand_thread($ctx);
# refill result set
- my $srch = $ctx->{-inbox}->isrch or return gone($ctx, 'search');
+ my $srch = $ctx->{ibx}->isrch or return gone($ctx, 'search');
my $mset = $srch->mset($ctx->{query}, $ctx->{qopts});
my $size = $mset->size or return;
$ctx->{qopts}->{offset} += $size;
@@ -253,9 +253,9 @@ sub mbox_all {
my ($ctx, $q) = @_;
my $q_string = $q->{'q'};
return mbox_all_ids($ctx) if $q_string !~ /\S/;
- my $srch = $ctx->{-inbox}->isrch or
+ my $srch = $ctx->{ibx}->isrch or
return PublicInbox::WWW::need($ctx, 'Search');
- my $over = $ctx->{-inbox}->over or
+ my $over = $ctx->{ibx}->over or
return PublicInbox::WWW::need($ctx, 'Overview');
my $qopts = $ctx->{qopts} = { mset => 2 }; # order by docid
diff --git a/lib/PublicInbox/MboxGz.pm b/lib/PublicInbox/MboxGz.pm
index 913be6e4..ab3c9770 100644
--- a/lib/PublicInbox/MboxGz.pm
+++ b/lib/PublicInbox/MboxGz.pm
@@ -22,7 +22,7 @@ sub async_next ($) {
sub mbox_gz {
my ($self, $cb, $fn) = @_;
$self->{cb} = $cb;
- $self->{base_url} = $self->{-inbox}->base_url($self->{env});
+ $self->{base_url} = $self->{ibx}->base_url($self->{env});
$self->{gz} = PublicInbox::GzipFilter::gzip_or_die();
$fn = to_filename($fn // '') // 'no-subject';
# http://www.iana.org/assignments/media-types/application/gzip
@@ -37,7 +37,7 @@ sub getline {
my ($self) = @_;
my $cb = $self->{cb} or return;
while (my $smsg = $cb->($self)) {
- my $eml = $self->{-inbox}->smsg_eml($smsg) or next;
+ my $eml = $self->{ibx}->smsg_eml($smsg) or next;
$self->zmore(msg_hdr($self, $eml, $smsg->{mid}));
return $self->translate(msg_body($eml));
}
diff --git a/lib/PublicInbox/SearchThread.pm b/lib/PublicInbox/SearchThread.pm
index 60f692b2..8fb3a030 100644
--- a/lib/PublicInbox/SearchThread.pm
+++ b/lib/PublicInbox/SearchThread.pm
@@ -42,7 +42,7 @@ sub thread {
# We'll trust the client Date: header here instead of the Received:
# time since this is for display (and not retrieval)
_set_parent(\%id_table, $_) for sort { $a->{ds} <=> $b->{ds} } @$msgs;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $rootset = [ grep {
!delete($_->{parent}) && $_->visible($ibx)
} values %id_table ];
@@ -166,7 +166,7 @@ sub order_children {
my %seen = ($cur => 1); # self-referential loop prevention
my @q = ($cur);
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
while (defined($cur = shift @q)) {
my $c = $cur->{children}; # The hashref here...
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index f3c96126..f568f31c 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -30,7 +30,7 @@ sub mbox_results {
sub sres_top_html {
my ($ctx) = @_;
- my $srch = $ctx->{-inbox}->isrch or
+ my $srch = $ctx->{ibx}->isrch or
return PublicInbox::WWW::need($ctx, 'Search');
my $q = PublicInbox::SearchQuery->new($ctx->{qp});
my $x = $q->{x};
@@ -93,7 +93,7 @@ sub mset_summary {
my $pad = length("$total");
my $pfx = ' ' x $pad;
my $res = \($ctx->{-html_tip});
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $obfs_ibx = $ibx->{obfuscate} ? $ibx : undef;
my @nums = @{$ibx->isrch->mset_to_artnums($mset)};
my %num2msg = map { $_->{num} => $_ } @{$ibx->over->get_all(@nums)};
@@ -156,7 +156,7 @@ sub path2inc ($) {
sub err_txt {
my ($ctx, $err) = @_;
- my $u = $ctx->{-inbox}->base_url($ctx->{env}) . '_/text/help/';
+ my $u = $ctx->{ibx}->base_url($ctx->{env}) . '_/text/help/';
$err =~ s/^\s*Exception:\s*//; # bad word to show users :P
$err =~ s!(\S+)!path2inc($1)!sge;
$err = ascii_html($err);
@@ -201,7 +201,7 @@ sub search_nav_top {
}
my $A = $q->qs_html(x => 'A', r => undef);
$rv .= qq{|<a\nhref="?$A">Atom feed</a>]};
- if ($ctx->{-inbox}->isrch->has_threadid) {
+ if ($ctx->{ibx}->isrch->has_threadid) {
$rv .= qq{\n\t\t\tdownload mbox.gz: } .
# we set name=z w/o using it since it seems required for
# lynx (but works fine for w3m).
@@ -286,7 +286,7 @@ sub get_pct ($) {
sub mset_thread {
my ($ctx, $mset, $q) = @_;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my @pct = map { get_pct($_) } $mset->items;
my $msgs = $ibx->isrch->mset_to_smsg($ibx, $mset);
my $i = 0;
@@ -353,7 +353,7 @@ sub ctx_prepare {
sub adump {
my ($cb, $mset, $q, $ctx) = @_;
- $ctx->{ids} = $ctx->{-inbox}->isrch->mset_to_artnums($mset);
+ $ctx->{ids} = $ctx->{ibx}->isrch->mset_to_artnums($mset);
$ctx->{search_query} = $q; # used by WwwAtomStream::atom_header
PublicInbox::WwwAtomStream->response($ctx, 200, \&adump_i);
}
@@ -362,7 +362,7 @@ sub adump {
sub adump_i {
my ($ctx) = @_;
while (my $num = shift @{$ctx->{ids}}) {
- my $smsg = eval { $ctx->{-inbox}->over->get_art($num) } or next;
+ my $smsg = eval { $ctx->{ibx}->over->get_art($num) } or next;
return $smsg;
}
}
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 1d5119cd..a27e9369 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -48,7 +48,7 @@ sub msg_page_i {
# /$INBOX/$MSGID/ for unindexed v1 inboxes
sub no_over_html ($) {
my ($ctx) = @_;
- my $bref = $ctx->{-inbox}->msg_by_mid($ctx->{mid}) or return; # 404
+ my $bref = $ctx->{ibx}->msg_by_mid($ctx->{mid}) or return; # 404
my $eml = PublicInbox::Eml->new($bref);
$ctx->{mhref} = '';
PublicInbox::WwwStream::init($ctx);
@@ -64,7 +64,7 @@ sub no_over_html ($) {
sub msg_page {
my ($ctx) = @_;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
$ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef;
my $over = $ctx->{over} = $ibx->over or return no_over_html($ctx);
my ($id, $prev);
@@ -88,7 +88,7 @@ sub msg_reply ($$) {
'https://en.wikipedia.org/wiki/Posting_style#Interleaved_style';
my $info = '';
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
if (my $url = $ibx->{infourl}) {
$url = prurl($ctx->{env}, $url);
$info = qq(\n List information: <a\nhref="$url">$url</a>\n);
@@ -421,7 +421,7 @@ sub stream_thread ($$) {
sub thread_html {
my ($ctx) = @_;
my $mid = $ctx->{mid};
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my ($nr, $msgs) = $ibx->over->get_thread($mid);
return missing_thread($ctx) if $nr == 0;
@@ -554,7 +554,7 @@ EOF
sub add_text_body { # callback for each_part
my ($p, $ctx) = @_;
my $upfx = $ctx->{mhref};
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $l = $ctx->{-linkify} //= PublicInbox::Linkify->new;
# $p - from each_part: [ Email::MIME-like, depth, $idx ]
my ($part, $depth, $idx) = @$p;
@@ -639,7 +639,7 @@ sub add_text_body { # callback for each_part
sub _msg_page_prepare_obuf {
my ($eml, $ctx) = @_;
- my $over = $ctx->{-inbox}->over;
+ my $over = $ctx->{ibx}->over;
my $obfs_ibx = $ctx->{-obfs_ibx};
my $rv = '';
my $mids = mids_for_index($eml);
@@ -729,7 +729,7 @@ sub SKEL_EXPAND () {
sub thread_skel ($$$) {
my ($skel, $ctx, $hdr) = @_;
my $mid = mids($hdr)->[0];
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my ($nr, $msgs) = $ibx->over->get_thread($mid);
my $parent = in_reply_to($hdr);
$$skel .= "\n<b>Thread overview: </b>";
@@ -800,7 +800,7 @@ sub _parent_headers {
# returns a string buffer
sub html_footer {
my ($ctx, $hdr) = @_;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $upfx = '../';
my $skel;
my $rv = '<pre>';
@@ -1072,7 +1072,7 @@ sub acc_topic { # walk_thread callback
my ($ctx, $level, $smsg) = @_;
my $mid = $smsg->{mid};
my $has_blob = $smsg->{blob} // do {
- if (my $by_mid = $ctx->{-inbox}->smsg_by_mid($mid)) {
+ if (my $by_mid = $ctx->{ibx}->smsg_by_mid($mid)) {
%$smsg = (%$smsg, %$by_mid);
1;
}
@@ -1116,7 +1116,7 @@ sub dump_topics {
}
my @out;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $obfs_ibx = $ibx->{obfuscate} ? $ibx : undef;
# sort by recency, this allows new posts to "bump" old topics...
@@ -1194,7 +1194,7 @@ sub paginate_recent ($$) {
$t =~ s/\A([0-9]{8,14})-// and $after = str2ts($1);
$t =~ /\A([0-9]{8,14})\z/ and $before = str2ts($1);
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $msgs = $ibx->recent($opts, $after, $before);
my $nr = scalar @$msgs;
if ($nr < $lim && defined($after)) {
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index 87927d5e..3f34ea82 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -197,7 +197,7 @@ sub show ($$;$) {
$ctx->{'log'} = tmpfile("solve.$oid_b");
$ctx->{fn} = $fn;
- my $solver = PublicInbox::SolverGit->new($ctx->{-inbox},
+ my $solver = PublicInbox::SolverGit->new($ctx->{ibx},
\&solve_result, $ctx);
# PSGI server will call this immediately and give us a callback (-wcb)
sub {
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index fc208816..6bae2190 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -213,7 +213,7 @@ sub invalid_inbox ($$) {
my $ibx = $ctx->{www}->{pi_config}->lookup_name($inbox) //
$ctx->{www}->{pi_config}->lookup_ei($inbox);
if (defined $ibx) {
- $ctx->{-inbox} = $ibx;
+ $ctx->{ibx} = $ibx;
return;
}
@@ -231,11 +231,11 @@ sub invalid_inbox_mid {
return $ret if $ret;
my $mid = $ctx->{mid} = uri_unescape($mid_ue);
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
if ($mid =~ m!\A([a-f0-9]{2})([a-f0-9]{38})\z!) {
my ($x2, $x38) = ($1, $2);
# this is horrifically wasteful for legacy URLs:
- my $str = $ctx->{-inbox}->msg_by_path("$x2/$x38") or return;
+ my $str = $ctx->{ibx}->msg_by_path("$x2/$x38") or return;
my $s = PublicInbox::Eml->new($str);
$mid = PublicInbox::MID::mid_clean($s->header_raw('Message-ID'));
return r301($ctx, $inbox, mid_escape($mid));
@@ -286,7 +286,7 @@ sub get_mid_html {
# /$INBOX/$MESSAGE_ID/t/
sub get_thread {
my ($ctx, $flat) = @_;
- $ctx->{-inbox}->over or return need($ctx, 'Overview');
+ $ctx->{ibx}->over or return need($ctx, 'Overview');
$ctx->{flat} = $flat;
require PublicInbox::View;
PublicInbox::View::thread_html($ctx);
@@ -339,7 +339,7 @@ EOF
# especially on older systems. Stick to zlib since that's what git uses.
sub get_thread_mbox {
my ($ctx, $sfx) = @_;
- my $over = $ctx->{-inbox}->over or return need($ctx, 'Overview');
+ my $over = $ctx->{ibx}->over or return need($ctx, 'Overview');
require PublicInbox::Mbox;
PublicInbox::Mbox::thread_mbox($ctx, $over, $sfx);
}
@@ -348,7 +348,7 @@ sub get_thread_mbox {
# /$INBOX/$MESSAGE_ID/t.atom -> thread as Atom feed
sub get_thread_atom {
my ($ctx) = @_;
- $ctx->{-inbox}->over or return need($ctx, 'Overview');
+ $ctx->{ibx}->over or return need($ctx, 'Overview');
require PublicInbox::Feed;
PublicInbox::Feed::generate_thread_atom($ctx);
}
@@ -413,11 +413,11 @@ sub legacy_redirects {
sub r301 {
my ($ctx, $inbox, $mid_ue, $suffix) = @_;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
unless ($ibx) {
my $r404 = invalid_inbox($ctx, $inbox);
return $r404 if $r404;
- $ibx = $ctx->{-inbox};
+ $ibx = $ctx->{ibx};
}
my $url = $ibx->base_url($ctx->{env});
my $qs = $ctx->{env}->{QUERY_STRING};
@@ -454,7 +454,7 @@ sub msg_page {
sub serve_git {
my ($ctx, $epoch, $path) = @_;
my $env = $ctx->{env};
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $git = defined $epoch ? $ibx->git_epoch($epoch) : $ibx->git;
$git ? PublicInbox::GitHTTPBackend::serve($env, $git, $path) : r404();
}
@@ -462,7 +462,7 @@ sub serve_git {
sub mbox_results {
my ($ctx) = @_;
if ($ctx->{env}->{QUERY_STRING} =~ /(?:\A|[&;])q=/) {
- $ctx->{-inbox}->isrch or return need($ctx, 'search');
+ $ctx->{ibx}->isrch or return need($ctx, 'search');
require PublicInbox::SearchView;
return PublicInbox::SearchView::mbox_results($ctx);
}
@@ -642,7 +642,7 @@ sub get_css ($$$) {
my $css = $css_map->{$key};
if (!defined($css) && $key eq 'userContent') {
my $env = $ctx->{env};
- $css = PublicInbox::UserContent::sample($ctx->{-inbox}, $env);
+ $css = PublicInbox::UserContent::sample($ctx->{ibx}, $env);
}
defined $css or return r404();
my $h = [ 'Content-Length', bytes::length($css),
@@ -654,7 +654,7 @@ sub get_css ($$$) {
sub get_description {
my ($ctx, $inbox) = @_;
invalid_inbox($ctx, $inbox) || do {
- my $d = $ctx->{-inbox}->description . "\n";
+ my $d = $ctx->{ibx}->description . "\n";
[ 200, [ 'Content-Length', bytes::length($d),
'Content-Type', 'text/plain' ], [ $d ] ];
};
diff --git a/lib/PublicInbox/WwwAltId.pm b/lib/PublicInbox/WwwAltId.pm
index 2818400e..204e2f82 100644
--- a/lib/PublicInbox/WwwAltId.pm
+++ b/lib/PublicInbox/WwwAltId.pm
@@ -30,7 +30,7 @@ sub check_output {
sub sqldump ($$) {
my ($ctx, $altid_pfx) = @_;
my $env = $ctx->{env};
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $altid_map = $ibx->altid_map;
my $fn = $altid_map->{$altid_pfx};
unless (defined $fn) {
diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm
index 388def12..912f860e 100644
--- a/lib/PublicInbox/WwwAtomStream.pm
+++ b/lib/PublicInbox/WwwAtomStream.pm
@@ -15,7 +15,7 @@ use PublicInbox::MsgTime qw(msg_timestamp);
sub new {
my ($class, $ctx, $cb) = @_;
- $ctx->{feed_base_url} = $ctx->{-inbox}->base_url($ctx->{env});
+ $ctx->{feed_base_url} = $ctx->{ibx}->base_url($ctx->{env});
$ctx->{cb} = $cb || \&PublicInbox::GzipFilter::close;
$ctx->{emit_header} = 1;
bless $ctx, $class;
@@ -53,7 +53,7 @@ sub getline {
my ($self) = @_;
my $cb = $self->{cb} or return;
while (my $smsg = $cb->($self)) {
- my $eml = $self->{-inbox}->smsg_eml($smsg) or next;
+ my $eml = $self->{ibx}->smsg_eml($smsg) or next;
return $self->translate(feed_entry($self, $smsg, $eml));
}
delete $self->{cb};
@@ -82,7 +82,7 @@ sub to_uuid ($) {
sub atom_header {
my ($ctx, $title) = @_;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $base_url = $ctx->{feed_base_url};
my $search_q = $ctx->{search_query};
my $self_url = $base_url;
@@ -136,10 +136,10 @@ sub feed_entry {
$title = title_tag($title);
my $from = $eml->header('From') // $eml->header('Sender') //
- $ctx->{-inbox}->{-primary_address};
+ $ctx->{ibx}->{-primary_address};
my ($email) = PublicInbox::Address::emails($from);
my $name = ascii_html(join(', ', PublicInbox::Address::names($from)));
- $email = ascii_html($email // $ctx->{-inbox}->{-primary_address});
+ $email = ascii_html($email // $ctx->{ibx}->{-primary_address});
my $s = delete($ctx->{emit_header}) ? atom_header($ctx, $title) : '';
$s .= "<entry><author><name>$name</name><email>$email</email>" .
diff --git a/lib/PublicInbox/WwwAttach.pm b/lib/PublicInbox/WwwAttach.pm
index 09c66d02..0fe63e42 100644
--- a/lib/PublicInbox/WwwAttach.pm
+++ b/lib/PublicInbox/WwwAttach.pm
@@ -16,7 +16,7 @@ sub referer_match ($) {
return 1 if $referer eq ''; # no referer is always OK for wget/curl
# prevent deep-linking from other domains on some browsers (Firefox)
- # n.b.: $ctx->{-inbox}->base_url($env) with INBOX_URL won't work
+ # n.b.: $ctx->{ibx}->base_url($env) with INBOX_URL won't work
# with dillo, we can only match "$url_scheme://$HTTP_HOST/" without
# path components
my $base_url = $env->{'psgi.url_scheme'} . '://' .
@@ -88,15 +88,15 @@ sub get_attach ($$$) {
$ctx->{idx} = $idx;
bless $ctx, __PACKAGE__;
my $eml;
- if ($ctx->{smsg} = $ctx->{-inbox}->smsg_by_mid($ctx->{mid})) {
+ if ($ctx->{smsg} = $ctx->{ibx}->smsg_by_mid($ctx->{mid})) {
return sub { # public-inbox-httpd-only
$ctx->{wcb} = $_[0];
scan_attach($ctx);
} if $ctx->{env}->{'pi-httpd.async'};
# generic PSGI:
- $eml = $ctx->{-inbox}->smsg_eml($ctx->{smsg});
- } elsif (!$ctx->{-inbox}->over) {
- if (my $bref = $ctx->{-inbox}->msg_by_mid($ctx->{mid})) {
+ $eml = $ctx->{ibx}->smsg_eml($ctx->{smsg});
+ } elsif (!$ctx->{ibx}->over) {
+ if (my $bref = $ctx->{ibx}->msg_by_mid($ctx->{mid})) {
$eml = PublicInbox::Eml->new($bref);
}
}
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index 2527b8ed..849831a6 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -16,7 +16,7 @@ our $CODE_URL = 'https://public-inbox.org/public-inbox.git';
sub base_url ($) {
my $ctx = shift;
- my $base_url = $ctx->{-inbox}->base_url($ctx->{env});
+ my $base_url = $ctx->{ibx}->base_url($ctx->{env});
chop $base_url; # no trailing slash for clone
$base_url;
}
@@ -35,7 +35,7 @@ sub async_eml { # for async_blob_cb
sub html_top ($) {
my ($ctx) = @_;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $desc = ascii_html($ibx->description);
my $title = delete($ctx->{-title_html}) // $desc;
my $upfx = $ctx->{-upfx} || '';
@@ -78,7 +78,7 @@ sub html_top ($) {
sub coderepos ($) {
my ($ctx) = @_;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my @ret;
if (defined(my $cr = $ibx->{coderepo})) {
my $cfg = $ctx->{www}->{pi_config};
@@ -109,7 +109,7 @@ sub _html_end {
id=mirror>This inbox may be cloned and mirrored by anyone:</a>
EOF
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $desc = ascii_html($ibx->description);
my @urls;
@@ -184,7 +184,7 @@ sub getline {
my $cb = $ctx->{cb} or return;
while (defined(my $x = $cb->($ctx))) { # x = smsg or scalar non-ref
if (ref($x)) { # smsg
- my $eml = $ctx->{-inbox}->smsg_eml($x) or next;
+ my $eml = $ctx->{ibx}->smsg_eml($x) or next;
$ctx->{smsg} = $x;
return $ctx->translate($cb->($ctx, $eml));
} else { # scalar
diff --git a/lib/PublicInbox/WwwText.pm b/lib/PublicInbox/WwwText.pm
index 8cc818df..53e15e45 100644
--- a/lib/PublicInbox/WwwText.pm
+++ b/lib/PublicInbox/WwwText.pm
@@ -49,7 +49,7 @@ sub get_text {
# enforce trailing slash for "wget -r" compatibility
if (!$have_tslash && $code == 200) {
- my $url = $ctx->{-inbox}->base_url($env);
+ my $url = $ctx->{ibx}->base_url($env);
$url .= "_/text/$key/";
return [ 302, [ 'Content-Type', 'text/plain',
@@ -100,7 +100,7 @@ sub _srch_prefix ($$) {
sub _colors_help ($$) {
my ($ctx, $txt) = @_;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $env = $ctx->{env};
my $base_url = $ibx->base_url($env);
$$txt .= "color customization for $base_url\n";
@@ -135,7 +135,7 @@ sub URI_PATH () { '^A-Za-z0-9\-\._~/' }
# n.b. this is a perfect candidate for memoization
sub inbox_config ($$$) {
my ($ctx, $hdr, $txt) = @_;
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
push @$hdr, 'Content-Disposition', 'inline; filename=inbox.config';
my $name = dq_escape($ibx->{name});
my $inboxdir = '/path/to/top-level-inbox';
@@ -221,7 +221,7 @@ sub _default_text ($$$$) {
return inbox_config($ctx, $hdr, $txt) if $key eq 'config';
return if $key ne 'help'; # TODO more keys?
- my $ibx = $ctx->{-inbox};
+ my $ibx = $ctx->{ibx};
my $base_url = $ibx->base_url($ctx->{env});
$$txt .= "public-inbox help for $base_url\n";
$$txt .= <<EOF;
diff --git a/t/feed.t b/t/feed.t
index 5ad90a07..9f6a987b 100644
--- a/t/feed.t
+++ b/t/feed.t
@@ -75,7 +75,7 @@ EOF
{
# check initial feed
{
- my $feed = string_feed({ -inbox => $ibx });
+ my $feed = string_feed({ ibx => $ibx });
SKIP: {
skip 'XML::TreePP missing', 3 unless $have_xml_treepp;
my $t = XML::TreePP->new->parse($feed);
@@ -109,7 +109,7 @@ EOF
# check spam shows up
{
- my $spammy_feed = string_feed({ -inbox => $ibx });
+ my $spammy_feed = string_feed({ ibx => $ibx });
SKIP: {
skip 'XML::TreePP missing', 2 unless $have_xml_treepp;
my $t = XML::TreePP->new->parse($spammy_feed);
@@ -127,7 +127,7 @@ EOF
# spam no longer shows up
{
- my $feed = string_feed({ -inbox => $ibx });
+ my $feed = string_feed({ ibx => $ibx });
SKIP: {
skip 'XML::TreePP missing', 2 unless $have_xml_treepp;
my $t = XML::TreePP->new->parse($feed);
diff --git a/t/filter_rubylang.t b/t/filter_rubylang.t
index e6c53f98..6d639c00 100644
--- a/t/filter_rubylang.t
+++ b/t/filter_rubylang.t
@@ -35,7 +35,7 @@ SKIP: {
];
my $ibx = PublicInbox::Inbox->new({ inboxdir => $git_dir,
altid => $altid });
- $f = PublicInbox::Filter::RubyLang->new(-inbox => $ibx);
+ $f = PublicInbox::Filter::RubyLang->new(ibx => $ibx);
$msg = <<'EOF';
X-Mail-Count: 12
Message-ID: <a@b>
diff --git a/xt/cmp-msgview.t b/xt/cmp-msgview.t
index 5bd7aa17..24151267 100644
--- a/xt/cmp-msgview.t
+++ b/xt/cmp-msgview.t
@@ -24,7 +24,7 @@ vec(my $vec = '', fileno($fh), 1) = 1;
select($vec, undef, undef, 60) or die "timed out waiting for --batch-check";
my $mime_ctx = {
env => { HTTP_HOST => 'example.com', 'psgi.url_scheme' => 'https' },
- -inbox => $ibx,
+ ibx => $ibx,
www => Plack::Util::inline_object(style => sub {''}),
obuf => \(my $mime_buf = ''),
mhref => '../',
diff --git a/xt/perf-msgview.t b/xt/perf-msgview.t
index d99101a3..30e133d7 100644
--- a/xt/perf-msgview.t
+++ b/xt/perf-msgview.t
@@ -29,7 +29,7 @@ select($vec, undef, undef, 60) or die "timed out waiting for --batch-check";
my $ctx = {
env => { HTTP_HOST => 'example.com', 'psgi.url_scheme' => 'https' },
- -inbox => $ibx,
+ ibx => $ibx,
www => Plack::Util::inline_object(style => sub {''}),
};
my ($mime, $res, $oid, $type);
diff --git a/xt/perf-threading.t b/xt/perf-threading.t
index b27c9cbd..472c1953 100644
--- a/xt/perf-threading.t
+++ b/xt/perf-threading.t
@@ -25,7 +25,7 @@ ok($n, 'got some messages');
diag "enquire: ".timestr($elapsed)." for $n";
$elapsed = timeit(1, sub {
- PublicInbox::View::thread_results({-inbox => $ibx}, $msgs);
+ PublicInbox::View::thread_results({ibx => $ibx}, $msgs);
});
diag "thread_results ".timestr($elapsed);
^ permalink raw reply related [relevance 2%]
* [PATCH 0/6] minor internal consistency things
@ 2020-12-08 21:21 7% Eric Wong
2020-12-08 21:21 2% ` [PATCH 1/6] treewide: replace {-inbox} with {ibx} for consistency Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-12-08 21:21 UTC (permalink / raw)
To: meta
Some more changes because the codebase needs to grow to
support client-side tooling and JMAP.
Lack of static type-checking means we need to be more consistent
with naming conventions to avoid confusing my easily-confused
mind.
Eric Wong (6):
treewide: replace {-inbox} with {ibx} for consistency
nntp: replace {ng} with {ibx} for consistency
rename {pi_config} fields to {pi_cfg}
extindex: do not use current dir like -index does
admin: resolve_repo_dir => resolve_inboxdir
extsearchidx: ck_existing: set $OID for warning context
Documentation/mknews.perl | 4 +-
examples/cgit.psgi | 4 +-
lib/PublicInbox/Admin.pm | 8 +-
lib/PublicInbox/Cgit.pm | 24 +++---
lib/PublicInbox/Config.pm | 2 +-
lib/PublicInbox/ExtMsg.pm | 18 ++---
lib/PublicInbox/ExtSearchIdx.pm | 2 +
lib/PublicInbox/Feed.pm | 6 +-
lib/PublicInbox/Filter/RubyLang.pm | 2 +-
lib/PublicInbox/GzipFilter.pm | 4 +-
lib/PublicInbox/IMAPD.pm | 28 +++----
lib/PublicInbox/Inbox.pm | 10 +--
lib/PublicInbox/InboxIdle.pm | 9 +--
lib/PublicInbox/InboxWritable.pm | 2 +-
lib/PublicInbox/MDA.pm | 4 +-
lib/PublicInbox/ManifestJsGz.pm | 2 +-
lib/PublicInbox/Mbox.pm | 30 +++----
lib/PublicInbox/MboxGz.pm | 4 +-
lib/PublicInbox/NNTP.pm | 124 ++++++++++++++---------------
lib/PublicInbox/NNTPD.pm | 16 ++--
lib/PublicInbox/NewsWWW.pm | 15 ++--
lib/PublicInbox/Qspawn.pm | 4 +-
lib/PublicInbox/SearchThread.pm | 4 +-
lib/PublicInbox/SearchView.pm | 14 ++--
lib/PublicInbox/Spamcheck.pm | 4 +-
lib/PublicInbox/Unsubscribe.pm | 6 +-
lib/PublicInbox/View.pm | 22 ++---
lib/PublicInbox/ViewVCS.pm | 2 +-
lib/PublicInbox/WWW.pm | 51 ++++++------
lib/PublicInbox/Watch.pm | 20 ++---
lib/PublicInbox/WwwAltId.pm | 2 +-
lib/PublicInbox/WwwAtomStream.pm | 10 +--
lib/PublicInbox/WwwAttach.pm | 10 +--
lib/PublicInbox/WwwListing.pm | 4 +-
lib/PublicInbox/WwwStream.pm | 12 +--
lib/PublicInbox/WwwText.pm | 12 +--
script/public-inbox-index | 1 +
script/public-inbox-learn | 8 +-
script/public-inbox-mda | 8 +-
scripts/import_slrnspool | 4 +-
t/admin.t | 28 ++++---
t/feed.t | 6 +-
t/filter_rubylang.t | 2 +-
t/imapd.t | 4 +-
t/inbox_idle.t | 8 +-
t/mda_filter_rubylang.t | 4 +-
t/nntp.t | 12 +--
t/psgi_mount.t | 6 +-
t/psgi_search.t | 6 +-
t/psgi_v2.t | 11 ++-
t/watch_filter_rubylang.t | 10 +--
t/watch_maildir.t | 26 +++---
t/watch_maildir_v2.t | 48 +++++------
t/watch_multiple_headers.t | 8 +-
xt/cmp-msgview.t | 2 +-
xt/perf-msgview.t | 2 +-
xt/perf-threading.t | 2 +-
57 files changed, 352 insertions(+), 349 deletions(-)
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-12-08 21:21 7% [PATCH 0/6] minor internal consistency things Eric Wong
2020-12-08 21:21 2% ` [PATCH 1/6] treewide: replace {-inbox} with {ibx} for consistency Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).