Monthly Archives: October 2009

Station 0.3

A new stable version of Rails Station is available. The Content Management System Engine reaches its 0.3 version. Although much work is still pending until the 1.0 release, the engine already provides much functionality. Furthermore, Station is the core of a couple of production websites, including the Virtual Conference Center

The major features of this release are:

There also are a bunch of minor features and fixes, which include:

  • Activate an Agent when resetting his password. Now a user can activate the account and reset the password simultaneously.
  • The Stage has a new method role(name) to find the roles easier.
  • ActionMailer is configured with the Site.current.domain automagically
  • vendor/plugins/station/app path is reloadable
  • Performance comes with two callbacks; avoid_downgrading_only_one_with_highest_role and avoid_destroying_only_one_with_highest_role. These will avoid the admin of a Stage leaves it without assigning a new admin first.

There is also included a database migration template for upgrading from version 0.2 to 0.3. It can be found at vendor/plugins/station/db/migrate/station_2_to_3.rb

Find installation instructions in Rails Station Homepage

Advertisements

New Authorization Framework

These days I’ve working in a new Authorization Framework for Rails Station.

After trying with ACLs and suffering from some scalability issues, the final version seems to be stable.

Like previous versions, you can protect your controller actions using authorization_filter

class PostsController
  authorization_filter :read, :post, :only => [ :show ]
end

Authorization is defined in each  model using authorizing declarations:

class Post
  authorizing do |user, permission|
    # Allow all actions to the author of the Post
    if user == agent
      true
    end
  end
end

You can define and chain all the authorizing declarations you need. These declarations build an authorization chain, which is evaluated from the first one until one of the declarations returns true or false.

This is the response you get when calling:

post.authorize? :read, :to => user

Station comes with two default declarations:

  • When a model acts_as_stage, the authorization queries will look for the permissions of the role the user is playing in the Stage
  • When a model acts_as_content, the authorization will query the Container

You can check the documentation for more information about authorization in Station

Admissions: Invitations and Join Requests

One of the new major features of Station 0.3 is Admissions.

Admissions gather the proccess of joining a Stage. There are two classes of Admissions:

  • Invitations: The new participant is contacted by email, providing a link where s/he can accept or deny the invitation. The role the new participant is playing in the Stage is preset in the Invitation request
  • Join Requests: The new participant requests the Stage admins s/he wants to participate in the Stage. The admins accept or deny the request.

Admissions basic support is already included in master and will be part of Station 0.3

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.