jekyll-ical-tag 1.0.9 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -3
- data/lib/jekyll-ical-tag.rb +58 -44
- data/lib/jekyll-ical-tag/event.rb +18 -1
- data/lib/jekyll-ical-tag/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdb49ea6fd0b6d006435344649a8a7d30f19155f7e1424683d8774b59e9bdcf2
|
4
|
+
data.tar.gz: e323590a17d904763e2169446a2152b24eeb90629fd4f88bba0adbac1bde523c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b3abd193f1de3eea850f2218ad8f42b7186e889b9915335a5da89418d59913898e09dc84e9f1d5fcf858eff2e9f49d4e0b960494fa2d930e3e2cfe75ff941a6
|
7
|
+
data.tar.gz: 93db87869c4f8d9b8c0e019a0e6c9bdd201d30a6b1edae8a0f1b1c3a68beeaa3fe1940435fbefb78cb521b2364b9955492657fb0f3f93278253e60232bb2c833
|
data/README.md
CHANGED
@@ -43,14 +43,21 @@ plugins:
|
|
43
43
|
|
44
44
|
## Event Attributes:
|
45
45
|
|
46
|
+
All RFC 5545 properties are supported, examples:
|
47
|
+
|
48
|
+
- `dtstart` - start time of event
|
49
|
+
- `dtend` - end time of event
|
46
50
|
- `summary` - Title or name of event
|
47
51
|
- `description` - Notes/description of event
|
48
|
-
- `simple_html_description` - Notes/description of event with urls auto-linked
|
49
52
|
- `location` - Location of event
|
50
|
-
- `start_time` - start time of event
|
51
|
-
- `end_time` - end time of event
|
52
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
|
+
|
53
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
|
54
61
|
|
55
62
|
# Special Thanks
|
56
63
|
|
data/lib/jekyll-ical-tag.rb
CHANGED
@@ -30,35 +30,60 @@ module Jekyll
|
|
30
30
|
|
31
31
|
result = []
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
context.stack do
|
34
|
+
url = get_url_from_assigned_value(context) ||
|
35
|
+
get_url_from_page_attributes(context) ||
|
36
|
+
@url
|
35
37
|
|
36
|
-
|
38
|
+
raise "No URL provided or in innapropriate form '#{url}'" unless is_valid_url?(url)
|
37
39
|
|
38
|
-
|
39
|
-
parser = CalendarLimiter.new(parser, only: @only)
|
40
|
-
parser = CalendarLimiter.new(parser, reverse: @reverse)
|
41
|
-
parser = CalendarLimiter.new(parser, before_date: @before_date)
|
42
|
-
parser = CalendarLimiter.new(parser, after_date: @after_date)
|
43
|
-
parser = CalendarLimiter.new(parser, limit: @limit)
|
40
|
+
puts "Fetching #{url}"
|
44
41
|
|
45
|
-
|
46
|
-
|
42
|
+
parser = CalendarParser.new(url)
|
43
|
+
parser = CalendarLimiter.new(parser, only: @only)
|
44
|
+
parser = CalendarLimiter.new(parser, reverse: @reverse)
|
45
|
+
parser = CalendarLimiter.new(parser, before_date: @before_date)
|
46
|
+
parser = CalendarLimiter.new(parser, after_date: @after_date)
|
47
|
+
parser = CalendarLimiter.new(parser, limit: @limit)
|
48
|
+
|
49
|
+
events = parser.events
|
50
|
+
length = events.length
|
47
51
|
|
48
|
-
context.stack do
|
49
52
|
events.each_with_index do |event, index|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
53
|
+
# Init
|
54
|
+
context["event"] = {}
|
55
|
+
|
56
|
+
# Jekyll helper variables
|
57
|
+
context["event"]["index"] = index
|
58
|
+
|
59
|
+
# RFC 5545 conformant and custom properties.
|
60
|
+
context["event"].merge!(event.all_properties)
|
61
|
+
|
62
|
+
# Supported but non-standard attributes.
|
63
|
+
context["event"]["attendees"] = event.attendees
|
64
|
+
context["event"]["simple_html_description"] = event.simple_html_description
|
65
|
+
|
66
|
+
# Overridden values
|
67
|
+
context["event"]["url"] ||= event.description_urls.first
|
68
|
+
|
69
|
+
# Deprecated attribute names.
|
70
|
+
context["event"]["end_time"] = context["event"]["dtend"]
|
71
|
+
context["event"]["start_time"] = context["event"]["dtstart"]
|
72
|
+
|
73
|
+
# Ensure all event values are utf8 encoded strings
|
74
|
+
# Ensure times (from dates)
|
75
|
+
# Ensure present
|
76
|
+
context["event"].transform_values! do |value|
|
77
|
+
v = case value
|
78
|
+
when String, Icalendar::Values::Text
|
79
|
+
value.force_encoding("UTF-8")
|
80
|
+
when Date, Icalendar::Values::DateTime
|
81
|
+
value.to_time
|
82
|
+
else
|
83
|
+
value
|
84
|
+
end
|
85
|
+
v.presence
|
86
|
+
end
|
62
87
|
|
63
88
|
context["forloop"] = {
|
64
89
|
"name" => "ical",
|
@@ -86,34 +111,23 @@ module Jekyll
|
|
86
111
|
|
87
112
|
private
|
88
113
|
|
89
|
-
def
|
90
|
-
!!(
|
114
|
+
def is_valid_url?(url)
|
115
|
+
!!(url =~ URI::regexp)
|
91
116
|
end
|
92
117
|
|
93
|
-
def
|
94
|
-
|
95
|
-
|
96
|
-
# Dereference @url from something like "page.calender_url" to the page's calendar_url
|
97
|
-
|
118
|
+
def get_url_from_page_attributes(context)
|
119
|
+
# Dereference url from something like "page.calender_url" to the page's calendar_url
|
98
120
|
dig_attrs = @url.split(".")
|
99
121
|
dig_attrs[0] = dig_attrs[0].to_sym if dig_attrs[0].present?
|
100
|
-
if dug_result = context.registers.dig(*dig_attrs)
|
101
|
-
@url = dug_result
|
102
|
-
end
|
103
|
-
end
|
104
122
|
|
105
|
-
|
106
|
-
return if has_valid_url?
|
107
|
-
return unless context.scopes.first[@url]
|
108
|
-
|
109
|
-
# Dereference the URL if we were passed a variable name.
|
110
|
-
@url = context.scopes.first[@url]
|
123
|
+
context.registers.dig(*dig_attrs) # will return result or nil (if not found)
|
111
124
|
end
|
112
125
|
|
113
|
-
def
|
114
|
-
return unless
|
126
|
+
def get_url_from_assigned_value(context)
|
127
|
+
return unless scope = context.scopes.find { |scope| scope[@url] }
|
115
128
|
|
116
|
-
|
129
|
+
# Dereference the URL if we were passed a variable name.
|
130
|
+
scope[@url]
|
117
131
|
end
|
118
132
|
|
119
133
|
def scan_attributes!
|
@@ -13,7 +13,23 @@ module Jekyll
|
|
13
13
|
@event = event
|
14
14
|
end
|
15
15
|
|
16
|
-
def_delegators :event, :
|
16
|
+
def_delegators :event, :dtstart, :dtend
|
17
|
+
|
18
|
+
def all_properties
|
19
|
+
@props ||= begin
|
20
|
+
props = {}
|
21
|
+
|
22
|
+
# RFC 5545 Properties
|
23
|
+
event.class.properties.each do |property|
|
24
|
+
props[property] = event.property(property)
|
25
|
+
end
|
26
|
+
|
27
|
+
# custom properties
|
28
|
+
props = props.merge(event.custom_properties)
|
29
|
+
|
30
|
+
props
|
31
|
+
end
|
32
|
+
end
|
17
33
|
|
18
34
|
def simple_html_description
|
19
35
|
@simple_html_description ||= begin
|
@@ -35,6 +51,7 @@ module Jekyll
|
|
35
51
|
|
36
52
|
private
|
37
53
|
|
54
|
+
def_delegators :event, :description, :attendee
|
38
55
|
attr_reader :event
|
39
56
|
end
|
40
57
|
end
|