jekyll 4.0.1 → 4.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +350 -163
  3. data/LICENSE +21 -21
  4. data/README.markdown +86 -90
  5. data/exe/jekyll +57 -57
  6. data/lib/blank_template/_config.yml +3 -3
  7. data/lib/blank_template/_layouts/default.html +12 -12
  8. data/lib/blank_template/_sass/main.scss +9 -9
  9. data/lib/blank_template/assets/css/main.scss +4 -4
  10. data/lib/blank_template/index.md +8 -8
  11. data/lib/jekyll/cache.rb +190 -190
  12. data/lib/jekyll/cleaner.rb +111 -111
  13. data/lib/jekyll/collection.rb +309 -309
  14. data/lib/jekyll/command.rb +105 -103
  15. data/lib/jekyll/commands/build.rb +93 -93
  16. data/lib/jekyll/commands/clean.rb +45 -45
  17. data/lib/jekyll/commands/doctor.rb +177 -173
  18. data/lib/jekyll/commands/help.rb +34 -34
  19. data/lib/jekyll/commands/new.rb +169 -169
  20. data/lib/jekyll/commands/new_theme.rb +40 -42
  21. data/lib/jekyll/commands/serve/live_reload_reactor.rb +122 -122
  22. data/lib/jekyll/commands/serve/livereload_assets/livereload.js +1183 -1183
  23. data/lib/jekyll/commands/serve/servlet.rb +202 -202
  24. data/lib/jekyll/commands/serve/websockets.rb +81 -81
  25. data/lib/jekyll/commands/serve.rb +362 -354
  26. data/lib/jekyll/configuration.rb +313 -316
  27. data/lib/jekyll/converter.rb +54 -54
  28. data/lib/jekyll/converters/identity.rb +41 -41
  29. data/lib/jekyll/converters/markdown/kramdown_parser.rb +199 -130
  30. data/lib/jekyll/converters/markdown.rb +113 -113
  31. data/lib/jekyll/converters/smartypants.rb +70 -70
  32. data/lib/jekyll/convertible.rb +257 -254
  33. data/lib/jekyll/deprecator.rb +50 -50
  34. data/lib/jekyll/document.rb +544 -522
  35. data/lib/jekyll/drops/collection_drop.rb +20 -20
  36. data/lib/jekyll/drops/document_drop.rb +70 -69
  37. data/lib/jekyll/drops/drop.rb +293 -215
  38. data/lib/jekyll/drops/excerpt_drop.rb +19 -19
  39. data/lib/jekyll/drops/jekyll_drop.rb +32 -32
  40. data/lib/jekyll/drops/site_drop.rb +66 -66
  41. data/lib/jekyll/drops/static_file_drop.rb +14 -14
  42. data/lib/jekyll/drops/unified_payload_drop.rb +26 -26
  43. data/lib/jekyll/drops/url_drop.rb +140 -132
  44. data/lib/jekyll/entry_filter.rb +121 -110
  45. data/lib/jekyll/errors.rb +20 -20
  46. data/lib/jekyll/excerpt.rb +201 -201
  47. data/lib/jekyll/external.rb +79 -79
  48. data/lib/jekyll/filters/date_filters.rb +110 -110
  49. data/lib/jekyll/filters/grouping_filters.rb +64 -64
  50. data/lib/jekyll/filters/url_filters.rb +98 -68
  51. data/lib/jekyll/filters.rb +535 -454
  52. data/lib/jekyll/frontmatter_defaults.rb +240 -245
  53. data/lib/jekyll/generator.rb +5 -5
  54. data/lib/jekyll/hooks.rb +107 -106
  55. data/lib/jekyll/inclusion.rb +32 -0
  56. data/lib/jekyll/layout.rb +67 -62
  57. data/lib/jekyll/liquid_extensions.rb +22 -22
  58. data/lib/jekyll/liquid_renderer/file.rb +77 -77
  59. data/lib/jekyll/liquid_renderer/table.rb +55 -75
  60. data/lib/jekyll/liquid_renderer.rb +80 -77
  61. data/lib/jekyll/log_adapter.rb +151 -151
  62. data/lib/jekyll/mime.types +866 -866
  63. data/lib/jekyll/page.rb +217 -186
  64. data/lib/jekyll/page_excerpt.rb +25 -0
  65. data/lib/jekyll/page_without_a_file.rb +14 -14
  66. data/lib/jekyll/path_manager.rb +74 -31
  67. data/lib/jekyll/plugin.rb +92 -92
  68. data/lib/jekyll/plugin_manager.rb +115 -115
  69. data/lib/jekyll/profiler.rb +58 -0
  70. data/lib/jekyll/publisher.rb +23 -23
  71. data/lib/jekyll/reader.rb +192 -187
  72. data/lib/jekyll/readers/collection_reader.rb +23 -22
  73. data/lib/jekyll/readers/data_reader.rb +79 -75
  74. data/lib/jekyll/readers/layout_reader.rb +62 -61
  75. data/lib/jekyll/readers/page_reader.rb +25 -24
  76. data/lib/jekyll/readers/post_reader.rb +85 -84
  77. data/lib/jekyll/readers/static_file_reader.rb +25 -24
  78. data/lib/jekyll/readers/theme_assets_reader.rb +52 -51
  79. data/lib/jekyll/regenerator.rb +195 -195
  80. data/lib/jekyll/related_posts.rb +52 -52
  81. data/lib/jekyll/renderer.rb +265 -267
  82. data/lib/jekyll/site.rb +551 -527
  83. data/lib/jekyll/static_file.rb +208 -203
  84. data/lib/jekyll/stevenson.rb +60 -60
  85. data/lib/jekyll/tags/highlight.rb +110 -110
  86. data/lib/jekyll/tags/include.rb +275 -221
  87. data/lib/jekyll/tags/link.rb +42 -41
  88. data/lib/jekyll/tags/post_url.rb +106 -107
  89. data/lib/jekyll/theme.rb +86 -80
  90. data/lib/jekyll/theme_builder.rb +121 -121
  91. data/lib/jekyll/url.rb +167 -164
  92. data/lib/jekyll/utils/ansi.rb +57 -57
  93. data/lib/jekyll/utils/exec.rb +26 -26
  94. data/lib/jekyll/utils/internet.rb +37 -37
  95. data/lib/jekyll/utils/platforms.rb +67 -82
  96. data/lib/jekyll/utils/thread_event.rb +31 -31
  97. data/lib/jekyll/utils/win_tz.rb +75 -75
  98. data/lib/jekyll/utils.rb +367 -367
  99. data/lib/jekyll/version.rb +5 -5
  100. data/lib/jekyll.rb +195 -206
  101. data/lib/site_template/.gitignore +5 -5
  102. data/lib/site_template/404.html +25 -25
  103. data/lib/site_template/_config.yml +55 -55
  104. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +29 -29
  105. data/lib/site_template/about.markdown +18 -18
  106. data/lib/site_template/index.markdown +6 -6
  107. data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -74
  108. data/lib/theme_template/Gemfile +4 -4
  109. data/lib/theme_template/LICENSE.txt.erb +21 -21
  110. data/lib/theme_template/README.md.erb +52 -52
  111. data/lib/theme_template/_layouts/default.html +1 -1
  112. data/lib/theme_template/_layouts/page.html +5 -5
  113. data/lib/theme_template/_layouts/post.html +5 -5
  114. data/lib/theme_template/example/_config.yml.erb +1 -1
  115. data/lib/theme_template/example/_post.md +12 -12
  116. data/lib/theme_template/example/index.html +14 -14
  117. data/lib/theme_template/example/style.scss +7 -7
  118. data/lib/theme_template/gitignore.erb +6 -6
  119. data/lib/theme_template/theme.gemspec.erb +16 -19
  120. data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -149
  121. data/rubocop/jekyll/no_p_allowed.rb +23 -23
  122. data/rubocop/jekyll/no_puts_allowed.rb +23 -23
  123. data/rubocop/jekyll.rb +5 -5
  124. metadata +20 -38
