]> Sergey Matveev's repositories - public-inbox.git/commitdiff
www: wire up /$INBOX/manifest.js.gz, too
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Sun, 9 Jun 2019 04:31:04 +0000 (04:31 +0000)
committerEric Wong <e@80x24.org>
Sun, 9 Jun 2019 04:32:31 +0000 (04:32 +0000)
I can imagine myself just wanting to clone a single v2 inbox
and all its epochs without thinking about include/exclude
rules in a grokmirror config file.

lib/PublicInbox/WWW.pm
t/www_listing.t

index 614adad67515e0194be0bbfab50611ba67c7f1b1..a54669808c76c6b3f5b86226289e613182f44a5c 100644 (file)
@@ -126,6 +126,8 @@ sub call {
                get_text($ctx, $1, $2);
        } elsif ($path_info =~ m!$INBOX_RE/([a-zA-Z0-9_\-\.]+)\.css\z!o) {
                get_css($ctx, $1, $2);
+       } elsif ($path_info =~ m!$INBOX_RE/manifest\.js\.gz\z!o) {
+               get_inbox_manifest($ctx, $1, $2);
        } elsif ($path_info =~ m!$INBOX_RE/($OID_RE)/s/\z!o) {
                get_vcs_object($ctx, $1, $2);
        } elsif ($path_info =~ m!$INBOX_RE/($OID_RE)/s/
@@ -490,6 +492,15 @@ sub www_listing {
        }
 }
 
+# GET $INBOX/manifest.js.gz
+sub get_inbox_manifest ($$$) {
+       my ($ctx, $inbox, $key) = @_;
+       my $r404 = invalid_inbox($ctx, $inbox);
+       return $r404 if $r404;
+       require PublicInbox::WwwListing;
+       PublicInbox::WwwListing::js($ctx->{env}, [$ctx->{-inbox}]);
+}
+
 sub get_attach {
        my ($ctx, $idx, $fn) = @_;
        require PublicInbox::WwwAttach;
index f9d543e592aa3b2fe001596878f6d77bd9b0518c..546c2f8fab0cc18a8f98620c04feb9819f74a205 100644 (file)
@@ -133,6 +133,26 @@ mymanifest = $tmpdir/local-manifest.js.gz
        for (qw(alt bare v2/0 v2/1 v2/2)) {
                ok(-d "$tmpdir/mirror/$_", "grok-pull created $_");
        }
+
+       # support per-inbox manifests, handy for v2:
+       # /$INBOX/v2/manifest.js.gz
+       open $fh, '>', "$tmpdir/per-inbox.conf" or die;
+       print $fh <<"" or die;
+# You can pull from multiple grok mirrors, just create
+# a separate section for each mirror. The name can be anything.
+[v2]
+site = http://$host:$port
+manifest = http://$host:$port/v2/manifest.js.gz
+toplevel = $tmpdir/per-inbox
+mymanifest = $tmpdir/per-inbox-manifest.js.gz
+
+       close $fh or die;
+       ok(mkdir("$tmpdir/per-inbox"), 'prepare single-v2-inbox mirror');
+       system(qw(grok-pull -c), "$tmpdir/per-inbox.conf");
+       is($? >> 8, 127, 'grok-pull exit code as expected');
+       for (qw(v2/0 v2/1 v2/2)) {
+               ok(-d "$tmpdir/per-inbox/$_", "grok-pull created $_");
+       }
 }
 
 done_testing();