about summary refs log tree commit homepage
path: root/lib/PublicInbox/WwwText.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-08-26 12:33:35 +0000
committerEric Wong <e@80x24.org>2021-08-28 10:37:01 +0000
commit2548e95f8f895523cb27ec310c3cfac1ab310025 (patch)
tree2bb2e869bb65f1cba6db45172a65b7e1fdfcbd37 /lib/PublicInbox/WwwText.pm
parent4363e6037fa7d597294186f60373e9de8e1b3d74 (diff)
downloadpublic-inbox-2548e95f8f895523cb27ec310c3cfac1ab310025.tar.gz
extindex doesn't use the same config stuff as normal
"publicinbox" entries, so we'll need a separate function
for them.
Diffstat (limited to 'lib/PublicInbox/WwwText.pm')
-rw-r--r--lib/PublicInbox/WwwText.pm29
1 files changed, 28 insertions, 1 deletions
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};