-# not really a stand-alone PSGI app, but maybe it could be...
-sub call {
- my ($self, $env) = @_;
- my $h = [ 'Content-Type', 'text/html; charset=UTF-8' ];
- my $hide_key = 'www';
- if ($env->{PATH_INFO} =~ m!/manifest\.js(?:\.gz)\z/!) {
- $hide_key = 'manifest';
+sub mset_footer ($$) {
+ my ($ctx, $mset) = @_;
+ # no footer if too few matches
+ return '' if $mset->get_matches_estimated == $mset->size;
+ require PublicInbox::SearchView;
+ PublicInbox::SearchView::search_nav_bot($mset, $ctx->{-sq});
+}
+
+sub mset_nav_top {
+ my ($ctx, $mset) = @_;
+ my $q = $ctx->{-sq};
+ my $qh = $q->{'q'} // '';
+ utf8::decode($qh);
+ $qh = ascii_html($qh);
+ $qh = qq[\nvalue="$qh"] if $qh ne '';
+ my $rv = <<EOM;
+<form
+action="./"><pre><input
+name=q
+type=text$qh /><input
+type=submit
+value="locate inbox" /></pre></form><pre>
+EOM
+ chomp $rv;
+ if (defined($q->{'q'})) {
+ my $initial_q = $ctx->{-uxs_retried};
+ if (defined $initial_q) {
+ my $rewritten = $q->{'q'};
+ utf8::decode($initial_q);
+ utf8::decode($rewritten);
+ $initial_q = ascii_html($initial_q);
+ $rewritten = ascii_html($rewritten);
+ $rv .= " Warning: Initial query:\n <b>$initial_q</b>\n";
+ $rv .= " returned no results, used:\n";
+ $rv .= " <b>$rewritten</b>\n instead\n\n";
+ }
+ $rv .= 'Search results ordered by [';
+ if ($q->{r}) {
+ my $d = $q->qs_html(r => 0);
+ $rv .= qq{<a\nhref="?$d">updated</a>|<b>relevance</b>};
+ } else {
+ my $d = $q->qs_html(r => 1);
+ $rv .= qq{<b>updated</b>|<a\nhref="?$d">relevance</a>};
+ }
+ $rv .= ']';