diff options
author | Eric Wong <e@80x24.org> | 2015-09-02 02:37:21 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-09-02 06:50:23 +0000 |
commit | 7ce4210ceb2a150e20e48676d8b635f6d2ed471f (patch) | |
tree | d93451ee4b018ebb24081175ce3a2e37d2e5137c | |
parent | 46a6294965dea8941ccdf66ed7739925469aac58 (diff) | |
download | public-inbox-7ce4210ceb2a150e20e48676d8b635f6d2ed471f.tar.gz |
This will allow users to navigate the flat view without making extra HTTP requests.
-rw-r--r-- | lib/PublicInbox/View.pm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 0331b62c..98fc133d 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -167,9 +167,10 @@ sub emit_thread_html { return missing_thread($cb) if $nr == 0; my $flat = $ctx->{flat}; my $orig_cb = $cb; + my $seen = {}; my $state = { ctx => $ctx, - seen => {}, + seen => $seen, root_anchor => anchor_for($mid), anchor_idx => 0, }; @@ -177,6 +178,7 @@ sub emit_thread_html { require PublicInbox::GitCatFile; my $git = PublicInbox::GitCatFile->new($ctx->{git_dir}); if ($flat) { + pre_anchor_entry($seen, $_) for (@$msgs); __thread_entry(\$cb, $git, $state, $_, 0) for (@$msgs); } else { my $th = thread_results($msgs); @@ -580,6 +582,12 @@ sub thread_html_head { $$cb->write("<html><head><title>$s</title></head><body>"); } +sub pre_anchor_entry { + my ($seen, $mime) = @_; + my $id = anchor_for($mime->header('Message-ID')); + $seen->{$id} = "#$id"; # save the anchor for children, later +} + sub __thread_entry { my ($cb, $git, $state, $mime, $level) = @_; |