Skip to content

Instantly share code, notes, and snippets.

@hoffmanc
Last active December 20, 2015 15:09
Show Gist options
  • Select an option

  • Save hoffmanc/6152405 to your computer and use it in GitHub Desktop.

Select an option

Save hoffmanc/6152405 to your computer and use it in GitHub Desktop.

Revisions

  1. hoffmanc revised this gist Aug 5, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions index.ics.rb
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,8 @@
    @appointments.each_with_index do |appt, idx|
    out << <<CAL
    BEGIN:VEVENT
    DTSTART;VALUE=#{l(appt.starts_at, format: :ical)}
    DTEND;VALUE=#{l(appt.ends_at, format: :ical)}
    DTSTART:#{l(appt.starts_at, format: :ical)}
    DTEND:#{l(appt.ends_at, format: :ical)}
    DTSTAMP:#{l(Time.now, format: :ical)}
    UID:appointment#{appt.id}@#{request.host}
    CREATED:#{l(appt.created_at, format: :ical)}
  2. hoffmanc revised this gist Aug 4, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion en.yml
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,4 @@
    en:
    time:
    formats:
    ical: "%Y%m%dT%H%MZ"
    ical: "%Y%m%dT%H%M%SZ"
  3. hoffmanc revised this gist Aug 4, 2013. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions en.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # locales/en.yml
    en:
    time:
    formats:
    ical: "%Y%m%dT%H%MZ"
  4. hoffmanc created this gist Aug 4, 2013.
    3 changes: 3 additions & 0 deletions ics.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    # config/initializers/ics.rb
    ActionView::Template.register_template_handler(:rb, :source.to_proc)
    Mime::Type.register_alias "text/calendar", :ics
    27 changes: 27 additions & 0 deletions index.ics.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    out = <<CAL
    BEGIN:VCALENDAR
    PRODID:-//I CAN HAZ COMPANY?//EN
    VERSION:2.0
    CALSCALE:GREGORIAN
    METHOD:PUBLISH
    CAL

    @appointments.each_with_index do |appt, idx|
    out << <<CAL
    BEGIN:VEVENT
    DTSTART;VALUE=#{l(appt.starts_at, format: :ical)}
    DTEND;VALUE=#{l(appt.ends_at, format: :ical)}
    DTSTAMP:#{l(Time.now, format: :ical)}
    UID:appointment#{appt.id}@#{request.host}
    CREATED:#{l(appt.created_at, format: :ical)}
    DESCRIPTION:#{appt.reason}
    LAST-MODIFIED:#{l(appt.updated_at, format: :ical)}
    LOCATION:
    SEQUENCE:#{idx}
    STATUS:#{appt.status_ical}
    SUMMARY:#{appt.reason}
    END:VEVENT
    CAL
    end

    out << "END:VCALENDAR"
    7 changes: 7 additions & 0 deletions some_controller.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #...

    def index
    format.ics
    end

    #...