X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWwwCoderepo.pm;h=7f8b34597b62a5d4069a6fecdf483da35483a43e;hb=1802dc29bda25a5478787d3d7a8a3c2de6cc6797;hp=2184e89d14572e0012bd9a2b0490c7b4cf2a6e52;hpb=cb4f3af963674ccdb0d540656bd2c58f9e130cf9;p=public-inbox.git diff --git a/lib/PublicInbox/WwwCoderepo.pm b/lib/PublicInbox/WwwCoderepo.pm index 2184e89d..7f8b3459 100644 --- a/lib/PublicInbox/WwwCoderepo.pm +++ b/lib/PublicInbox/WwwCoderepo.pm @@ -16,6 +16,7 @@ use PublicInbox::GitAsyncCat; use PublicInbox::WwwStream; use PublicInbox::Hval qw(ascii_html); use PublicInbox::RepoSnapshot; +use PublicInbox::RepoAtom; my $EACH_REF = "git for-each-ref --sort=-creatordate --format='%(HEAD)%00". join('%00', map { "%($_)" } @@ -27,16 +28,26 @@ sub prepare_coderepos { my $pi_cfg = $self->{pi_cfg}; # TODO: support gitweb and other repository viewers? - defined($pi_cfg->{'publicinbox.cgitrc'}) and - $pi_cfg->parse_cgitrc(undef, 0); + $pi_cfg->parse_cgitrc(undef, 0); my $code_repos = $pi_cfg->{-code_repos}; for my $k (grep(/\Acoderepo\.(?:.+)\.dir\z/, keys %$pi_cfg)) { $k = substr($k, length('coderepo.'), -length('.dir')); $code_repos->{$k} //= $pi_cfg->fill_code_repo($k); } - while (my ($nick, $repo) = each %$code_repos) { - $self->{"\0$nick"} = $repo; + + # associate inboxes and extindices with coderepos for search: + for my $k (grep(/\Apublicinbox\.(?:.+)\.coderepo\z/, keys %$pi_cfg)) { + $k = substr($k, length('publicinbox.'), -length('.coderepo')); + my $ibx = $pi_cfg->lookup_name($k) // next; + $pi_cfg->repo_objs($ibx); + push @{$self->{-strong}}, $ibx; # strengthen {-ibxs} weakref + } + for my $k (grep(/\Aextindex\.(?:.+)\.coderepo\z/, keys %$pi_cfg)) { + $k = substr($k, length('extindex.'), -length('.coderepo')); + my $eidx = $pi_cfg->lookup_ei($k) // next; + $pi_cfg->repo_objs($eidx); + push @{$self->{-strong}}, $eidx; # strengthen {-ibxs} weakref } } @@ -197,25 +208,31 @@ sub srv { # endpoint called by PublicInbox::WWW my $path_info = $ctx->{env}->{PATH_INFO}; my $git; # handle clone requests + my $cr = $self->{pi_cfg}->{-code_repos}; if ($path_info =~ m!\A/(.+?)/($PublicInbox::GitHTTPBackend::ANY)\z!x) { - $git = $self->{"\0$1"} and return + $git = $cr->{$1} and return PublicInbox::GitHTTPBackend::serve($ctx->{env},$git,$2); } $path_info =~ m!\A/(.+?)/\z! and - ($ctx->{git} = $self->{"\0$1"}) and return summary($self, $ctx); + ($ctx->{git} = $cr->{$1}) and return summary($self, $ctx); $path_info =~ m!\A/(.+?)/([a-f0-9]+)/s/\z! and - ($ctx->{git} = $self->{"\0$1"}) and + ($ctx->{git} = $cr->{$1}) and return PublicInbox::ViewVCS::show($ctx, $2); # snapshots: if ($path_info =~ m!\A/(.+?)/snapshot/([^/]+)\z! and - ($ctx->{git} = $self->{"\0$1"})) { + ($ctx->{git} = $cr->{$1})) { $ctx->{wcr} = $self; return PublicInbox::RepoSnapshot::srv($ctx, $2) // r(404); } + if ($path_info =~ m!\A/(.+?)/atom/(.*)\z! and + ($ctx->{git} = $cr->{$1})) { + return PublicInbox::RepoAtom::srv_atom($ctx, $2) // r(404); + } + # enforce trailing slash: - if ($path_info =~ m!\A/(.+?)\z! and ($git = $self->{"\0$1"})) { + if ($path_info =~ m!\A/(.+?)\z! and ($git = $cr->{$1})) { my $qs = $ctx->{env}->{QUERY_STRING}; my $url = $git->base_url($ctx->{env}); $url .= "?$qs" if $qs ne '';