diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 80bb3ae3..5d66af25 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -191,6 +191,29 @@ module EventsHelper end end + def calendar_timestamp(timestamp, timezone) + timestamp = timestamp.in_time_zone('GMT') + timestamp -= timestamp.utc_offset + timestamp.strftime('%Y%m%dT%H%M%S') + end + + def google_calendar_link(event_schedule) + event = event_schedule.event + conference = event.conference + calendar_base = 'https://www.google.com/calendar/render' + start_timestamp = calendar_timestamp(event_schedule.start_time, conference.timezone) + end_timestamp = calendar_timestamp(event_schedule.end_time, conference.timezone) + event_details = { + action: 'TEMPLATE', + text: "#{event.title} at #{conference.title}", + details: "#{conference.title}:\n\n#{event.room&.url}\n\n#{truncate(event.abstract, length: 200)}", + location: "#{event.room.name} #{event.room&.url}", + dates: "#{start_timestamp}/#{end_timestamp}", + ctz: event_schedule.timezone + } + "#{calendar_base}?#{event_details.to_param}" + end + private def active_dropdown(selection, options) diff --git a/app/views/proposals/show.html.haml b/app/views/proposals/show.html.haml index 3ca2aeea..733ed8e5 100644 --- a/app/views/proposals/show.html.haml +++ b/app/views/proposals/show.html.haml @@ -13,7 +13,7 @@ .container .row.page-header - .col-md-10 + .col-md-8 %h2 = @event.title - if @event.subtitle @@ -22,8 +22,12 @@ = @event.subtitle %h3 = join_event_link(@event, current_user) - .col-md-2 + .col-md-4 %p{style: "margin-top: 20px"} + - if @event_schedule.start_time + = link_to google_calendar_link(@event_schedule), target: '_blank', class: 'btn btn-success' do + %i.fa.fa-calendar + Google Calendar - if can?(:update, @event) && @event.require_registration? = link_to 'Registrations', registrations_conference_program_proposal_path(@conference.short_title, @event), class: 'btn btn-mini btn-success' - if can?(:edit, @event) diff --git a/app/views/schedules/_event.html.haml b/app/views/schedules/_event.html.haml index 15702528..112758d7 100644 --- a/app/views/schedules/_event.html.haml +++ b/app/views/schedules/_event.html.haml @@ -27,7 +27,7 @@ -# TODO: More informative text or aria-label. = link_to 'more', conference_program_proposal_path(@conference.short_title, event.id) if event.abstract.length > 400 - if event_schedule.present? - = inyourtz(event_schedule.start_time, @conference.timezone) do + = inyourtz(event_schedule.start_time) do %span.track %span.fa.fa-clock-o %span.label{ style: "background-color: grey" }