Skip to content
Snippets Groups Projects
Unverified Commit 242e8229 authored by Arnaud Levy's avatar Arnaud Levy Committed by GitHub
Browse files

Merge pull request #1511 from noesya/ical

Génération de fichiers iCalendar (ics)
parents 7ba80456 43e64d7c
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ ruby "3.1.4"
gem "activestorage-scaleway-service"#, path: "../activestorage-scaleway-service"
gem "active_storage_validations", "~> 1"
gem "add_to_calendar"
gem "angularjs-rails"
gem "aws-sdk-s3"
gem "bootstrap"
......
......@@ -110,6 +110,9 @@ GEM
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
add_to_calendar (0.4.0)
tzinfo (>= 1.1, < 3)
tzinfo-data (~> 1.2020)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
angularjs-rails (1.8.0)
......@@ -580,6 +583,8 @@ GEM
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2023.4)
tzinfo (>= 1.0.0)
unaccent (0.4.0)
unicode-display_width (2.5.0)
unsplash (3.1.1)
......@@ -624,6 +629,7 @@ PLATFORMS
DEPENDENCIES
active_storage_validations (~> 1)
activestorage-scaleway-service
add_to_calendar
angularjs-rails
annotate
aws-sdk-s3
......
......@@ -148,12 +148,49 @@ class Communication::Website::Agenda::Event < ApplicationRecord
"#{Static.remove_trailing_slash website.url}#{Static.clean_path current_permalink_in_website(website).path}"
end
def cal
@cal ||= AddToCalendar::URLs.new(
start_datetime: from_time,
end_datetime: to_time,
timezone: 'Europe/Paris',
title: "#{title} #{subtitle}",
url: url,
description: summary,
all_day: (from_hour.nil? && to_hour.nil?)
)
end
def to_s
"#{title}"
end
protected
def from_time
from_hour.nil? ? from_day.to_time
: date_and_time(from_day, from_hour)
end
def to_time
if to_day.nil? && to_hour.nil?
# Pas de fin
nil
elsif to_day.nil? && to_hour.present?
# Heure de fin sans jour de fin, donc on se base sur le jour de début
date_and_time(from_day, to_hour)
elsif to_day.present? && to_hour.nil?
# Jour de fin seul
to_day.to_time
elsif to_day.present? && to_hour.nil?
# Jour et heure de fin
date_and_time(to_day, to_hour)
end
end
def date_and_time(date, time)
Time.new(date.year, date.month, date.day, time.hour, time.min, time.sec, time.zone)
end
def check_accessibility
accessibility_merge_array blocks
end
......
......@@ -24,4 +24,10 @@ indentation = ' ' * depth
<%= indentation %> day: <%= event.to_day || event.from_day %>
<% if event.to_hour %>
<%= indentation %> hour: <%= event.to_hour.strftime "%H:%M" %>
<% end %>
\ No newline at end of file
<% end %>
<%= indentation %> add_to_calendar:
<%= indentation %> google: "<%= @event.cal.google_url %>"
<%= indentation %> yahoo: "<%= @event.cal.yahoo_url %>"
<%= indentation %> office: "<%= @event.cal.office365_url %>"
<%= indentation %> outlook: "<%= @event.cal.outlook_com_url %>"
<%= indentation %> ical: "<%= @event.cal.ical_url %>"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment