* [PATCH 0/3] expand Atom feeds to search results
2015-09-13 22:35 7% [PATCH 1/3] feed: consolidate updated tag generation Eric Wong
@ 2015-09-13 22:37 6% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-09-13 22:37 UTC (permalink / raw)
To: meta
Oops, forgot cover letter. Atom feeds for search views are finally
implemented, and Atom links show up in per-message pages, now.
lib/PublicInbox/Feed.pm | 27 ++++++++++++---------------
lib/PublicInbox/SearchView.pm | 42 +++++++++++++++++++++++++++++++++---------
lib/PublicInbox/View.pm | 15 +++++++++++----
3 files changed, 56 insertions(+), 28 deletions(-)
Eric Wong (3):
feed: consolidate updated tag generation
searchview: implement Atom feed for search results
view: add Atom links in headers for per-message links
^ permalink raw reply [relevance 6%]
* [PATCH 1/3] feed: consolidate updated tag generation
@ 2015-09-13 22:35 7% Eric Wong
2015-09-13 22:37 6% ` [PATCH 0/3] expand Atom feeds to search results Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2015-09-13 22:35 UTC (permalink / raw)
To: meta
We'll be reusing this code further in the next commit.
---
lib/PublicInbox/Feed.pm | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 258ef03..5a2f62b 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -68,9 +68,7 @@ sub emit_atom {
each_recent_blob($ctx, sub {
my ($path, undef, $ts) = @_;
if (defined $x) {
- $fh->write($x . '<updated>' .
- strftime(DATEFMT, gmtime($ts)) .
- '</updated>');
+ $fh->write($x . feed_updated(undef, $ts));
$x = undef;
}
add_to_feed($feed_opts, $fh, $path, $git);
@@ -317,11 +315,12 @@ sub mime_header {
PublicInbox::Hval->new_oneline($mime->header($name))->raw;
}
-sub feed_date {
- my ($date) = @_;
- my @t = eval { strptime($date) };
+sub feed_updated {
+ my ($date, $ts) = @_;
+ my @t = eval { strptime($date) } if defined $date;
+ @t = gmtime($ts || time) unless scalar @t;
- scalar(@t) ? strftime(DATEFMT, @t) : 0;
+ '<updated>' . strftime(DATEFMT, @t) . '</updated>';
}
# returns 0 (skipped) or 1 (added)
@@ -342,9 +341,7 @@ sub add_to_feed {
$mime = undef;
my $date = $header_obj->header('Date');
- $date = PublicInbox::Hval->new_oneline($date);
- $date = feed_date($date->raw) or return 0;
- $date = "<updated>$date</updated>";
+ my $updated = feed_updated($date);
my $title = mime_header($header_obj, 'Subject') or return 0;
$title = title_tag($title);
@@ -356,10 +353,10 @@ sub add_to_feed {
$email = PublicInbox::Hval->new_oneline($email)->as_html;
if (delete $feed_opts->{emit_header}) {
- $fh->write(atom_header($feed_opts, $title) . $date);
+ $fh->write(atom_header($feed_opts, $title) . $updated);
}
$fh->write("<entry><author><name>$name</name><email>$email</email>" .
- "</author>$title$date" .
+ "</author>$title$updated" .
qq{<content\ntype="xhtml">} .
qq{<div\nxmlns="http://www.w3.org/1999/xhtml">});
$fh->write($content);
--
EW
^ permalink raw reply related [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-09-13 22:35 7% [PATCH 1/3] feed: consolidate updated tag generation Eric Wong
2015-09-13 22:37 6% ` [PATCH 0/3] expand Atom feeds to search results Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).