X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FFeed.pm;h=2f141c4413b9473e0f4ee3cdaaaa692633a95428;hb=e158d56a54d3c6d4890aa6ac4caa28a834279af0;hp=a0aa62af4e2697eac563d0708a00407246ab4993;hpb=5094d0b97975f06c67b4a8fc11500fd350406cd2;p=public-inbox.git diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index a0aa62af..2f141c44 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -5,22 +5,19 @@ package PublicInbox::Feed; use strict; use warnings; -use Email::Address; use Email::MIME; use Date::Parse qw(strptime); -use PublicInbox::Hval; +use PublicInbox::Hval qw/ascii_html/; use PublicInbox::Git; use PublicInbox::View; use PublicInbox::MID qw/mid_clean mid2path/; +use PublicInbox::Address; use POSIX qw/strftime/; use constant { DATEFMT => '%Y-%m-%dT%H:%M:%SZ', # Atom standard MAX_PER_PAGE => 25, # this needs to be tunable }; -use Encode qw/find_encoding/; -my $enc_utf8 = find_encoding('UTF-8'); - # main function sub generate { my ($ctx) = @_; @@ -37,12 +34,39 @@ 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} = ''; + 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 .= '' unless $more; + return $s; + } + undef; + }); +} + # private subs sub title_tag { my ($title) = @_; + $title =~ tr/\t\n / /s; # squeeze spaces # try to avoid the type attribute in title: - $title = PublicInbox::Hval->new_oneline($title)->as_html; + $title = ascii_html($title); my $type = index($title, '&') >= 0 ? "\ntype=\"html\"" : ''; "