]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchView.pm
use both Date: and Received: times
[public-inbox.git] / lib / PublicInbox / SearchView.pm
index 3eff7087cc45c642ad1c58f2cc6f22e14f4259b8..55c588cb2285dd31048e0bf84cc476cbbcd1a8e6 100644 (file)
@@ -1,5 +1,5 @@
-# Copyright (C) 2015 all contributors <meta@public-inbox.org>
-# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
+# Copyright (C) 2015-2018 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Displays search results for the web interface
 package PublicInbox::SearchView;
@@ -18,12 +18,19 @@ our $LIM = 200;
 
 sub noop {}
 
+sub mbox_results {
+       my ($ctx) = @_;
+       my $q = PublicInbox::SearchQuery->new($ctx->{qp});
+       my $x = $q->{x};
+       return PublicInbox::Mbox::mbox_all($ctx, $q->{'q'}) if $x eq 'm';
+       sres_top_html($ctx);
+}
+
 sub sres_top_html {
        my ($ctx) = @_;
        my $q = PublicInbox::SearchQuery->new($ctx->{qp});
        my $x = $q->{x};
        my $query = $q->{'q'};
-       return PublicInbox::Mbox::mbox_all($ctx, $query) if $x eq 'm';
 
        my $code = 200;
        # double the limit for expanded views:
@@ -60,7 +67,7 @@ retry:
        } else {
                return adump($_[0], $mset, $q, $ctx) if $x eq 'A';
 
-               $ctx->{-html_tip} = search_nav_top($mset, $q, $ctx) . "\n\n";
+               $ctx->{-html_tip} = search_nav_top($mset, $q, $ctx);
                if ($x eq 't') {
                        $cb = mset_thread($ctx, $mset, $q);
                } else {
@@ -110,11 +117,11 @@ sub mset_summary {
                        obfuscate_addrs($obfs_ibx, $s);
                        obfuscate_addrs($obfs_ibx, $f);
                }
-               my $ts = PublicInbox::View::fmt_ts($smsg->ts);
+               my $date = PublicInbox::View::fmt_ts($smsg->ds);
                my $mid = PublicInbox::Hval->new_msgid($smsg->mid)->{href};
                $$res .= qq{$rank. <b><a\nhref="$mid/">}.
                        $s . "</a></b>\n";
-               $$res .= "$pfx  - by $f @ $ts UTC [$pct%]\n\n";
+               $$res .= "$pfx  - by $f @ $date UTC [$pct%]\n\n";
        }
        $$res .= search_nav_bot($mset, $q);
        *noop;
@@ -131,8 +138,8 @@ sub err_txt {
 
 sub search_nav_top {
        my ($mset, $q, $ctx) = @_;
-
-       my $rv = '<pre>';
+       my $m = $q->qs_html(x => 'm', r => undef);
+       my $rv = qq{<form\naction="?$m"\nmethod="post"><pre>};
        my $initial_q = $ctx->{-uxs_retried};
        if (defined $initial_q) {
                my $rewritten = $q->{'q'};
@@ -166,9 +173,8 @@ sub search_nav_top {
        }
        my $A = $q->qs_html(x => 'A', r => undef);
        $rv .= qq{|<a\nhref="?$A">Atom feed</a>]};
-       my $m = $q->qs_html(x => 'm', r => undef);
-       warn "m: $m\n";
-       $rv .= qq{\n\t\t\t\t\t\tdownload: <a\nhref="?$m">mbox.gz</a>};
+       $rv .= qq{\n\t\t\t\t\t\tdownload: };
+       $rv .= qq{<input\ntype=submit\nvalue="mbox.gz"/></pre></form><pre>};
 }
 
 sub search_nav_bot {
@@ -221,7 +227,7 @@ sub mset_thread {
        } ($mset->items) ]});
        my $r = $q->{r};
        my $rootset = PublicInbox::SearchThread::thread($msgs,
-               $r ? sort_relevance(\%pct) : *PublicInbox::View::sort_ts,
+               $r ? sort_relevance(\%pct) : *PublicInbox::View::sort_ds,
                $srch);
        my $skel = search_nav_bot($mset, $q). "<pre>";
        my $inbox = $ctx->{-inbox};