Skip to content

Commit

Permalink
Add missing author and updated elements to atom feed.
Browse files Browse the repository at this point in the history
  • Loading branch information
gavincarr committed Jan 10, 2012
1 parent 67166be commit 092b7cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions conf/spoor.conf.dist
Expand Up @@ -6,6 +6,11 @@
# Title
title = @somerandomguy's microblog

# Author details, for atom feed
author_name = Some Author
#author_email = dude@example.com
#author_url = http://www.example.com/dude/

# Instance secret - change this to a random string of your choice
# (used for generating secure signed cookies)
secret = f097c174-12bb-4ae2-9d64-a108f7d94024
Expand Down
12 changes: 12 additions & 0 deletions spoor
Expand Up @@ -77,18 +77,26 @@ helper render_atom => sub {

$XML::Atom::DefaultVersion = "1.0";

my $author = XML::Atom::Person->new;
$author->name($config->get('author_name') || 'Some Author');
$author->email($config->get('author_email')) if $config->get('author_email');
$author->uri($config->get('author_url')) if $config->get('author_url');

my $new_feed = sub {
my $feed = XML::Atom::Feed->new;
$feed->title($title);
$feed->id($spoor_url . $path);
$feed->author($author);
return $feed;
};
my $feed = $new_feed->();

my $max_updated = '';
while (my $post = $rs->next) {
# If we find a post that is paused, reset the feed and start again from the next post
if (! $post->forward_flag) {
$feed = $new_feed->();
$max_updated = '';
next;
}

Expand All @@ -105,11 +113,15 @@ helper render_atom => sub {
elsif ($post->forward_flag == 2) {
$entry->published(ts2iso8601($post->timestamp));
}
$entry->updated($entry->published);
$max_updated = $entry->updated if $entry->updated gt $max_updated;

if (defined $post->latitude && defined $post->longitude) {
$entry->point(join(' ', $post->latitude, $post->longitude));
}
$feed->add_entry($entry);
}
$feed->updated($max_updated) if $max_updated;

# Note XML::Atom encodes as utf-8, so render_data avoids double-encoding here
$self->render_data($feed->as_xml, format => 'xml');
Expand Down

0 comments on commit 092b7cd

Please sign in to comment.