* [PATCH 1/3] inbox: altid_map becomes a method
2020-03-26 8:21 5% [PATCH 0/3] wwwaltid: add pointers for usability Eric Wong
@ 2020-03-26 8:21 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-03-26 8:21 UTC (permalink / raw)
To: meta
We want to be able to preload that, as well as to access it
in WwwText for a config comment in the config example.
---
lib/PublicInbox/Inbox.pm | 15 +++++++++++++++
lib/PublicInbox/WWW.pm | 1 +
lib/PublicInbox/WwwAltId.pm | 14 +-------------
3 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 4f27d1bb..95ffd039 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -376,4 +376,19 @@ sub modified {
git($self)->modified; # v1
}
+# returns prefix => pathname mapping
+# (pathname is NOT public, but prefix is used for Xapian queries)
+sub altid_map ($) {
+ my ($self) = @_;
+ $self->{-altid_map} //= eval {
+ require PublicInbox::AltId;
+ my $altid = $self->{altid} or return {};
+ my %h = map {;
+ my $x = PublicInbox::AltId->new($self, $_);
+ "$x->{prefix}" => $x->{filename}
+ } @$altid;
+ \%h;
+ } // {};
+}
+
1;
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index 5017f572..56d2c42a 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -170,6 +170,7 @@ sub preload {
sub preload_inbox {
my $ibx = shift;
+ $ibx->altid_map;
$ibx->cloneurl;
$ibx->description;
$ibx->base_url;
diff --git a/lib/PublicInbox/WwwAltId.pm b/lib/PublicInbox/WwwAltId.pm
index 34641a92..a45d8061 100644
--- a/lib/PublicInbox/WwwAltId.pm
+++ b/lib/PublicInbox/WwwAltId.pm
@@ -10,18 +10,6 @@ use PublicInbox::AltId;
use PublicInbox::Spawn qw(which);
our $sqlite3 = $ENV{SQLITE3};
-# returns prefix => pathname mapping
-# (pathname is NOT public, but prefix is used for Xapian queries)
-sub altid_map ($) {
- my ($ibx) = @_;
- my $altid = $ibx->{altid} or return {};
- my %h = map {;
- my $x = PublicInbox::AltId->new($ibx, $_);
- "$x->{prefix}" => $x->{filename}
- } @$altid;
- \%h;
-}
-
sub sqlite3_missing ($) {
PublicInbox::WwwResponse::oneshot($_[0], 501, \<<EOF);
<pre>sqlite3 not available
@@ -51,7 +39,7 @@ sub check_output {
sub sqldump ($$) {
my ($ctx, $altid_pfx) = @_;
my $ibx = $ctx->{-inbox};
- my $altid_map = $ibx->{-altid_map} //= altid_map($ibx);
+ my $altid_map = $ibx->altid_map;
my $fn = $altid_map->{$altid_pfx};
unless (defined $fn) {
return PublicInbox::WwwStream::oneshot($ctx, 404, \<<EOF);
^ permalink raw reply related [relevance 7%]
* [PATCH 0/3] wwwaltid: add pointers for usability
@ 2020-03-26 8:21 5% Eric Wong
2020-03-26 8:21 7% ` [PATCH 1/3] inbox: altid_map becomes a method Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-03-26 8:21 UTC (permalink / raw)
To: meta
Provide helpful hints and pointers in existing config example
to reproduce altid DBs when mirroring
Eric Wong (3):
inbox: altid_map becomes a method
wwwtext: show altid instructions in config
wwwaltid: inform users to use POST instead of GET
lib/PublicInbox/Inbox.pm | 15 +++++++++++++++
lib/PublicInbox/WWW.pm | 3 +++
lib/PublicInbox/WwwAltId.pm | 32 ++++++++++++++++++--------------
lib/PublicInbox/WwwText.pm | 20 ++++++++++++++++++--
4 files changed, 54 insertions(+), 16 deletions(-)
^ permalink raw reply [relevance 5%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-03-26 8:21 5% [PATCH 0/3] wwwaltid: add pointers for usability Eric Wong
2020-03-26 8:21 7% ` [PATCH 1/3] inbox: altid_map becomes a method 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).