user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: "Eric Wong (Contractor, The Linux Foundation)" <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/4] www: wire up /$INBOX/manifest.js.gz, too
Date: Sun,  9 Jun 2019 04:31:04 +0000	[thread overview]
Message-ID: <20190609043105.22338-4-e@80x24.org> (raw)
In-Reply-To: <20190609043105.22338-1-e@80x24.org>

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 | 11 +++++++++++
 t/www_listing.t        | 20 ++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index 614adad..a546698 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -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;
diff --git a/t/www_listing.t b/t/www_listing.t
index f9d543e..546c2f8 100644
--- a/t/www_listing.t
+++ b/t/www_listing.t
@@ -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();
-- 
EW


  parent reply	other threads:[~2019-06-09  4:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-09  4:31 [PATCH 0/4] grokmirror-compatible manifests Eric Wong (Contractor, The Linux Foundation)
2019-06-09  4:31 ` [PATCH 1/4] wwwlisting: allow hiding entries from manifest Eric Wong (Contractor, The Linux Foundation)
2019-06-09  4:31 ` [PATCH 2/4] wwwlisting: generate grokmirror-compatible manifest.js.gz Eric Wong (Contractor, The Linux Foundation)
2019-06-09  4:31 ` Eric Wong (Contractor, The Linux Foundation) [this message]
2019-06-09  4:31 ` [PATCH 4/4] www: support $INBOX/git/$EPOCH.git for v2 cloning Eric Wong (Contractor, The Linux Foundation)
2019-06-10  6:21 ` [PATCH 5/4] git: ensure ->modified returns an integer Eric Wong (Contractor, The Linux Foundation)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190609043105.22338-4-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).