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 $cr = $ctx->{ibx}->{coderepo} // return ();
+ my $cfg = $ctx->{www}->{pi_cfg};
my @ret;
- if (defined(my $cr = $ibx->{coderepo})) {
- my $cfg = $ctx->{www}->{pi_config};
- my $env = $ctx->{env};
- for my $cr_name (@$cr) {
- my $urls = $cfg->{"coderepo.$cr_name.cgiturl"};
- if ($urls) {
- $ret[0] //= <<EOF;
+ for my $cr_name (@$cr) {
+ my $urls = $cfg->{"coderepo.$cr_name.cgiturl"} // next;
+ $ret[0] //= <<EOF;
code repositories for the project(s) associated with this inbox:
EOF
- $ret[0] .= "\n\t".prurl($env, $_) for @$urls;
- }
+ for my $u (@$urls) {
+ $u = ascii_html(prurl($ctx->{env}, $u));
+ $ret[0] .= qq(\n\t<a\nhref="$u">$u</a>);
}
}
- @ret; # may be empty
+ @ret; # may be empty, this sub is called as an arg for join()
}
sub code_footer ($) {
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;
}
$urls .= "\n" . join('', map { "\tgit clone --mirror $_\n" } @urls);
- my $addrs = $ibx->{address};
- $addrs = join(' ', @$addrs) if ref($addrs) eq 'ARRAY';
- my $v = defined $max ? '-V2' : '-V1';
- $urls .= <<EOF;
+ if (my $addrs = $ibx->{address}) {
+ $addrs = join(' ', @$addrs) if ref($addrs) eq 'ARRAY';
+ my $v = defined $max ? '-V2' : '-V1';
+ $urls .= <<EOF;
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
$addrs
public-inbox-index $dir
EOF
+ }
my $cfg_link = ($ctx->{-upfx} // '').'_/text/config/raw';
$urls .= <<EOF;
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