github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

grosser / acts_as_feed

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 26
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (1)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (1)
    • v0.3.0
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Rails/AR: Transform a Model into a Feed Representation (Feed Reader) — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

fix parsing error reported by Juan Maiz 
grosser (author)
Sun Jan 03 06:09:43 -0800 2010
commit  9f64e0b81915a4b967a0479ff9e8b7dd9cf0bf7f
tree    cc26e207d3ee7de68bc1f4dec1c4c393817aedba
parent  e3904482e1cd61bd2fea8ed5eeb556dff8c82141
acts_as_feed /
name age
history
message
file MIGRATION Wed Dec 17 22:08:57 -0800 2008 removed non essential parts from ActsAsFeed::Fe... [grosser]
file README.markdown Sun Jan 03 06:09:43 -0800 2010 fix parsing error reported by Juan Maiz [grosser]
file Rakefile Sun Jan 03 06:09:43 -0800 2010 fix parsing error reported by Juan Maiz [grosser]
file VERSION Sun Jan 03 05:04:52 -0800 2010 release as gem [grosser]
file acts_as_feed.gemspec Sun Jan 03 06:09:43 -0800 2010 fix parsing error reported by Juan Maiz [grosser]
directory examples/ Wed Dec 17 22:33:45 -0800 2008 example task to update feeds [grosser]
file init.rb Sun Jan 03 05:04:52 -0800 2010 release as gem [grosser]
directory lib/ Sun Jan 03 06:09:43 -0800 2010 fix parsing error reported by Juan Maiz [grosser]
directory spec/ Sun Jan 03 06:09:43 -0800 2010 fix parsing error reported by Juan Maiz [grosser]
README.markdown

Features

  • Easy feed reading for ActiveRecord Models
  • Transparently support RSS and Atom
  • Update feed if feed is old (last feed update > 15 minutes)
  • Update feed if url has changed
  • Support http://url and url
  • Protect from unresponsive sites
  • Protect from giant files
  • Basic implementation of Feed and FeedEntry
  • Full test coverage

INSTALL

As gem

sudo gem install acts_as_feed

OR as Rails plugin:

sudo gem install rss-client
script/plugin install git://github.com/grosser/acts_as_feed.git

Table with (see: MIGRATION):

#essential
feed_url : string
feed_updated_at : timestamp
feed_data : text

#if you want to use a polymorphic feed
covered_id : integer
covered_type : string

Simple Model addition:

User < ActiveRecord::Base
  acts_as_feed
end

Polymorphic Model:

#leverage basic implementation (see lib/acts_as_feed/feed)
class Feed < ActsAsFeed::Feed
  belongs_to :covered, :polymorphic => true
  attr_accessible :feed_url, :covered
  after_save :update_feed
end

#roll you own
class Feed < ActiveRecord::Base
  acts_as_feed :timeout=>3 #seconds

  belongs_to :covered, :polymorphic => true

  validates_length_of :feed_url, :in=>10..250
  attr_accessible :feed_url, :covered

  after_save :update_feed
end

USAGE

  • Call update_feed if the feed could be out of date. If it is not, noting will be done.
  • MyFeed.create!(:feed_url="xxx.com/rss").update_feed

DATA USAGE

!If you do not extend ActsAsFeed::Feed please read /examples/raw_data_usage.txt!

#HAML view example
- if feed.filled?
  %h2="Blog: #{feed.title}"
  - for item in feed.entries[0...5]
    -date = item.published_at.to_date.to_s(:long) rescue ''#can be nil depending on parsed feed

    %h2=link_to(h(item.title),h(item.url))
    %br
    =date
    %br
    - unless item.description.blank?
      =truncate(item.description,70)  #description is always cleared with strip_tags

Alternatives

If you only want to display the feeds contents to browser-using-users, try Googles Feed API instead.
Google Feed API Google Feed API example

AUTHOR

Michael Grosser
grosser.michael@gmail.com
Hereby placed under public domain, do what you want, just do not hold me accountable...

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server