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
First create the rails project: rails o_rly. By default it uses sqlite.
Next, install the following gems:
FeedNormalizer — This makes reading rss/atom feeds easy.
sudo gem install FeedNormalizer
Twitter — For doing twittery things, of course.
sudo gem install twitter
Plugins next:
I’m using rspec for testing, so I need to do the following to install it for rails:
We also need to run it’s generator. I am running it to set up authentication required.
script/generate authenticated user sessions --include-activation --stateful --rspec
Run its migration
rake db:migrate
If you are running autotest (which is a good idea), now would be a good time to create your test database as well.
rake db:migrate RAILS_ENV=test
Configuration
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:
Next we need to add an observer to config/environment.rb (look for the section labeled observers).
config.active_record.observers = :user_observer
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:
SITE_URL='localhost:3000'
and likewise in config/environments/production.rb
SITE_URL='myapplication.com'
Modify myapplication.com to reflect the url of your application.
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.
Now we need to update the vendor/models/user_mailer.rb to pick up the SITE_URL change. Any place there is a reference to YOURSITE replace it with #{SITE_URL}.
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)
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.