]> Sergey Matveev's repositories - public-inbox.git/commitdiff
cleanup: use '$ibx' consistently when referring to Inbox refs
authorEric Wong <e@80x24.org>
Tue, 16 Apr 2019 01:10:09 +0000 (01:10 +0000)
committerEric Wong <e@80x24.org>
Tue, 16 Apr 2019 20:58:23 +0000 (20:58 +0000)
'$inbox' is more human-readable, so that is for the more
human-readable name in most cases.  Making our variable naming
more consistent should make the code easier-to-review and
harder to screw up.

lib/PublicInbox/AltId.pm
lib/PublicInbox/Config.pm
lib/PublicInbox/Import.pm
lib/PublicInbox/NewsWWW.pm
lib/PublicInbox/SearchView.pm
lib/PublicInbox/Unsubscribe.pm
lib/PublicInbox/View.pm
lib/PublicInbox/WWW.pm
lib/PublicInbox/WwwStream.pm
t/altid.t

index 300bdc0b49fbda3d561c4037ab812ce732ac79b1..c22b9598f6a0acc3c04d70091c47eb279b1ccfc5 100644 (file)
@@ -18,7 +18,7 @@ use URI::Escape qw(uri_unescape);
 # The PREFIX will be a searchable boolean prefix in Xapian
 # Example: serial:gmane:file=/path/to/altmsgmap.sqlite3
 sub new {
-       my ($class, $inbox, $spec, $writable) = @_;
+       my ($class, $ibx, $spec, $writable) = @_;
        my ($type, $prefix, $query) = split(/:/, $spec, 3);
        $type eq 'serial' or die "non-serial not supported, yet\n";
 
@@ -31,10 +31,10 @@ sub new {
        } split(/[&;]/, $query);
        my $f = $params{file} or die "file: required for $type spec $spec\n";
        unless (index($f, '/') == 0) {
-               if (($inbox->{version} || 1) == 1) {
-                       $f = "$inbox->{mainrepo}/public-inbox/$f";
+               if (($ibx->{version} || 1) == 1) {
+                       $f = "$ibx->{mainrepo}/public-inbox/$f";
                } else {
-                       $f = "$inbox->{mainrepo}/$f";
+                       $f = "$ibx->{mainrepo}/$f";
                }
        }
        bless {
index cdc939a60e59ecbb590d1ed72ff1f931e6d2ed42..27222c033c330aed99a4e10af1fb51920b63cc5f 100644 (file)
@@ -60,8 +60,8 @@ sub new {
 sub lookup {
        my ($self, $recipient) = @_;
        my $addr = lc($recipient);
-       my $inbox = $self->{-by_addr}->{$addr};
-       return $inbox if $inbox;
+       my $ibx = $self->{-by_addr}->{$addr};
+       return $ibx if $ibx;
 
        my $pfx;
 
index 7e596abc38b2bc541074f757c560ca33ed64610f..fc4e72dc93ea0ce978a93f5224c74e5b8178acc3 100644 (file)
@@ -178,8 +178,8 @@ sub _update_git_info ($$) {
        run_die([@cmd, 'update-server-info'], undef);
        ($self->{path_type} eq '2/38') and eval {
                require PublicInbox::SearchIdx;
-               my $inbox = $self->{inbox} || $git_dir;
-               my $s = PublicInbox::SearchIdx->new($inbox);
+               my $ibx = $self->{inbox} || $git_dir;
+               my $s = PublicInbox::SearchIdx->new($ibx);
                $s->index_sync({ ref => $self->{ref} });
        };
        eval { run_die([@cmd, qw(gc --auto)], undef) } if $do_gc;
index d7fcb0daec1d2d35161c82e15333dc09e4daed23..8626cf96eaba44acee92a10a2aa3d84fcb7ab788 100644 (file)
@@ -44,11 +44,11 @@ sub call {
        my (undef, @parts) = split(m!/!, $env->{PATH_INFO});
        my ($ng, $article) = @parts;
        my $pi_config = $self->{pi_config};
-       if (my $inbox = $pi_config->lookup_newsgroup($ng)) {
-               my $url = PublicInbox::Hval::prurl($env, $inbox->{url});
+       if (my $ibx = $pi_config->lookup_newsgroup($ng)) {
+               my $url = PublicInbox::Hval::prurl($env, $ibx->{url});
                my $code = 301;
                if (defined $article && $article =~ /\A\d+\z/) {
-                       my $mid = eval { $inbox->mm->mid_for($article) };
+                       my $mid = eval { $ibx->mm->mid_for($article) };
                        if (defined $mid) {
                                # article IDs are not stable across clones,
                                # do not encourage caching/bookmarking them
index c33caec905e1cfe96475d5f7a55e37d74a976f42..7ef6b075bf60a5b18080f43dafc6380b407258c9 100644 (file)
@@ -231,7 +231,7 @@ sub mset_thread {
                $r ? sort_relevance(\%pct) : *PublicInbox::View::sort_ds,
                $ctx);
        my $skel = search_nav_bot($mset, $q). "<pre>";
-       my $inbox = $ctx->{-inbox};
+       my $ibx = $ctx->{-inbox};
        $ctx->{-upfx} = '';
        $ctx->{anchor_idx} = 1;
        $ctx->{cur_level} = 0;
@@ -252,7 +252,7 @@ sub mset_thread {
                return unless $msgs;
                my $smsg;
                while (my $m = pop @$msgs) {
-                       $smsg = $inbox->smsg_mime($m) and last;
+                       $smsg = $ibx->smsg_mime($m) and last;
                }
                if ($smsg) {
                        return PublicInbox::View::index_entry($smsg, $ctx,
index 2644f7a9cacca2e868d88c66b3f7a3ad3f5af410..11a347ee82f4e6f138d04c1524a2a9f3e6987558 100644 (file)
@@ -151,9 +151,9 @@ sub archive_info {
        unless ($archive_url) {
                if (my $config = $self->{pi_config}) {
                        # PublicInbox::Config::lookup
-                       my $inbox = $config->lookup($list_addr);
+                       my $ibx = $config->lookup($list_addr);
                        # PublicInbox::Inbox::base_url
-                       $archive_url = $inbox->base_url if $inbox;
+                       $archive_url = $ibx->base_url if $ibx;
                }
        }
 
index 429eba863d534268c620a15aa555d8d22af0fc65..f94daaf2bd65521a97ab591eacb102fc71056ddd 100644 (file)
@@ -399,7 +399,7 @@ sub thread_index_entry {
 
 sub stream_thread ($$) {
        my ($rootset, $ctx) = @_;
-       my $inbox = $ctx->{-inbox};
+       my $ibx = $ctx->{-inbox};
        my @q = map { (0, $_) } @$rootset;
        my $level;
        my $smsg;
@@ -408,11 +408,11 @@ sub stream_thread ($$) {
                my $node = shift @q or next;
                my $cl = $level + 1;
                unshift @q, map { ($cl, $_) } @{$node->{children}};
-               $smsg = $inbox->smsg_mime($node->{smsg}) and last;
+               $smsg = $ibx->smsg_mime($node->{smsg}) and last;
        }
        return missing_thread($ctx) unless $smsg;
 
-       $ctx->{-obfs_ibx} = $inbox->{obfuscate} ? $inbox : undef;
+       $ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef;
        $ctx->{-title_html} = ascii_html($smsg->subject);
        $ctx->{-html_tip} = thread_index_entry($ctx, $level, $smsg);
        $smsg = undef;
@@ -423,7 +423,7 @@ sub stream_thread ($$) {
                        my $node = shift @q or next;
                        my $cl = $level + 1;
                        unshift @q, map { ($cl, $_) } @{$node->{children}};
-                       if ($smsg = $inbox->smsg_mime($node->{smsg})) {
+                       if ($smsg = $ibx->smsg_mime($node->{smsg})) {
                                return thread_index_entry($ctx, $level, $smsg);
                        } else {
                                return ghost_index_entry($ctx, $level, $node);
@@ -462,8 +462,8 @@ sub thread_html {
        my $rootset = thread_results($ctx, $msgs);
 
        # reduce hash lookups in pre_thread->skel_dump
-       my $inbox = $ctx->{-inbox};
-       $ctx->{-obfs_ibx} = $inbox->{obfuscate} ? $inbox : undef;
+       my $ibx = $ctx->{-inbox};
+       $ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef;
        walk_thread($rootset, $ctx, *pre_thread);
 
        $skel .= '</pre>';
@@ -472,7 +472,7 @@ sub thread_html {
        # flat display: lazy load the full message from smsg
        my $smsg;
        while (my $m = shift @$msgs) {
-               $smsg = $inbox->smsg_mime($m) and last;
+               $smsg = $ibx->smsg_mime($m) and last;
        }
        return missing_thread($ctx) unless $smsg;
        $ctx->{-title_html} = ascii_html($smsg->subject);
@@ -482,7 +482,7 @@ sub thread_html {
                return unless $msgs;
                $smsg = undef;
                while (my $m = shift @$msgs) {
-                       $smsg = $inbox->smsg_mime($m) and last;
+                       $smsg = $ibx->smsg_mime($m) and last;
                }
                return index_entry($smsg, $ctx, scalar @$msgs) if $smsg;
                $msgs = undef;
index aa05a23dda4aa4b1fb765817d93d40f766e63300..6e69001c4c4d78fa2e52fc851525c30bfd8f7a59 100644 (file)
@@ -186,9 +186,9 @@ sub news_cgit_fallback ($) {
 # returns undef if valid, array ref response if invalid
 sub invalid_inbox ($$) {
        my ($ctx, $inbox) = @_;
-       my $obj = $ctx->{www}->{pi_config}->lookup_name($inbox);
-       if (defined $obj) {
-               $ctx->{-inbox} = $obj;
+       my $ibx = $ctx->{www}->{pi_config}->lookup_name($inbox);
+       if (defined $ibx) {
+               $ctx->{-inbox} = $ibx;
                return;
        }
 
@@ -402,13 +402,13 @@ sub legacy_redirects {
 
 sub r301 {
        my ($ctx, $inbox, $mid_ue, $suffix) = @_;
-       my $obj = $ctx->{-inbox};
-       unless ($obj) {
+       my $ibx = $ctx->{-inbox};
+       unless ($ibx) {
                my $r404 = invalid_inbox($ctx, $inbox);
                return $r404 if $r404;
-               $obj = $ctx->{-inbox};
+               $ibx = $ctx->{-inbox};
        }
-       my $url = $obj->base_url($ctx->{env});
+       my $url = $ibx->base_url($ctx->{env});
        my $qs = $ctx->{env}->{QUERY_STRING};
        if (defined $mid_ue) {
                # common, and much nicer as '@' than '%40':
index 8ae35c73931f19f947b0f99a076db6f832ec6e35..8b79923b64efeab0946e18b1b3bf03094dd6a5fc 100644 (file)
@@ -33,8 +33,8 @@ sub response {
 sub _html_top ($) {
        my ($self) = @_;
        my $ctx = $self->{ctx};
-       my $obj = $ctx->{-inbox};
-       my $desc = ascii_html($obj->description);
+       my $ibx = $ctx->{-inbox};
+       my $desc = ascii_html($ibx->description);
        my $title = $ctx->{-title_html} || $desc;
        my $upfx = $ctx->{-upfx} || '';
        my $help = $upfx.'_/text/help';
@@ -45,7 +45,7 @@ sub _html_top ($) {
        my $links = "<a\nhref=\"$help\">help</a> / ".
                        "<a\nhref=\"$color\">color</a> / ".
                        "<a\nhref=\"$atom\">Atom feed</a>";
-       if ($obj->search) {
+       if ($ibx->search) {
                my $q_val = $ctx->{-q_value_html};
                if (defined $q_val && $q_val ne '') {
                        $q_val = qq(\nvalue="$q_val");
@@ -75,19 +75,19 @@ sub _html_end {
        my ($self) = @_;
        my $urls = 'Archives are clonable:';
        my $ctx = $self->{ctx};
-       my $obj = $ctx->{-inbox};
-       my $desc = ascii_html($obj->description);
+       my $ibx = $ctx->{-inbox};
+       my $desc = ascii_html($ibx->description);
 
        my (%seen, @urls);
-       my $http = $obj->base_url($ctx->{env});
+       my $http = $ibx->base_url($ctx->{env});
        chop $http; # no trailing slash for clone
-       my $part = $obj->max_git_part;
+       my $part = $ibx->max_git_part;
        my $dir = (split(m!/!, $http))[-1];
        if (defined($part)) { # v2
                $seen{$http} = 1;
                for my $i (0..$part) {
                        # old parts my be deleted:
-                       -d "$obj->{mainrepo}/git/$i.git" or next;
+                       -d "$ibx->{mainrepo}/git/$i.git" or next;
                        my $url = "$http/$i";
                        $seen{$url} = 1;
                        push @urls, "$url $dir/git/$i.git";
@@ -99,7 +99,7 @@ sub _html_end {
 
        # FIXME: partitioning in can be different in other repositories,
        # use the "cloneurl" file as-is for now:
-       foreach my $u (@{$obj->cloneurl}) {
+       foreach my $u (@{$ibx->cloneurl}) {
                next if $seen{$u};
                $seen{$u} = 1;
                push @urls, $u =~ /\Ahttps?:/ ? qq(<a\nhref="$u">$u</a>) : $u;
@@ -112,19 +112,19 @@ sub _html_end {
                $urls .= " git clone --mirror $urls[0]";
        }
        if (defined $part) {
-               my $addrs = $obj->{address};
+               my $addrs = $ibx->{address};
                $addrs = join(' ', @$addrs) if ref($addrs) eq 'ARRAY';
                $urls .=  <<EOF
 
 
        # If you have public-inbox 1.1+ installed, you may
        # initialize and index your mirror using the following commands:
-       public-inbox-init -V2 $obj->{name} $dir/ $http \\
+       public-inbox-init -V2 $ibx->{name} $dir/ $http \\
                $addrs
        public-inbox-index $dir
 EOF
        }
-       my @nntp = map { qq(<a\nhref="$_">$_</a>) } @{$obj->nntp_url};
+       my @nntp = map { qq(<a\nhref="$_">$_</a>) } @{$ibx->nntp_url};
        if (@nntp) {
                $urls .= "\n\n";
                $urls .= @nntp == 1 ? 'Newsgroup' : 'Newsgroups are';
index d4f6152e302651e34825d2e65a6c6dde5da5eb6a..13a44a3b53221dcb1baacb63bd07dc0be69a823b 100644 (file)
--- a/t/altid.t
+++ b/t/altid.t
@@ -42,9 +42,9 @@ my $altid = [ "serial:gmane:file=$alt_file" ];
        $im->done;
 }
 {
-       my $inbox = PublicInbox::Inbox->new({mainrepo=>$git_dir});
-       $inbox->{altid} = $altid;
-       my $rw = PublicInbox::SearchIdx->new($inbox, 1);
+       my $ibx = PublicInbox::Inbox->new({mainrepo => $git_dir});
+       $ibx->{altid} = $altid;
+       my $rw = PublicInbox::SearchIdx->new($ibx, 1);
        $rw->index_sync;
 }