);
$ibx->{-primary_address} = $addr;
my $ctx = {
- -inbox => $ibx,
+ ibx => $ibx,
-upfx => "$base_url/",
-hr => 1,
};
# 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;
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;
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)) {
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;
# 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);
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;
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);
}
# 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);
}
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;
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];
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");
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);
}
$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+/;
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}));
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)));
$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';
# 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) ] ]
# /$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;
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);
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
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;
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;
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;
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
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
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));
}
# 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 ];
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...
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};
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)};
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);
}
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).
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;
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);
}
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;
}
}
# /$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);
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);
'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);
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;
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;
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);
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>";
# 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>';
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;
}
}
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...
$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)) {
$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 {
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;
}
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));
# /$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);
# 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);
}
# /$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);
}
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};
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();
}
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);
}
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),
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 ] ];
};
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) {
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;
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};
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;
$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>" .
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'} . '://' .
$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);
}
}
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;
}
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} || '';
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};
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;
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
# 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',
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";
# 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';
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;
{
# 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);
# 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);
# 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);
];
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>
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 => '../',
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);
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);