From a40df1af9d5a31fb5accedc75d49045d2f533cb1 Mon Sep 17 00:00:00 2001 From: Dennis Schubert Date: Sun, 14 Dec 2014 01:54:23 +0100 Subject: [PATCH] implement the planets feed --- app/controllers/planet_controller.rb | 2 +- app/views/planet/feed.atom.builder | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 app/views/planet/feed.atom.builder diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb index 1d67b90..9b0f4d8 100644 --- a/app/controllers/planet_controller.rb +++ b/app/controllers/planet_controller.rb @@ -9,6 +9,6 @@ def index end def feed - # TODO implement me + @entries = Planet::Models::Entry.order(:published_at => :desc).limit 25 end end diff --git a/app/views/planet/feed.atom.builder b/app/views/planet/feed.atom.builder new file mode 100644 index 0000000..b19a6c4 --- /dev/null +++ b/app/views/planet/feed.atom.builder @@ -0,0 +1,16 @@ +atom_feed do |feed| + feed.title(t 'pages.planet.headline') + feed.updated(@entries.first.updated_at) + + for entry in @entries + feed.entry(entry, :url => entry.url) do |feeditem| + feeditem.title(entry.title) + + feeditem.author do |author| + author.name entry.author + end + + feeditem.content(entry.body, :type => 'html') + end + end +end