Ocsigen (OCaml Web Server + Framework) module to display a Google Calendar iframe.
- Ocsigen version 2.1 minimum
- An account on Google Calendar
- At lead one calendar to display :)
Just test it
- Install it by launching the script
./install.shIt will install the required external modules and generate a configuration file for you.
- Move to the example directory:
- Compile the example using
- Launch the website using
ocsigenserver -c example.conf
- Open the website in your browser
How to display a calendar on my website?
- Install the module by launching the script
./install.shIt will install external modules.
You will need these files to add GCal to your website:
Copy them (and their interfaces
.eliomi) in your website source code directory.
Edit your Makefile to compile them on server side.
- Edit your configuration file to add the two news
.cmoyou will have to insert:
<eliom module="/real/path/to/your/sources/folder/_server/tools.cmo" /> <eliom module="/real/path/to/your/sources/folder/_server/gCal.eliom" />
- Don't forget to edit these lines with your own paths!
Find my calendar ID
You will need your calendar ID to display it.
- Go to the Google Calendar home page and log in: http://google.com/calendar
- In the calendar list on the left side of the page, click the down-arrow button next to the appropriate calendar, then select Calendar settings.
- Have a look at the Calendar Address section. Your ID is the e-mail address displayed after Calendar ID:.
Make my calendar public
If you want your calendar to be seen by anybody who visit your website, you must make it public.
- In the calendar list on the left, click on the down-arrow button next to the appropriate calendar, then select Share this calendar.
- Select Make this calendar public.
- If you don't want others to view the details of your events, select See only free/busy (hide details).
- Click Save.
Add it to my website code
calendar take in parameter the calendars you want to display and
some extra optional parameters that allow you to customize the display. It returns
iframe element that can be added on your website, anywhere that its
possible to add an
iframe element :)
GCal.calendar [("firstname.lastname@example.org", GCal.Blue)];
The parameter is a list of pair containing:
- calendar ID
List of available colors is in the
You can't use custom colors that are not in this list.
Display/Hide some informations
You can chose to display or hide some informations:
By default, these informations are displayed (
GCal.calendar ~show_title:false calendars
The calendar can be displayed in 3 formats:
The default value is
Example of agenda:
GCal.calendar ~display_mode:GCal.Agenda calendars
Size of the calendar
The default size of the calendar is 600px x 800 px.
You can change these values using optional parameters
heightmust be a size in pixels
widthcan be a size in pixels (
Pixels) or in percentage (
GCal.calendar ~width:(GCal.Pixels 300) ~height:200 calendars
Week start on Sunday?
You can chose on which day the week start:
GCal.calendar ~week_start_on:GCal.Monday calendars
The default timezone is the one that is configured by the calendar itself.
You can chose to display the calendar with an other timezone.
The parameter is an optional value,
None will ask Google Calendar for the default value.
GCal.calendar ~timezone:(Some "Africa/Djibouti") calendars
The list of available timezone is the value
To display them all:
List.iter print_endline GCal.timezones
The language of the calendar can be change using standad languages acronyms.
GCal.calendar ~lang:(Some "fr") calendars
The background color of the calendar can be change to fit your website.
The parameter is the hexadecimal string representation of the color, starting with a
GCal.calendar ~background_color:"#668CD9" calendars
I can see my calendar events, but nobody else can see them!
Don't forget to make your calendar public.
Unbound module GCal
In OCaml and Ocsigen, file order is important. So, in your Makefile and in your configuration file, don't forget to put tools before gCal, and gCal before the file which is calling gCal functions!
Unbound module Gcal
The name of the module is
What is Ocsigen and why should I use it for my website?
Ocsigen is a powerful web server and framework written in OCaml.
Ocsigen makes it possible to write Web applications, client and server side, using OCaml, very expressive and safe programming language.
- Same language and libraries for client and server parts
- No need to encode data before sending it
- Use server-side values in your client code!
- Call server-side functions from the browser!
- Handle server-to-client communications transparently!
- Keep your client side program running when you change page!
More information: Official Website
Copyright 2012 Barbara Lepage Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Up to date
Latest version of this project is on GitHub: