about summary refs log tree commit homepage
path: root/lib/PublicInbox/View.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r--lib/PublicInbox/View.pm46
1 files changed, 13 insertions, 33 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 17af21f7..e29922ef 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -153,10 +153,7 @@ sub thread_html {
         my $msgs = load_results($res);
         my $nr = scalar @$msgs;
         return $rv if $nr == 0;
-        require PublicInbox::Thread;
-        my $th = PublicInbox::Thread->new(@$msgs);
-        $th->thread;
-        $th->order(*PublicInbox::Thread::sort_ts);
+        my $th = thread_results($msgs);
         my $state = [ $srch, { root_anchor => anchor_for($mid) }, undef, 0 ];
         {
                 require PublicInbox::GitCatFile;
@@ -176,30 +173,6 @@ sub thread_html {
         $rv .= "<hr />" . PRE_WRAP . $next . $foot . "</pre>";
 }
 
-sub subject_path_html {
-        my (undef, $ctx, $foot, $srch) = @_;
-        my $path = $ctx->{subject_path};
-        my $res = $srch->get_subject_path($path);
-        my $rv = '';
-        my $msgs = load_results($res);
-        my $nr = scalar @$msgs;
-        return $rv if $nr == 0;
-        require PublicInbox::Thread;
-        my $th = PublicInbox::Thread->new(@$msgs);
-        $th->thread;
-        $th->order(*PublicInbox::Thread::sort_ts);
-        my $state = [ $srch, { root_anchor => 'dummy' }, undef, 0 ];
-        {
-                require PublicInbox::GitCatFile;
-                my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
-                thread_entry(\$rv, $git, $state, $_, 0) for $th->rootset;
-        }
-        my $final_anchor = $state->[3];
-        my $next = "<a\nid=\"s$final_anchor\">end of thread</a>\n";
-
-        $rv .= "<hr />" . PRE_WRAP . $next . $foot . "</pre>";
-}
-
 # only private functions below.
 
 sub index_walk {
@@ -560,12 +533,10 @@ sub simple_dump {
 
 sub thread_followups {
         my ($dst, $root, $res) = @_;
-        my $msgs = load_results($res);
-        require PublicInbox::Thread;
         $root->header_set('X-PI-TS', '0');
-        my $th = PublicInbox::Thread->new($root, @$msgs);
-        $th->thread;
-        $th->order(*PublicInbox::Thread::sort_ts);
+        my $msgs = load_results($res);
+        push @$msgs, $root;
+        my $th = thread_results($msgs);
         my $srch = $res->{srch};
         my $subj = $srch->subject_path($root->header('Subject'));
         my %seen = ($subj => 1);
@@ -618,4 +589,13 @@ sub msg_timestamp {
         defined($ts) ? $ts : 0;
 }
 
+sub thread_results {
+        my ($msgs) = @_;
+        require PublicInbox::Thread;
+        my $th = PublicInbox::Thread->new(@$msgs);
+        $th->thread;
+        $th->order(*PublicInbox::Thread::sort_ts);
+        $th
+}
+
 1;