jekyll 4.2.1 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +474 -350
- data/LICENSE +21 -21
- data/README.markdown +83 -86
- data/exe/jekyll +57 -57
- data/lib/blank_template/_config.yml +3 -3
- data/lib/blank_template/_layouts/default.html +12 -12
- data/lib/blank_template/_sass/main.scss +9 -9
- data/lib/blank_template/assets/css/main.scss +4 -4
- data/lib/blank_template/index.md +8 -8
- data/lib/jekyll/cache.rb +186 -190
- data/lib/jekyll/cleaner.rb +111 -111
- data/lib/jekyll/collection.rb +310 -309
- data/lib/jekyll/command.rb +105 -105
- data/lib/jekyll/commands/build.rb +82 -93
- data/lib/jekyll/commands/clean.rb +44 -45
- data/lib/jekyll/commands/doctor.rb +177 -177
- data/lib/jekyll/commands/help.rb +34 -34
- data/lib/jekyll/commands/new.rb +168 -169
- data/lib/jekyll/commands/new_theme.rb +39 -40
- data/lib/jekyll/commands/serve/live_reload_reactor.rb +119 -122
- data/lib/jekyll/commands/serve/livereload_assets/livereload.js +1183 -1183
- data/lib/jekyll/commands/serve/mime_types_charset.json +71 -0
- data/lib/jekyll/commands/serve/servlet.rb +206 -202
- data/lib/jekyll/commands/serve/websockets.rb +81 -81
- data/lib/jekyll/commands/serve.rb +367 -362
- data/lib/jekyll/configuration.rb +313 -313
- data/lib/jekyll/converter.rb +54 -54
- data/lib/jekyll/converters/identity.rb +41 -41
- data/lib/jekyll/converters/markdown/kramdown_parser.rb +197 -199
- data/lib/jekyll/converters/markdown.rb +113 -113
- data/lib/jekyll/converters/smartypants.rb +70 -70
- data/lib/jekyll/convertible.rb +257 -257
- data/lib/jekyll/data_entry.rb +83 -0
- data/lib/jekyll/data_hash.rb +61 -0
- data/lib/jekyll/deprecator.rb +50 -50
- data/lib/jekyll/document.rb +543 -544
- data/lib/jekyll/drops/collection_drop.rb +20 -20
- data/lib/jekyll/drops/document_drop.rb +71 -70
- data/lib/jekyll/drops/drop.rb +293 -293
- data/lib/jekyll/drops/excerpt_drop.rb +23 -19
- data/lib/jekyll/drops/jekyll_drop.rb +32 -32
- data/lib/jekyll/drops/site_drop.rb +71 -66
- data/lib/jekyll/drops/static_file_drop.rb +14 -14
- data/lib/jekyll/drops/theme_drop.rb +36 -0
- data/lib/jekyll/drops/unified_payload_drop.rb +30 -26
- data/lib/jekyll/drops/url_drop.rb +140 -140
- data/lib/jekyll/entry_filter.rb +117 -121
- data/lib/jekyll/errors.rb +20 -20
- data/lib/jekyll/excerpt.rb +200 -201
- data/lib/jekyll/external.rb +75 -79
- data/lib/jekyll/filters/date_filters.rb +110 -110
- data/lib/jekyll/filters/grouping_filters.rb +64 -64
- data/lib/jekyll/filters/url_filters.rb +98 -98
- data/lib/jekyll/filters.rb +532 -535
- data/lib/jekyll/frontmatter_defaults.rb +238 -240
- data/lib/jekyll/generator.rb +5 -5
- data/lib/jekyll/hooks.rb +107 -107
- data/lib/jekyll/inclusion.rb +32 -32
- data/lib/jekyll/layout.rb +55 -67
- data/lib/jekyll/liquid_extensions.rb +22 -22
- data/lib/jekyll/liquid_renderer/file.rb +77 -77
- data/lib/jekyll/liquid_renderer/table.rb +55 -55
- data/lib/jekyll/liquid_renderer.rb +80 -80
- data/lib/jekyll/log_adapter.rb +151 -151
- data/lib/jekyll/mime.types +939 -866
- data/lib/jekyll/page.rb +215 -217
- data/lib/jekyll/page_excerpt.rb +25 -25
- data/lib/jekyll/page_without_a_file.rb +14 -14
- data/lib/jekyll/path_manager.rb +74 -74
- data/lib/jekyll/plugin.rb +92 -92
- data/lib/jekyll/plugin_manager.rb +123 -115
- data/lib/jekyll/profiler.rb +55 -58
- data/lib/jekyll/publisher.rb +23 -23
- data/lib/jekyll/reader.rb +209 -192
- data/lib/jekyll/readers/collection_reader.rb +23 -23
- data/lib/jekyll/readers/data_reader.rb +116 -79
- data/lib/jekyll/readers/layout_reader.rb +62 -62
- data/lib/jekyll/readers/page_reader.rb +25 -25
- data/lib/jekyll/readers/post_reader.rb +85 -85
- data/lib/jekyll/readers/static_file_reader.rb +25 -25
- data/lib/jekyll/readers/theme_assets_reader.rb +52 -52
- data/lib/jekyll/regenerator.rb +195 -195
- data/lib/jekyll/related_posts.rb +52 -52
- data/lib/jekyll/renderer.rb +263 -265
- data/lib/jekyll/site.rb +582 -551
- data/lib/jekyll/static_file.rb +205 -208
- data/lib/jekyll/stevenson.rb +60 -60
- data/lib/jekyll/tags/highlight.rb +114 -110
- data/lib/jekyll/tags/include.rb +275 -275
- data/lib/jekyll/tags/link.rb +42 -42
- data/lib/jekyll/tags/post_url.rb +106 -106
- data/lib/jekyll/theme.rb +90 -86
- data/lib/jekyll/theme_builder.rb +121 -121
- data/lib/jekyll/url.rb +167 -167
- data/lib/jekyll/utils/ansi.rb +57 -57
- data/lib/jekyll/utils/exec.rb +26 -26
- data/lib/jekyll/utils/internet.rb +37 -37
- data/lib/jekyll/utils/platforms.rb +67 -67
- data/lib/jekyll/utils/thread_event.rb +31 -31
- data/lib/jekyll/utils/win_tz.rb +46 -75
- data/lib/jekyll/utils.rb +378 -367
- data/lib/jekyll/version.rb +5 -5
- data/lib/jekyll.rb +197 -195
- data/lib/site_template/.gitignore +5 -5
- data/lib/site_template/404.html +25 -25
- data/lib/site_template/_config.yml +55 -55
- data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +29 -29
- data/lib/site_template/about.markdown +18 -18
- data/lib/site_template/index.markdown +6 -6
- data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -74
- data/lib/theme_template/Gemfile +4 -4
- data/lib/theme_template/LICENSE.txt.erb +21 -21
- data/lib/theme_template/README.md.erb +50 -52
- data/lib/theme_template/_layouts/default.html +1 -1
- data/lib/theme_template/_layouts/page.html +5 -5
- data/lib/theme_template/_layouts/post.html +5 -5
- data/lib/theme_template/example/_config.yml.erb +1 -1
- data/lib/theme_template/example/_post.md +12 -12
- data/lib/theme_template/example/index.html +14 -14
- data/lib/theme_template/example/style.scss +7 -7
- data/lib/theme_template/gitignore.erb +6 -6
- data/lib/theme_template/theme.gemspec.erb +16 -16
- data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -149
- data/rubocop/jekyll/no_p_allowed.rb +23 -23
- data/rubocop/jekyll/no_puts_allowed.rb +23 -23
- data/rubocop/jekyll.rb +5 -5
- metadata +62 -14
@@ -1,32 +1,32 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Drops
|
5
|
-
class JekyllDrop < Liquid::Drop
|
6
|
-
class << self
|
7
|
-
def global
|
8
|
-
@global ||= JekyllDrop.new
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def version
|
13
|
-
Jekyll::VERSION
|
14
|
-
end
|
15
|
-
|
16
|
-
def environment
|
17
|
-
Jekyll.env
|
18
|
-
end
|
19
|
-
|
20
|
-
def to_h
|
21
|
-
@to_h ||= {
|
22
|
-
"version" => version,
|
23
|
-
"environment" => environment,
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
def to_json(state = nil)
|
28
|
-
JSON.generate(to_h, state)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drops
|
5
|
+
class JekyllDrop < Liquid::Drop
|
6
|
+
class << self
|
7
|
+
def global
|
8
|
+
@global ||= JekyllDrop.new
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def version
|
13
|
+
Jekyll::VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
def environment
|
17
|
+
Jekyll.env
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_h
|
21
|
+
@to_h ||= {
|
22
|
+
"version" => version,
|
23
|
+
"environment" => environment,
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_json(state = nil)
|
28
|
+
JSON.generate(to_h, state)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,66 +1,71 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Drops
|
5
|
-
class SiteDrop < Drop
|
6
|
-
extend Forwardable
|
7
|
-
|
8
|
-
mutable false
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
#
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
#
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drops
|
5
|
+
class SiteDrop < Drop
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
mutable false
|
9
|
+
|
10
|
+
delegate_methods :time, :pages, :static_files, :tags, :categories
|
11
|
+
|
12
|
+
private delegate_method_as :config, :fallback_data
|
13
|
+
|
14
|
+
def [](key)
|
15
|
+
if key != "posts" && @obj.collections.key?(key)
|
16
|
+
@obj.collections[key].docs
|
17
|
+
else
|
18
|
+
super(key)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def key?(key)
|
23
|
+
(key != "posts" && @obj.collections.key?(key)) || super
|
24
|
+
end
|
25
|
+
|
26
|
+
def data
|
27
|
+
@obj.site_data.tap do |value|
|
28
|
+
value.context = @context if value.respond_to?(:context=)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def posts
|
33
|
+
@site_posts ||= @obj.posts.docs.sort { |a, b| b <=> a }
|
34
|
+
end
|
35
|
+
|
36
|
+
def html_pages
|
37
|
+
@site_html_pages ||= @obj.pages.select do |page|
|
38
|
+
page.html? || page.url.end_with?("/")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def collections
|
43
|
+
@site_collections ||= @obj.collections.values.sort_by(&:label).map(&:to_liquid)
|
44
|
+
end
|
45
|
+
|
46
|
+
# `Site#documents` cannot be memoized so that `Site#docs_to_write` can access the
|
47
|
+
# latest state of the attribute.
|
48
|
+
#
|
49
|
+
# Since this method will be called after `Site#pre_render` hook, the `Site#documents`
|
50
|
+
# array shouldn't thereafter change and can therefore be safely memoized to prevent
|
51
|
+
# additional computation of `Site#documents`.
|
52
|
+
def documents
|
53
|
+
@documents ||= @obj.documents
|
54
|
+
end
|
55
|
+
|
56
|
+
# `{{ site.related_posts }}` is how posts can get posts related to
|
57
|
+
# them, either through LSI if it's enabled, or through the most
|
58
|
+
# recent posts.
|
59
|
+
# We should remove this in 4.0 and switch to `{{ post.related_posts }}`.
|
60
|
+
def related_posts
|
61
|
+
return nil unless @current_document.is_a?(Jekyll::Document)
|
62
|
+
|
63
|
+
@current_document.related_posts
|
64
|
+
end
|
65
|
+
attr_writer :current_document
|
66
|
+
|
67
|
+
# return nil for `{{ site.config }}` even if --config was passed via CLI
|
68
|
+
def config; end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Drops
|
5
|
-
class StaticFileDrop < Drop
|
6
|
-
extend Forwardable
|
7
|
-
delegate_methods :name, :extname, :modified_time, :basename
|
8
|
-
delegate_method_as :relative_path, :path
|
9
|
-
delegate_method_as :type, :collection
|
10
|
-
|
11
|
-
private delegate_method_as :data, :fallback_data
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drops
|
5
|
+
class StaticFileDrop < Drop
|
6
|
+
extend Forwardable
|
7
|
+
delegate_methods :name, :extname, :modified_time, :basename
|
8
|
+
delegate_method_as :relative_path, :path
|
9
|
+
delegate_method_as :type, :collection
|
10
|
+
|
11
|
+
private delegate_method_as :data, :fallback_data
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drops
|
5
|
+
class ThemeDrop < Drop
|
6
|
+
delegate_methods :root
|
7
|
+
delegate_method_as :runtime_dependencies, :dependencies
|
8
|
+
|
9
|
+
def authors
|
10
|
+
@authors ||= gemspec.authors.join(", ")
|
11
|
+
end
|
12
|
+
|
13
|
+
def version
|
14
|
+
@version ||= gemspec.version.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def description
|
18
|
+
@description ||= gemspec.description || gemspec.summary
|
19
|
+
end
|
20
|
+
|
21
|
+
def metadata
|
22
|
+
@metadata ||= gemspec.metadata
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def gemspec
|
28
|
+
@gemspec ||= @obj.send(:gemspec)
|
29
|
+
end
|
30
|
+
|
31
|
+
def fallback_data
|
32
|
+
@fallback_data ||= {}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,26 +1,30 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Drops
|
5
|
-
class UnifiedPayloadDrop < Drop
|
6
|
-
mutable true
|
7
|
-
|
8
|
-
attr_accessor :
|
9
|
-
|
10
|
-
|
11
|
-
def jekyll
|
12
|
-
JekyllDrop.global
|
13
|
-
end
|
14
|
-
|
15
|
-
def site
|
16
|
-
@site_drop ||= SiteDrop.new(@obj)
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drops
|
5
|
+
class UnifiedPayloadDrop < Drop
|
6
|
+
mutable true
|
7
|
+
|
8
|
+
attr_accessor :content, :page, :layout, :paginator,
|
9
|
+
:highlighter_prefix, :highlighter_suffix
|
10
|
+
|
11
|
+
def jekyll
|
12
|
+
JekyllDrop.global
|
13
|
+
end
|
14
|
+
|
15
|
+
def site
|
16
|
+
@site_drop ||= SiteDrop.new(@obj)
|
17
|
+
end
|
18
|
+
|
19
|
+
def theme
|
20
|
+
@theme_drop ||= ThemeDrop.new(@obj.theme) if @obj.theme
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def fallback_data
|
26
|
+
@fallback_data ||= {}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,140 +1,140 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Drops
|
5
|
-
class UrlDrop < Drop
|
6
|
-
extend Forwardable
|
7
|
-
|
8
|
-
mutable false
|
9
|
-
|
10
|
-
delegate_method :output_ext
|
11
|
-
delegate_method_as :cleaned_relative_path, :path
|
12
|
-
|
13
|
-
def collection
|
14
|
-
@obj.collection.label
|
15
|
-
end
|
16
|
-
|
17
|
-
def name
|
18
|
-
Utils.slugify(@obj.basename_without_ext)
|
19
|
-
end
|
20
|
-
|
21
|
-
def title
|
22
|
-
Utils.slugify(@obj.data["slug"], :mode => "pretty", :cased => true) ||
|
23
|
-
Utils.slugify(@obj.basename_without_ext, :mode => "pretty", :cased => true)
|
24
|
-
end
|
25
|
-
|
26
|
-
def slug
|
27
|
-
Utils.slugify(@obj.data["slug"]) || Utils.slugify(@obj.basename_without_ext)
|
28
|
-
end
|
29
|
-
|
30
|
-
def categories
|
31
|
-
category_set = Set.new
|
32
|
-
Array(@obj.data["categories"]).each do |category|
|
33
|
-
category_set << category.to_s.downcase
|
34
|
-
end
|
35
|
-
category_set.to_a.join("/")
|
36
|
-
end
|
37
|
-
|
38
|
-
# Similar to output from #categories, but each category will be downcased and
|
39
|
-
# all non-alphanumeric characters of the category replaced with a hyphen.
|
40
|
-
def slugified_categories
|
41
|
-
Array(@obj.data["categories"]).each_with_object(Set.new) do |category, set|
|
42
|
-
set << Utils.slugify(category.to_s)
|
43
|
-
end.to_a.join("/")
|
44
|
-
end
|
45
|
-
|
46
|
-
# CCYY
|
47
|
-
def year
|
48
|
-
@obj.date.strftime("%Y")
|
49
|
-
end
|
50
|
-
|
51
|
-
# MM: 01..12
|
52
|
-
def month
|
53
|
-
@obj.date.strftime("%m")
|
54
|
-
end
|
55
|
-
|
56
|
-
# DD: 01..31
|
57
|
-
def day
|
58
|
-
@obj.date.strftime("%d")
|
59
|
-
end
|
60
|
-
|
61
|
-
# hh: 00..23
|
62
|
-
def hour
|
63
|
-
@obj.date.strftime("%H")
|
64
|
-
end
|
65
|
-
|
66
|
-
# mm: 00..59
|
67
|
-
def minute
|
68
|
-
@obj.date.strftime("%M")
|
69
|
-
end
|
70
|
-
|
71
|
-
# ss: 00..59
|
72
|
-
def second
|
73
|
-
@obj.date.strftime("%S")
|
74
|
-
end
|
75
|
-
|
76
|
-
# D: 1..31
|
77
|
-
def i_day
|
78
|
-
@obj.date.strftime("%-d")
|
79
|
-
end
|
80
|
-
|
81
|
-
# M: 1..12
|
82
|
-
def i_month
|
83
|
-
@obj.date.strftime("%-m")
|
84
|
-
end
|
85
|
-
|
86
|
-
# MMM: Jan..Dec
|
87
|
-
def short_month
|
88
|
-
@obj.date.strftime("%b")
|
89
|
-
end
|
90
|
-
|
91
|
-
# MMMM: January..December
|
92
|
-
def long_month
|
93
|
-
@obj.date.strftime("%B")
|
94
|
-
end
|
95
|
-
|
96
|
-
# YY: 00..99
|
97
|
-
def short_year
|
98
|
-
@obj.date.strftime("%y")
|
99
|
-
end
|
100
|
-
|
101
|
-
# CCYYw, ISO week year
|
102
|
-
# may differ from CCYY for the first days of January and last days of December
|
103
|
-
def w_year
|
104
|
-
@obj.date.strftime("%G")
|
105
|
-
end
|
106
|
-
|
107
|
-
# WW: 01..53
|
108
|
-
# %W and %U do not comply with ISO 8601-1
|
109
|
-
def week
|
110
|
-
@obj.date.strftime("%V")
|
111
|
-
end
|
112
|
-
|
113
|
-
# d: 1..7 (Monday..Sunday)
|
114
|
-
def w_day
|
115
|
-
@obj.date.strftime("%u")
|
116
|
-
end
|
117
|
-
|
118
|
-
# dd: Mon..Sun
|
119
|
-
def short_day
|
120
|
-
@obj.date.strftime("%a")
|
121
|
-
end
|
122
|
-
|
123
|
-
# ddd: Monday..Sunday
|
124
|
-
def long_day
|
125
|
-
@obj.date.strftime("%A")
|
126
|
-
end
|
127
|
-
|
128
|
-
# DDD: 001..366
|
129
|
-
def y_day
|
130
|
-
@obj.date.strftime("%j")
|
131
|
-
end
|
132
|
-
|
133
|
-
private
|
134
|
-
|
135
|
-
def fallback_data
|
136
|
-
@fallback_data ||= {}
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drops
|
5
|
+
class UrlDrop < Drop
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
mutable false
|
9
|
+
|
10
|
+
delegate_method :output_ext
|
11
|
+
delegate_method_as :cleaned_relative_path, :path
|
12
|
+
|
13
|
+
def collection
|
14
|
+
@obj.collection.label
|
15
|
+
end
|
16
|
+
|
17
|
+
def name
|
18
|
+
Utils.slugify(@obj.basename_without_ext)
|
19
|
+
end
|
20
|
+
|
21
|
+
def title
|
22
|
+
Utils.slugify(@obj.data["slug"], :mode => "pretty", :cased => true) ||
|
23
|
+
Utils.slugify(@obj.basename_without_ext, :mode => "pretty", :cased => true)
|
24
|
+
end
|
25
|
+
|
26
|
+
def slug
|
27
|
+
Utils.slugify(@obj.data["slug"]) || Utils.slugify(@obj.basename_without_ext)
|
28
|
+
end
|
29
|
+
|
30
|
+
def categories
|
31
|
+
category_set = Set.new
|
32
|
+
Array(@obj.data["categories"]).each do |category|
|
33
|
+
category_set << category.to_s.downcase
|
34
|
+
end
|
35
|
+
category_set.to_a.join("/")
|
36
|
+
end
|
37
|
+
|
38
|
+
# Similar to output from #categories, but each category will be downcased and
|
39
|
+
# all non-alphanumeric characters of the category replaced with a hyphen.
|
40
|
+
def slugified_categories
|
41
|
+
Array(@obj.data["categories"]).each_with_object(Set.new) do |category, set|
|
42
|
+
set << Utils.slugify(category.to_s)
|
43
|
+
end.to_a.join("/")
|
44
|
+
end
|
45
|
+
|
46
|
+
# CCYY
|
47
|
+
def year
|
48
|
+
@obj.date.strftime("%Y")
|
49
|
+
end
|
50
|
+
|
51
|
+
# MM: 01..12
|
52
|
+
def month
|
53
|
+
@obj.date.strftime("%m")
|
54
|
+
end
|
55
|
+
|
56
|
+
# DD: 01..31
|
57
|
+
def day
|
58
|
+
@obj.date.strftime("%d")
|
59
|
+
end
|
60
|
+
|
61
|
+
# hh: 00..23
|
62
|
+
def hour
|
63
|
+
@obj.date.strftime("%H")
|
64
|
+
end
|
65
|
+
|
66
|
+
# mm: 00..59
|
67
|
+
def minute
|
68
|
+
@obj.date.strftime("%M")
|
69
|
+
end
|
70
|
+
|
71
|
+
# ss: 00..59
|
72
|
+
def second
|
73
|
+
@obj.date.strftime("%S")
|
74
|
+
end
|
75
|
+
|
76
|
+
# D: 1..31
|
77
|
+
def i_day
|
78
|
+
@obj.date.strftime("%-d")
|
79
|
+
end
|
80
|
+
|
81
|
+
# M: 1..12
|
82
|
+
def i_month
|
83
|
+
@obj.date.strftime("%-m")
|
84
|
+
end
|
85
|
+
|
86
|
+
# MMM: Jan..Dec
|
87
|
+
def short_month
|
88
|
+
@obj.date.strftime("%b")
|
89
|
+
end
|
90
|
+
|
91
|
+
# MMMM: January..December
|
92
|
+
def long_month
|
93
|
+
@obj.date.strftime("%B")
|
94
|
+
end
|
95
|
+
|
96
|
+
# YY: 00..99
|
97
|
+
def short_year
|
98
|
+
@obj.date.strftime("%y")
|
99
|
+
end
|
100
|
+
|
101
|
+
# CCYYw, ISO week year
|
102
|
+
# may differ from CCYY for the first days of January and last days of December
|
103
|
+
def w_year
|
104
|
+
@obj.date.strftime("%G")
|
105
|
+
end
|
106
|
+
|
107
|
+
# WW: 01..53
|
108
|
+
# %W and %U do not comply with ISO 8601-1
|
109
|
+
def week
|
110
|
+
@obj.date.strftime("%V")
|
111
|
+
end
|
112
|
+
|
113
|
+
# d: 1..7 (Monday..Sunday)
|
114
|
+
def w_day
|
115
|
+
@obj.date.strftime("%u")
|
116
|
+
end
|
117
|
+
|
118
|
+
# dd: Mon..Sun
|
119
|
+
def short_day
|
120
|
+
@obj.date.strftime("%a")
|
121
|
+
end
|
122
|
+
|
123
|
+
# ddd: Monday..Sunday
|
124
|
+
def long_day
|
125
|
+
@obj.date.strftime("%A")
|
126
|
+
end
|
127
|
+
|
128
|
+
# DDD: 001..366
|
129
|
+
def y_day
|
130
|
+
@obj.date.strftime("%j")
|
131
|
+
end
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
def fallback_data
|
136
|
+
@fallback_data ||= {}
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|