lib/PublicInbox/Qspawn.pm
lib/PublicInbox/Reply.pm
lib/PublicInbox/RepoAtom.pm
+lib/PublicInbox/RepoList.pm
lib/PublicInbox/RepoSnapshot.pm
lib/PublicInbox/RepoTree.pm
lib/PublicInbox/SHA.pm
}
}
+sub repos_sorted {
+ my $pi_cfg = shift;
+ my @recs = map { [ 0, $_ ] } @_; # PublicInbox::Git objects
+ my @todo = @recs;
+ $pi_cfg->each_cindex(\&load_commit_times, \@todo);
+ @recs = sort { $b->[0] <=> $a->[0] } @recs;
+}
+
1;
--- /dev/null
+# Copyright (C) all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+package PublicInbox::RepoList;
+use v5.12;
+use parent qw(PublicInbox::WwwStream);
+use PublicInbox::Hval qw(ascii_html prurl fmt_ts);
+require PublicInbox::CodeSearch;
+
+sub html_top_fallback { # WwwStream->html_repo_top
+ my ($ctx) = @_;
+ my $title = delete($ctx->{-title_html}) //
+ ascii_html("$ctx->{env}->{PATH_INFO}*");
+ my $upfx = $ctx->{-upfx} // '';
+ "<html><head><title>$title</title>" .
+ $ctx->{www}->style($upfx) . '</head><body>';
+}
+
+sub html ($$$) {
+ my ($wcr, $ctx, $pfx) = @_;
+ my $cr = $wcr->{pi_cfg}->{-coderepos};
+ my @nicks = grep(m!\A\Q$pfx\E/!, keys %$cr) or return; # 404
+ __PACKAGE__->html_init($ctx);
+ my $zfh = $ctx->zfh;
+ print $zfh "<pre>matching coderepos\n";
+ my @recs = PublicInbox::CodeSearch::repos_sorted($wcr->{pi_cfg},
+ @$cr{@nicks});
+ my $env = $ctx->{env};
+ for (@recs) {
+ my ($t, $git) = @$_;
+ my $nick = ascii_html("$git->{nick}");
+ for my $u ($git->pub_urls($env)) {
+ $u = prurl($env, $u);
+ print $zfh "\n".fmt_ts($t).qq{ <a\nhref="$u">$nick</a>}
+ }
+ }
+ $ctx->html_done('</pre>');
+}
+
+1;
use PublicInbox::RepoSnapshot;
use PublicInbox::RepoAtom;
use PublicInbox::RepoTree;
+use PublicInbox::RepoList;
use PublicInbox::OnDestroy;
use URI::Escape qw(uri_escape_utf8);
use File::Spec;
} elsif ($path_info =~ m!\A/(.+?)/(refs/(?:heads|tags))/\z! and
($ctx->{git} = $pi_cfg->get_coderepo($1))) {
refs_foo($self, $ctx, $2);
+ } elsif ($path_info =~ m!\A/(.+?)/\z!) {
+ PublicInbox::RepoList::html($self, $ctx, $1) // r(404);
} elsif ($path_info =~ m!\A/(.+?)\z! and
($git = $pi_cfg->get_coderepo($1))) {
my $qs = $ctx->{env}->{QUERY_STRING};
https://public-inbox.org/public-inbox.git) ];
sub base_url ($) {
- my $ctx = shift;
- my $base_url = ($ctx->{ibx} // $ctx->{git})->base_url($ctx->{env});
+ my ($ctx) = @_;
+ my $thing = $ctx->{ibx} // $ctx->{git} // return;
+ my $base_url = $thing->base_url($ctx->{env});
chop $base_url; # no trailing slash for clone
$base_url;
}
sub html_repo_top ($) {
my ($ctx) = @_;
- my $git = $ctx->{git};
+ my $git = $ctx->{git} // return $ctx->html_top_fallback;
my $desc = ascii_html($git->description);
my $title = delete($ctx->{-title_html}) // $desc;
my $upfx = $ctx->{-upfx} // '';
}
sub html_init {
- my ($ctx) = @_;
+ my $ctx = $_[-1];
$ctx->{base_url} = base_url($ctx);
my $h = $ctx->{-res_hdr} = ['Content-Type', 'text/html; charset=UTF-8'];
$ctx->{gz} = PublicInbox::GzipFilter::gz_or_noop($h, $ctx->{env});
- bless $ctx, __PACKAGE__;
+ bless $ctx, @_ > 1 ? $_[0] : __PACKAGE__;
print { $ctx->zfh } html_top($ctx);
}
my $cr = $cfg->repo_objs($ctx->{ibx}) or return ();
my $buf = 'Code repositories for project(s) associated with this '.
$ctx->{ibx}->thing_type . ":\n";
- my @recs = map { [ 0, $_ ] } @$cr;
- my @todo = @recs;
- $cfg->each_cindex('load_commit_times', \@todo);
- @recs = sort { $b->[0] <=> $a->[0] } @recs;
+ my @recs = PublicInbox::CodeSearch::repos_sorted($cfg, @$cr);
my $cr_score = $ctx->{ibx}->{-cr_score};
+ my $env = $ctx->{env};
for (@recs) {
my ($t, $git) = @$_;
- for ($git->pub_urls($ctx->{env})) {
+ for ($git->pub_urls($env)) {
my $u = m!\A(?:[a-z\+]+:)?//!i ? $_ : $top_url.$_;
my $nr = $cr_score->{$git->{nick}};
$buf .= "\n";
$buf .= $nr ? sprintf('% 9u', $nr) : (' 'x9);
- $buf .= ' '.fmt_ts($t).' '.prurl($ctx->{env}, $u);
+ $buf .= ' '.fmt_ts($t).' '.prurl($env, $u);
}
}
($buf);