Giter Club home page Giter Club logo

to_rss's Introduction

to_rss()

To start use it you must install plugin

script/plugin install git://github.com/over/to_rss.git

Easiest way to generate RSS:

@posts = Post.all
render :rss => @posts.to_rss {|feed, item| feed[:link] = polymorphic_url(item) }

And add link to RSS in your <head></head>

<%= rss_link_tag "RSS", posts_url(:format => :xml) %>

Plugin searches title of feed item in these fields:

title, name, lead, heading

And description in following:

description, body, contents

Also you can define own values of these RSS attributes. Check out examples of usage:

render :rss => @posts.to_rss do |feed, item| 
  feed[:title] = "#{item.title}: #{item.description.first(10)}..."
  feed[:description] = render_to_string(:partial => "posts/to_rss", :object => item)
  feed[:link] = polymorphic_url(item)
  feed[:author] = "#{item.user.name}"
end

The only required attribute is feed Also, you can customize feed properties:

# config/environment.rb

ToRss::Config.feed[:title] = "The best channel you have ever seen"
ToRss::Config.feed[:link] = "http://tandp.ru"
ToRss::Config.feed[:description] = "Feed of posts"

Also, you can rewrite it in controller:

render :rss => @posts.to_rss(:feed_title => "Overwritten title", :feed_link => "http://google.com", :feed_description => "Zhopa123") do |feed, item| 
  feed[:title] = "#{item.title}: #{item.description.first(10)}..."
  feed[:description] = render_to_string(:partial => "posts/to_rss", :object => item)
  feed[:link] = polymorphic_url(item)
end

Copyright © 2009 Mikhail Tabunov, released under the MIT license

to_rss's People

Contributors

igorgladkoborodov avatar over avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.