The Artima Developer Community
Sponsored Link

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

0 replies.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a flat view of this topic  Flat View
Previous Topic   Next Topic
Threaded View: This topic has 0 replies on 1 page
Matt Williams

Posts: 466
Nickname: aetherical
Registered: Feb, 2008

Matt Williams is a jack-of-all trades living in Columbus, OH.
O_RLY? A Ruby/Rails implementation of snowl (Part I) Posted: Aug 12, 2008 11:48 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Matt Williams.
Original Post: O_RLY? A Ruby/Rails implementation of snowl (Part I)
Feed Title: Ramblings
Feed URL: http://feeds.feedburner.com/matthewkwilliams
Feed Description: Musings of Matt Williams
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Matt Williams
Latest Posts From Ramblings

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.
      sudo gem install FeedNormalizer
    • Twitter — For doing twittery things, of course.
      sudo gem install twitter
  3. Plugins next:
    1. I’m using rspec for testing, so I need to do the following to install it for rails:
      script/plugin install git://github.com/dchelimsky/rspec.git
      	  script/plugin install git://github.com/dchelimsky/rspec-rails.git
      	  script/generate rspec
    2. acts_as_state_machine — This is used by Restful Authentication for user creation.
      script/plugin install http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk acts_as_state_machine
    3. Restful Authentication - This allows us to easily work with users.
      script/plugin install git://github.com/technoweenie/restful-authentication.git

      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
  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:
      require File.dirname(__FILE__) + '/lib/authorization'
      require File.dirname(__FILE__) + '/lib/authorization/stateful_roles'

      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
       map.activate '/activate/:activation_code', :controller => 'users', :action => 'activate', :activation_code => nil

      Additionally the resource mapping for users (map.resources :users) needs to be changed to

        map.resources :users, :member => { :suspend   => :put,
                :unsuspend => :put,
                :purge     => :delete }
    3. Next we need to add an observer to config/environment.rb (look for the section labeled observers).
      config.active_record.observers = :user_observer
    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:
      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.

    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.
    6. 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}.
    7. Next create config/initializers/mail.rb and place the following code in it:
      ActionMailer::Base.delivery_method = :smtp
      	  ActionMailer::Base.smtp_settings = {
      	  :address => "mail.example-domain.com",
      	  :port => 25,
      	  :domain => "www.example-domain.com",
      	  :authentication => :login,
      	  :user_name => "user@example-domain.com",
      	  :password => "secret"
      	  }

      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

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


Topic: Structured Warnings Are Here Previous Topic   Next Topic Topic: finder_filter gem released

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use