user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] show date in top-level threaded index
@ 2014-08-26  5:54 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2014-08-26  5:54 UTC (permalink / raw)
  To: meta

This is probably useful information for folks browsing via web
interface.  It'll probably make more sense if we show the entire
body in the threaded display, though.
---
 lib/PublicInbox/Feed.pm | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 0104a6b..4ec8e97 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -85,7 +85,7 @@ sub generate_html_index {
 			$a->topmost->message->header('X-PI-Date')
 		} @_;
 	});
-	dump_html_line($_, 0, \$html) for $th->rootset;
+	dump_html_line($_, 0, \$html, time) for $th->rootset;
 
 	Email::Address->purge_cache;
 
@@ -278,11 +278,11 @@ sub add_to_feed {
 }
 
 sub dump_html_line {
-	my ($self, $level, $html) = @_;
+	my ($self, $level, $html, $now) = @_;
 	if ($self->message) {
-		$$html .= (' ' x $level);
 		my $mime = $self->message;
 		my $subj = $mime->header('Subject');
+		my $ts = $mime->header('X-PI-Date');
 		my $mid = $mime->header_obj->header_raw('Message-ID');
 		$mid = PublicInbox::Hval->new_msgid($mid);
 		my $href = 'm/' . $mid->as_href . '.html';
@@ -294,10 +294,17 @@ sub dump_html_line {
 
 		$from = PublicInbox::Hval->new_oneline($from)->as_html;
 		$subj = PublicInbox::Hval->new_oneline($subj)->as_html;
+		if ($now > ($ts + (24 * 60 * 60))) {
+			$ts = POSIX::strftime('%m/%d ', gmtime($ts));
+		} else {
+			$ts = POSIX::strftime('%H:%M ', gmtime($ts));
+		}
+
+		$$html .= $ts . (' ' x $level);
 		$$html .= "<a href=\"$href\">$subj</a> $from\n";
 	}
-	dump_html_line($self->child, $level+1, $html) if $self->child;
-	dump_html_line($self->next, $level, $html) if $self->next;
+	dump_html_line($self->child, $level+1, $html, $now) if $self->child;
+	dump_html_line($self->next, $level, $html, $now) if $self->next;
 }
 
 sub do_cat_mail {
-- 
EW

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-08-26  5:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-26  5:54 [PATCH] show date in top-level threaded index 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).