From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id D801C20FD4 for ; Thu, 30 Jun 2016 09:21:47 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 05/13] feed: add $INBOX/new.html endpoint Date: Thu, 30 Jun 2016 09:21:35 +0000 Message-Id: <20160630092143.31651-6-e@80x24.org> In-Reply-To: <20160630092143.31651-1-e@80x24.org> References: <20160630092143.31651-1-e@80x24.org> List-Id: This acts like the Atom feed; but should be viewable directly from browsers. --- lib/PublicInbox/Feed.pm | 27 +++++++++++++++++++++++++++ lib/PublicInbox/WWW.pm | 10 +++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index ddc1e3c..c16c417 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -34,6 +34,33 @@ 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} = '
';
+	$ctx->{-upfx} = '';
+	my $res = PublicInbox::WwwStream->new($ctx, 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 .= '
' unless $more; + return $s; + } + undef; + }); + [ 200, ['Content-Type', 'text/html; charset=UTF-8'], $res ] +} + # private subs sub title_tag { diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index 196486f..da5c1d3 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -75,7 +75,8 @@ sub call { invalid_inbox($self, $ctx, $1) || get_index($ctx); } elsif ($path_info =~ m!$INBOX_RE/(?:atom\.xml|new\.atom)\z!o) { invalid_inbox($self, $ctx, $1) || get_atom($ctx); - + } elsif ($path_info =~ m!$INBOX_RE/new\.html\z!o) { + invalid_inbox($self, $ctx, $1) || get_new($ctx); } elsif ($path_info =~ m!$INBOX_RE/ ($PublicInbox::GitHTTPBackend::ANY)\z!ox) { my $path = $2; @@ -189,6 +190,13 @@ sub get_atom { PublicInbox::Feed::generate($ctx); } +# /$INBOX/new.html -> HTML only +sub get_new { + my ($ctx) = @_; + require PublicInbox::Feed; + PublicInbox::Feed::new_html($ctx); +} + # /$INBOX/?r=$GIT_COMMIT -> HTML only sub get_index { my ($ctx) = @_; -- EW