Permalink
Browse files

RSS feed.

  • Loading branch information...
1 parent 2d9ef96 commit cbf9575172fb71ac1c3f4fe8da6aac2469ba5569 @marano committed May 1, 2013
Showing with 32 additions and 2 deletions.
  1. +1 −0 Gemfile
  2. +2 −0 Gemfile.lock
  3. +10 −1 controller.rb
  4. +1 −1 views/home.slim
  5. +18 −0 views/rss.builder
View
@@ -7,6 +7,7 @@ gem 'therubyracer' # required by less
gem 'less'
gem 'rollin'
gem 'rack-google-analytics'
+gem 'builder'
group :development do
gem 'pry'
View
@@ -2,6 +2,7 @@ GEM
remote: https://rubygems.org/
specs:
backports (3.3.0)
+ builder (3.2.0)
coderay (1.0.9)
commonjs (0.2.6)
jsmin (1.0.1)
@@ -49,6 +50,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ builder
less
pry
rack-google-analytics
View
@@ -38,6 +38,11 @@ def blog
@article = blog.find_article_by_id(params[:id])
slim :article
end
+
+ get '/rss.xml' do
+ @articles = blog.articles
+ builder :rss
+ end
end
class Integer
@@ -57,7 +62,11 @@ def ordinal
end
class Rollin::Article
- def link_to_self
+ def relative_link_to_self
"/article/#{id}"
end
+
+ def link_to_self
+ "http://mara.nu/#{relative_link_to_self}"
+ end
end
View
@@ -9,5 +9,5 @@
= article.day.ordinal
.title-home
h2
- a href=article.link_to_self
+ a href=article.relative_link_to_self
= article.title
View
@@ -0,0 +1,18 @@
+xml.instruct! :xml, :version => '1.0'
+xml.rss :version => "2.0" do
+ xml.channel do
+ xml.title "mara.nu"
+ xml.description ""
+ xml.link "http://mara.nu/"
+
+ @articles.each do |article|
+ xml.item do
+ xml.title article.title
+ xml.link article.link_to_self
+ xml.description article.body
+ xml.pubDate Time.parse(article.date.to_s).rfc822()
+ xml.guid article.link_to_self
+ end
+ end
+ end
+end

0 comments on commit cbf9575

Please sign in to comment.