Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
634 views
in Technique[技术] by (71.8m points)

export - Does anyone know any gems/plugins/tutorials related to exporting events to iCal, Google Calendar, Outlook from a Rails application?

I am trying to figure out if there is already a plug in that does the interaction with iCal, Google APIs that I can use or do I need to just get my hands dirty and write it myself.

If anyone knows of good resources that I can look at that could help me with the implementation, that would be good as well.

I am new to RoR and I have been trying to learn it for a while. I finally decided to just start playing with my own application rather than just following a book.

Any help in this matter would be appreciated.

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Check out the Google Calendar gem for rails. It lets you display a user's Google Calendar in your rails app and they have sample snippets showing how to export events to Google Calendar:

require 'googlecalendar'
g = GData.new
g.login('REPLACE_WITH_YOUR_MAIL@gmail.com', 'REPLACE_WITH_YOUR_PASSWORD')
event = { :title=>'title',
:content=>'content',
:author=>'pub.cog',
:email=>'pub.cog@gmail.com',
:where=>'Toulouse,France',
:startTime=>'2007-06-06T15:00:00.000Z',
:endTime=>'2007-06-06T17:00:00.000Z'}
g.new_event(event)

For iCal, use the iCalendar gem and then you can export events as follows:

require ‘icalendar’

class EventController < ApplicationController
  def export_events
    @event = Event.find(params[:id])
    @calendar = Icalendar::Calendar.new
    event = Icalendar::Event.new
    event.start = @event.dt_time.strftime(”%Y%m%dT%H%M%S”)
    event.end = @event.dt_time.strftime(”%Y%m%dT%H%M%S”)
    event.summary = @event.summary
    event.description = @event.description
    event.location = @event.location
    @calendar.add event
    @calendar.publish
    headers['Content-Type'] = “text/calendar; charset=UTF-8″
    render_without_layout :text => @calendar.to_ical
  end
end

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...