One of the great features of Google Calendar is the ability to embed a calendar view into any webpage using the <iframe> tag. Google makes this especially simple by providing a great tool that allows you to choose formatting options, which calendar you want to display, color, etc. This is great, however it only generates the static tag, and there is no easy way to dynamically produce the correct <iframe> tag.
With the latest release of GCal4Ruby, I’ve included three helper methods for producing a dynamically generated <iframe> tag on demand. This is great for AJAX applications where you want to create your own user interface for the calendar, say to select different calendars to show in one combined calendar view. GCal4Ruby makes this impressively easy:
service = Service.new()
service.authenticate('account', 'password')
cal = service.calendars.first
cal.to_iframe
Which outputs the following<iframe> tag:
<iframe src='http://www.google.com/calendar/embed?&height=600&bgcolor=%23FFFFFF&width=600&color=%232952A3&src=iowacity1%40seabourneconsulting.com&' style='0 px solid;' width='600' height='600' frameborder='0' scrolling='no'></iframe>
You also have the ability to specify all the standard formatting features using GCal4Ruby. The following code produces a calendar with no navigation controls in the agenda view:
cal.to_iframe({:showTitle => false,
:showNav => false,
:showPrint => false,
:showTabs => false,
:showCalendars => false,
:showTimezone => false,
:viewMode => 'AGENDA'})
You can also include multiple calendars in one embedded view by using the Service#to_iframe method. You can display all calendars in the service using the :all token, or you can pass an array of calendar ids:
cals = ['calendarid@gmail.com', '23209384lkjdf9lakdjd@gmail.com']
service.to_iframe(cals)
You can use the same options to choose which calendar elements to display.
Lastly, if you already know the calendar id, and don’t want to authenticate, you can use the to_iframe class method, which looks like this:
Calendar.to_iframe('calendar_id@gmail.com')
Using the class method means you don’t have to authenticate the service and create the calendar instance, which reduces latency by bypassing all communications with the Google Calendar API, as long as you know the Calendar ID ahead of time.
For more information, and all the options you can pass, check out the documentation.
s, but I’ve wanted to create my own library that includes the functionality I’ve had to monkey patch into others’. So, I’ve gone ahead and created
to CPAN or PEAR, the Gem infrastructure allows users to download additional libraries from a central online repository and install it locally. All you need to do is start a project at
app with Google Calendar so that the milestone information would be available to anyone who wanted to subscribe to it. I looked around and found a couple of google calendar integration libraries, but suprisingly there isn’t a fully implemented GData API that allow access to all the features of the Google Calendar API.