class TestController {
def index = {
render(contentType: 'text/calendar', filename: '<optional filename>') {
calendar {
events {
event(start: Date.parse('dd.MM.yyyy HH:mm', '31.10.2009 14:00'),
end: Date.parse('dd.MM.yyyy HH:mm', '31.10.2009 15:00'),
description: 'Events description',
summary: 'Short info1') {
organizer(name: 'Silvio Wangler', email: '[email protected]')
}
event(start: Date.parse('dd.MM.yyyy HH:mm', '01.11.2009 14:00'),
end: Date.parse('dd.MM.yyyy HH:mm', '01.11.2009 15:00'),
description: 'hell yes',
summary: 'Short info2',
location: '@home',
classification: 'private'){
organizer(name: 'Silvio Wangler', email: '[email protected]')
}
}
}
}
}
}
This plugin uses the ical4j API and is therefore iCal RFC compliant. The output has been tested against the Google calendar importer, Microsoft Outlook and Mozilla Sunbird.
The plugin is at the current stage of development limited to events only. That means that you currently can only export VEVENTS
.
This documentation does not claim to cover all the features that are implemented in the iCalendar plugin. But there is a Unit Test Suite that covers the feature set of this plugin and therefore a very good entry point if you are looking for an overview.
If you do not want to have this feature injected into every controller you can specify which controllers to be excluded in Config.groovy
grails.plugins.ical.controllers.exclude = ['excludedTest']
This Configuration parameter has to be a list of controller names!
render(contentType: 'text/calendar') {
calendar {
events {
event(start: new Date(), end: (new Date()).next(), summary: 'We need to talk') {
organizer(name:"Peter O'Brien", email:'[email protected]')
reminder(minutesBefore: 5, description: 'Your meeting starts in 5 minutes!')
attendees {
attendee(email:'[email protected]', role: REQ_PARTICIPANT, partstat: NEEDS_ACTION, cutype: INDIVIDUAL, rsvp: TRUE)
attendee(email:'[email protected]', role: REQ_PARTICIPANT, partstat: NEEDS_ACTION, cutype: INDIVIDUAL, rsvp: FALSE)
}
}
}
}
}
Since version 0.4.0
the plugin supports UTC dates. Each event accepts an optional parameter called utc
. If the parameter is missing
UTC is set to false
.
render(contentType: 'text/calendar') {
calendar {
events {
event(
start: new Date(),
end: new Date(),
description: 'Some large text',
summary: 'Project stand up meeting',
utc: true // optional parameter (default = false)
)
}
}
}
Version 0.4.1
introduces DSL support for all day events. You can use a String by defining a date like 12.10.2014
.
calendar {
events {
allDayEvent(date: '12.04.2013', summary: 'Text') {
organizer(name: 'Silvio', email: '[email protected]')
reminder(minutesBefore: 5, description: 'Alarm 123')
}
}
}
Currently there is a limitation that the date format has to be DD.MM.YYYY
. The fix of this limitation will be address in a future release.
Another way is to simply provide a Date instance
calendar {
events {
allDayEvent(date: new java.util.Date(), summary: 'Text') {
organizer(name: 'Silvio', email: '[email protected]')
reminder(minutesBefore: 5, description: 'Alarm 123')
}
}
}