jekyll-ical-tag 1.4.0 → 1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +20 -20
- data/jekyll-ical-tag.gemspec +1 -1
- data/lib/jekyll-ical-tag/event.rb +1 -1
- data/lib/jekyll-ical-tag/version.rb +1 -1
- metadata +7 -23
- data/_site/README.md +0 -64
- data/_site/bin/build-and-publish-gem +0 -5
- data/_site/bin/rspec +0 -29
- data/_site/jekyll-ical-tag.gemspec +0 -40
- data/_site/lib/jekyll-ical-tag/calendar_feed_coordinator.rb +0 -40
- data/_site/lib/jekyll-ical-tag/calendar_fetcher.rb +0 -30
- data/_site/lib/jekyll-ical-tag/calendar_limiter.rb +0 -46
- data/_site/lib/jekyll-ical-tag/calendar_parser.rb +0 -26
- data/_site/lib/jekyll-ical-tag/event.rb +0 -111
- data/_site/lib/jekyll-ical-tag/version.rb +0 -7
- data/_site/lib/jekyll-ical-tag.rb +0 -169
- data/_site/spec/calendar_feed_coordinator_spec.rb +0 -219
- data/_site/spec/spec_helper.rb +0 -85
- data/_site/spec/support/basic.ics +0 -1310
- data/_site/spec/support/italian.ics +0 -155
- data/_site/spec/support/sesh.ics +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd9aae8578b4e747ceb38bae139ef9a7b900a9ab15c4b7ddd8b86c2bc4e1d63d
|
4
|
+
data.tar.gz: b9b8f3f424cd86baee95a8ecff82ec7e5a9423f2118e4a70d949d8689f8a10c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34dc052e75be4eac928d6b4d0e6eaa4ab2bb80cae1d12770cad69079fbb37815c668df61584a1b735ccb71c6adae9b1d7220e6b45504aa81b6e476d51c414a7b
|
7
|
+
data.tar.gz: 6071a16177cdbcdb4e508d3e8974b25af01cc59f8f4511ea122734ca18b2d00d5aa83e695abcfe6912f79d52dd97f97ff350ec46936db078972c55aee16c4639
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (7.0.
|
4
|
+
activesupport (7.0.5.1)
|
5
5
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
6
|
i18n (>= 1.6, < 2)
|
7
7
|
minitest (>= 5.1)
|
8
8
|
tzinfo (~> 2.0)
|
9
|
-
addressable (2.8.
|
9
|
+
addressable (2.8.4)
|
10
10
|
public_suffix (>= 2.0.2, < 6.0)
|
11
11
|
api_cache (0.3.0)
|
12
12
|
colorator (1.1.0)
|
@@ -18,11 +18,11 @@ GEM
|
|
18
18
|
eventmachine (1.2.7)
|
19
19
|
ffi (1.15.5)
|
20
20
|
forwardable-extended (2.6.0)
|
21
|
-
google-protobuf (3.
|
21
|
+
google-protobuf (3.23.3)
|
22
22
|
http_parser.rb (0.8.0)
|
23
|
-
i18n (1.
|
23
|
+
i18n (1.14.1)
|
24
24
|
concurrent-ruby (~> 1.0)
|
25
|
-
icalendar (2.
|
25
|
+
icalendar (2.10.1)
|
26
26
|
ice_cube (~> 0.16)
|
27
27
|
ice_cube (0.16.4)
|
28
28
|
jekyll (4.3.2)
|
@@ -54,38 +54,38 @@ GEM
|
|
54
54
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
55
55
|
rb-inotify (~> 0.9, >= 0.9.10)
|
56
56
|
mercenary (0.4.0)
|
57
|
-
mini_portile2 (2.8.
|
58
|
-
minitest (5.
|
59
|
-
nokogiri (1.
|
60
|
-
mini_portile2 (~> 2.8.
|
57
|
+
mini_portile2 (2.8.2)
|
58
|
+
minitest (5.18.1)
|
59
|
+
nokogiri (1.15.2)
|
60
|
+
mini_portile2 (~> 2.8.2)
|
61
61
|
racc (~> 1.4)
|
62
62
|
pathutil (0.16.2)
|
63
63
|
forwardable-extended (~> 2.6)
|
64
64
|
public_suffix (5.0.1)
|
65
|
-
racc (1.
|
65
|
+
racc (1.7.1)
|
66
66
|
rake (13.0.6)
|
67
67
|
rb-fsevent (0.11.2)
|
68
68
|
rb-inotify (0.10.1)
|
69
69
|
ffi (~> 1.0)
|
70
70
|
rexml (3.2.5)
|
71
|
-
rouge (4.1.
|
71
|
+
rouge (4.1.2)
|
72
72
|
rspec (3.12.0)
|
73
73
|
rspec-core (~> 3.12.0)
|
74
74
|
rspec-expectations (~> 3.12.0)
|
75
75
|
rspec-mocks (~> 3.12.0)
|
76
|
-
rspec-core (3.12.
|
76
|
+
rspec-core (3.12.2)
|
77
77
|
rspec-support (~> 3.12.0)
|
78
|
-
rspec-expectations (3.12.
|
78
|
+
rspec-expectations (3.12.3)
|
79
79
|
diff-lcs (>= 1.2.0, < 2.0)
|
80
80
|
rspec-support (~> 3.12.0)
|
81
|
-
rspec-mocks (3.12.
|
81
|
+
rspec-mocks (3.12.5)
|
82
82
|
diff-lcs (>= 1.2.0, < 2.0)
|
83
83
|
rspec-support (~> 3.12.0)
|
84
|
-
rspec-support (3.12.
|
84
|
+
rspec-support (3.12.1)
|
85
85
|
safe_yaml (1.0.5)
|
86
|
-
sass-embedded (1.
|
87
|
-
google-protobuf (~> 3.
|
88
|
-
rake (>=
|
86
|
+
sass-embedded (1.63.6)
|
87
|
+
google-protobuf (~> 3.23)
|
88
|
+
rake (>= 13.0.0)
|
89
89
|
terminal-table (3.0.2)
|
90
90
|
unicode-display_width (>= 1.1.1, < 3)
|
91
91
|
tzinfo (2.0.6)
|
@@ -99,10 +99,10 @@ PLATFORMS
|
|
99
99
|
DEPENDENCIES
|
100
100
|
activesupport
|
101
101
|
api_cache
|
102
|
-
icalendar
|
102
|
+
icalendar (~> 2.10.1)
|
103
103
|
jekyll
|
104
104
|
nokogiri
|
105
105
|
rspec
|
106
106
|
|
107
107
|
BUNDLED WITH
|
108
|
-
2.
|
108
|
+
2.1.4
|
data/jekyll-ical-tag.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_dependency "jekyll", "> 3"
|
34
34
|
spec.add_dependency "api_cache"
|
35
35
|
spec.add_dependency "activesupport"
|
36
|
-
spec.add_dependency "icalendar"
|
36
|
+
spec.add_dependency "icalendar", "~> 2.10.1"
|
37
37
|
|
38
38
|
spec.add_development_dependency "bundler", "~> 1.15"
|
39
39
|
spec.add_development_dependency "rspec", "~> 3.5"
|
@@ -80,7 +80,7 @@ module Jekyll
|
|
80
80
|
props.transform_values! do |value|
|
81
81
|
new_value =
|
82
82
|
case value
|
83
|
-
when Array, Icalendar::Values::Array
|
83
|
+
when Array, Icalendar::Values::Helpers::Array
|
84
84
|
value.join("\n").force_encoding("UTF-8")
|
85
85
|
when String, Icalendar::Values::Text
|
86
86
|
value.force_encoding("UTF-8")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-ical-tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricky Chilcott
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: icalendar
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.10.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.10.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,22 +107,6 @@ files:
|
|
107
107
|
- Gemfile
|
108
108
|
- Gemfile.lock
|
109
109
|
- README.md
|
110
|
-
- _site/README.md
|
111
|
-
- _site/bin/build-and-publish-gem
|
112
|
-
- _site/bin/rspec
|
113
|
-
- _site/jekyll-ical-tag.gemspec
|
114
|
-
- _site/lib/jekyll-ical-tag.rb
|
115
|
-
- _site/lib/jekyll-ical-tag/calendar_feed_coordinator.rb
|
116
|
-
- _site/lib/jekyll-ical-tag/calendar_fetcher.rb
|
117
|
-
- _site/lib/jekyll-ical-tag/calendar_limiter.rb
|
118
|
-
- _site/lib/jekyll-ical-tag/calendar_parser.rb
|
119
|
-
- _site/lib/jekyll-ical-tag/event.rb
|
120
|
-
- _site/lib/jekyll-ical-tag/version.rb
|
121
|
-
- _site/spec/calendar_feed_coordinator_spec.rb
|
122
|
-
- _site/spec/spec_helper.rb
|
123
|
-
- _site/spec/support/basic.ics
|
124
|
-
- _site/spec/support/italian.ics
|
125
|
-
- _site/spec/support/sesh.ics
|
126
110
|
- bin/build-and-publish-gem
|
127
111
|
- bin/rspec
|
128
112
|
- jekyll-ical-tag.gemspec
|
@@ -153,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
137
|
- !ruby/object:Gem::Version
|
154
138
|
version: '0'
|
155
139
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
140
|
+
rubygems_version: 3.5.3
|
157
141
|
signing_key:
|
158
142
|
specification_version: 4
|
159
143
|
summary: A Jekyll plugin to pull ICS feed and provide a for-like loop of calendar
|
data/_site/README.md
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# Jekyll ical tag
|
2
|
-
|
3
|
-
Author: Ricky Chilcott https://www.rakefire.io
|
4
|
-
|
5
|
-
Description: Pull ICS feed and provide a for-like loop of calendar events
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
To your Gemfile:
|
10
|
-
|
11
|
-
`gem 'jekyll-ical-tag'`
|
12
|
-
|
13
|
-
To your `_config.yml`
|
14
|
-
|
15
|
-
```yml
|
16
|
-
plugins:
|
17
|
-
- jekyll-ical-tag
|
18
|
-
```
|
19
|
-
|
20
|
-
## Syntax
|
21
|
-
|
22
|
-
```html
|
23
|
-
{% ical url: https://space.floern.com/launch.ics reverse: true only_future: true %}
|
24
|
-
{{ event.summary }}
|
25
|
-
{{ event.description }}
|
26
|
-
{{ event.simple_html_description }}
|
27
|
-
{{ event.start_time }}
|
28
|
-
{{ event.end_time }}
|
29
|
-
{{ event.url }}
|
30
|
-
{{ event.attendees }}
|
31
|
-
{% endical %}
|
32
|
-
```
|
33
|
-
|
34
|
-
## Options
|
35
|
-
|
36
|
-
- `reverse` - Defaults to 'false', ordering events by start_time (or reverse start_time).
|
37
|
-
- `only_past` - Defaults to 'false', limits returned events to start_times before now.
|
38
|
-
- `only_future` - Defaults to 'false', limits returned events to start_time after now.
|
39
|
-
|
40
|
-
- `before_date` - limits returned events to dates before a specific date. This gets parsed with Ruby's Time.parse (e.g. 01-01-2018)
|
41
|
-
- `after_date` - limits returned events to dates before a specific date. This gets parsed with Ruby's Time.parse (e.g. 01-01-2018).
|
42
|
-
- `limit` - limits the number of returned events to the first N events matching the specified criteria. For example, `{% ical url: https://example.com/events.ics only_future:true limit:5 %}` returns the first five future events.
|
43
|
-
|
44
|
-
## Event Attributes:
|
45
|
-
|
46
|
-
All RFC 5545 properties are supported, examples:
|
47
|
-
|
48
|
-
- `dtstart` - start time of event
|
49
|
-
- `dtend` - end time of event
|
50
|
-
- `summary` - Title or name of event
|
51
|
-
- `description` - Notes/description of event
|
52
|
-
- `location` - Location of event
|
53
|
-
- `url` - url of event, if provided, if not, take the first url from the description.
|
54
|
-
|
55
|
-
A few helper properties are also supported:
|
56
|
-
|
57
|
-
- `attendees` - [Array] of attendees names/emails
|
58
|
-
- `simple_html_description` - Notes/description of event with urls auto-linked
|
59
|
-
- `start_time` - start time of event
|
60
|
-
- `end_time` - end time of event
|
61
|
-
|
62
|
-
# Special Thanks
|
63
|
-
|
64
|
-
Special thanks to the following contributors: @marchehab98 @meitar
|
data/_site/bin/rspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rspec' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
-
Pathname.new(__FILE__).realpath)
|
14
|
-
|
15
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
-
|
17
|
-
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
-
load(bundle_binstub)
|
20
|
-
else
|
21
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require "rubygems"
|
27
|
-
require "bundler/setup"
|
28
|
-
|
29
|
-
load Gem.bin_path("rspec-core", "rspec")
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path("lib", __dir__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
|
6
|
-
require "jekyll"
|
7
|
-
require "jekyll-ical-tag/version"
|
8
|
-
|
9
|
-
Gem::Specification.new do |spec|
|
10
|
-
spec.name = "jekyll-ical-tag"
|
11
|
-
spec.version = Jekyll::IcalTag::VERSION
|
12
|
-
spec.authors = ["Ricky Chilcott"]
|
13
|
-
spec.email = ["ricky@rakefire.io"]
|
14
|
-
spec.summary = "A Jekyll plugin to pull ICS feed and provide a for-like loop of calendar events"
|
15
|
-
spec.homepage = "https://github.com/rakefire/jekyll-ical-tag"
|
16
|
-
spec.license = "MIT"
|
17
|
-
|
18
|
-
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
19
|
-
# delete this section to allow pushing this gem to any host.
|
20
|
-
if spec.respond_to?(:metadata)
|
21
|
-
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
22
|
-
else
|
23
|
-
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
24
|
-
end
|
25
|
-
|
26
|
-
spec.required_ruby_version = ">= 2.3.0"
|
27
|
-
|
28
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
|
29
|
-
spec.bindir = "exe"
|
30
|
-
spec.executables = spec.files.grep(%r!^exe/!) { |f| File.basename(f) }
|
31
|
-
spec.require_paths = ["lib"]
|
32
|
-
|
33
|
-
spec.add_dependency "jekyll", "> 3"
|
34
|
-
spec.add_dependency "api_cache"
|
35
|
-
spec.add_dependency "activesupport"
|
36
|
-
spec.add_dependency "icalendar"
|
37
|
-
|
38
|
-
spec.add_development_dependency "bundler", "~> 1.15"
|
39
|
-
spec.add_development_dependency "rspec", "~> 3.5"
|
40
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Jekyll
|
5
|
-
class IcalTag
|
6
|
-
class CalendarFeedCoordinator
|
7
|
-
def initialize(url:, only: nil, reverse: nil, before_date: nil, after_date: nil, limit: nil)
|
8
|
-
@url = url
|
9
|
-
@only = only
|
10
|
-
@reverse = reverse
|
11
|
-
@before_date = before_date
|
12
|
-
@after_date = after_date
|
13
|
-
@limit = limit
|
14
|
-
end
|
15
|
-
|
16
|
-
def events
|
17
|
-
parser.events
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
attr_reader :url, :only, :reverse, :before_date, :after_date, :limit
|
23
|
-
|
24
|
-
def raw_ical
|
25
|
-
@raw_ical ||= CalendarFetcher.new(url).fetch
|
26
|
-
end
|
27
|
-
|
28
|
-
def parser
|
29
|
-
@parser ||= begin
|
30
|
-
parser = CalendarParser.new(raw_ical)
|
31
|
-
parser = CalendarLimiter.new(parser, only: only)
|
32
|
-
parser = CalendarLimiter.new(parser, reverse: reverse)
|
33
|
-
parser = CalendarLimiter.new(parser, before_date: before_date)
|
34
|
-
parser = CalendarLimiter.new(parser, after_date: after_date)
|
35
|
-
CalendarLimiter.new(parser, limit: limit)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "cgi"
|
5
|
-
require "api_cache"
|
6
|
-
|
7
|
-
module Jekyll
|
8
|
-
class IcalTag
|
9
|
-
class CalendarFetcher
|
10
|
-
def initialize(url)
|
11
|
-
@url = CGI.unescape(url)
|
12
|
-
|
13
|
-
raise "No URL provided or in innapropriate form '#{url}'" unless is_valid_url?
|
14
|
-
end
|
15
|
-
|
16
|
-
def fetch
|
17
|
-
puts "Fetching #{url}"
|
18
|
-
@fetch ||= APICache.get(url)
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
attr_reader :url
|
24
|
-
|
25
|
-
def is_valid_url?
|
26
|
-
!!(url =~ URI::regexp)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Jekyll
|
5
|
-
class IcalTag
|
6
|
-
class CalendarLimiter
|
7
|
-
def initialize(parser, options = {})
|
8
|
-
@parser = parser
|
9
|
-
@options = options
|
10
|
-
end
|
11
|
-
|
12
|
-
def events
|
13
|
-
case
|
14
|
-
when options[:only] == :future
|
15
|
-
now = Time.now
|
16
|
-
parser.events.select do |event|
|
17
|
-
event.dtstart.to_time >= now
|
18
|
-
end
|
19
|
-
when options[:only] == :past
|
20
|
-
now = Time.now
|
21
|
-
parser.events.select do |event|
|
22
|
-
event.dtstart.to_time < now
|
23
|
-
end
|
24
|
-
when options[:reverse]
|
25
|
-
parser.events.reverse
|
26
|
-
when options[:after_date]
|
27
|
-
parser.events.select do |event|
|
28
|
-
event.dtstart.to_time >= options[:after_date]
|
29
|
-
end
|
30
|
-
when options[:before_date]
|
31
|
-
parser.events.select do |event|
|
32
|
-
event.dtstart.to_time < options[:before_date]
|
33
|
-
end
|
34
|
-
when options[:limit]
|
35
|
-
parser.events.first(options[:limit])
|
36
|
-
else
|
37
|
-
parser.events
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
attr_reader :parser, :options
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "active_support"
|
5
|
-
require "icalendar"
|
6
|
-
|
7
|
-
module Jekyll
|
8
|
-
class IcalTag
|
9
|
-
class CalendarParser
|
10
|
-
def initialize(raw_feed)
|
11
|
-
@raw_feed = raw_feed
|
12
|
-
end
|
13
|
-
|
14
|
-
def events
|
15
|
-
@events ||= parsed_feed.sort { |event1, event2| event1.dtstart <=> event2.dtstart }
|
16
|
-
.map { |event| Jekyll::IcalTag::Event.new(event) }
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def parsed_feed
|
22
|
-
Icalendar::Event.parse(@raw_feed)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "uri"
|
5
|
-
require "active_support"
|
6
|
-
|
7
|
-
module Jekyll
|
8
|
-
class IcalTag
|
9
|
-
class Event
|
10
|
-
URL_REGEX = /
|
11
|
-
(?:(?:https?|ftp):\/\/) # Allowable schemes
|
12
|
-
(?:\S+(?::\S*)?@)? # username:password, which is optional
|
13
|
-
(?: # Domain part follows; non-capturing
|
14
|
-
# These IP addresses are valid domain values
|
15
|
-
(?!10(?:\.\d{1,3}){3})
|
16
|
-
(?!127(?:\.\d{1,3}){3})
|
17
|
-
(?!169\.254(?:\.\d{1,3}){2})
|
18
|
-
(?!192\.168(?:\.\d{1,3}){2})
|
19
|
-
(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})
|
20
|
-
(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])
|
21
|
-
(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}
|
22
|
-
(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))
|
23
|
-
|
|
24
|
-
(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)
|
25
|
-
(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*
|
26
|
-
(?:\.(?:[a-z\u00a1-\uffff]{2,}))
|
27
|
-
)
|
28
|
-
(?::\d{2,5})? # Optional port number
|
29
|
-
(?:\/[^\s"]*)? # Anything that is not a space or a double quote
|
30
|
-
/x
|
31
|
-
|
32
|
-
def initialize(ical_event)
|
33
|
-
@ical_event = ical_event
|
34
|
-
setup_all_properties!
|
35
|
-
setup_property_accessor_methods!
|
36
|
-
end
|
37
|
-
|
38
|
-
attr_reader :all_properties
|
39
|
-
|
40
|
-
def simple_html_description
|
41
|
-
@simple_html_description ||= begin
|
42
|
-
description.clone.tap do |description|
|
43
|
-
description_urls.each do |url|
|
44
|
-
description.gsub! url, %(<a href='#{url}'>#{url}</a>)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def attendees
|
51
|
-
ical_event.attendee.map(&:to_s).map { |a| a.slice!("mailto:"); a }
|
52
|
-
end
|
53
|
-
|
54
|
-
def description_urls
|
55
|
-
return [] unless description
|
56
|
-
|
57
|
-
@description_urls ||= description.scan(URL_REGEX).to_a
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
attr_reader :ical_event
|
63
|
-
|
64
|
-
def setup_all_properties!
|
65
|
-
@all_properties ||= begin
|
66
|
-
props = {}
|
67
|
-
|
68
|
-
# RFC 5545 Properties
|
69
|
-
ical_event.class.properties.each do |property|
|
70
|
-
props[property] = ical_event.property(property)
|
71
|
-
end
|
72
|
-
|
73
|
-
# custom properties
|
74
|
-
props = props.merge(ical_event.custom_properties)
|
75
|
-
|
76
|
-
# Ensure all arrays get flattened to utf8 encoded strings
|
77
|
-
# Ensure all event values are utf8 encoded strings
|
78
|
-
# Ensure times (from dates)
|
79
|
-
# Ensure present
|
80
|
-
props.transform_values! do |value|
|
81
|
-
new_value =
|
82
|
-
case value
|
83
|
-
when Array, Icalendar::Values::Array
|
84
|
-
value.join("\n").force_encoding("UTF-8")
|
85
|
-
when String, Icalendar::Values::Text
|
86
|
-
value.force_encoding("UTF-8")
|
87
|
-
when Date, Icalendar::Values::DateTime
|
88
|
-
value.to_time
|
89
|
-
when Icalendar::Values::Uri
|
90
|
-
value.to_s
|
91
|
-
else
|
92
|
-
value
|
93
|
-
end
|
94
|
-
|
95
|
-
new_value.presence
|
96
|
-
end
|
97
|
-
|
98
|
-
props
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def setup_property_accessor_methods!
|
103
|
-
all_properties.each do |prop, value|
|
104
|
-
define_singleton_method prop do
|
105
|
-
all_properties[prop]
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|