user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 0/3] www cgit support updates
@ 2024-02-13  9:31 Eric Wong
  2024-02-13  9:31 ` [PATCH 1/3] www: cgit: support non-standard cgitrc locations Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2024-02-13  9:31 UTC (permalink / raw)
  To: meta

I only noticed the fix for 1/3 because I wasn't using a
custom-patched+built cgit for the first time, ever; but
our cgit support was unusable for non-default config files
without it.

I only noticed 3/3 while checking the result of 2/3.

Eric Wong (3):
  www: cgit: support non-standard cgitrc locations
  doc: config: cgit=rewrite isn't implemented, yet
  doc: fix formatting for CLI switch aliases

 Documentation/lei-q.pod               |  2 ++
 Documentation/public-inbox-clone.pod  |  1 +
 Documentation/public-inbox-config.pod |  6 ++++++
 lib/PublicInbox/Cgit.pm               | 12 +++++-------
 lib/PublicInbox/Config.pm             |  3 ++-
 5 files changed, 16 insertions(+), 8 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] www: cgit: support non-standard cgitrc locations
  2024-02-13  9:31 [PATCH 0/3] www cgit support updates Eric Wong
@ 2024-02-13  9:31 ` Eric Wong
  2024-02-13  9:31 ` [PATCH 2/3] doc: config: cgit=rewrite isn't implemented, yet Eric Wong
  2024-02-13  9:31 ` [PATCH 3/3] doc: fix formatting for CLI switch aliases Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2024-02-13  9:31 UTC (permalink / raw)
  To: meta

If publicinbox.cgitrc is set in the config file, we'll ensure
cgit sees it as CGIT_CONFIG since the configured
publicinbox.cgitrc knob may not be the default path the cgit.cgi
binary was configured to use.

Furthermore, we'll respect CGIT_CONFIG in the environment if
publicinbox.cgitrc is unset in the config file at -httpd/-netd
startup.
---
 lib/PublicInbox/Cgit.pm   | 12 +++++-------
 lib/PublicInbox/Config.pm |  3 ++-
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/lib/PublicInbox/Cgit.pm b/lib/PublicInbox/Cgit.pm
index 10cad57a..78fc9ca0 100644
--- a/lib/PublicInbox/Cgit.pm
+++ b/lib/PublicInbox/Cgit.pm
@@ -58,6 +58,7 @@ sub new {
 		cmd => [ $cgit_bin ],
 		cgit_data => $cgit_data,
 		pi_cfg => $pi_cfg,
+		cgitrc => $pi_cfg->{'publicinbox.cgitrc'} // $ENV{CGIT_CONFIG},
 	}, $class;
 
 	# some cgit repos may not be mapped to inboxes, so ensure those exist:
@@ -100,15 +101,12 @@ sub call {
 		return PublicInbox::WwwStatic::response($env, [], $f);
 	}
 
-	my $cgi_env = { PATH_INFO => $path_info };
-	foreach (@PASS_ENV) {
-		my $v = $env->{$_} // next;
-		$cgi_env->{$_} = $v;
-	}
-	$cgi_env->{'HTTPS'} = 'on' if $env->{'psgi.url_scheme'} eq 'https';
+	my %cgi_env = (CGIT_CONFIG => $self->{cgitrc}, PATH_INFO => $path_info);
+	@cgi_env{@PASS_ENV} = @$env{@PASS_ENV}; # spawn ignores undef vals
+	$cgi_env{HTTPS} = 'on' if $env->{'psgi.url_scheme'} eq 'https';
 
 	my $rdr = input_prepare($env) or return r(500);
