diff --git a/app/views/api/events/index.ics.erb b/app/views/api/events/index.ics.erb new file mode 100644 index 0000000..21e38f8 --- /dev/null +++ b/app/views/api/events/index.ics.erb @@ -0,0 +1,24 @@ +<% +cal = Icalendar::Calendar.new + +@events.each do |event| + next unless event&.slot&.starts_at + + cal.event do |ical_event| + ical_event.dtstart = event.slot.starts_at + ical_event.dtend = event.slot.ends_at + ical_event.summary = event.title + ical_event.description = event.description + ical_event.created = event.created_at + ical_event.last_modified = event.updated_at + ical_event.location = event.slot.hall.name + ical_event.url = "https://www.openfest.org/2019/bg/full-schedule-bg/#lecture-#{event.id}" + ical_event.alarm do |alarm| + alarm.summary = event.title + alarm.trigger = "-PT15M" + end + end +end +cal.publish +-%> +<%= raw cal.to_ical %> diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index f4c73f9..2f924a9 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -4,3 +4,4 @@ # Mime::Type.register "text/richtext", :rtf Mime::Type.register "image/svg+xml", :svg +Mime::Type.register "text/calendar", :ics