user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Cc: Eric Wong <e@80x24.org>
Subject: [PATCH 1/2] index group state parameters together for generation
Date: Mon, 15 Sep 2014 04:23:21 +0000	[thread overview]
Message-ID: <1410755002-15885-1-git-send-email-e@80x24.org> (raw)

This allows us to more-easily group and pass parameters.
---
 lib/PublicInbox/Feed.pm | 15 +++++++--------
 lib/PublicInbox/View.pm |  5 +++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 385e573..1fa38bf 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -86,14 +86,14 @@ sub generate_html_index {
 		} @_;
 	});
 
-	my %seen;
 	# except we sort top-level messages reverse chronologically
+	my $state = [ time, {}, $first ];
 	for (sort { (eval { $b->message->header('X-PI-Date') } || 0) <=>
 		    (eval { $a->message->header('X-PI-Date') } || 0)
 		  } $th->rootset) {
-		dump_msg($_, 0, \$html, time, \%seen, $first);
+		dump_msg($_, 0, \$html, $state);
 	}
-
+	$state = undef;
 	Email::Address->purge_cache;
 
 	my $footer = nav_footer($args->{cgi}, $first, $last, $feed_opts);
@@ -287,14 +287,13 @@ sub add_to_feed {
 }
 
 sub dump_msg {
-	my ($self, $level, $html, $now, $seen, $first) = @_;
+	my ($self, $level, $html, $state) = @_;
 	my $mime = $self->message;
 	if ($mime) {
-		$$html .= PublicInbox::View->index_entry($mime, $now, $level,
-		                                         $seen, $first);
+		$$html .= PublicInbox::View->index_entry($mime, $level, $state);
 	}
-	dump_msg($self->child, $level+1, $html, $now, $seen, $first) if $self->child;
-	dump_msg($self->next, $level, $html, $now, $seen, $first) if $self->next;
+	dump_msg($self->child, $level+1, $html, $state) if $self->child;
+	dump_msg($self->next, $level, $html, $state) if $self->next;
 }
 
 sub do_cat_mail {
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index d3849dc..b3797d3 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -43,8 +43,9 @@ sub feed_entry {
 
 # this is already inside a <pre>
 sub index_entry {
-	my ($class, $mime, $now, $level, $seen, $first) = @_;
-	my $rv = "";
+	my ($class, $mime, $level, $state) = @_;
+	my ($now, $seen, $first) = @$state;
+	my $rv = '';
 	my $part_nr = 0;
 	my $enc_msg = enc_for($mime->header("Content-Type"));
 	my $subj = $mime->header('Subject');
-- 
EW


             reply	other threads:[~2014-09-15  4:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-15  4:23 Eric Wong [this message]
2014-09-15  4:23 ` [PATCH 2/2] index: add prev/next index navigation Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1410755002-15885-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).