X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2FPublicInbox%2FSearchView.pm;h=f1c4b6a052181e28c28127403a07d3732972151b;hb=c41c7aa95d55dcff7cb01a744bbf1bfb200e23b4;hp=5b15e0d7e2fed72ef84fe0785d34f8e2ffd5dfc3;hpb=398e29344ecc43548a7d3998bb5d2fcee62d66cd;p=public-inbox.git diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index 5b15e0d7..f1c4b6a0 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,70 +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($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} = "\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); + $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); } - $res .= "\n\n"; - dump_mset(\$res, $mset); - $res .= 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 .= "