The new ical generators

This commit is contained in:
echarp 2018-07-14 00:50:13 +02:00
parent 32a5eb605b
commit c1546d9684
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,20 @@
:ruby
domain = root_url.gsub(/www/, '').gsub(/http.?:../, '').gsub(/:.*/, '')
# Create a calendar with an event (standard method)
cal = Icalendar::Calendar.new
@events.each do |event|
cal.event do |e|
e.dtstamp = Icalendar::Values::DateTime.new event.decision_time
e.uid = "#{event.id}@#{domain}"
e.dtstart = Icalendar::Values::DateTime.new event.start_time
e.dtend = Icalendar::Values::DateTime.new event.end_time
e.summary = event.title
e.description = event.description.tr '\'', ''
e.location = event.full_address.tr '\'', ''
end
end
cal.publish
= cal.to_ical

View File

@ -0,0 +1,14 @@
:ruby
# Create a calendar with an event (standard method)
cal = Icalendar::Calendar.new
cal.event do |e|
e.dtstart = Icalendar::Values::DateTime.new @event.start_time
e.dtend = Icalendar::Values::DateTime.new @event.end_time
e.summary = @event.title
e.description = strip_tags(@event.description).tr '\'', ''
e.location = @event.full_address
end
cal.publish
= cal.to_ical