clarion/app/views/api/events/index.ics.erb

25 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2019-10-28 13:16:43 +02:00
<%
cal = Icalendar::Calendar.new
2019-11-01 04:39:58 +02:00
cal.add_timezone(Time.zone.tzinfo.ical_timezone(Time.now))
2019-10-28 13:16:43 +02:00
@events.each do |event|
2019-11-01 04:39:58 +02:00
next unless event&.slot&.starts_at
2019-10-28 13:16:43 +02:00
2019-11-01 04:39:58 +02:00
cal.event do |ical_event|
ical_event.dtstart = Icalendar::Values::DateTime.new(event.slot.starts_at, 'tzid' => event.slot.starts_at.time_zone.tzinfo.identifier)
ical_event.dtend = Icalendar::Values::DateTime.new(event.slot.ends_at, 'tzid' => event.slot.ends_at.time_zone.tzinfo.identifier)
ical_event.summary = event.title
ical_event.description = event.description
ical_event.created = Icalendar::Values::DateTime.new(event.created_at, 'tzid' => event.created_at.time_zone.tzinfo.identifier)
ical_event.last_modified = Icalendar::Values::DateTime.new(event.updated_at, 'tzid' => event.updated_at.time_zone.tzinfo.identifier)
ical_event.location = event.slot.hall.name
ical_event.alarm do |alarm|
alarm.summary = event.title
alarm.trigger = "-PT15M"
end
2019-10-28 13:16:43 +02:00
end
end
cal.publish
-%>
<%= raw cal.to_ical %>