} .
- qq{$title} .
- qq({url}"/>) .
- qq({atomurl}"/>) .
- qq(mailto:$feed_opts->{id_addr});
+ my $env = $ctx->{env};
+ my $url = $ctx->{-inbox}->base_url($env) . 'new.html';
+ my $qs = $env->{QUERY_STRING};
+ $url .= "?$qs" if $qs ne '';
+ [302, [ 'Location', $url, 'Content-Type', 'text/plain'],
+ [ "Redirecting to $url\n" ] ];
}
-sub emit_atom {
- my ($cb, $ctx) = @_;
- my $fh = $cb->([ 200, ['Content-Type' => 'application/atom+xml']]);
- my $max = $ctx->{max} || MAX_PER_PAGE;
- my $feed_opts = get_feedopts($ctx);
- my $x = atom_header($feed_opts);
- my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
- each_recent_blob($ctx, sub {
- my ($path, undef, $ts) = @_;
- if (defined $x) {
- $fh->write($x . feed_updated(undef, $ts));
- $x = undef;
+sub new_html {
+ my ($ctx) = @_;
+ my $msgs = recent_msgs($ctx);
+ if (!@$msgs) {
+ return [404, ['Content-Type', 'text/plain'],
+ ["No messages, yet\n"] ];
+ }
+ $ctx->{-html_tip} = '';
+ $ctx->{-upfx} = '';
+ $ctx->{-hr} = 1;
+ my $ibx = $ctx->{-inbox};
+ PublicInbox::WwwStream->response($ctx, 200, sub {
+ while (my $smsg = shift @$msgs) {
+ my $m = $ibx->smsg_mime($smsg) or next;
+ my $more = scalar @$msgs;
+ return PublicInbox::View::index_entry($m, $ctx, $more);
}
- add_to_feed($feed_opts, $fh, $path, $git);
+ PublicInbox::View::pagination_footer($ctx, './new.html');
});
- $git = undef; # destroy pipes
- end_feed($fh);
-}
-
-sub _no_thread {
- my ($cb) = @_;
- my $fh = $cb->([404, ['Content-Type' => 'text/plain']]);
- $fh->write("No feed found for thread\n");
- $fh->close;
-}
-
-sub end_feed {
- my ($fh) = @_;
- Email::Address->purge_cache;
- $fh->write('
');
- $fh->close;
-}
-
-sub emit_atom_thread {
- my ($cb, $ctx) = @_;
- my $res = $ctx->{srch}->get_thread($ctx->{mid});
- return _no_thread($cb) unless $res->{total};
- my $fh = $cb->([200, ['Content-Type' => 'application/atom+xml']]);
- my $feed_opts = get_feedopts($ctx);
-
- my $html_url = $feed_opts->{atomurl} = $ctx->{self_url};
- $html_url =~ s!/t\.atom\z!/!;
- $feed_opts->{url} = $html_url;
- $feed_opts->{emit_header} = 1;
-
- my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
- foreach my $msg (@{$res->{msgs}}) {
- add_to_feed($feed_opts, $fh, mid2path($msg->mid), $git);
- }
- $git = undef; # destroy pipes
- end_feed($fh);
-}
-
-sub emit_html_index {
- my ($cb, $ctx) = @_;
- my $fh = $cb->([200,['Content-Type'=>'text/html; charset=UTF-8']]);
-
- my $max = $ctx->{max} || MAX_PER_PAGE;
- my $feed_opts = get_feedopts($ctx);
-
- my $title = $feed_opts->{description} || '';
- $title = PublicInbox::Hval->new_oneline($title)->as_html;
- my $atom_url = $feed_opts->{atomurl};
- my ($footer, $param, $last);
- my $state = { ctx => $ctx, seen => {}, anchor_idx => 0 };
- my $srch = $ctx->{srch};
-
- my $top = "