data/lib/jekyll/hooks.rb CHANGED
@@ -1,106 +1,107 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- module Hooks
5
- DEFAULT_PRIORITY = 20
6
-
7
- # compatibility layer for octopress-hooks users
8
- PRIORITY_MAP = {
9
- :low => 10,
10
- :normal => 20,
11
- :high => 30,
12
- }.freeze
13
-
14
- # initial empty hooks
15
- @registry = {
16
- :site => {
17
- :after_init => [],
18
- :after_reset => [],
19
- :post_read => [],
20
- :pre_render => [],
21
- :post_render => [],
22
- :post_write => [],
23
- },
24
- :pages => {
25
- :post_init => [],
26
- :pre_render => [],
27
- :post_render => [],
28
- :post_write => [],
29
- },
30
- :posts => {
31
- :post_init => [],
32
- :pre_render => [],
33
- :post_render => [],
34
- :post_write => [],
35
- },
36
- :documents => {
37
- :post_init => [],
38
- :pre_render => [],
39
- :post_render => [],
40
- :post_write => [],
41
- },
42
- :clean => {
43
- :on_obsolete => [],
44
- },
45
- }
46
-
47
- # map of all hooks and their priorities
48
- @hook_priority = {}
49
-
50
- NotAvailable = Class.new(RuntimeError)
51
- Uncallable = Class.new(RuntimeError)
52
-
53
- # register hook(s) to be called later, public API
54
- def self.register(owners, event, priority: DEFAULT_PRIORITY, &block)
55
- Array(owners).each do |owner|
56
- register_one(owner, event, priority_value(priority), &block)
57
- end
58
- end
59
-
60
- # Ensure the priority is a Fixnum
61
- def self.priority_value(priority)
62
- return priority if priority.is_a?(Integer)
63
-
64
- PRIORITY_MAP[priority] || DEFAULT_PRIORITY
65
- end
66
-
67
- # register a single hook to be called later, internal API
68
- def self.register_one(owner, event, priority, &block)
69
- @registry[owner] ||= {
70
- :post_init => [],
71
- :pre_render => [],
72
- :post_render => [],
73
- :post_write => [],
74
- }
75
-
76
- unless @registry[owner][event]
77
- raise NotAvailable, "Invalid hook. #{owner} supports only the " \
78
- "following hooks #{@registry[owner].keys.inspect}"
79
- end
80
-
81
- raise Uncallable, "Hooks must respond to :call" unless block.respond_to? :call
82
-
83
- insert_hook owner, event, priority, &block
84
- end
85
-
86
- def self.insert_hook(owner, event, priority, &block)
87
- @hook_priority[block] = [-priority, @hook_priority.size]
88
- @registry[owner][event] << block
89
- end
90
-
91
- # interface for Jekyll core components to trigger hooks
92
- def self.trigger(owner, event, *args)
93
- # proceed only if there are hooks to call
94
- return unless @registry[owner]
95
- return unless @registry[owner][event]
96
-
97
- # hooks to call for this owner and event
98
- hooks = @registry[owner][event]
99
-
100
- # sort and call hooks according to priority and load order
101
- hooks.sort_by { |h| @hook_priority[h] }.each do |hook|
102
- hook.call(*args)
103
- end
104
- end
105
- end
106
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Hooks
5
+ DEFAULT_PRIORITY = 20
6
+
7
+ # compatibility layer for octopress-hooks users
8
+ PRIORITY_MAP = {
9
+ :low => 10,
10
+ :normal => 20,
11
+ :high => 30,
12
+ }.freeze
13
+
14
+ # initial empty hooks
15
+ @registry = {
16
+ :site => {
17
+ :after_init => [],
18
+ :after_reset => [],
19
+ :post_read => [],
20
+ :pre_render => [],
21
+ :post_render => [],
22
+ :post_write => [],
23
+ },
24
+ :pages => {
25
+ :post_init => [],
26
+ :pre_render => [],
27
+ :post_convert => [],
28
+ :post_render => [],
29
+ :post_write => [],
30
+ },
31
+ :posts => {
32
+ :post_init => [],
33
+ :pre_render => [],
34
+ :post_convert => [],
35
+ :post_render => [],
36
+ :post_write => [],
37
+ },
38
+ :documents => {
39
+ :post_init => [],
40
+ :pre_render => [],
41
+ :post_convert => [],
42
+ :post_render => [],
43
+ :post_write => [],
44
+ },
45
+ :clean => {
46
+ :on_obsolete => [],
47
+ },
48
+ }
49
+
50
+ # map of all hooks and their priorities
51
+ @hook_priority = {}
52
+
53
+ NotAvailable = Class.new(RuntimeError)
54
+ Uncallable = Class.new(RuntimeError)
55
+
56
+ # register hook(s) to be called later, public API
57
+ def self.register(owners, event, priority: DEFAULT_PRIORITY, &block)
58
+ Array(owners).each do |owner|
59
+ register_one(owner, event, priority_value(priority), &block)
60
+ end
61
+ end
62
+
63
+ # Ensure the priority is a Fixnum
64
+ def self.priority_value(priority)
65
+ return priority if priority.is_a?(Integer)
66
+
67
+ PRIORITY_MAP[priority] || DEFAULT_PRIORITY
68
+ end
69
+
70
+ # register a single hook to be called later, internal API
71
+ def self.register_one(owner, event, priority, &block)
72
+ @registry[owner] ||= {
73
+ :post_init => [],
74
+ :pre_render => [],
75
+ :post_convert => [],
76
+ :post_render => [],
77
+ :post_write => [],
78
+ }
79
+
80
+ unless @registry[owner][event]
81
+ raise NotAvailable, "Invalid hook. #{owner} supports only the " \
82
+ "following hooks #{@registry[owner].keys.inspect}"
83
+ end
84
+
85
+ raise Uncallable, "Hooks must respond to :call" unless block.respond_to? :call
86
+
87
+ insert_hook owner, event, priority, &block
88
+ end
89
+
90
+ def self.insert_hook(owner, event, priority, &block)
91
+ @hook_priority[block] = [-priority, @hook_priority.size]
92
+ @registry[owner][event] << block
93
+ end
94
+
95
+ # interface for Jekyll core components to trigger hooks
96
+ def self.trigger(owner, event, *args)
97
+ # proceed only if there are hooks to call
98
+ hooks = @registry.dig(owner, event)
99
+ return if hooks.nil? || hooks.empty?
100
+
101
+ # sort and call hooks according to priority and load order
102
+ hooks.sort_by { |h| @hook_priority[h] }.each do |hook|
103
+ hook.call(*args)
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class Inclusion
5
+ attr_reader :site, :name, :path
6
+ private :site
7
+
8
+ def initialize(site, base, name)
9
+ @site = site
10
+ @name = name
11
+ @path = PathManager.join(base, name)
12
+ end
13
+
14
+ def render(context)
15
+ @template ||= site.liquid_renderer.file(path).parse(content)
16
+ @template.render!(context)
17
+ rescue Liquid::Error => e
18
+ e.template_name = path
19
+ e.markup_context = "included " if e.markup_context.nil?
20
+ raise e
21
+ end
22
+
23
+ def content
24
+ @content ||= File.read(path, **site.file_read_opts)
25
+ end
26
+
27
+ def inspect
28
+ "#{self.class} #{path.inspect}"
29
+ end
30
+ alias_method :to_s, :inspect
31
+ end
32
+ end
data/lib/jekyll/layout.rb CHANGED
@@ -1,62 +1,67 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- class Layout
5
- include Convertible
6
-
7
- # Gets the Site object.
8
- attr_reader :site
9
-
10
- # Gets the name of this layout.
11
- attr_reader :name
12
-
13
- # Gets the path to this layout.
14
- attr_reader :path
15
-
16
- # Gets the path to this layout relative to its base
17
- attr_reader :relative_path
18
-
19
- # Gets/Sets the extension of this layout.
20
- attr_accessor :ext
21
-
22
- # Gets/Sets the Hash that holds the metadata for this layout.
23
- attr_accessor :data
24
-
25
- # Gets/Sets the content of this layout.
26
- attr_accessor :content
27
-
28
- # Initialize a new Layout.
29
- #
30
- # site - The Site.
31
- # base - The String path to the source.
32
- # name - The String filename of the post file.
33
- def initialize(site, base, name)
34
- @site = site
35
- @base = base
36
- @name = name
37
-
38
- if site.theme && site.theme.layouts_path.eql?(base)
39
- @base_dir = site.theme.root
40
- @path = site.in_theme_dir(base, name)
41
- else
42
- @base_dir = site.source
43
- @path = site.in_source_dir(base, name)
44
- end
45
- @relative_path = @path.sub(@base_dir, "")
46
-
47
- self.data = {}
48
-
49
- process(name)
50
- read_yaml(base, name)
51
- end
52
-
53
- # Extract information from the layout filename.
54
- #
55
- # name - The String filename of the layout file.
56
- #
57
- # Returns nothing.
58
- def process(name)
59
- self.ext = File.extname(name)
60
- end
61
- end
62
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class Layout
5
+ include Convertible
6
+
7
+ # Gets the Site object.
8
+ attr_reader :site
9
+
10
+ # Gets the name of this layout.
11
+ attr_reader :name
12
+
13
+ # Gets the path to this layout.
14
+ attr_reader :path
15
+
16
+ # Gets the path to this layout relative to its base
17
+ attr_reader :relative_path
18
+
19
+ # Gets/Sets the extension of this layout.
20
+ attr_accessor :ext
21
+
22
+ # Gets/Sets the Hash that holds the metadata for this layout.
23
+ attr_accessor :data
24
+
25
+ # Gets/Sets the content of this layout.
26
+ attr_accessor :content
27
+
28
+ # Initialize a new Layout.
29
+ #
30
+ # site - The Site.
31
+ # base - The String path to the source.
32
+ # name - The String filename of the post file.
33
+ def initialize(site, base, name)
34
+ @site = site
35
+ @base = base
36
+ @name = name
37
+
38
+ if site.theme && site.theme.layouts_path.eql?(base)
39
+ @base_dir = site.theme.root
40
+ @path = site.in_theme_dir(base, name)
41
+ else
42
+ @base_dir = site.source
43
+ @path = site.in_source_dir(base, name)
44
+ end
45
+ @relative_path = @path.sub(@base_dir, "")
46
+
47
+ self.data = {}
48
+
49
+ process(name)
50
+ read_yaml(base, name)
51
+ end
52
+
53
+ # Extract information from the layout filename.
54
+ #
55
+ # name - The String filename of the layout file.
56
+ #
57
+ # Returns nothing.
58
+ def process(name)
59
+ self.ext = File.extname(name)
60
+ end
61
+
62
+ # Returns the object as a debug String.
63
+ def inspect
64
+ "#<#{self.class} @path=#{@path.inspect}>"
65
+ end
66
+ end
67
+ end
@@ -1,22 +1,22 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- module LiquidExtensions
5
- # Lookup a Liquid variable in the given context.
6
- #
7
- # context - the Liquid context in question.
8
- # variable - the variable name, as a string.
9
- #
10
- # Returns the value of the variable in the context
11
- # or the variable name if not found.
12
- def lookup_variable(context, variable)
13
- lookup = context
14
-
15
- variable.split(".").each do |value|
16
- lookup = lookup[value]
17
- end
18
-
19
- lookup || variable
20
- end
21
- end
22
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module LiquidExtensions
5
+ # Lookup a Liquid variable in the given context.
6
+ #
7
+ # context - the Liquid context in question.
8
+ # variable - the variable name, as a string.
9
+ #
10
+ # Returns the value of the variable in the context
11
+ # or the variable name if not found.
12
+ def lookup_variable(context, variable)
13
+ lookup = context
14
+
15
+ variable.split(".").each do |value|
16
+ lookup = lookup[value]
17
+ end
18
+
19
+ lookup || variable
20
+ end
21
+ end
22
+ end
@@ -1,77 +1,77 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- class LiquidRenderer
5
- class File
6
- def initialize(renderer, filename)
7
- @renderer = renderer
8
- @filename = filename
9
- end
10
-
11
- def parse(content)
12
- measure_time do
13
- @renderer.cache[@filename] ||= Liquid::Template.parse(content, :line_numbers => true)
14
- end
15
- @template = @renderer.cache[@filename]
16
-
17
- self
18
- end
19
-
20
- def render(*args)
21
- reset_template_assigns
22
-
23
- measure_time do
24
- measure_bytes do
25
- measure_counts do
26
- @template.render(*args)
27
- end
28
- end
29
- end
30
- end
31
-
32
- # This method simply 'rethrows any error' before attempting to render the template.
33
- def render!(*args)
34
- reset_template_assigns
35
-
36
- measure_time do
37
- measure_bytes do
38
- measure_counts do
39
- @template.render!(*args)
40
- end
41
- end
42
- end
43
- end
44
-
45
- def warnings
46
- @template.warnings
47
- end
48
-
49
- private
50
-
51
- # clear assigns to `Liquid::Template` instance prior to rendering since
52
- # `Liquid::Template` instances are cached in Jekyll 4.
53
- def reset_template_assigns
54
- @template.instance_assigns.clear
55
- end
56
-
57
- def measure_counts
58
- @renderer.increment_count(@filename)
59
- yield
60
- end
61
-
62
- def measure_bytes
63
- yield.tap do |str|
64
- @renderer.increment_bytes(@filename, str.bytesize)
65
- end
66
- end
67
-
68
- def measure_time
69
- before = Time.now
70
- yield
71
- ensure
72
- after = Time.now
73
- @renderer.increment_time(@filename, after - before)
74
- end
75
- end
76
- end
77
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class LiquidRenderer
5
+ class File
6
+ def initialize(renderer, filename)
7
+ @renderer = renderer
8
+ @filename = filename
9
+ end
10
+
11
+ def parse(content)
12
+ measure_time do
13
+ @renderer.cache[@filename] ||= Liquid::Template.parse(content, :line_numbers => true)
14
+ end
15
+ @template = @renderer.cache[@filename]
16
+
17
+ self
18
+ end
19
+
20
+ def render(*args)
21
+ reset_template_assigns
22
+
23
+ measure_time do
24
+ measure_bytes do
25
+ measure_counts do
26
+ @template.render(*args)
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ # This method simply 'rethrows any error' before attempting to render the template.
33
+ def render!(*args)
34
+ reset_template_assigns
35
+
36
+ measure_time do
37
+ measure_bytes do
38
+ measure_counts do
39
+ @template.render!(*args)
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ def warnings
46
+ @template.warnings
47
+ end
48
+
49
+ private
50
+
51
+ # clear assigns to `Liquid::Template` instance prior to rendering since
52
+ # `Liquid::Template` instances are cached in Jekyll 4.
53
+ def reset_template_assigns
54
+ @template.instance_assigns.clear
55
+ end
56
+
57
+ def measure_counts
58
+ @renderer.increment_count(@filename)
59
+ yield
60
+ end
61
+
62
+ def measure_bytes
63
+ yield.tap do |str|
64
+ @renderer.increment_bytes(@filename, str.bytesize)
65
+ end
66
+ end
67
+
68
+ def measure_time
69
+ before = Time.now
70
+ yield
71
+ ensure
72
+ after = Time.now
73
+ @renderer.increment_time(@filename, after - before)
74
+ end
75
+ end
76
+ end
77
+ end