Google Calendaer Link

This commit is contained in:
Michael Ball 2020-07-31 15:09:19 -07:00
parent 2417bad4db
commit 29cea21c84
3 changed files with 30 additions and 3 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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" }