«

»

Aug 12

O_RLY? A Ruby/Rails implementation of snowl (Part I)

Recently Mozilla Labs released a prototype of snowl, a rss/atom/twitter feed reader. It is a firefox plugin and provides two views of messages — a “traditional” message view, as well as a “river of news“. I thought that this could be easily “redone” as a rails application. The rest of this article steps through the process of creating it.

So what’s O_RLY all about?

Well, the name snowl struck me as being a merger of two words, “snow” and “owl”. So, a quick google on snow owl, and it led me to the Wikipedia entry for “Snowy Owl”, which then referenced “o_rly“. The image associated with “o_rly” is that of a snowy owl:

So….. The name was set.

Next on to the creation of the app…

Programming O_RLY

I’m assuming rails 2.1.0 as well as an up-to-date installation of rubygems.

The basics: RubyGems, testing, and Restful Authentication setup

  1. First create the rails project: rails o_rly. By default it uses sqlite.
  2. Next, install the following gems:
    • FeedNormalizer — This makes reading rss/atom feeds easy.
    • Twitter — For doing twittery things, of course.
  3. Plugins next:
    1. I’m using rspec for testing, so I need to do the following to install it for rails:
    2. acts_as_state_machine — This is used by Restful Authentication for user creation.
    3. Restful Authentication – This allows us to easily work with users.

      We also need to run it’s generator. I am running it to set up authentication required.

      Run its migration

      If you are running autotest (which is a good idea), now would be a good time to create your test database as well.
  4. Configuration
    1. As of 12 Aug, 2008, there’s an issue with rails and restful_authentication.  To resolve this, according to Luca Guidi you need to make sure that the following lines are in vendor/plugins/restful_authentication/init.rb:

      I found that I was missing the second, but the first was there.
    2. According the the restful authentication wiki, we need to add the following to config/routes.rb

      Additionally the resource mapping for users (map.resources :users) needs to be changed to
    3. Next we need to add an observer to config/environment.rb (look for the section labeled observers).
    4. In order to make things easier for development, we’ll take a note from avnet lab’s Restful Authentication with rails 2 and edit config/environments/development.rb to add the following line:

      and likewise in config/environments/production.rb

      Modify myapplication.com to reflect the url of your application. Make the production change to config/environments/test.rb.
    5. In both config/environments/development.rb and config/environments/development.rb add a ADMINEMAIL variable representing the email address from whence you want the activation notices to be sent. Make the production change to config/environments/test.rb.
    6. Now we need to update the app/models/user_mailer.rb to pick up the SITE_URL change. Any place there is a reference to YOURSITE replace it with #{SITE_URL}.
    7. Next create config/initializers/mail.rb and place the following code in it:

      You’ll need to change the settings to reflect your smtp settings. (The last three may not be needed—if that is the case, just remove them)
    8. Don’t forget to remove public/index.html.

That’s a decent stopping point. In part II, we’ll look at adding OpenID and password retrieval. Part III will see us adding feeds. Part IV will add twitter.

Here’s the code so far: o_rly_parti.tar.gz

EDIT: Added changes needed to config/environments/test.rb to pass tests.

Leave a Reply

%d bloggers like this: