]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchview: add link at bottom to reverse results
authorEric Wong <e@80x24.org>
Sat, 15 Jun 2019 20:23:42 +0000 (20:23 +0000)
committerEric Wong <e@80x24.org>
Sat, 15 Jun 2019 20:25:25 +0000 (20:25 +0000)
I could not find a place to put the link the top without
making navigation too cluttered.  Putting it at the bottom
of the page seems reasonable...

lib/PublicInbox/SearchView.pm
t/psgi_v2.t

index f0d803ea1583b616b6c9451aec298175b49aa8d8..6f07279bd72c21d05aeb3527fc0af02b7785bcdc 100644 (file)
@@ -232,7 +232,9 @@ sub search_nav_bot {
        $rv .= qq{  <a\nhref="?$next"\nrel=next>next</a>} if $next;
        $rv .= $join if $join;
        $rv .= qq{<a\nhref="?$prev"\nrel=prev>prev</a>} if $prev;
-       $rv .= '</pre>';
+
+       my $rev = $q->qs_html(o => $o < 0 ? 0 : -1);
+       $rv .= qq{ | <a\nhref="?$rev">reverse results</a></pre>};
 }
 
 sub sort_relevance {
index 5c358cdecb591720c785cce6ecc6a8fd1a718c96..b8062de280ccdc02318c7a55e0b3775d37f0ab25 100644 (file)
@@ -155,7 +155,7 @@ test_psgi(sub { $www->call(@_) }, sub {
        $res = $cb->(GET('/v2test/?q=m:a-mid@b&x=t'));
        is($res->code, 200, 'success with threaded search');
        my $raw = $res->content;
-       ok($raw =~ s/\A.*>Results 1-3 of 3<//s, 'got all results');
+       ok($raw =~ s/\A.*>Results 1-3 of 3\b//s, 'got all results');
        my @over = ($raw =~ m/\d{4}-\d+-\d+\s+\d+:\d+ (.+)$/gm);
        is_deeply(\@over, [ '<a', '` <a', '` <a' ], 'threaded messages show up');