X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FFeed.pm;h=c16c417a099e9e6b88bdc94e5f9897e37293380a;hb=2c69f7bc34a2b12dc7f55e2bb24fa28565f24f03;hp=a5828a8e16bf9f475c1897b60f7cd4279e064c24;hpb=8968889e3ebfa09dd2c80fe8b917b83ac13ff356;p=public-inbox.git diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index a5828a8e..c16c417a 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,40 @@ 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 { 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\"" : ''; "