Tag Archives: atom

Introspecting Uris HTML

I have been working on the support for discovering several kinds of services and resources in HTML. This is part of a short research project we’ll hopefully launch soon.

Station now provides support for discovering this type of services:

Advertisements

Import Feeds to your Containers

Station provides basic (and still in development) support for Atom/RSS feeds. You can import feeds to your Containers and create new Contents from each Atom/RSS element.

A Container is any model that give context to other models. Lets take the following example:

class Space
  has_many :posts
end

The has_many relation indicates Space is probably a Container.  If a posts always belongs_to a space, then you have it. Space is a Container.

Station provides an easy way to import feeds to your Containers. This is achieved by the Sources support.

Add the sources table to your database.
The sources table is defined in station/db/migrate/station_2_to_3.rb and will be included in the next version of the Station migration schema.

Indicate Station that your Space is a Container and it supports Sources.

Just add the suitable option to the container declaration:

class Space
  has_many :posts
  acts_as_container :sources => true
end

Write the Atom Parser in your models

You’ll have to describe the conversion between the source feed elements and your models. This is easily achieved using the params_from_atom function


class Posts
  def self.params_from_atom(entry)
    { :title => entry.title.to_s,
       :text => entry.content.to_s }
  end
end

And that’s it! Now you can visit /spaces/1/sources and automatically add new Posts to your Spaces.