X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=lib%2FPublicInbox%2FView.pm;h=a774febdc9c4a383de9bf9a577b6ce11abb09105;hp=65788dbebc01717c6ae49db5563996f23855095d;hb=5422a844b7384c32b3532d128e15e0b50d24435b;hpb=5c5dfb7d5558ff248477fa57aef08e2a8bbd9800 diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 65788dbe..a774febd 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -97,8 +97,7 @@ sub nr_to_s ($$$) { # this is already inside a
sub index_entry { - my ($mime, $level, $state) = @_; - $state->{anchor_idx}++; + my ($mime, $state) = @_; my $ctx = $state->{ctx}; my $srch = $ctx->{srch}; my $hdr = $mime->header_obj; @@ -118,7 +117,7 @@ sub index_entry { $subj = "$subj" if $root_anchor eq $id_m; my $ts = _msg_date($hdr); - my $rv = "# "; + my $rv = "# "; $rv .= $subj; my $mhref = $path.$href.'/'; my $from = _hdr_names($hdr, 'From'); @@ -154,13 +153,7 @@ sub index_entry { if (my $pct = $state->{pct}) { # used by SearchView.pm $rv .= " [relevance $pct->{$mid_raw}%]"; } - $state->{fh}->write($rv .= "\n"); # '\n' for lynx -} - -sub thread_html { - my ($ctx, $foot, $srch) = @_; - # $_[0] in sub is the Plack callback - sub { emit_thread_html($_[0], $ctx, $foot, $srch) } + $rv .= "\n\n"; } sub walk_thread { @@ -186,25 +179,26 @@ sub pre_thread { skel_dump($state, $level, $node); } -# only private functions below. - -sub emit_thread_html { - my ($res, $ctx, $foot, $srch) = @_; +sub thread_html { + my ($ctx) = @_; my $mid = $ctx->{mid}; - my $sres = $srch->get_thread($mid, { asc => 1 }); + my $sres = $ctx->{srch}->get_thread($mid, { asc => 1 }); my $msgs = load_results($sres); my $nr = $sres->{total}; - return missing_thread($res, $ctx) if $nr == 0; - my $skel = ''; + return missing_thread($ctx) if $nr == 0; + my $skel = '
'; + $skel .= $nr == 1 ? 'only message in thread' : 'end of thread'; + $skel .= ", back to index"; + $skel .= "\n$nr+ messages in thread: (download: "; + $skel .= "mbox.gz"; + $skel .= " / follow: Atom feed)\n"; my $state = { - anchor_idx => 0, ctx => $ctx, cur_level => 0, dst => \$skel, mapping => {}, # mid -> reply count prev_attr => '', prev_level => 0, - res => $res, root_anchor => anchor_for($mid), seen => {}, srch => $ctx->{srch}, @@ -213,21 +207,28 @@ sub emit_thread_html { walk_thread(thread_results($msgs), $state, *pre_thread); - thread_entry($state, $_, 0) for @$msgs; - - # there could be a race due to a message being deleted in git - # but still being in the Xapian index: - my $fh = delete $state->{fh} or return missing_thread($res, $ctx); - - my $next = @$msgs == 1 ? 'only message in thread' : 'end of thread'; - $next .= ", back to index"; - $next .= "\n$nr+ messages in thread: (download: "; - $next .= "mbox.gz"; - $next .= " / follow: Atom feed)\n"; - $next .= $skel; - $fh->write('' . $next . "\n\n". - $foot . '