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.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE 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 039B91F622 for ; Mon, 29 Aug 2022 09:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1661765209; bh=UScb/oUwSge/fIWdeYSWIToW/mraprVHyYrm5USWoMM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WWo0wUV6VeDVtXcOCv0xzG+NHhdDIYcrNiXHZ+L93W7bePxEZbOAA1EuzCGIy8H+t uwodnhkYsoUOeie9bNlP6Z+Lgm8Ie+yEwzJghgjIA6vyrv4fD1K2hljJSJMioF3fWf 9lfrcdUp19ggHfSkPdj26byXHNTQIqHNPwoKD4fE= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 10/18] view: /$INBOX/: show "messages from $old to $new" Date: Mon, 29 Aug 2022 09:26:39 +0000 Message-Id: <20220829092647.1512215-11-e@80x24.org> In-Reply-To: <20220829092647.1512215-1-e@80x24.org> References: <20220829092647.1512215-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: With the ViewVCS commit view using /$INBOX/?t=YYYYMMDDhhmmss- links, the use of `t=' may not be immediately obvious to a reader and confuse them into thinking the inbox hasn't been updated in a while. So add a header to the top of the page whenever the `t=' query parameter is used. And kill a couple of redundant variable assignments while we're at it. --- lib/PublicInbox/View.pm | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 466ec6cf..11ed2d76 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -20,6 +20,7 @@ use PublicInbox::WwwStream qw(html_oneshot); use PublicInbox::Reply; use PublicInbox::ViewDiff qw(flush_diff); use PublicInbox::Eml; +use POSIX qw(strftime); use Time::Local qw(timegm); use PublicInbox::Smsg qw(subject_normalized); use PublicInbox::ContentHash qw(content_hash); @@ -1161,9 +1162,10 @@ sub dump_topics { } my @out; - my $ibx = $ctx->{ibx}; - my $obfs_ibx = $ibx->{obfuscate} ? $ibx : undef; - + my $obfs_ibx = $ctx->{ibx}->{obfuscate} ? $ctx->{ibx} : undef; + if (my $note = delete $ctx->{t_note}) { + push @out, $note; # "messages from ... to ..." + } # sort by recency, this allows new posts to "bump" old topics... foreach my $topic (sort { $b->[0] <=> $a->[0] } @$order) { my ($ds, $n, $seen, $top_subj, @extra) = @$topic; @@ -1222,7 +1224,7 @@ sub pagination_footer ($$) { $next = $next ? "$next | " : ' | '; $prev .= qq[ | latest]; } - ($next || $prev) ? "
page: $next$prev
" : ''; + ($next || $prev) ? "
" : ''; } sub paginate_recent ($$) { @@ -1238,21 +1240,29 @@ sub paginate_recent ($$) { $t =~ /\A([0-9]{8,14})\z/ and $before = str2ts($1); my $msgs = $ctx->{ibx}->over->recent($opts, $after, $before); - my $nr = scalar @$msgs; - if ($nr < $lim && defined($after)) { + if (defined($after) && scalar(@$msgs) < $lim) { $after = $before = undef; $msgs = $ctx->{ibx}->over->recent($opts); - $nr = scalar @$msgs; } - my $more = $nr == $lim; + my $more = scalar(@$msgs) == $lim; my ($newest, $oldest); - if ($nr) { + if (@$msgs) { $newest = $msgs->[0]->{ts}; $oldest = $msgs->[-1]->{ts}; # if we only had $after, our SQL query in ->recent ordered if ($newest < $oldest) { ($oldest, $newest) = ($newest, $oldest); - $more = 0 if defined($after) && $after < $oldest; + $more = undef if defined($after) && $after < $oldest; + } + if (defined($after // $before)) { + my $n = strftime('%Y-%m-%d %H:%M:%S', gmtime($newest)); + my $o = strftime('%Y-%m-%d %H:%M:%S', gmtime($oldest)); + $ctx->{t_note} = <more...] +EOM + my $s = ts2str($newest); + $ctx->{prev_page} = qq[] . + 'prev (newer)'; } } if (defined($oldest) && $more) { @@ -1260,11 +1270,6 @@ sub paginate_recent ($$) { $ctx->{next_page} = qq[] . 'next (older)'; } - if (defined($newest) && (defined($before) || defined($after))) { - my $s = ts2str($newest); - $ctx->{prev_page} = qq[] . - 'prev (newer)'; - } $msgs; }