lib/PublicInbox/Feed.pm | 2 +- lib/PublicInbox/View.pm | 53 +++++++++++++++++++++++++++++------------------------ lib/PublicInbox/WWW.pm | 2 ++ diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index 1a89fbad076b94e99d9dcc6517474e0a3a9e079d..5a41beaa48cbdcf15a7cb98ac6463e855a22896a 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -76,7 +76,7 @@ # sort child messages in chronological order $th->order(*PublicInbox::Thread::sort_ts); # except we sort top-level messages reverse chronologically - my $state = [ undef, {}, $first, 0 ]; + my $state = [ $args->{srch}, {}, $first, 0 ]; for (PublicInbox::Thread::rsort_ts($th->rootset)) { dump_msg($_, 0, \$html, $state) } diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 47082431ec8fa375580c7b85afa95117ea0496a9..496093510659c19eb52c35484700013d38a3691b 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -48,7 +48,7 @@ # this is already inside a
 # state = [ time, seen = {}, first_commit, page_nr = 0 ]
 sub index_entry {
 	my (undef, $mime, $level, $state) = @_;
-	my (undef, $seen, $first_commit) = @$state;
+	my ($srch, $seen, $first_commit) = @$state;
 	my $midx = $state->[3]++;
 	my ($prev, $next) = ($midx - 1, $midx + 1);
 	my $rv = '';
@@ -75,10 +75,26 @@ 	my $path;
 	my $more = 'permalink';
 	if ($root_anchor) {
 		$path = '../';
-		$subj = "$subj" if $root_anchor eq $id;
 	} else {
 		$path = '';
 	}
+	my $href = $mid->as_href;
+	my $irt = $header_obj->header_raw('In-Reply-To');
+	my ($anchor_idx, $anchor, $t_anchor);
+	if (defined $irt) {
+		$anchor_idx = anchor_for($irt);
+		$anchor = $seen->{$anchor_idx};
+		$t_anchor = T_ANCHOR;
+	} else {
+		$t_anchor = '';
+	}
+
+	if (defined $srch) {
+		$subj = "$subj";
+	}
+	if ($root_anchor && $root_anchor eq $id) {
+		$subj = "$subj";
+	}
 
 	my $ts = $mime->header('X-PI-TS');
 	my $fmt = '%Y-%m-%d %H:%M UTC';
@@ -92,16 +108,6 @@ 		$rv .= "/prev";
 	}
 	$rv .= "\n\n";
 
-	my $irt = $header_obj->header_raw('In-Reply-To');
-	my ($anchor_idx, $anchor, $t_anchor);
-	if (defined $irt) {
-		$anchor_idx = anchor_for($irt);
-		$anchor = $seen->{$anchor_idx};
-		$t_anchor = T_ANCHOR;
-	} else {
-		$t_anchor = '';
-	}
-	my $href = $mid->as_href;
 	my $mhref = "${path}m/$href.html";
 	my $fhref = "${path}f/$href.html";
 	# scan through all parts, looking for displayable text
@@ -126,8 +132,8 @@ 		}
 		$rv .= " parent";
 	}
 
-	if ($first_commit) {
-		$rv .= " thread";
+	if ($srch) {
+		$rv .= " thread";
 	}
 
 	$rv . "\n\n";
@@ -145,7 +151,7 @@ 	require PublicInbox::Thread;
 	my $th = PublicInbox::Thread->new(@$msgs);
 	$th->thread;
 	$th->order(*PublicInbox::Thread::sort_ts);
-	my $state = [ undef, { root_anchor => anchor_for($mid) }, undef, 0 ];
+	my $state = [ $srch, { root_anchor => anchor_for($mid) }, undef, 0 ];
 	thread_entry(\$rv, $state, $_, 0) for $th->rootset;
 	my $final_anchor = $state->[3];
 	my $next = "end of thread\n";
@@ -165,7 +171,7 @@ 	require PublicInbox::Thread;
 	my $th = PublicInbox::Thread->new(@$msgs);
 	$th->thread;
 	$th->order(*PublicInbox::Thread::sort_ts);
-	my $state = [ undef, { root_anchor => 'dummy' }, undef, 0 ];
+	my $state = [ $srch, { root_anchor => 'dummy' }, undef, 0 ];
 	thread_entry(\$rv, $state, $_, 0) for $th->rootset;
 	my $final_anchor = $state->[3];
 	my $next = "end of thread\n";
@@ -340,6 +346,10 @@ 	my ($mime, $full_pfx, $srch) = @_;
 
 	my $rv = "";
 	my @title;
+	my $header_obj = $mime->header_obj;
+	my $mid = $header_obj->header_raw('Message-ID');
+	$mid = PublicInbox::Hval->new_msgid($mid);
+	my $mid_href = $mid->as_href;
 	foreach my $h (qw(From To Cc Subject Date)) {
 		my $v = $mime->header($h);
 		defined($v) && length($v) or next;
@@ -351,8 +361,7 @@ 			$title[1] = ascii_html($from[0]->name);
 		} elsif ($h eq 'Subject') {
 			$title[0] = $v->as_html;
 			if ($srch) {
-				my $path = $srch->subject_path($v->raw);
-				$rv .= "$h: ";
+				$rv .= "$h: ";
 				$rv .= $v->as_html . "\n";
 				next;
 			}
@@ -361,13 +370,9 @@ 		$rv .= "$h: " . $v->as_html . "\n";
 
 	}
 
-	my $header_obj = $mime->header_obj;
-	my $mid = $header_obj->header_raw('Message-ID');
-	$mid = PublicInbox::Hval->new_msgid($mid);
 	$rv .= 'Message-ID: <' . $mid->as_html . '> ';
-	my $href = $mid->as_href;
-	$href = "../m/$href" unless $full_pfx;
-	$rv .= "(raw)\n";
+	$mid_href = "../m/$mid_href" unless $full_pfx;
+	$rv .= "(raw)\n";
 
 	my $irt = $header_obj->header_raw('In-Reply-To');
 	if (defined $irt) {
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index bbd438a2d939bc1d42d9fbbcc83b1634ec74d0e8..5021509572efdecdca3b62981ce5e3bf9d97fca7 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -126,8 +126,10 @@ # /$LISTNAME/?r=$GIT_COMMIT                 -> HTML only
 sub get_index {
 	my ($ctx, $cgi, $top) = @_;
 	require PublicInbox::Feed;
+	my $srch = searcher($ctx);
 	[ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ],
 	  [ PublicInbox::Feed->generate_html_index({
+			srch => $srch,
 			git_dir => $ctx->{git_dir},
 			listname => $ctx->{listname},
 			pi_config => $pi_config,