zeus.ugent.be/lib/helpers/ical.rb

24 lines
513 B
Ruby
Raw Normal View History

2016-07-27 00:13:36 +02:00
module IcalHelper
def event_calendar
cal = Icalendar::Calendar.new
2016-08-23 20:21:02 +02:00
items.find_all('/events/*/*.md').each do |i|
cal.add_event(event_for(i))
end
2016-07-27 00:13:36 +02:00
cal.to_ical
end
2016-08-23 20:21:02 +02:00
def event_for(item)
2017-02-08 17:05:48 +01:00
e = Icalendar::Event.new
e.dtstart = item[:time]
e.dtend = item[:end] if item[:end]
e.summary = item[:title]
e.description = item[:description] + "\n\n" + item.reps[:text].compiled_content
e.location = item[:location]
e.url = @config[:base_url] + item.path
2016-07-27 00:13:36 +02:00
2017-02-08 17:05:48 +01:00
e
2016-07-27 00:13:36 +02:00
end
end