user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 10/18] view: /$INBOX/: show "messages from $old to $new"
  2022-08-29  9:26  5% [PATCH 00/18] WWW: patch, tree, git glossary Eric Wong
@ 2022-08-29  9:26  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2022-08-29  9:26 UTC (permalink / raw)
  To: meta

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[ | <a\nhref="$latest">latest</a>];
 	}
-	($next || $prev) ? "<hr><pre>page: $next$prev</pre>" : '';
+	($next || $prev) ? "<hr><pre id=nav>page: $next$prev</pre>" : '';
 }
 
 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} = <<EOM;
+ messages from $o to $n UTC, [<a href="#nav">more...</a>]
+EOM
+			my $s = ts2str($newest);
+			$ctx->{prev_page} = qq[<a\nhref="?t=$s-"\nrel=prev>] .
+						'prev (newer)</a>';
 		}
 	}
 	if (defined($oldest) && $more) {
@@ -1260,11 +1270,6 @@ sub paginate_recent ($$) {
 		$ctx->{next_page} = qq[<a\nhref="?t=$s"\nrel=next>] .
 					'next (older)</a>';
 	}
-	if (defined($newest) && (defined($before) || defined($after))) {
-		my $s = ts2str($newest);
-		$ctx->{prev_page} = qq[<a\nhref="?t=$s-"\nrel=prev>] .
-					'prev (newer)</a>';
-	}
 	$msgs;
 }
 

^ permalink raw reply related	[relevance 7%]

* [PATCH 00/18] WWW: patch, tree, git glossary
@ 2022-08-29  9:26  5% Eric Wong
  2022-08-29  9:26  7% ` [PATCH 10/18] view: /$INBOX/: show "messages from $old to $new" Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2022-08-29  9:26 UTC (permalink / raw)
  To: meta

Raw format-patch and tree HTML output now supported for git
output.  I suppose tags can be displayed, too, at some point...

One thing I'm not 100% sure about is adding a git-related
glossary for stuff like trees, commits, etc...  It seems
to bloat the page a bit, but it could be useful in slowly
teaching basic git data concepts to beginners.

I suspect folks who have trouble learning git too focused on the
commands rather than the data concepts.  (IMHO, the same goes
for learning projects based on studying code vs studying
(DB schemas || struct layouts)).

I snuck one speedup in there, hopefully more to come...

Eric Wong (18):
  solver: create tmpdir lazily
  viewvcs: share File::Temp::Dir with solver
  viewvcs: delay stringification of solver debug log
  www: allow html_oneshot to take an array arg
  viewvcs: use array for highlighted blob display
  viewvcs: add patch download link for single-parent commits
  viewvcs: author date links to contemporary messages
  view: speed up /$INBOX/ landing page by 0.5-1.0%
  treewide: ditch inbox->recent method
  view: /$INBOX/: show "messages from $old to $new"
  view: cleanups and reuse for {obuf} preparation
  www: atom: fix "changed" href to nowhere
  www: provide text/help/#search anchor
  solver: early make hints detection more robust
  viewvcs: add tree view
  viewvcs: reduce hash assignments for commit info
  viewvcs: add glossary for commit
  viewvcs: show "blob $OID" rather than "$OID blob"

 lib/PublicInbox/ExtSearch.pm      |   1 -
 lib/PublicInbox/Inbox.pm          |   5 -
 lib/PublicInbox/LeiSavedSearch.pm |   1 -
 lib/PublicInbox/LeiXSearch.pm     |   7 -
 lib/PublicInbox/SolverGit.pm      |  22 +-
 lib/PublicInbox/View.pm           | 101 ++++-----
 lib/PublicInbox/ViewDiff.pm       |  18 +-
 lib/PublicInbox/ViewVCS.pm        | 341 ++++++++++++++++++++----------
 lib/PublicInbox/WWW.pm            |   2 +-
 lib/PublicInbox/WwwAltId.pm       |   6 +-
 lib/PublicInbox/WwwAtomStream.pm  |   1 +
 lib/PublicInbox/WwwStream.pm      |   7 +-
 lib/PublicInbox/WwwText.pm        |   3 +-
 t/convert-compact.t               |   2 +-
 t/indexlevels-mirror.t            |  10 +-
 t/lei_xsearch.t                   |   2 +-
 t/plack.t                         |   2 +-
 t/replace.t                       |   4 +-
 t/solver_git.t                    |   3 +-
 t/v1-add-remove-add.t             |   2 +-
 t/v2-add-remove-add.t             |   2 +-
 21 files changed, 333 insertions(+), 209 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 --
2022-08-29  9:26  5% [PATCH 00/18] WWW: patch, tree, git glossary Eric Wong
2022-08-29  9:26  7% ` [PATCH 10/18] view: /$INBOX/: show "messages from $old to $new" 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).