From 6eef235bbe781e6a566198cd60f1c65708c4ac35 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Tue, 7 Aug 2012 15:57:57 +0200 Subject: [PATCH] flux rss --- app/controllers/public/articles_controller.rb | 15 +++++++++++++ app/views/public/articles/feed.rss.builder | 22 +++++++++++++++++++ config/routes.rb | 4 ++++ 3 files changed, 41 insertions(+) create mode 100644 app/views/public/articles/feed.rss.builder diff --git a/app/controllers/public/articles_controller.rb b/app/controllers/public/articles_controller.rb index a89fa59..f078222 100644 --- a/app/controllers/public/articles_controller.rb +++ b/app/controllers/public/articles_controller.rb @@ -13,6 +13,21 @@ class Public::ArticlesController < ApplicationController @title = "Articles du blog" end + + def feed + # this will be the name of the feed displayed on the feed reader + @title = "Blog de Nicolas Bally" + + # the news items + @articles = Article.before(Date.today).recents + + # this will be our Feed's update timestamp + @updated = @articles.first.updated_at unless @articles.empty? + + + end + + def category diff --git a/app/views/public/articles/feed.rss.builder b/app/views/public/articles/feed.rss.builder new file mode 100644 index 0000000..88947cb --- /dev/null +++ b/app/views/public/articles/feed.rss.builder @@ -0,0 +1,22 @@ + + + +xml.instruct! :xml, :version => "1.0" +xml.rss :version => "2.0" do + xml.channel do + xml.title "Blog de Nicolas Bally" + xml.description "" + xml.link "http://blog.nicolasbally.com" + + for article in @articles + xml.item do + xml.title article.title + xml.description simple_format(article.description) + xml.pubDate article.published_at.to_s(:rfc822) + xml.link article_url(:slug => article.slug) + xml.guid article_url(:slug => article.slug) + end + end + end +end + diff --git a/config/routes.rb b/config/routes.rb index fb32b51..2c8a8c8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,10 @@ Crossey2::Application.routes.draw do #blog + match '/feed' => 'public/articles#feed', :as => :feed, :defaults => { :format => 'atom' } + + + match "blog/categorie/:slug.:f"=> "public/articles#category", :as => :category_public_article, :f => "html"