├── LICENSE ├── README └── ical2gcal.rb /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 David Verhasselt (david@crowdway.com) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | iCal2GCal 2 | ========= 3 | 4 | Takes a .ics file and adds the events to the Google Calendar. Excellent to tie 5 | to .ics files for easy-clicking in browsers on .ics links. 6 | 7 | Installation 8 | ------------ 9 | You need ruby 1.8, the "googlecalendar" gem, and the ruby-gnome2 devkit. In 10 | Ubuntu you can do: 11 | 12 | $ sudo gem install googlecalendar 13 | $ sudo apt-get install ruby-gnome2 14 | 15 | Configuration 16 | ------------- 17 | 18 | There's only one file, ical2gcal.rb. Set the USERNAME, and PASSWORD to the 19 | correct values. Optionally you can select one of your calendars and set 20 | DEFAULT_CAL to it's title. This calendar will then be selected by default, 21 | but you'll always be asked to confirm the addition for safety reasons. 22 | 23 | Usage 24 | ----- 25 | 26 | Execute ical2gcal.rb with a .ics file as a paramater: 27 | 28 | $ ./ical2gcal.rb event.ics 29 | 30 | A window will appear asking you to select the calendar you wish to add this 31 | event or these events to and to confirm the addition. 32 | 33 | Best results are obtained when you configure your browser to open .ics files 34 | with ical2gcal. You can then click on .ics links to add them to Google Calendar 35 | directly, without having to save and manually import them. 36 | 37 | License 38 | ------- 39 | 40 | iCal2GCal is Copyright (C) 2009 David Verhasselt (david@crowdway.com) and 41 | licensed under the MIT License (see file LICENSE). 42 | -------------------------------------------------------------------------------- /ical2gcal.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # 3 | # Takes a .ics file as parameter, adds it to Google Calendar 4 | # 5 | # Change USERNAME and PASSWORD to your username and password, respectively, 6 | # set DEFAULT_CAL to define the calendar selected by default (you'll still 7 | # get the option to choose one). 8 | # 9 | # (C) 2009 David Verhasselt (david@crowdway.com) 10 | # 11 | # Licensed under MIT License, see included file LICENSE 12 | 13 | USERNAME = "user" 14 | PASSWORD = "password" 15 | DEFAULT_CAL = "" 16 | 17 | require 'gtk2' 18 | require 'rubygems' 19 | require 'googlecalendar' 20 | 21 | # Make "calendars" accessible 22 | class Googlecalendar::GData 23 | attr_reader :calendars 24 | end 25 | 26 | if ARGV.length < 1 27 | puts "Need at least 1 .ics file" 28 | exit 29 | end 30 | 31 | # Parse the iCal file 32 | iCal = parse(IO.read(ARGV[0])); 33 | 34 | if iCal.events.length < 1 35 | puts ".ics file doesn't contain any events" 36 | exit 37 | end 38 | 39 | g = Googlecalendar::GData.new; 40 | g.login(USERNAME, PASSWORD); 41 | g.get_calendars(); 42 | 43 | cals = g.calendars.map { |item| item.title } 44 | 45 | # Create GUI 46 | window = Gtk::Window.new 47 | window.title = "Add iCal" 48 | window.border_width = 5 49 | 50 | vBoxMain = Gtk::VBox.new(false, 5) 51 | window.add(vBoxMain) 52 | 53 | descriptionTable = Gtk::Table.new(5, 2, false) 54 | descriptionTable.set_row_spacings(5) 55 | descriptionTable.set_row_spacing(0, 10) 56 | vBoxMain.pack_start(descriptionTable) 57 | 58 | label = Gtk::Label.new; 59 | label.set_markup("Add iCal to Google Calendar") 60 | descriptionTable.attach(label, 0, 2, 0, 1) 61 | 62 | if iCal.events.length > 1 63 | label = Gtk::Label.new("Events found:") 64 | descriptionTable.attach(label, 0, 1, 1, 2) 65 | 66 | label = Gtk::Label.new(iCal.events.length.to_s) 67 | descriptionTable.attach(label, 1, 2, 1, 2) 68 | end 69 | 70 | label = Gtk::Label.new("Event:") 71 | descriptionTable.attach(label, 0, 1, 2, 3) 72 | 73 | label = Gtk::Label.new(iCal.events[0].summary) 74 | descriptionTable.attach(label, 1, 2, 2, 3) 75 | 76 | label = Gtk::Label.new("Date:") 77 | descriptionTable.attach(label, 0, 1, 3, 4) 78 | 79 | label = Gtk::Label.new(iCal.events[0].start_date.to_s) 80 | descriptionTable.attach(label, 1, 2, 3, 4) 81 | 82 | 83 | separator = Gtk::HSeparator.new() 84 | descriptionTable.attach(separator, 0, 2, 4, 5) 85 | 86 | controlBox = Gtk::HBox.new(false, 0) 87 | vBoxMain.pack_end(controlBox, true, true, 0) 88 | 89 | calSelector = Gtk::ComboBox.new(true) 90 | cals.each { |title| calSelector.append_text(title) } 91 | calSelector.active = cals.index(DEFAULT_CAL) || 0 92 | controlBox.pack_start(calSelector, true, true, 0) 93 | 94 | window.signal_connect("delete_event") do 95 | Gtk.main_quit 96 | false 97 | end 98 | 99 | buttonAdd = Gtk::Button.new("Add event") 100 | buttonAdd.signal_connect("clicked") do 101 | iCal.events.each do |event| 102 | eventHash = {} 103 | eventHash[:title] = event.summary 104 | eventHash[:content] = event.description 105 | eventHash[:where] = event.location 106 | eventHash[:startTime] = event.start_date 107 | eventHash[:endTime] = event.end_date 108 | eventHash[:author] = "iCal2GCal" 109 | eventHash[:email] = "iCal2GCal" 110 | 111 | g.new_event(eventHash, calSelector.active_text) 112 | 113 | end 114 | 115 | Gtk.main_quit 116 | false 117 | end 118 | controlBox.pack_start(buttonAdd, true, true, 0) 119 | window.show_all 120 | Gtk.main 121 | --------------------------------------------------------------------------------