about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchView.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-12-31 07:37:17 +0000
committerEric Wong <e@80x24.org>2015-12-31 07:37:17 +0000
commit3979330907a90821283ac21bc00f0f6506e90383 (patch)
tree1a3394c4dc3c4c287a61470a4e7bc6b060aa86a5 /lib/PublicInbox/SearchView.pm
parent430a7799c319df9dcef0dae0a5aa0add0a40d6a1 (diff)
downloadpublic-inbox-3979330907a90821283ac21bc00f0f6506e90383.tar.gz
Oops, the rarely-accessed threaded search view was completely
broken.  Additionally, the normal threading depths were broken
when we attempted to go up-thread and replies got nested
improperly

Followup to commit be984ce279776d4513b4ca1bff05ebecafdd1bad
("view: thread using <ul> instead of <table>")
Diffstat (limited to 'lib/PublicInbox/SearchView.pm')
-rw-r--r--lib/PublicInbox/SearchView.pm18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index ab3dddb4..5d4f4fe2 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -138,7 +138,7 @@ sub search_nav_bot {
 sub tdump {
         my ($cb, $res, $mset, $q, $ctx) = @_;
         my $fh = $cb->([200, ['Content-Type'=>'text/html; charset=UTF-8']]);
-        $fh->write($res);
+        $fh->write($res .= '</pre>');
         my %pct;
         my @m = map {
                 my $i = $_;
@@ -168,9 +168,15 @@ sub tdump {
         }
 
         my $git = $ctx->{git} ||= PublicInbox::Git->new($ctx->{git_dir});
-        my $state = { ctx => $ctx, anchor_idx => 0, pct => \%pct };
+        my $state = {
+                ctx => $ctx,
+                anchor_idx => 0,
+                pct => \%pct,
+                cur_level => 0
+        };
         $ctx->{searchview} = 1;
         tdump_ent($fh, $git, $state, $_, 0) for $th->rootset;
+        PublicInbox::View::thread_adj_level($fh, $state, 0);
         Email::Address->purge_cache;
 
         $fh->write(search_nav_bot($mset, $q). "\n\n" .
@@ -193,10 +199,13 @@ sub tdump_ent {
                 };
         }
         if ($mime) {
+                my $end =
+                  PublicInbox::View::thread_adj_level($fh, $state, $level);
                 PublicInbox::View::index_entry($fh, $mime, $level, $state);
+                $fh->write($end) if $end;
         } else {
                 my $mid = $node->messageid;
-                $fh->write(PublicInbox::View::ghost_table('', $mid, $level));
+                PublicInbox::View::ghost_flush($fh, $state, '', $mid, $level);
         }
         tdump_ent($fh, $git, $state, $node->child, $level + 1);
         tdump_ent($fh, $git, $state, $node->next, $level);
@@ -214,7 +223,8 @@ sub html_start {
 
         my $qh = $query->as_html;
         my $A = $q->qs_html(x => 'A', r => undef);
-        my $res = "<html><head><title>$qh - search results</title>" .
+        my $res = '<html><head>' . PublicInbox::Hval::STYLE .
+                "<title>$qh - search results</title>" .
                 qq{<link\nrel=alternate\ntitle="Atom feed"\n} .
                 qq!href="?$A"\ntype="application/atom+xml"/></head>! .
                 qq{<body><form\naction="">} .