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

前端 未结 1 2053
逝去的感伤
逝去的感伤 2020-12-14 04:43

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

相关标签:
1条回答
  • 2020-12-14 04:47

    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
    
    0 讨论(0)
提交回复
热议问题