WWDC 2008 is coming up next month! The sessions sound very interesting and it will be difficult to choose. The Apple website with the session info is great, but since the whole thing is "ajaxified" some browsers have trouble printing the session schedule. And yes: I am one of those guys who wants a printed page to scribble on. I need that. To think and to doodle and to eventually circle or mark the sessions I'm going to attend. So I looked at the source for the session page and found the XML with the session info and a JavaScript file with some more info. The next step was just to simply make a PDF file from this. With Ruby, that's quite easy. This is what I came up with:
#!/usr/bin/env ruby # WWDC 2008 Session PDF Generator, 2008 by Johannes Fahrenkrug. # No licence, do with it what you want # http://springenwerk.com require 'rexml/document' require 'open-uri' require 'FPDF' require 'fpdf/table' class FPDF include Fpdf::Table end TRACKS = { 16 => 'iPhone', 15 => 'Mac', 17 => 'IT' } CATEGORIES = { 33 => 'Essentials', 37 => 'Getting Started', 34 => 'Integration', 35 => 'Media', 36 => 'Tools' } TYPES = { 33 => 'Lab', 31 => 'Session' } puts 'WWDC 2008 Session PDF Generator by Johannes Fahrenkrug' print 'Getting sessions.xml file...' file = open('http://developer.apple.com/wwdc/data/sessions.xml') if file puts 'OK' print 'Parsing XML...' xml = REXML::Document.new(file) if xml puts 'OK' print 'Generating PDF...' data = [] xml.elements.each("//item") do |c| line = [] linestr = c.attributes['name'] + " (#{c.attributes['id']})\n" c.elements.each do |sub_element| #You just have to download it here, unzip it and run the program. That's it: You'll have a great ugly text PDF waiting to be printed. This is a very limited tool, I know, so please feel free to enhance it!if sub_element.name == 'theme' themes = '' if sub_element.text sub_element.text.split(',').each do |theme| begin themes += TRACKS[theme.to_i] + ' ' rescue # unknown track end end end linestr += "Tracks: #{themes}\n" if themes.size > 0 end #
Comments
Anonymous said...
Um... It didn't work for me...
But I moved it out of the downloaded folder and into
~ and it worked fine THERE
Johannes Fahrenkrug said...
Thanks, guys! I just fixed it. Note to self: double check download links next time ;-)
May 13, 2008 11:37 AMAnonymous said...
Hi, the download link isn't working at the moment
May 13, 2008 11:35 AMThe boy Ken said...
Hi, the download link isn't working
May 13, 2008 11:32 AM
luigi193 said...
It didn't work for me...
May 16, 2008 07:01 PMBut it DID work when i put it in ~ weird.