adding something to Ical / Outlook with Rails

984 views
Skip to first unread message

Michael Gerstenblatt

unread,
Dec 24, 2009, 1:57:02 PM12/24/09
to boston-r...@googlegroups.com
Hi All,

Does anyone know if any ruby or javascript solutions exist that will allow me to have a link that will open up Outlook, Ical, etc and add an event (provided by rails) to their calendar?

Thanks and happy holidays,
Mike

Phil Darnowsky

unread,
Dec 28, 2009, 12:14:52 PM12/28/09
to boston-r...@googlegroups.com
Hi Mike,

iCalendar has a defined MIME type (text/calendar), so something like this should work, provided the browser has the right association set for that type:

response.content_type = 'text/calendar'
render :text => @event.to_ical

I don't know of any library that will automatically implement that to_ical method, and I'm far too lazy to look, but the iCalendar format seems like it would be really simple to implement.

--Phil

--- On Thu, 12/24/09, Michael Gerstenblatt <mgerst...@gmail.com> wrote:

> --
>
> You received this message because you are subscribed to the
> Boston Ruby Group mailing list
>
> To post to this group, send email to
> boston-r...@googlegroups.com
>
> To unsubscribe from this group, send email to
> boston-rubygro...@googlegroups.com
>
> For more options, visit this group at http://groups.google.com/group/boston-rubygroup



Pascal Rettig

unread,
Dec 28, 2009, 12:24:48 PM12/28/09
to boston-r...@googlegroups.com
Hi Mike,

There's a icalendar gem (http://icalendar.rubyforge.org/) we used a while back.

We did something like this a couple of years ago for displaying event bookings (RDoc's probably more up to date):

require 'icalendar'

cal = Icalendar::Calendar.new
bookings.each do |booking|
      event = Icalendar::Event.new
      event.start = booking.to_time.strftime("%Y%m%dT%H%M%S")
      event.end = booking.to_end_time.strftime("%Y%m%dT%H%M%S")
      event.summary = booking.recipient_name + " " + booking.time
      cal.add_event(event)
    end

send_data(cal.to_ical,:type => 'text/calendar', :disposition => 'inline; filename=calendar.vcs', :filename => 'calendar.vcs')


-Pascal

-- 
Pascal Rettig
Cykod.com
pas...@cykod.com
Ph# 857-363-0597

Dan Croak

unread,
Dec 28, 2009, 12:47:51 PM12/28/09
to boston-r...@googlegroups.com
It seems to me like there should be a really good microformats gem that handles this.


I should be able to:

sudo gem install microformats

Then, it could be mixed into whatever view layer you're using like:

<%= hCalendar(event) %>
<%= hCard(person) %>
<%= hCard(company) %>
<%= hCard(place) %>

The hCalendar microformat should meet Mike's needs and the others are becoming more handy as browsers implement these two "stable" microformats.

For example, when you use the the "tel" property, mobile Safari on the iPhone turns that into a link that when you click, you can call the number.


Looking on github, the closest that currently exists is:

* mofo, which does microformat *parsing*, not HTML generation
* microformats_helper, which is a Rails plugin (no Sinatra love) and does the hCard but not hCalendar microformat
Dan Croak
@Croaky

Keenan Brock

unread,
Dec 28, 2009, 5:32:53 PM12/28/09
to boston-r...@googlegroups.com
Microformats are all about adding meta data to your markup.

There is no real way the generator could know if you want a paragraph style (with spans) or a block structure (li, p, or div)

It works best for me if I basically ignore the micro format, put in the information in HTML, then add spans/classes/titles accordingly.

--K


Reply all
Reply to author
Forward
0 new messages