add_to_calendar_links 0.4.2 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/add_to_calendar_links.rb +27 -9
- data/lib/add_to_calendar_links/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: 495a1ab43eeb5602bfcdc9f5eee15799cab1c22a2ff2190f8fa2b0c84242c9e9
|
4
|
+
data.tar.gz: 5cfd8e912a027a63f355dededbf5dd66c050b0adab9678d3285227c82191cfef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d48b9f117fc0dd0b1bb7dfedf5bc1a363e3da547904f964e4cc33bc9952d00a8b26d17b3f0d2e0dd22586172b43477a7d081c785ae99d7a96075c3dc864a1a9
|
7
|
+
data.tar.gz: 766601c05aa976fd3692d300aa7e8f7ea2b4c649cd22d90e8b3aef574d9724dfffcf9159efdd417ae82043974fd909b3a5fd43c3defe69f9c8208dd04dd972f7
|
@@ -12,8 +12,8 @@ module AddToCalendarLinks
|
|
12
12
|
class Error < StandardError; end
|
13
13
|
|
14
14
|
class URLs
|
15
|
-
attr_accessor :start_datetime, :end_datetime, :title, :timezone, :location, :url, :description, :add_url_to_description, :organizer, :strip_html, :sequence, :last_modified
|
16
|
-
def initialize(start_datetime:, end_datetime: nil, title:, timezone:, location: nil, url: nil, description: nil, add_url_to_description: true, organizer: nil, strip_html: false, sequence: nil, last_modified: Time.now.utc)
|
15
|
+
attr_accessor :start_datetime, :end_datetime, :title, :timezone, :location, :url, :description, :add_url_to_description, :organizer, :strip_html, :sequence, :last_modified, :uid
|
16
|
+
def initialize(start_datetime:, end_datetime: nil, title:, timezone:, location: nil, url: nil, description: nil, add_url_to_description: true, organizer: nil, strip_html: false, sequence: nil, last_modified: Time.now.utc, uid:)
|
17
17
|
@start_datetime = start_datetime
|
18
18
|
@end_datetime = end_datetime
|
19
19
|
@title = title
|
@@ -22,9 +22,10 @@ module AddToCalendarLinks
|
|
22
22
|
@url = url
|
23
23
|
@description = description
|
24
24
|
@add_url_to_description = add_url_to_description
|
25
|
-
@organizer =
|
25
|
+
@organizer = organizer if organizer
|
26
26
|
@strip_html = strip_html
|
27
27
|
@sequence = sequence
|
28
|
+
@uid = uid
|
28
29
|
@last_modified = last_modified
|
29
30
|
validate_attributes
|
30
31
|
end
|
@@ -120,15 +121,23 @@ module AddToCalendarLinks
|
|
120
121
|
end
|
121
122
|
end
|
122
123
|
params[:LOCATION] = strip_html_tags(location) if location
|
123
|
-
|
124
|
-
|
124
|
+
if uid
|
125
|
+
params[:UID] = uid
|
126
|
+
else
|
127
|
+
params[:UID] = "-#{urlc}" if url
|
128
|
+
params[:UID] = "-#{utc_datetime(start_datetime)}-#{title}" unless params[:UID] # set uid based on starttime and title only if url is unavailable
|
129
|
+
end
|
125
130
|
params[:ORGANIZER] = organizer if organizer
|
126
131
|
params[:SEQUENCE] = sequence if sequence
|
127
132
|
params["LAST-MODIFIED"] = format_date_google(last_modified) if last_modified
|
128
133
|
params[:METHOD] = "REQUEST"
|
129
134
|
|
130
135
|
params.each do |key, value|
|
131
|
-
|
136
|
+
if key == :ORGANIZER
|
137
|
+
calendar_url << "\n#{key}#{value}"
|
138
|
+
else
|
139
|
+
calendar_url << "\n#{key}:#{value}"
|
140
|
+
end
|
132
141
|
end
|
133
142
|
|
134
143
|
calendar_url << "\nEND:VEVENT\nEND:VCALENDAR"
|
@@ -159,15 +168,23 @@ module AddToCalendarLinks
|
|
159
168
|
end
|
160
169
|
end
|
161
170
|
params[:LOCATION] = url_encode_ical(location) if location
|
162
|
-
|
163
|
-
|
171
|
+
if uid
|
172
|
+
params[:UID] = uid
|
173
|
+
else
|
174
|
+
params[:UID] = "-#{url_encode(url)}" if url
|
175
|
+
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
|
176
|
+
end
|
164
177
|
params[:ORGANIZER] = organizer if organizer
|
165
178
|
params[:SEQUENCE] = sequence if sequence
|
166
179
|
params["LAST-MODIFIED"] = format_date_google(last_modified) if last_modified
|
167
180
|
|
168
181
|
new_line = "%0A"
|
169
182
|
params.each do |key, value|
|
170
|
-
|
183
|
+
if key == :ORGANIZER
|
184
|
+
calendar_url << "\n#{key}#{value}"
|
185
|
+
else
|
186
|
+
calendar_url << "\n#{key}:#{value}"
|
187
|
+
end
|
171
188
|
end
|
172
189
|
|
173
190
|
calendar_url << "%0AEND:VEVENT%0AEND:VCALENDAR"
|
@@ -320,6 +337,7 @@ module AddToCalendarLinks
|
|
320
337
|
string.gsub!("&", "and")
|
321
338
|
string.gsub!(" ", " ")
|
322
339
|
string.gsub!(/<\/?[^>]*>/, "")
|
340
|
+
string.gsub!(/\n/, "\\n")
|
323
341
|
string.gsub!(/(\\n){2,}/, "\\n\\n")
|
324
342
|
string.strip
|
325
343
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: add_to_calendar_links
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Turner
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-03-
|
12
|
+
date: 2021-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tzinfo
|