-	my $qsp = PublicInbox::Qspawn->new($self->{cmd}, $cgi_env, $rdr);
+	my $qsp = PublicInbox::Qspawn->new($self->{cmd}, \%cgi_env, $rdr);
 	my $limiter = $self->{pi_cfg}->limiter('-cgit');
 	$qsp->psgi_yield($env, $limiter, $parse_cgi_headers, $ctx);
 }
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index b8d3c485..607197f6 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -305,7 +305,8 @@ sub apply_cgit_scan_path {
 
 sub parse_cgitrc {
 	my ($self, $cgitrc, $nesting) = @_;
-	$cgitrc //= $self->{'publicinbox.cgitrc'} // return;
+	$cgitrc //= $self->{'publicinbox.cgitrc'} //
+			$ENV{CGIT_CONFIG} // return;
 	if ($nesting == 0) {
 		# defaults:
 		my %s = map { $_ => 1 } qw(/cgit.css /cgit.png

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] doc: config: cgit=rewrite isn't implemented, yet
  2024-02-13  9:31 [PATCH 0/3] www cgit support updates Eric Wong
  2024-02-13  9:31 ` [PATCH 1/3] www: cgit: support non-standard cgitrc locations Eric Wong
@ 2024-02-13  9:31 ` Eric Wong
  2024-02-13  9:31 ` [PATCH 3/3] doc: fix formatting for CLI switch aliases Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2024-02-13  9:31 UTC (permalink / raw)
  To: meta

It'll probably be done for another release, I doubt most cgit
users are willing to completely replace it with our coderepo
viewer just yet...
---
 Documentation/public-inbox-config.pod | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/public-inbox-config.pod b/Documentation/public-inbox-config.pod
index f533ea9d..b875df58 100644
--- a/Documentation/public-inbox-config.pod
+++ b/Documentation/public-inbox-config.pod
@@ -337,11 +337,15 @@ Try using C<cgit> as the first choice, this is the default.
 Fall back to using C<cgit> only if our native, inbox-aware
 git code repository viewer doesn't recognize the URL.
 
+=begin comment
+=for comment rewrite is not yet implemented
 =item * rewrite
 
 Rewrite C<cgit> URLs for our native, inbox-aware code repository viewer.
 This implies C<fallback> for URLs the native viewer does not recognize.
 
+=end comment
+
 =back
 
 Default: C<first>  (C<cgit> will be used iff C<publicinbox.cgitrc>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] doc: fix formatting for CLI switch aliases
  2024-02-13  9:31 [PATCH 0/3] www cgit support updates Eric Wong
  2024-02-13  9:31 ` [PATCH 1/3] www: cgit: support non-standard cgitrc locations Eric Wong
  2024-02-13  9:31 ` [PATCH 2/3] doc: config: cgit=rewrite isn't implemented, yet Eric Wong
@ 2024-02-13  9:31 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2024-02-13  9:31 UTC (permalink / raw)
  To: meta

`=item' elements in Pod need to be surrounded by empty lines.
It's an unfortunate waste of vertical space, but Pod is still better
than *roff and usually available out-of-the-box.
---
 Documentation/lei-q.pod               | 2 ++
 Documentation/public-inbox-clone.pod  | 1 +
 Documentation/public-inbox-config.pod | 2 ++
 3 files changed, 5 insertions(+)

diff --git a/Documentation/lei-q.pod b/Documentation/lei-q.pod
index 95f3f702..4476a806 100644
--- a/Documentation/lei-q.pod
+++ b/Documentation/lei-q.pod
@@ -130,9 +130,11 @@ Caveat: C<-tt> only works on locally-indexed messages at the
 moment, and not on remote (HTTP(S)) endpoints.
 
 =item --jobs=QUERY_WORKERS[,WRITE_WORKERS]
+
 =item --jobs=,WRITE_WORKERS
 
 =item -j QUERY_WORKERS[,WRITE_WORKERS]
+
 =item -j ,WRITE_WORKERS
 
 Set the number of query and write worker processes for parallelism.
diff --git a/Documentation/public-inbox-clone.pod b/Documentation/public-inbox-clone.pod
index c3254fa0..64ee3138 100644
--- a/Documentation/public-inbox-clone.pod
+++ b/Documentation/public-inbox-clone.pod
@@ -234,6 +234,7 @@ Whether to wrap L<git(1)> and L<curl(1)> commands with L<torsocks(1)>.
 Default: C<auto>
 
 =item -j JOBS
+
 =item --jobs=JOBS
 
 The number of parallel processes to spawn at once for various network
diff --git a/Documentation/public-inbox-config.pod b/Documentation/public-inbox-config.pod
index b875df58..d3f5d04b 100644
--- a/Documentation/public-inbox-config.pod
+++ b/Documentation/public-inbox-config.pod
@@ -356,7 +356,9 @@ is set and the C<cgit> binary exists).
 See L<public-inbox-edit(1)>
 
 =item publicinbox.indexMaxSize
+
 =item publicinbox.indexBatchSize
+
 =item publicinbox.indexSequentialShard
 
 See L<public-inbox-index(1)>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-13  9:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13  9:31 [PATCH 0/3] www cgit support updates Eric Wong
2024-02-13  9:31 ` [PATCH 1/3] www: cgit: support non-standard cgitrc locations Eric Wong
2024-02-13  9:31 ` [PATCH 2/3] doc: config: cgit=rewrite isn't implemented, yet Eric Wong
2024-02-13  9:31 ` [PATCH 3/3] doc: fix formatting for CLI switch aliases Eric Wong

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).