]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchView.pm
searchview: nofollow on mbox downloads
[public-inbox.git] / lib / PublicInbox / SearchView.pm
index c42cf2d63fa3c9b99c2ce5fc534addffcebe8fd6..8e0c3cfc60d733cbdd5847f5a014b9018c5a9069 100644 (file)
@@ -21,8 +21,11 @@ sub noop {}
 sub sres_top_html {
        my ($ctx) = @_;
        my $q = PublicInbox::SearchQuery->new($ctx->{qp});
-       my $code = 200;
+       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:
        my $opts = {
                limit => $LIM,
@@ -33,7 +36,7 @@ sub sres_top_html {
        my ($mset, $total, $err, $cb);
 retry:
        eval {
-               $mset = $ctx->{srch}->query($q->{'q'}, $opts);
+               $mset = $ctx->{srch}->query($query, $opts);
                $total = $mset->get_matches_estimated;
        };
        $err = $@;
@@ -55,7 +58,6 @@ retry:
                $ctx->{-html_tip} = "<pre>\n[No results found]</pre><hr>";
                $cb = *noop;
        } else {
-               my $x = $q->{x};
                return adump($_[0], $mset, $q, $ctx) if $x eq 'A';
 
                $ctx->{-html_tip} = search_nav_top($mset, $q, $ctx) . "\n\n";
@@ -79,7 +81,7 @@ sub load_doc_retry {
        }
 }
 
-# display non-threaded search results similar to what users expect from
+# display non-nested search results similar to what users expect from
 # regular WWW search engines:
 sub mset_summary {
        my ($ctx, $mset, $q) = @_;
@@ -157,13 +159,17 @@ sub search_nav_top {
        my $x = $q->{x};
        if ($x eq '') {
                my $t = $q->qs_html(x => 't');
-               $rv .= qq{<b>summary</b>|<a\nhref="?$t">threaded</a>}
+               $rv .= qq{<b>summary</b>|<a\nhref="?$t">nested</a>}
        } elsif ($q->{x} eq 't') {
                my $s = $q->qs_html(x => '');
-               $rv .= qq{<a\nhref="?$s">summary</a>|<b>threaded</b>};
+               $rv .= qq{<a\nhref="?$s">summary</a>|<b>nested</b>};
        }
        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: };
+       $rv .= qq{<a\nhref="?$m"\nrel="nofollow">mbox.gz</a>};
 }
 
 sub search_nav_bot {
@@ -327,7 +333,7 @@ sub qs_html {
                $qs .= "&amp;r";
        }
        if (my $x = $self->{x}) {
-               $qs .= "&amp;x=$x" if ($x eq 't' || $x eq 'A');
+               $qs .= "&amp;x=$x" if ($x eq 't' || $x eq 'A' || $x eq 'm');
        }
        $qs;
 }