]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchView.pm
use "Atom feed" consistently in headers/footers
[public-inbox.git] / lib / PublicInbox / SearchView.pm
index 7f790902ca4c74e83b024196eafa3c47320b866c..ab3dddb48252ea62197fd79d8fbb2d746175825b 100644 (file)
@@ -10,6 +10,7 @@ use PublicInbox::Hval;
 use PublicInbox::View;
 use PublicInbox::MID qw(mid2path mid_clean);
 use Email::MIME;
+require PublicInbox::Git;
 our $LIM = 50;
 
 sub sres_top_html {
@@ -31,7 +32,7 @@ sub sres_top_html {
                $total = $mset->get_matches_estimated;
        };
        my $err = $@;
-       my $res = html_start($q, $ctx) . PublicInbox::View::PRE_WRAP;
+       my $res = html_start($q, $ctx) . '<pre>';
        if ($err) {
                $code = 400;
                $res .= err_txt($err) . "</pre><hr /><pre>" . foot($ctx);
@@ -42,13 +43,13 @@ sub sres_top_html {
                my $x = $q->{x};
                return sub { adump($_[0], $mset, $q, $ctx) } if ($x eq 'A');
 
-               $res .= search_nav_top($mset, $q);
+               $res .= search_nav_top($mset, $q) . "\n\n";
                if ($x eq 't') {
                        return sub { tdump($_[0], $res, $mset, $q, $ctx) };
                }
-               $res .= "\n\n";
                dump_mset(\$res, $mset);
-               $res .= search_nav_bot($mset, $q) . "\n\n" . foot($ctx);
+               $res .= '</pre>' . search_nav_bot($mset, $q) .
+                       "\n\n" . foot($ctx);
        }
 
        $res .= "</pre></body></html>";
@@ -102,16 +103,13 @@ sub search_nav_top {
        my $x = $q->{x};
        if ($x eq '') {
                my $t = $q->qs_html(x => 't');
-               $rv .= qq{<b>summary</b>|};
-               $rv .= qq{<a\nhref="?$t">threaded</a>}
+               $rv .= qq{<b>summary</b>|<a\nhref="?$t">threaded</a>}
        } elsif ($q->{x} eq 't') {
                my $s = $q->qs_html(x => '');
-               $rv .= qq{<a\nhref="?$s">summary</a>|};
-               $rv .= qq{<b>threaded</b>};
+               $rv .= qq{<a\nhref="?$s">summary</a>|<b>threaded</b>};
        }
        my $A = $q->qs_html(x => 'A', r => undef);
-       $rv .= qq{|<a\nhref="?$A">Atom</a>};
-       $rv .= ']';
+       $rv .= qq{|<a\nhref="?$A">Atom feed</a>]};
 }
 
 sub search_nav_bot {
@@ -169,12 +167,10 @@ sub tdump {
                $th->order(*PublicInbox::View::rsort_ts);
        }
 
-       require PublicInbox::GitCatFile;
-       my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
+       my $git = $ctx->{git} ||= PublicInbox::Git->new($ctx->{git_dir});
        my $state = { ctx => $ctx, anchor_idx => 0, pct => \%pct };
        $ctx->{searchview} = 1;
        tdump_ent($fh, $git, $state, $_, 0) for $th->rootset;
-       $git = undef;
        Email::Address->purge_cache;
 
        $fh->write(search_nav_bot($mset, $q). "\n\n" .
@@ -236,8 +232,7 @@ sub html_start {
 sub adump {
        my ($cb, $mset, $q, $ctx) = @_;
        my $fh = $cb->([ 200, ['Content-Type' => 'application/atom+xml']]);
-       require PublicInbox::GitCatFile;
-       my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
+       my $git = $ctx->{git} ||= PublicInbox::Git->new($ctx->{git_dir});
        my $feed_opts = PublicInbox::Feed::get_feedopts($ctx);
        my $x = PublicInbox::Hval->new_oneline($q->{q})->as_html;
        $x = qq{$x - search results};
@@ -251,7 +246,6 @@ sub adump {
                $x = mid2path($x);
                PublicInbox::Feed::add_to_feed($feed_opts, $fh, $x, $git);
        }
-       $git = undef;
        PublicInbox::Feed::end_feed($fh);
 }