add_to_calendar 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -5
- data/lib/add_to_calendar.rb +16 -11
- data/lib/add_to_calendar/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aff21a2c3fa1774cf66361fd8ee0c622f0ccf2fd49fb3e72076ef59bff25395
|
4
|
+
data.tar.gz: 857af7085fca3048223d84164c186c812f7d8f1dff1924653c42c5a74ef2988b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 616a8be90a3e717363a103aae6a5a49df1b7989cb7df701585fc203a90e4be6032644b53436b5c82dd26106ed8d94519a3dd4a63c5640fd8c766eae1f8418305
|
7
|
+
data.tar.gz: 0f1bef8067ff2aab99807c8aa02a7d3234be487328ab1a1cef0495ade1830c5f4f722c61b08fc9635fe3d9fa277e621875f68381f9c03a9c3a53ebb67c50ec67
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -50,14 +50,14 @@ Or install it yourself as:
|
|
50
50
|
|
51
51
|
# ical provides a data-uri which will download a properly formatted *.ics file (see 'Creating HTML links' section)
|
52
52
|
@cal.ical_url
|
53
|
-
#=> "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT%0ADTSTART
|
53
|
+
#=> "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT%0ADTSTART:20201212T133000Z%0ADTEND:20201212T143000Z%0ASUMMARY:Christmas%20party%21%0AUID:-20201212T133000Z-Christmas%20party%21%0AEND:VEVENT%0AEND:VCALENDAR"
|
54
54
|
|
55
55
|
# apple_url and outlook_url are simply helper methods that call ical_url
|
56
56
|
@cal.apple_url
|
57
|
-
#=> "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT%0ADTSTART
|
57
|
+
#=> "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT%0ADTSTART:20201212T133000Z%0ADTEND:20201212T143000Z%0ASUMMARY:Christmas%20party%21%0AUID:-20201212T133000Z-Christmas%20party%21%0AEND:VEVENT%0AEND:VCALENDAR"
|
58
58
|
|
59
59
|
@cal.outlook_url
|
60
|
-
#=> "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT%0ADTSTART
|
60
|
+
#=> "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT%0ADTSTART:20201212T133000Z%0ADTEND:20201212T143000Z%0ASUMMARY:Christmas%20party%21%0AUID:-20201212T133000Z-Christmas%20party%21%0AEND:VEVENT%0AEND:VCALENDAR"
|
61
61
|
```
|
62
62
|
|
63
63
|
### Creating HTML links
|
@@ -104,11 +104,12 @@ cal = AddToCalendar::URLs.new(event_attributes)
|
|
104
104
|
|
105
105
|
- Offset values eg. "2020-05-13 15:31:00 **+05:00**" are ignored. It is only important that you have the correct date and time numbers set. The timezone is set directly using its own attribute `timezone`.
|
106
106
|
- You must set a timezone so that when users add the event to their calendar it shows at their correct local time.
|
107
|
-
- Eg. London event @ `2020-05-13 13:30:00` will save in a New
|
107
|
+
- Eg. London event @ `2020-05-13 13:30:00` will save in a New Yorker's calendar as local time `2020-05-13 17:30:00`
|
108
108
|
|
109
109
|
### Browser support
|
110
110
|
|
111
|
-
- IE11 and lower will not work for `ical_url`, `apple_url` and `outlook_url` (IE does not properly support [data-uri links](https://caniuse.com/#feat=datauri). See [#16](https://github.com/jaredlt/add_to_calendar/issues/16)).
|
111
|
+
- IE11 and lower will not work for `ical_url`, `apple_url` and `outlook_url` (IE does not properly support [data-uri links](https://caniuse.com/#feat=datauri). See [#16](https://github.com/jaredlt/add_to_calendar/issues/16)).
|
112
|
+
- IE11 will also not work with `Yahoo`, but this is because Yahoo only offers a simplified interface for IE11 which does not work with the add event URL.
|
112
113
|
|
113
114
|
### More details
|
114
115
|
|
data/lib/add_to_calendar.rb
CHANGED
@@ -95,8 +95,8 @@ module AddToCalendar
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def ical_url
|
98
|
-
# Downloads a *.ics file provided as a data
|
99
|
-
# Eg. data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT%0ADTSTART
|
98
|
+
# Downloads a *.ics file provided as a data-uri
|
99
|
+
# Eg. "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT%0ADTSTART:20200512T123000Z%0ADTEND:20200512T160000Z%0ASUMMARY:Holly%27s%208th%20Birthday%21%0AURL:https%3A%2F%2Fwww.example.com%2Fevent-details%0ADESCRIPTION:Come%20join%20us%20for%20lots%20of%20fun%20%26%20cake%21\\n\\nhttps%3A%2F%2Fwww.example.com%2Fevent-details%0ALOCATION:Flat%204%5C%2C%20The%20Edge%5C%2C%2038%20Smith-Dorrien%20St%5C%2C%20London%5C%2C%20N1%207GU%0AUID:-https%3A%2F%2Fwww.example.com%2Fevent-details%0AEND:VEVENT%0AEND:VCALENDAR"
|
100
100
|
calendar_url = "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT"
|
101
101
|
params = {}
|
102
102
|
params[:DTSTART] = utc_datetime(start_datetime)
|
@@ -105,9 +105,9 @@ module AddToCalendar
|
|
105
105
|
else
|
106
106
|
params[:DTEND] = utc_datetime(start_datetime + 60*60) # 1 hour later
|
107
107
|
end
|
108
|
-
params[:SUMMARY] =
|
108
|
+
params[:SUMMARY] = url_encode_ical(title)
|
109
109
|
params[:URL] = url_encode(url) if url
|
110
|
-
params[:DESCRIPTION] =
|
110
|
+
params[:DESCRIPTION] = url_encode_ical(description) if description
|
111
111
|
if add_url_to_description && url
|
112
112
|
if params[:DESCRIPTION]
|
113
113
|
params[:DESCRIPTION] << "\\n\\n#{url_encode(url)}"
|
@@ -115,9 +115,9 @@ module AddToCalendar
|
|
115
115
|
params[:DESCRIPTION] = url_encode(url)
|
116
116
|
end
|
117
117
|
end
|
118
|
-
params[:LOCATION] =
|
118
|
+
params[:LOCATION] = url_encode_ical(location) if location
|
119
119
|
params[:UID] = "-#{url_encode(url)}" if url
|
120
|
-
params[:UID] = "-#{utc_datetime(start_datetime)}-#{
|
120
|
+
params[:UID] = "-#{utc_datetime(start_datetime)}-#{url_encode_ical(title)}" unless params[:UID] # set uid based on starttime and title only if url is unavailable
|
121
121
|
|
122
122
|
new_line = "%0A"
|
123
123
|
params.each do |key, value|
|
@@ -239,12 +239,17 @@ module AddToCalendar
|
|
239
239
|
string.gsub(/(?:\n\r?|\r\n?)/, '<br>')
|
240
240
|
end
|
241
241
|
|
242
|
-
def
|
243
|
-
|
244
|
-
|
245
|
-
|
242
|
+
def url_encode_ical(string)
|
243
|
+
# per https://tools.ietf.org/html/rfc5545#section-3.3.11
|
244
|
+
string.gsub!("\\", "\\\\\\") # \ >> \\ --yes, really: https://stackoverflow.com/questions/6209480/how-to-replace-backslash-with-double-backslash
|
245
|
+
string.gsub!(",", "\\,")
|
246
|
+
string.gsub!(";", "\\;")
|
247
|
+
string.gsub!("\r\n", "\n") # so can handle all newlines the same
|
248
|
+
string.split("\n").map { |e|
|
249
|
+
if e.empty?
|
250
|
+
e
|
246
251
|
else
|
247
|
-
url_encode(e)
|
252
|
+
url_encode(e)
|
248
253
|
end
|
249
254
|
}.join("\\n")
|
250
255
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: add_to_calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Turner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|