From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 54F211FD20 for ; Tue, 1 Sep 2015 08:55:29 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/11] feed: use updated date based on git commit date Date: Tue, 1 Sep 2015 08:55:21 +0000 Message-Id: <1441097728-31950-4-git-send-email-e@80x24.org> In-Reply-To: <1441097728-31950-1-git-send-email-e@80x24.org> References: <1441097728-31950-1-git-send-email-e@80x24.org> List-Id: This will hopefully make life easier for feed readers. --- lib/PublicInbox/Feed.pm | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index bc76cdc..71042d7 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -10,6 +10,7 @@ use PublicInbox::Hval; use PublicInbox::GitCatFile; use PublicInbox::View; use PublicInbox::MID qw/mid_clean mid_compress/; +use POSIX qw/strftime/; use constant { DATEFMT => '%Y-%m-%dT%H:%M:%SZ', # atom standard MAX_PER_PAGE => 25, # this needs to be tunable @@ -33,7 +34,6 @@ sub generate_html_index { sub emit_atom { my ($cb, $ctx) = @_; - require POSIX; my $fh = $cb->([ 200, ['Content-Type' => 'application/xml']]); my $max = $ctx->{max} || MAX_PER_PAGE; my $feed_opts = get_feedopts($ctx); @@ -45,18 +45,23 @@ sub emit_atom { my $type = index($title, '&') >= 0 ? "\ntype=\"html\"" : ''; my $url = $feed_opts->{url} || "http://example.com/"; my $atomurl = $feed_opts->{atomurl}; - $fh->write(qq(\n) . + my $x = qq(\n) . qq{} . qq{$title} . qq{} . qq{} . - qq{mailto:$addr} . - '' . POSIX::strftime(DATEFMT, gmtime) . ''); + qq{mailto:$addr}; my $git = PublicInbox::GitCatFile->new($ctx->{git_dir}); each_recent_blob($ctx, sub { - my ($add, undef) = @_; - add_to_feed($feed_opts, $fh, $add, $git); + my ($path, undef, $ts) = @_; + if (defined $x) { + $fh->write($x . ''. + strftime(DATEFMT, gmtime($ts)) . + ''); + $x = undef; + } + add_to_feed($feed_opts, $fh, $path, $git); }); $git = undef; # destroy pipes Email::Address->purge_cache; @@ -259,7 +264,7 @@ sub feed_date { my ($date) = @_; my @t = eval { strptime($date) }; - scalar(@t) ? POSIX::strftime(DATEFMT, @t) : 0; + scalar(@t) ? strftime(DATEFMT, @t) : 0; } # returns 0 (skipped) or 1 (added) @@ -363,7 +368,7 @@ sub dump_topics { $subj = PublicInbox::Hval->new($subj)->as_html; $u = PublicInbox::Hval->new($u)->as_html; $dst .= "\n$subj\n- "; - $ts = POSIX::strftime('%Y-%m-%d %H:%M', gmtime($ts)); + $ts = strftime('%Y-%m-%d %H:%M', gmtime($ts)); if ($n == 1) { $dst .= "created by $u @ $ts UTC\n" } else { -- EW