jekyll-ical-tag 1.3.3 → 1.4.0

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: d7d1dce12392f01bb0a4d092684ffcec0dd51dd099a5c4d84634c2a4f5873785
4
- data.tar.gz: 3bea7aac7663335f7df8928a10cff12bdc45a0ed0d59dc98530e18f35ca302ce
3
+ metadata.gz: 138258ebd3c243d7029b59499ed3efb4b26aacbeada1a965e5775f0df4d8ef19
4
+ data.tar.gz: c5085b894aa91497fdec2a0505138a5acacbe5e47e0934491fb9f79311371e36
5
5
  SHA512:
6
- metadata.gz: 422e9632764d6c14a00aabab84592fde181f66782870de1d9eeaee7bdfa2c7531cf262c00ec16d25c13951490a8a937edfc746cd55387870169aebb3687cc58c
7
- data.tar.gz: 6cc3cb90d9c76cfb50768522dc6c0205fdeab97baf621fe9be7983185724cbd1c79773f5c5027fb5fe527995706b25b186d97327b08399fb45a5caa3ae26fd8f
6
+ metadata.gz: 0deebc23d524101ca2e1ec02c1351316228f1d94533fc5646c4886ad979be920add4ffcdd58831bd654b2ae09669c51fa6bc939ee7ccae200c3a0f61e3329343
7
+ data.tar.gz: a02c429cb649bfd8e9abb70499d711e2417d0c35eb24a477ade046c1f95083cda9f90e1afcdc9b95bb10028746e3b68759f98ed71f7c99bdb453f716ae3ac5aa
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby system
data/Gemfile.lock CHANGED
@@ -1,93 +1,97 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (5.2.4.3)
4
+ activesupport (7.0.4.2)
5
5
  concurrent-ruby (~> 1.0, >= 1.0.2)
6
- i18n (>= 0.7, < 2)
7
- minitest (~> 5.1)
8
- tzinfo (~> 1.1)
9
- addressable (2.7.0)
10
- public_suffix (>= 2.0.2, < 5.0)
6
+ i18n (>= 1.6, < 2)
7
+ minitest (>= 5.1)
8
+ tzinfo (~> 2.0)
9
+ addressable (2.8.1)
10
+ public_suffix (>= 2.0.2, < 6.0)
11
11
  api_cache (0.3.0)
12
12
  colorator (1.1.0)
13
- concurrent-ruby (1.1.6)
14
- diff-lcs (1.3)
15
- em-websocket (0.5.1)
13
+ concurrent-ruby (1.2.2)
14
+ diff-lcs (1.5.0)
15
+ em-websocket (0.5.3)
16
16
  eventmachine (>= 0.12.9)
17
- http_parser.rb (~> 0.6.0)
17
+ http_parser.rb (~> 0)
18
18
  eventmachine (1.2.7)
19
- ffi (1.12.2)
19
+ ffi (1.15.5)
20
20
  forwardable-extended (2.6.0)
21
- http_parser.rb (0.6.0)
22
- i18n (1.8.2)
21
+ google-protobuf (3.22.0)
22
+ http_parser.rb (0.8.0)
23
+ i18n (1.12.0)
23
24
  concurrent-ruby (~> 1.0)
24
- icalendar (2.5.0)
25
+ icalendar (2.8.0)
25
26
  ice_cube (~> 0.16)
26
- ice_cube (0.16.3)
27
- jekyll (4.0.0)
27
+ ice_cube (0.16.4)
28
+ jekyll (4.3.2)
28
29
  addressable (~> 2.4)
29
30
  colorator (~> 1.0)
30
31
  em-websocket (~> 0.5)
31
- i18n (>= 0.9.5, < 2)
32
- jekyll-sass-converter (~> 2.0)
32
+ i18n (~> 1.0)
33
+ jekyll-sass-converter (>= 2.0, < 4.0)
33
34
  jekyll-watch (~> 2.0)
34
- kramdown (~> 2.1)
35
+ kramdown (~> 2.3, >= 2.3.1)
35
36
  kramdown-parser-gfm (~> 1.0)
36
37
  liquid (~> 4.0)
37
- mercenary (~> 0.3.3)
38
+ mercenary (>= 0.3.6, < 0.5)
38
39
  pathutil (~> 0.9)
39
- rouge (~> 3.0)
40
+ rouge (>= 3.0, < 5.0)
40
41
  safe_yaml (~> 1.0)
41
- terminal-table (~> 1.8)
42
- jekyll-sass-converter (2.1.0)
43
- sassc (> 2.0.1, < 3.0)
42
+ terminal-table (>= 1.8, < 4.0)
43
+ webrick (~> 1.7)
44
+ jekyll-sass-converter (3.0.0)
45
+ sass-embedded (~> 1.54)
44
46
  jekyll-watch (2.2.1)
