Created
January 10, 2012 20:44
-
-
Save skord/1591075 to your computer and use it in GitHub Desktop.
parses eve's calendar export, converts to iCal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # I'd have added a little memcached thing I did and made it so | |
| # anyone can use it, but well, they love to lock people out after | |
| # a few api accesses. Varnish cache anyone? | |
| require 'sinatra' | |
| require 'nokogiri' | |
| require 'ri_cal' | |
| get '/calendar' do | |
| "#{api_calendar}" | |
| end | |
| def api_calendar | |
| f = File.open('UpcomingCalendarEvents.xml') | |
| doc = Nokogiri::XML(f) | |
| f.close | |
| happenings = doc.xpath('/eveapi/result/rowset/row') | |
| RiCal.Calendar do | |
| happenings.each do |happening| | |
| event do |event| | |
| event.description happening['eventTitle'] | |
| event.dtstart = DateTime.parse(happening['eventDate'] + 'Z') | |
| event.dtend = DateTime.parse(happening['eventDate'] + 'Z') + happening['duration'].to_i | |
| event.add_attendee happening['ownerID'] | |
| event.add_comment happening['eventText'] | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment