From 6dec9bf8c0e1b859703d7a5dfb87052cf4e87846 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 4 Oct 2022 19:12:35 +0000 Subject: www_coderepo: an alternative to cgit This will allow it to easily map a single coderepo to multiple inboxes (or multiple coderepos to any number of inboxes). For now, this is just a summary, but $REPO/$OID/s/ support will be added, along with archive downloads. Indexing of coderepos will probably be supported via -extindex, only. --- lib/PublicInbox/Git.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/Git.pm') diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 2f0bb6a0..395add1f 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -463,6 +463,16 @@ sub host_prefix_url ($$) { "$scheme://$host_port". ($env->{SCRIPT_NAME} || '/') . $url; } +sub base_url { # for coderepos, PSGI-only + my ($self, $env) = @_; # env - PSGI env + my $url = host_prefix_url($env, ''); + # for mount in Plack::Builder + $url .= '/' if substr($url, -1, 1) ne '/'; + $url . $self->{nick} . '/'; +} + +sub isrch {} # TODO + sub pub_urls { my ($self, $env) = @_; if (my $urls = $self->{cgit_url}) { @@ -518,11 +528,11 @@ sub description { } sub cloneurl { - my ($self) = @_; + my ($self, $env) = @_; $self->{cloneurl} // do { my @urls = split(/\s+/s, try_cat("$self->{git_dir}/cloneurl")); scalar(@urls) ? ($self->{cloneurl} = \@urls) : undef; - } // []; + } // [ substr(base_url($self, $env), 0, -1) ]; } # for grokmirror, which doesn't read gitweb.description -- cgit v1.2.3-24-ge0c7