]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwText.pm
www: _/text/config/raw Last-Modified: is mm->created_at
[public-inbox.git] / lib / PublicInbox / WwwText.pm
index 858fc2f70b77cc3cefff1c48ddb076067c4022ff..8b929f7431560979ddb076b321016241e854459a 100644 (file)
@@ -8,6 +8,7 @@ use v5.10.1;
 use PublicInbox::Linkify;
 use PublicInbox::WwwStream;
 use PublicInbox::Hval qw(ascii_html prurl);
+use HTTP::Date qw(time2str);
 use URI::Escape qw(uri_escape_utf8);
 use PublicInbox::GzipFilter qw(gzf_maybe);
 our $QP_URL = 'https://xapian.org/docs/queryparser.html';
@@ -171,6 +172,8 @@ sub inbox_config ($$$) {
        my ($ctx, $hdr, $txt) = @_;
        my $ibx = $ctx->{ibx};
        push @$hdr, 'Content-Disposition', 'inline; filename=inbox.config';
+       my $t = eval { $ibx->mm->created_at };
+       push(@$hdr, 'Last-Modified', time2str($t)) if $t;
        my $name = dq_escape($ibx->{name});
        my $inboxdir = '/path/to/top-level-inbox';
        my $base_url = $ibx->base_url($ctx->{env});
@@ -210,7 +213,8 @@ EOF
                defined(my $v = $ibx->{$k}) or next;
                $$txt .= "\t$k = $v\n";
        }
-       $$txt .= "\tnntpmirror = $_\n" for (@{$ibx->nntp_url});
+       $$txt .= "\tnntpmirror = $_\n" for (@{$ibx->nntp_url($ctx)});
+       $$txt .= "\timapmirror = $_\n" for (@{$ibx->imap_url($ctx)});
        _coderepo_config($ctx, $txt);
        1;
 }
@@ -246,9 +250,13 @@ sub coderepos_raw ($$) {
        my $cfg = $ctx->{www}->{pi_cfg};
        my @ret;
        for my $cr_name (@$cr) {
-               $ret[0] //= <<EOF;
-code repositories for project(s) associated with this inbox:
+               $ret[0] //= do {
+                       my $thing = $ctx->{ibx}->can('cloneurl') ?
+                               'public inbox' : 'external index';
+                       <<EOF;
+Code repositories for project(s) associated with this $thing
 EOF
+               };
                my $urls = $cfg->get_all("coderepo.$cr_name.cgiturl");
                if ($urls) {
                        for (@$urls) {
@@ -276,7 +284,8 @@ sub _mirror_help ($$) {
        $top_url =~ s!/[^/]+\z!/!;
        $$txt .= "public-inbox mirroring instructions\n\n";
        if ($ibx->can('cloneurl')) { # PublicInbox::Inbox
-               $$txt .= "This inbox may be cloned and mirrored by anyone:\n";
+               $$txt .=
+                 "This public inbox may be cloned and mirrored by anyone:\n";
                my @urls;
                my $max = $ibx->max_git_epoch;
                # TODO: some of these URLs may be too long and we may need to
@@ -322,8 +331,8 @@ EOF
                }
        } else { # PublicInbox::ExtSearch
                $$txt .= <<EOM;
-This is an extindex which is an amalgamation of several public-inboxes.
-Each public-inbox needs to be mirrored individually.
+This is an external index which is an amalgamation of several public inboxes.
+Each public inbox needs to be mirrored individually.
 EOM
                my $v = $ctx->{www}->{pi_cfg}->{lc('publicInbox.wwwListing')};
                if (($v // '') =~ /\A(?:all|match=domain)\z/) {
@@ -337,8 +346,19 @@ EOM
 
 Example config snippet for mirrors: $cfg_link
 EOF
+       if ($ibx->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 .= <<EOM
+       # each subfolder (starting with `0') holds 50K messages at most
+EOM
+               }
+       }
        if ($ibx->can('nntp_url')) {
-               my $nntp = $ibx->nntp_url;
+               my $nntp = $ibx->nntp_url($ctx);
                if (scalar @$nntp) {
                        $$txt .= "\n";
                        $$txt .= @$nntp == 1 ? 'Newsgroup' : 'Newsgroups are';