I use Safari as my primary browser and Google Reader (and Byline) for reading feeds. Subscribing to feeds was painful for me for a long time until I discovered Reader Notifier. Reader Notifier will sit in your status bar and notify you when you have new feed entries to read. You can also set it as your Default RSS reader in Safari and it will redirect you to Google Reader when you click the RSS button. This felt like overkill to me. My status bar is sacred, and I don’t need to be notified throughout the day about new feed entries. What I needed was a HotCocoa application that just did the bare minimum. Enter SafariRSS.
The Competition
Halfway through coding this app I was googling for some info on NSAppleEventManager and came across a remarkably similar project called Reader Helper. This is a good example of one of the benefits of using MacRuby & HotCocoa, with SafariRSS weighing in at around 25% of Reader Helper in terms of lines of code. On the flip side Reader Helper weighs in at less than 1% of the download size of SafariRSS if we bundle MacRuby with the application. Anyway I’m glad this project existed, as I was able to translate some of the code into MacRuby very easily.
Usage
Download SafariRSS and then go into Preferences in Safari and select it as the Default RSS reader:

Go to an awesome website and click on the RSS button on the right hand side of the Address Bar:

Wait a few seconds and you will be redirected to Google Reader with the option of subscribing to the feed in question:

Changing the redirect to another URL or launching another application should be a trivial exercise, here is the entire app:
begin
require 'hotcocoa'
rescue LoadError
require 'rubygems'
require 'hotcocoa'
end
class Application
include HotCocoa
def start
application :name => "SafariRSS" do |app|
eventManager = NSAppleEventManager.sharedAppleEventManager
gurl = 'GURL'.unpack('N').first
eventManager.setEventHandler self, andSelector:"getURL:reply:", forEventClass:gurl , andEventID:gurl
end
end
def getURL(event, reply:reply)
url = event.paramDescriptorForKeyword('----'.unpack('N').first).stringValue.gsub('feed://', 'http://')
NSWorkspace.sharedWorkspace.openURL NSURL.URLWithString("http://www.google.com/reader/view/feed/#{url}")
NSApplication.sharedApplication.terminate nil
end
end
Application.new.start
I’m not totally happy with how long it takes to launch the app and redirect to the URL, but all the apps I tried seem to take a similar length of time so I don’t think its an issue with MacRuby. Any ideas on how to speed it up would be much appreciated.
Checkout the source on GitHub and let me know what you think. I have only tested this app on MacRuby 0.5 but it will probably work on 0.6 also. As usual you can find a version with MacRuby bundled in the downloads section of the GitHub repo. I tried to make embedding MacRuby a little easier with this app, but I’ll go into the details of that in a future post.