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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 735242b817fc47985c9ba42dac9623eae14ca6a9b92ef51097321a562a520b63
4
- data.tar.gz: 0b3b95d809779120ce76ad1748f431980566422385c3e817183c3b195828487b
3
+ metadata.gz: 8aff21a2c3fa1774cf66361fd8ee0c622f0ccf2fd49fb3e72076ef59bff25395
4
+ data.tar.gz: 857af7085fca3048223d84164c186c812f7d8f1dff1924653c42c5a74ef2988b
5
5
  SHA512:
6
- metadata.gz: 73ca22730936819071d80504c54a471b18cd17b6f8b0b1f4a35c79758ca7e1762b53c9d8b57637c6f2f7fc2552b5097e7a7bce6984aba849b3e3f286c3774bc4
7
- data.tar.gz: c73793ded24a174c81ee7411a16b8e3a09e426ec208b388a9f905f6aa6457d57b8880c9df99650965ff0ce2c4deca254d6920543af95ab25075e5bc18dbce573
6
+ metadata.gz: 616a8be90a3e717363a103aae6a5a49df1b7989cb7df701585fc203a90e4be6032644b53436b5c82dd26106ed8d94519a3dd4a63c5640fd8c766eae1f8418305
7
+ data.tar.gz: 0f1bef8067ff2aab99807c8aa02a7d3234be487328ab1a1cef0495ade1830c5f4f722c61b08fc9635fe3d9fa277e621875f68381f9c03a9c3a53ebb67c50ec67
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- add_to_calendar (0.2.2)
4
+ add_to_calendar (0.2.3)
5
5
  tzinfo (>= 1.1, < 3)
6
6
  tzinfo-data (~> 1.2020)
7
7
 
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=20201212T133000Z%0ADTEND=20201212T143000Z%0ASUMMARY=Christmas%20party%21%0AUID=-20201212T133000Z-Christmas%20party%21%0AEND:VEVENT%0AEND:VCALENDAR"
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=20201212T133000Z%0ADTEND=20201212T143000Z%0ASUMMARY=Christmas%20party%21%0AUID=-20201212T133000Z-Christmas%20party%21%0AEND:VEVENT%0AEND:VCALENDAR"
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=20201212T133000Z%0ADTEND=20201212T143000Z%0ASUMMARY=Christmas%20party%21%0AUID=-20201212T133000Z-Christmas%20party%21%0AEND:VEVENT%0AEND:VCALENDAR"
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 Yorkers calendar as local time `2020-05-13 17:30:00`
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
 
@@ -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:text href
99
- # Eg. data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT%0ADTSTART=20200610T123000Z%0ADTEND=20200610T133000Z%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%2C%20The%20Edge%2C%2038%20Smith-Dorrien%20St%2C%20London%2C%20N1%207GU%0AUID=-https%3A%2F%2Fwww.example.com%2Fevent-details%0AEND:VEVENT%0AEND:VCALENDAR
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] = url_encode(title)
108
+ params[:SUMMARY] = url_encode_ical(title)
109
109
  params[:URL] = url_encode(url) if url
110
- params[:DESCRIPTION] = url_encode_ical_description(description) if 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] = url_encode(location) if 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)}-#{url_encode(title)}" unless params[:UID] # set uid based on starttime and title only if url is unavailable
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 url_encode_ical_description(description)
243
- description.split("\n").map { |e|
244
- if e == "\n"
245
- "\\n"
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) if e != "\n"
252
+ url_encode(e)
248
253
  end
249
254
  }.join("\\n")
250
255
  end
@@ -1,3 +1,3 @@
1
1
  module AddToCalendar
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  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.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-18 00:00:00.000000000 Z
11
+ date: 2020-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo