X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=lib%2FPublicInbox%2FSearchView.pm;h=488822e6c594ea243aac51d1ee9d097c1c75a8d9;hp=fbef4116e9623f2838f17cf0c4fc31c9ff31acaf;hb=5422a844b7384c32b3532d128e15e0b50d24435b;hpb=5c5dfb7d5558ff248477fa57aef08e2a8bbd9800 diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index fbef4116..488822e6 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -8,12 +8,14 @@ use warnings; use PublicInbox::SearchMsg; use PublicInbox::Hval qw/ascii_html/; use PublicInbox::View; -use PublicInbox::MID qw(mid2path mid_mime); +use PublicInbox::MID qw(mid2path mid_mime mid_clean); use Email::MIME; require PublicInbox::Git; require PublicInbox::Thread; our $LIM = 50; +sub noop {} + sub sres_top_html { my ($ctx) = @_; my $q = PublicInbox::SearchQuery->new($ctx->{qp}); @@ -27,44 +29,46 @@ sub sres_top_html { relevance => $q->{r}, }; my ($mset, $total); - eval { - $mset = $ctx->{srch}->query($q->{q}, $opts); + $mset = $ctx->{srch}->query($q->{'q'}, $opts); $total = $mset->get_matches_estimated; }; my $err = $@; - my $res = html_start($q, $ctx) . '
'; + ctx_prepare($q, $ctx); + my $cb; if ($err) { $code = 400; - $res .= err_txt($ctx, $err) . "
" . foot($ctx); + $ctx->{-html_tip} = ''.err_txt($ctx, $err).'
'; + $cb = *noop; } elsif ($total == 0) { $code = 404; - $res .= "\n\n[No results found]
".foot($ctx); + $ctx->{-html_tip} = "' . search_nav_bot($mset, $q) . - "\n\n" . foot($ctx); } - $res .= "\n[No results found]
"; + $cb = *noop; } else { my $x = $q->{x}; return sub { adump($_[0], $mset, $q, $ctx) } if ($x eq 'A'); - $res .= search_nav_top($mset, $q) . "\n\n"; + $ctx->{-html_tip} = search_nav_top($mset, $q) . "\n\n"; if ($x eq 't') { - return sub { tdump($_[0], $res, $mset, $q, $ctx) }; + $cb = mset_thread($ctx, $mset, $q); + } else { + $cb = mset_summary($ctx, $mset, $q); } - dump_mset(\$res, $mset); - $res .= '