]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwText.pm
www_text: add #nntp, #pop3, and #imap anchors to help HTML
[public-inbox.git] / lib / PublicInbox / WwwText.pm
index 211ee8c928e7f74bd10bb39df4c6dbf7c3a0279f..320f0d840f9e92d96486d7092d899cd9dba4440c 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # used for displaying help texts and other non-mail content
@@ -38,11 +38,7 @@ sub get_text {
        }
        my $env = $ctx->{env};
        if ($raw) {
-               if ($code == 200) {
-                       my $gzf = gzf_maybe($hdr, $env);
-                       $txt = $gzf->translate($txt);
-                       $txt .= $gzf->zflush;
-               }
+               $txt = gzf_maybe($hdr, $env)->zflush($txt) if $code == 200;
                $hdr->[3] = length($txt);
                return [ $code, $hdr, [ $txt ] ]
        }
@@ -71,6 +67,9 @@ sub get_text {
                $txt = ascii_html($txt);
        }
        $txt = '<pre>' . $l->linkify_2($txt) . '</pre>';
+       $txt =~ s!\bPOP3\b!<a\nid=pop3>POP3</a>!;
+       $txt =~ s!\bNewsgroups\b!<a\nid=nntp>Newsgroups</a>!;
+       $txt =~ s!\bIMAP\b!<a\nid=imap>IMAP</a>!;
        PublicInbox::WwwStream::html_oneshot($ctx, $code, \$txt);
 }
 
@@ -272,7 +271,7 @@ EOF
        @ret; # may be empty, this sub is called as an arg for join()
 }
 
-sub _add_imap_nntp_urls ($$) {
+sub _add_non_http_urls ($$) {
        my ($ctx, $txt) = @_;
        $ctx->{ibx}->can('nntp_url') or return; # TODO extindex can have IMAP
        my $urls = $ctx->{ibx}->imap_url($ctx);
@@ -284,13 +283,27 @@ sub _add_imap_nntp_urls ($$) {
   # each subfolder (starting with `0') holds 50K messages at most
 EOM
        }
-       $urls = $ctx->{ibx}->imap_url($ctx);
+       $urls = $ctx->{ibx}->nntp_url($ctx);
        if (@$urls) {
-               $$txt .= "\n";
-               $$txt .= @$urls == 1 ? 'Newsgroup' : 'Newsgroups are';
+               $$txt .= @$urls == 1 ? "\nNewsgroup" : "\nNewsgroups are";
                $$txt .= ' available over NNTP:';
                $$txt .= "\n  " . join("\n  ", @$urls) . "\n";
        }
+       $urls = $ctx->{ibx}->pop3_url($ctx);
+       if (@$urls) {
+               $urls = join("\n  ", @$urls);
+               $$txt .= <<EOM;
+
+POP3 access is available:
+  $urls
+
+The password is: anonymous
+The username is: \$(uuidgen)\@$ctx->{ibx}->{newsgroup}
+where \$(uuidgen) in the output of the `uuidgen' command on your system.
+The UUID in the username functions as a private cookie (don't share it).
+Idle accounts will expire periodically.
+EOM
+       }
 }
 
 sub _add_onion_note ($) {
@@ -379,7 +392,7 @@ EOM
 
 Example config snippet for mirrors: $cfg_link
 EOF
-       _add_imap_nntp_urls($ctx, $txt);
+       _add_non_http_urls($ctx, $txt);
        _add_onion_note($txt);
 
        my $code_url = prurl($ctx->{env}, $PublicInbox::WwwStream::CODE_URL);
@@ -508,7 +521,7 @@ message threading
 EOF
        } # $over
 
-       _add_imap_nntp_urls($ctx, \(my $note = ''));
+       _add_non_http_urls($ctx, \(my $note = ''));
        $note and $note =~ s/^/  /gms and $$txt .= <<EOF;
 additional protocols
 --------------------