X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FSearchView.pm;h=cec87c6ad1c84c891fe41d4eac62ec556e6b3a97;hb=4ba430497bfb4763691b0ad8af573eb6ff420b96;hp=746cb838bbf3f49a616b903312c42edc1813fae7;hpb=57cbe47ad5e935f5071e37b07c0a2bdcc91beea0;p=public-inbox.git diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index 746cb838..cec87c6a 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -6,16 +6,20 @@ package PublicInbox::SearchView; use strict; use warnings; use PublicInbox::SearchMsg; -use PublicInbox::Hval; +use PublicInbox::Hval qw/ascii_html/; use PublicInbox::View; -use PublicInbox::MID qw(mid2path mid_clean); -use Email::MIME; +use PublicInbox::WwwAtomStream; +use PublicInbox::MID qw(mid2path mid_mime mid_clean mid_escape); +use PublicInbox::MIME; require PublicInbox::Git; -our $LIM = 50; +require PublicInbox::SearchThread; +our $LIM = 200; + +sub noop {} sub sres_top_html { my ($ctx) = @_; - my $q = PublicInbox::SearchQuery->new($ctx->{cgi}); + my $q = PublicInbox::SearchQuery->new($ctx->{qp}); my $code = 200; # double the limit for expanded views: @@ -26,73 +30,92 @@ 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); } + PublicInbox::WwwStream->response($ctx, $code, $cb); +} + +# allow undef for individual doc loads... +sub load_doc_retry { + my ($srch, $mitem) = @_; - $res .= "\n[No results found]
"; + $cb = *noop; } else { my $x = $q->{x}; - return sub { adump($_[0], $mset, $q, $ctx) } if ($x eq 'A'); + return 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 .= '