Fullstack-rss

RSS Feed Gem for fullstack-cms

Installation

  gem 'fullstack-rss'

Usage

First of all any item shoud respond at least to :title, :link, :pubdate, :category and :description, :guid and :guid_is_permalink?.

The simplest way to achieve that is use a decorator:

class PostRssItem < Fullstack::Rss::Item

  # ============
  # = Required =
  # ============

  def title
    cdata(object.title)
  end

  def link
    site_post_url(object)
  end

  def pubdate
    object.created_at.xmlschema
  end

  def category
    cdata(object.category.title) # cdata helper is provided by Fullstack::Rss::ItemDecorator
  end

  def description
    cdata(object.intro.html_safe)
  end

  # ============
  # = Optional =
  # ============

  def guid
    link # this is the default 
  end

  def guid_is_permalink?
    false # this is also the default
  end

end

Then you can build a feed like that

class Site::SiteController < Site::BaseController

  include Fullstack::Rss::Helpers

  # ...

  action :feed, :path => "/feed", :format => "xml"
    @items = Post.all.map { |post|  PostRssItem.new(post) }
    render_feed @items
  end

end

And link it in your views with rss_feed_link

<%= rss_feed_link site_feed_url %>

Copyright (c) 2012 mcasimir

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.