- my $urls = <<EOF;
-<a
-id=mirror>This inbox may be cloned and mirrored by anyone:</a>
-EOF
-
- my $ibx = $ctx->{-inbox};
- my $desc = ascii_html($ibx->description);
-
- my @urls;
- my $http = $ctx->{base_url};
- my $max = $ibx->max_git_epoch;
- my $dir = (split(m!/!, $http))[-1];
- my %seen = ($http => 1);
- if (defined($max)) { # v2
- for my $i (0..$max) {
- # old epochs my be deleted:
- -d "$ibx->{inboxdir}/git/$i.git" or next;
- my $url = "$http/$i";
- $seen{$url} = 1;
- push @urls, "$url $dir/git/$i.git";
- }
- my $nr = scalar(@urls);
- if ($nr > 1) {
- $urls .= "\n\t# this inbox consists of $nr epochs:";
- $urls[0] .= "\t# oldest";
- $urls[-1] .= "\t# newest";
+ $ctx->{ibx} // return inboxes($ctx);
+ my $cr = $ctx->{ibx}->{coderepo} // return ();
+ my $cfg = $ctx->{www}->{pi_cfg};
+ my $upfx = ($ctx->{-upfx} // ''). '../';
+ my $pfx = $ctx->{base_url} //= $ctx->base_url;
+ my $up = $upfx =~ tr!/!/!;
+ $pfx =~ s!/[^/]+\z!/! for (1..$up);
+ my @ret = ('<a id=code>' .
+ 'Code repositories for project(s) associated with this '.
+ $ctx->{ibx}->thing_type . "\n");
+ for my $cr_name (@$cr) {
+ my $urls = $cfg->get_all("coderepo.$cr_name.cgiturl");
+ if ($urls) {
+ for (@$urls) {
+ my $u = m!\A(?:[a-z\+]+:)?//! ? $_ : $pfx.$_;
+ $u = ascii_html(prurl($ctx->{env}, $u));
+ $ret[0] .= qq(\n\t<a\nhref="$u">$u</a>);
+ }
+ } else {
+ $ret[0] .= qq[\n\t$cr_name.git (no URL configured)];