]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Feed.pm
www_stream: add response wrapper sub
[public-inbox.git] / lib / PublicInbox / Feed.pm
index ddc1e3c14f8b3fc4860f73363ac10cf8c6f84efe..2f141c4413b9473e0f4ee3cdaaaa692633a95428 100644 (file)
@@ -34,6 +34,32 @@ sub generate_html_index {
        sub { emit_html_index($_[0], $ctx) };
 }
 
+sub new_html {
+       my ($ctx) = @_;
+       my @paths;
+       my (undef, $last) = each_recent_blob($ctx, sub {
+               my ($path, $commit, $ts, $u, $subj) = @_;
+               $ctx->{first} ||= $commit;
+               push @paths, $path;
+       });
+       if (!@paths) {
+               return [404, ['Content-Type', 'text/plain'],
+                       ["No messages, yet\n"] ];
+       }
+       $ctx->{-html_tip} = '<pre>';
+       $ctx->{-upfx} = '';
+       PublicInbox::WwwStream->response($ctx, 200, sub {
+               while (my $path = shift @paths) {
+                       my $m = do_cat_mail($ctx->{-inbox}, $path) or next;
+                       my $more = scalar @paths;
+                       my $s = PublicInbox::View::index_entry($m, $ctx, $more);
+                       $s .= '</pre>' unless $more;
+                       return $s;
+               }
+               undef;
+       });
+}
+
 # private subs
 
 sub title_tag {