45
47
  listen (~> 3.0)
46
- kramdown (2.3.1)
48
+ kramdown (2.4.0)
47
49
  rexml
48
50
  kramdown-parser-gfm (1.1.0)
49
51
  kramdown (~> 2.0)
50
- liquid (4.0.3)
51
- listen (3.2.1)
52
+ liquid (4.0.4)
53
+ listen (3.8.0)
52
54
  rb-fsevent (~> 0.10, >= 0.10.3)
53
55
  rb-inotify (~> 0.9, >= 0.9.10)
54
- mercenary (0.3.6)
55
- mini_portile2 (2.5.0)
56
- minitest (5.14.1)
57
- nokogiri (1.11.0)
58
- mini_portile2 (~> 2.5.0)
56
+ mercenary (0.4.0)
57
+ mini_portile2 (2.8.1)
58
+ minitest (5.17.0)
59
+ nokogiri (1.14.2)
60
+ mini_portile2 (~> 2.8.0)
59
61
  racc (~> 1.4)
60
62
  pathutil (0.16.2)
61
63
  forwardable-extended (~> 2.6)
62
- public_suffix (4.0.3)
63
- racc (1.5.2)
64
- rb-fsevent (0.10.3)
64
+ public_suffix (5.0.1)
65
+ racc (1.6.2)
66
+ rake (13.0.6)
67
+ rb-fsevent (0.11.2)
65
68
  rb-inotify (0.10.1)
66
69
  ffi (~> 1.0)
67
- rexml (3.2.4)
68
- rouge (3.17.0)
69
- rspec (3.7.0)
70
- rspec-core (~> 3.7.0)
71
- rspec-expectations (~> 3.7.0)
72
- rspec-mocks (~> 3.7.0)
73
- rspec-core (3.7.0)
74
- rspec-support (~> 3.7.0)
75
- rspec-expectations (3.7.0)
70
+ rexml (3.2.5)
71
+ rouge (4.1.0)
72
+ rspec (3.12.0)
73
+ rspec-core (~> 3.12.0)
74
+ rspec-expectations (~> 3.12.0)
75
+ rspec-mocks (~> 3.12.0)
76
+ rspec-core (3.12.1)
77
+ rspec-support (~> 3.12.0)
78
+ rspec-expectations (3.12.2)
76
79
  diff-lcs (>= 1.2.0, < 2.0)
77
- rspec-support (~> 3.7.0)
78
- rspec-mocks (3.7.0)
80
+ rspec-support (~> 3.12.0)
81
+ rspec-mocks (3.12.3)
79
82
  diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.7.0)
81
- rspec-support (3.7.0)
83
+ rspec-support (~> 3.12.0)
84
+ rspec-support (3.12.0)
82
85
  safe_yaml (1.0.5)
83
- sassc (2.2.1)
84
- ffi (~> 1.9)
85
- terminal-table (1.8.0)
86
- unicode-display_width (~> 1.1, >= 1.1.1)
87
- thread_safe (0.3.6)
88
- tzinfo (1.2.7)
89
- thread_safe (~> 0.1)
90
- unicode-display_width (1.7.0)
86
+ sass-embedded (1.58.3)
87
+ google-protobuf (~> 3.21)
88
+ rake (>= 10.0.0)
89
+ terminal-table (3.0.2)
90
+ unicode-display_width (>= 1.1.1, < 3)
91
+ tzinfo (2.0.6)
92
+ concurrent-ruby (~> 1.0)
93
+ unicode-display_width (2.4.2)
94
+ webrick (1.8.1)
91
95
 
92
96
  PLATFORMS
93
97
  ruby
@@ -101,4 +105,4 @@ DEPENDENCIES
101
105
  rspec
102
106
 
103
107
  BUNDLED WITH
104
- 2.1.4
108
+ 2.3.10
data/_site/README.md ADDED
@@ -0,0 +1,64 @@
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
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ rm -f *.gem
4
+ bundle exec gem build jekyll-ical-tag.gemspec
5
+ bundle exec gem push jekyll-ical-tag-*.gem
data/_site/bin/rspec ADDED
@@ -0,0 +1,29 @@
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")
@@ -0,0 +1,40 @@
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
@@ -0,0 +1,40 @@
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
@@ -0,0 +1,30 @@
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
@@ -0,0 +1,46 @@
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
@@ -0,0 +1,26 @@
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
@@ -0,0 +1,111 @@
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
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class IcalTag < Liquid::Block
5
+ VERSION = "1.3.3"
6
+ end
7
+ end