lib/PublicInbox/Feed.pm | 6 +++--- lib/PublicInbox/SearchView.pm | 42 +++++++++++++++++++++++++++++++++--------- diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index 5a2f62b193d0db0241cf525f3d4c975ea3fa60f3..85c598e56c20ae94d71e4f85955f462f0ce2385a 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -74,7 +74,7 @@ } add_to_feed($feed_opts, $fh, $path, $git); }); $git = undef; # destroy pipes - _end_feed($fh); + end_feed($fh); } sub _no_thread { @@ -84,7 +84,7 @@ $fh->write("No feed found for thread\n"); $fh->close; } -sub _end_feed { +sub end_feed { my ($fh) = @_; Email::Address->purge_cache; $fh->write(''); @@ -108,7 +108,7 @@ foreach my $msg (@{$res->{msgs}}) { add_to_feed($feed_opts, $fh, mid2path($msg->mid), $git); } $git = undef; # destroy pipes - _end_feed($fh); + end_feed($fh); } sub emit_html_index { diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index c15a0463f4079b76245534e047a08b28d307a9c6..b65351aa18b5250b4fb3a96cd55e39f22e776d57 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -30,7 +30,7 @@ $mset = $ctx->{srch}->query($q->{q}, $opts); $total = $mset->get_matches_estimated; }; my $err = $@; - my $res = html_start($q) . PublicInbox::View::PRE_WRAP; + my $res = html_start($q, $ctx) . PublicInbox::View::PRE_WRAP; if ($err) { $code = 400; $res .= err_txt($err) . "
" . foot($ctx); @@ -39,8 +39,7 @@ $code = 404; $res .= "\n\n[No results found]
".foot($ctx);
} else {
my $x = $q->{x};
- # TODO
- #return sub { adump($_[0], $mset, $q, $ctx) } if ($x eq 'A');
+ return sub { adump($_[0], $mset, $q, $ctx) } if ($x eq 'A');
$res .= search_nav_top($mset, $q);
if ($x eq 't') {
@@ -109,8 +108,8 @@ my $s = $q->qs_html(x => '');
$rv .= qq{summary|};
$rv .= qq{threaded};
}
- # my $A = $q->qs_html(x => 'a');
- # $rv .= qq{|Atom}; # TODO
+ my $A = $q->qs_html(x => 'A');
+ $rv .= qq{|Atom};
$rv .= ']';
}
@@ -213,13 +212,16 @@ qq{Back to index.\n$foot};
}
sub html_start {
- my ($q) = @_;
+ my ($q, $ctx) = @_;
my $query = PublicInbox::Hval->new_oneline($q->{q});
my $qh = $query->as_html;
- my $res = "$qh - search results " .
- qq{};
+}
+
+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 $feed_opts = PublicInbox::Feed::get_feedopts($ctx);
+ my $x = PublicInbox::Hval->new_oneline($q->{q})->as_html;
+ $x = qq{$x - search results};
+ $feed_opts->{atomurl} = $feed_opts->{url} . '?'. $q->qs_html;
+ $feed_opts->{url} .= '?'. $q->qs_html(x => undef);
+ $x = PublicInbox::Feed::atom_header($feed_opts, $x);
+ $fh->write($x. PublicInbox::Feed::feed_updated());
+
+ for ($mset->items) {
+ $x = PublicInbox::SearchMsg->load_doc($_->get_document)->mid;
+ $x = mid2path($x);
+ PublicInbox::Feed::add_to_feed($feed_opts, $fh, $x, $git);
+ }
+ $git = undef;
+ PublicInbox::Feed::end_feed($fh);
}
package PublicInbox::SearchQuery;