]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WWW.pm
www_coderepo: an alternative to cgit
[public-inbox.git] / lib / PublicInbox / WWW.pm
index a33709e96fc918867ed9f7a05623f19e29597a03..d0e20fb54da4a82768d899c53fb693415b759a67 100644 (file)
@@ -197,7 +197,9 @@ sub news_cgit_fallback ($) {
        my $www = $ctx->{www};
        my $env = $ctx->{env};
        my $res = $www->news_www->call($env);
-       $res->[0] == 404 ? $www->cgit->call($env) : $res;
+       $res = $www->cgit->call($env) if $res->[0] == 404;
+       $res = $www->coderepo->srv($ctx) if $res->[0] == 404;
+       $res;
 }
 
 # returns undef if valid, array ref response if invalid
@@ -303,7 +305,8 @@ sub get_text {
 sub get_vcs_object ($$$;$) {
        my ($ctx, $inbox, $oid, $filename) = @_;
        my $r404 = invalid_inbox($ctx, $inbox);
-       return $r404 if $r404 || !$ctx->{www}->{pi_cfg}->repo_objs($ctx->{ibx});
+       return $r404 if $r404;
+       return r(404) if !$ctx->{www}->{pi_cfg}->repo_objs($ctx->{ibx});
        require PublicInbox::ViewVCS;
        PublicInbox::ViewVCS::show($ctx, $oid, $filename);
 }
@@ -319,7 +322,7 @@ sub get_altid_dump {
 sub need {
        my ($ctx, $extra) = @_;
        require PublicInbox::WwwStream;
-       PublicInbox::WwwStream::html_oneshot($ctx, 501, \<<EOF);
+       PublicInbox::WwwStream::html_oneshot($ctx, 501, <<EOF);
 <pre>$extra is not available for this public-inbox
 <a\nhref="../">Return to index</a></pre>
 EOF
@@ -493,6 +496,14 @@ sub cgit {
        }
 }
 
+sub coderepo {
+       my ($self) = @_;
+       $self->{coderepo} //= do {
+               require PublicInbox::WwwCoderepo;
+               PublicInbox::WwwCoderepo->new($self->{pi_cfg});
+       }
+}
+
 # GET $INBOX/manifest.js.gz
 sub get_inbox_manifest ($$$) {
        my ($ctx, $inbox, $key) = @_;