user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 5/8] www_text: fix example config snippet for extindex
  2021-08-26 12:33  7% ` [PATCH 0/8] various WWW + extindex stuff Eric Wong
@ 2021-08-26 12:33  6%   ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-08-26 12:33 UTC (permalink / raw)
  To: meta

extindex doesn't use the same config stuff as normal
"publicinbox" entries, so we'll need a separate function
for them.
---
 lib/PublicInbox/WwwText.pm | 29 ++++++++++++++++++++++++++++-
 t/extindex-psgi.t          | 12 ++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/WwwText.pm b/lib/PublicInbox/WwwText.pm
index db5060ea..eb5e3ac7 100644
--- a/lib/PublicInbox/WwwText.pm
+++ b/lib/PublicInbox/WwwText.pm
@@ -214,10 +214,37 @@ EOF
 	1;
 }
 
+# n.b. this is a perfect candidate for memoization
+sub extindex_config ($$$) {
+	my ($ctx, $hdr, $txt) = @_;
+	my $ibx = $ctx->{ibx};
+	push @$hdr, 'Content-Disposition', 'inline; filename=extindex.config';
+	my $name = dq_escape($ibx->{name});
+	my $base_url = $ibx->base_url($ctx->{env});
+	$$txt .= <<EOS;
+; Example public-inbox config snippet for the external index (extindex) at:
+; $base_url
+; See public-inbox-config(5)manpage for more details:
+; https://public-inbox.org/public-inbox-config.html
+[extindex "$name"]
+	topdir = /path/to/extindex-topdir
+	url = https://example.com/$name/
+	url = http://example.onion/$name/
+EOS
+	for my $k (qw(infourl)) {
+		defined(my $v = $ibx->{$k}) or next;
+		$$txt .= "\t$k = $v\n";
+	}
+	# TODO: coderepo support for extindex
+	1;
+}
+
 sub _default_text ($$$$) {
 	my ($ctx, $key, $hdr, $txt) = @_;
 	return _colors_help($ctx, $txt) if $key eq 'color';
-	return inbox_config($ctx, $hdr, $txt) if $key eq 'config';
+	$key eq 'config' and return $ctx->{ibx}->can('cloneurl') ?
+			inbox_config($ctx, $hdr, $txt) :
+			extindex_config($ctx, $hdr, $txt);
 	return if $key ne 'help'; # TODO more keys?
 
 	my $ibx = $ctx->{ibx};
diff --git a/t/extindex-psgi.t b/t/extindex-psgi.t
index 6f62b5a0..b9acc979 100644
--- a/t/extindex-psgi.t
+++ b/t/extindex-psgi.t
@@ -40,6 +40,18 @@ my $client = sub {
 		'Host: header respected in Atom feed');
 	unlike($res->content, qr!http://bogus\.example\.com/!s,
 		'default URL ignored with different host header');
+
+	$res = $cb->(GET('/all/_/text/config/'));
+	is($res->code, 200, '/text/config HTML');
+	$res = $cb->(GET('/all/_/text/config/raw'));
+	is($res->code, 200, '/text/config raw');
+	my $f = "$tmpdir/extindex.config";
+	open my $fh, '>', $f or xbail $!;
+	print $fh $res->content or xbail $!;
+	close $fh or xbail $!;
+	my $cfg = PublicInbox::Config->git_config_dump($f);
+	is($?, 0, 'no errors from git-config parsing');
+	ok($cfg->{'extindex.all.topdir'}, 'extindex.topdir defined');
 };
 test_psgi(sub { $www->call(@_) }, $client);
 %$env = (%$env, TMPDIR => $tmpdir, PI_CONFIG => $pi_config);

^ permalink raw reply related	[relevance 6%]

* [PATCH 0/8] various WWW + extindex stuff
  @ 2021-08-26 12:33  7% ` Eric Wong
  2021-08-26 12:33  6%   ` [PATCH 5/8] www_text: fix example config snippet for extindex Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-08-26 12:33 UTC (permalink / raw)
  To: meta; +Cc: Konstantin Ryabitsev

This hopefully makes the long .onion URL more usable on small
displays; but I also got sidetracked into making our "use bytes"
stuff less scary based on the notice in the bytes(3perl)
manpage.

There's a couple of small extindex-related fixes to reconcile
the differences between the two ibxish object types for WWW.

Eric Wong (8):
  get rid of unnecessary bytes::length usage
  ds: use bytes::substr and bytes::length module-wide for now
  www_stream: sh-friendly .onion URLs wrapping
  www: avoid incorrect instructions for extindex
  www_text: fix example config snippet for extindex
  config: do not parse altid for extindex
  www_text: add coderepo config support for extindex
  move ->ids_after from mm to over

 lib/PublicInbox/Config.pm       |   2 +-
 lib/PublicInbox/DS.pm           |  21 +++---
 lib/PublicInbox/ExtSearch.pm    |   4 -
 lib/PublicInbox/HTTP.pm         |  17 ++---
 lib/PublicInbox/ManifestJsGz.pm |   3 +-
 lib/PublicInbox/Mbox.pm         |  10 +--
 lib/PublicInbox/Msgmap.pm       |  11 ---
 lib/PublicInbox/NNTP.pm         |   4 +-
 lib/PublicInbox/Over.pm         |  11 +++
 lib/PublicInbox/View.pm         |   5 +-
 lib/PublicInbox/ViewVCS.pm      |   5 +-
 lib/PublicInbox/WWW.pm          |  10 +--
 lib/PublicInbox/WwwAttach.pm    |   4 +-
 lib/PublicInbox/WwwHighlight.pm |   5 +-
 lib/PublicInbox/WwwListing.pm   |   4 +-
 lib/PublicInbox/WwwStatic.pm    |   4 +-
 lib/PublicInbox/WwwStream.pm    | 126 +++++++++++++++++++-------------
 lib/PublicInbox/WwwText.pm      | 103 ++++++++++++++++----------
 t/extindex-psgi.t               |  15 ++++
 t/psgi_search.t                 |   1 -
 t/search-thr-index.t            |   8 +-
 t/www_listing.t                 |  19 ++++-
 xt/cmp-msgstr.t                 |   2 +-
 23 files changed, 229 insertions(+), 165 deletions(-)


^ permalink raw reply	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-08-16 16:36     RFE: Long .onion URL breaks mobile view Konstantin Ryabitsev
2021-08-26 12:33  7% ` [PATCH 0/8] various WWW + extindex stuff Eric Wong
2021-08-26 12:33  6%   ` [PATCH 5/8] www_text: fix example config snippet for extindex 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).