Backpack Ruby Script

Each week I edit the Rails Envy podcast. We use Backpack to work together on the stories each week. Each story is a note in the Backpack page:

Today while I was preparing the post, I remembered that Backpack had an API. A quick google turned up the Backpack API page with a link to the Ruby wrapper. About 10 minutes and some regular expressions later I had a script to auto format the weekly podcast links each week by just passing in the page id.

require 'rubygems'
require 'XmlSimple'
require 'ruby_wrapper'
 
stories = []
backpack = Backpack.new('username', 'api key');
backpack.page_id='the page you want'
notes = backpack.list_notes
notes = notes['notes'].first['note']
 
# {'title' => 'A note', 'id' => 'An id', 'content' => 'asdf followed by a url'}
notes.each do |note|
  story_link = note['content'].scan(/(http\:\/\/.*)$/m)[0]
  stories.push("<li><a title=\"#{note['title']}\" href=\"#{story_link}\" rel=\"nofollow\">#{note['title']}</a></li>".gsub(/\n/,''))
end
 
puts stories.join("\n")