From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id F1E461F670 for ; Fri, 15 Oct 2021 07:30:01 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] www: various help text updates Date: Fri, 15 Oct 2021 07:30:01 +0000 Message-Id: <20211015073001.30551-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: `dt:' documentation is redundant with `d:' approxidate support; so drop `dt:' since mairix uses `d:'. We'll also document `rt:' since there are legit messages from senders with broken clocks. Reduce indentation level of help texts to be in 2-space increments to using too much horizontal space. We'll always place IMAP ahead of NNTP since it's alphabetical and there's likely more IMAP clients out there. Add "--ng NEWSGROUP" to -init instructions if configured. There's also some minor wording changes throughout. --- lib/PublicInbox/Search.pm | 14 +-- lib/PublicInbox/WwwText.pm | 228 +++++++++++++++++++------------------ 2 files changed, 125 insertions(+), 117 deletions(-) diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index d89bf545..145fb56c 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -15,7 +15,7 @@ use Carp (); # compatibility with old indices (so don't change them it) use constant { TS => 0, # Received: in Unix time (IMAP INTERNALDATE, JMAP receivedAt) - YYYYMMDD => 1, # Date: header for searching in the WWW UI + YYYYMMDD => 1, # redundant with DT below DT => 2, # Date: YYYYMMDDHHMMSS (IMAP SENT*, JMAP sentAt) # added for public-inbox 1.6.0+ @@ -154,12 +154,9 @@ my %prob_prefix = ( our @HELP = ( 's:' => 'match within Subject e.g. s:"a quick brown fox"', 'd:' => < < 'match within message body, including text attachments', 'nq:' => 'match non-quoted text within message body', @@ -180,6 +177,9 @@ EOF 'dfpre:' => 'match pre-image git blob ID', 'dfpost:' => 'match post-image git blob ID', 'dfblob:' => 'match either pre or post-image git blob ID', + 'rt:' => <help; + my $help = $ibx->isrch->help; my $i; for ($i = 0; $i < @$help; $i += 2) { my $pfx = $help->[$i]; @@ -89,10 +89,9 @@ sub _srch_prefix ($$) { $htxt .= "\f\n"; } $pad += 2; - my $padding = ' ' x ($pad + 8); + my $padding = ' ' x ($pad + 4); $htxt =~ s/^/$padding/gms; - $htxt =~ s/^$padding(\S+)\0/" $1". - (' ' x ($pad - length($1)))/egms; + $htxt =~ s/^$padding(\S+)\0/" $1".(' ' x ($pad - length($1)))/egms; $htxt =~ s/\f\n/\n/gs; $$txt .= $htxt; 1; @@ -113,7 +112,7 @@ Users of browsers such as dillo, Firefox, or some browser extensions may start by downloading the following sample CSS file to control the colors they see: - ${base_url}userContent.css + ${base_url}userContent.css CSS sample ---------- @@ -213,8 +212,8 @@ EOF defined(my $v = $ibx->{$k}) or next; $$txt .= "\t$k = $v\n"; } - $$txt .= "\tnntpmirror = $_\n" for (@{$ibx->nntp_url($ctx)}); $$txt .= "\timapmirror = $_\n" for (@{$ibx->imap_url($ctx)}); + $$txt .= "\tnntpmirror = $_\n" for (@{$ibx->nntp_url($ctx)}); _coderepo_config($ctx, $txt); 1; } @@ -273,6 +272,36 @@ EOF @ret; # may be empty, this sub is called as an arg for join() } +sub _add_imap_nntp_urls ($$) { + my ($ctx, $txt) = @_; + $ctx->{ibx}->can('nntp_url') or return; # TODO extindex can have IMAP + my $urls = $ctx->{ibx}->imap_url($ctx); + if (@$urls) { + $$txt .= "\nIMAP subfolder(s) are available under:"; + $$txt .= "\n " . join("\n ", @$urls); + $$txt .= <{ibx}->imap_url($ctx); + if (@$urls) { + $$txt .= "\n"; + $$txt .= @$urls == 1 ? 'Newsgroup' : 'Newsgroups are'; + $$txt .= ' available over NNTP:'; + $$txt .= "\n " . join("\n ", @$urls) . "\n"; + } +} + +sub _add_onion_note ($) { + my ($txt) = @_; + $$txt =~ m!\b[^:]+://\w+\.onion/!i and $$txt .= <{ibx}; @@ -301,8 +330,10 @@ sub _mirror_help ($$) { } my $nr = scalar(@urls); if ($nr > 1) { - $$txt .= "\n\t"; - $$txt .= "# this inbox consists of $nr epochs:"; + chomp($$txt .= <{address}) { - $addrs = join(' ', @$addrs) if ref($addrs) eq 'ARRAY'; - my $v = defined $max ? '-V2' : '-V1'; - $$txt .= <{name} $dir/ $base_url \\ - $addrs - public-inbox-index $dir + $$txt .= join('', map { " git clone --mirror $_\n" } @urls); + my $addrs = $ibx->{address} // 'inbox@example.com'; + my $ng = $ibx->{newsgroup} // ''; + substr($ng, 0, 0, ' --ng ') if $ng; + $addrs = join(' ', @$addrs) if ref($addrs) eq 'ARRAY'; + my $v = defined $max ? '-V2' : '-V1'; + $$txt .= <{name} ./$dir $base_url \\ + $addrs + public-inbox-index ./$dir EOF - } } else { # PublicInbox::ExtSearch $$txt .= <can('imap_url')) { - my $imap = $ibx->imap_url($ctx); - if (@$imap) { - $$txt .= "\n"; - $$txt .= 'IMAP subfolder(s) available under:'; - $$txt .= "\n\t" . join("\n\t", @$imap) . "\n"; - $$txt .= <can('nntp_url')) { - my $nntp = $ibx->nntp_url($ctx); - if (scalar @$nntp) { - $$txt .= "\n"; - $$txt .= @$nntp == 1 ? 'Newsgroup' : 'Newsgroups are'; - $$txt .= ' available over NNTP:'; - $$txt .= "\n\t" . join("\n\t", @$nntp) . "\n"; - } - } - if ($$txt =~ m!\b[^:]+://\w+\.onion/!) { - $$txt .= <{env}, $PublicInbox::WwwStream::CODE_URL); $$txt .= join("\n\n", coderepos_raw($ctx, $top_url), # may be empty - "AGPL code for this site:\n\tgit clone $code_url"); + "AGPL code for this site:\n git clone $code_url"); 1; } @@ -391,128 +400,127 @@ sub _default_text ($$$$) { inbox_config($ctx, $hdr, $txt) : extindex_config($ctx, $hdr, $txt); } - return if $key ne 'help'; # TODO more keys? my $ibx = $ctx->{ibx}; my $base_url = $ibx->base_url($ctx->{env}); - $$txt .= "public-inbox help for $base_url\n"; $$txt .= <') into the URL. - Forward slash ('/') characters in the Message-IDs - need to be escaped as "%2F" (without quotes). + public-inbox uses Message-ID identifiers in URLs. + One may look up messages by substituting Message-IDs + (without the leading '<' or trailing '>') into the URL. + Forward slash ('/') characters in the Message-IDs + need to be escaped as "%2F" (without quotes). - Thus, it is possible to retrieve any message by its - Message-ID by going to: + Thus, it is possible to retrieve any message by its + Message-ID by going to: - $base_url/ + $base_url/ + (without the '<' or '>') - (without the '<' or '>') + Message-IDs are described at: - Message-IDs are described at: - - $WIKI_URL/Message-ID + $WIKI_URL/Message-ID EOF # n.b. we use the Xapian DB for any regeneratable, # order-of-arrival-independent data. - my $srch = $ibx->isrch; - if ($srch) { + if ($ibx->isrch) { $$txt .= <over; - if ($over) { + if ($ibx->over) { $$txt .= </T/#u + * $base_url/T/#u - Loads the thread belonging to the given - in flat chronological order. The "#u" anchor - focuses the browser on the given . + Loads the thread belonging to the given + in flat chronological order. The "#u" anchor + focuses the browser on the given . - * $base_url/t/#u + * $base_url/t/#u - Loads the thread belonging to the given - in threaded order with nesting. For deep threads, - this requires a wide display or horizontal scrolling. + Loads the thread belonging to the given + in threaded order with nesting. For deep threads, + this requires a wide display or horizontal scrolling. - Both of these HTML endpoints are suitable for offline reading - using the thread overview at the bottom of each page. + Both of these HTML endpoints are suitable for offline reading + using the thread overview at the bottom of each page. - Users of feed readers may follow a particular thread using: + The gzipped mbox for a thread is available for downloading and + importing into your favorite mail client: - * $base_url/t.atom + * $base_url/t.mbox.gz - Which loads the thread in Atom Syndication Standard - described at Wikipedia and RFC4287: + We use the mboxrd variant of the mbox format described at: - $WIKI_URL/Atom_(standard) - https://tools.ietf.org/html/rfc4287 + $WIKI_URL/Mbox - Atom Threading Extensions (RFC4685) is supported: + Users of feed readers may follow a particular thread using: - https://tools.ietf.org/html/rfc4685 + * $base_url/t.atom - Finally, the gzipped mbox for a thread is available for - downloading and importing into your favorite mail client: + Which loads the thread in Atom Syndication Standard + described at Wikipedia and RFC4287: - * $base_url/t.mbox.gz + $WIKI_URL/Atom_(standard) + https://tools.ietf.org/html/rfc4287 - We use the mboxrd variant of the mbox format described - at: + Atom Threading Extensions (RFC4685) are supported: - $WIKI_URL/Mbox + https://tools.ietf.org/html/rfc4685 EOF } # $over + _add_imap_nntp_urls($ctx, \(my $note = '')); + $note and $note =~ s/^/ /gms and $$txt .= <