jekyll 4.2.1 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +474 -350
  3. data/LICENSE +21 -21
  4. data/README.markdown +83 -86
  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 +186 -190
  12. data/lib/jekyll/cleaner.rb +111 -111
  13. data/lib/jekyll/collection.rb +310 -309
  14. data/lib/jekyll/command.rb +105 -105
  15. data/lib/jekyll/commands/build.rb +82 -93
  16. data/lib/jekyll/commands/clean.rb +44 -45
  17. data/lib/jekyll/commands/doctor.rb +177 -177
  18. data/lib/jekyll/commands/help.rb +34 -34
  19. data/lib/jekyll/commands/new.rb +168 -169
  20. data/lib/jekyll/commands/new_theme.rb +39 -40
  21. data/lib/jekyll/commands/serve/live_reload_reactor.rb +119 -122
  22. data/lib/jekyll/commands/serve/livereload_assets/livereload.js +1183 -1183
  23. data/lib/jekyll/commands/serve/mime_types_charset.json +71 -0
  24. data/lib/jekyll/commands/serve/servlet.rb +206 -202
  25. data/lib/jekyll/commands/serve/websockets.rb +81 -81
  26. data/lib/jekyll/commands/serve.rb +367 -362
  27. data/lib/jekyll/configuration.rb +313 -313
  28. data/lib/jekyll/converter.rb +54 -54
  29. data/lib/jekyll/converters/identity.rb +41 -41
  30. data/lib/jekyll/converters/markdown/kramdown_parser.rb +197 -199
  31. data/lib/jekyll/converters/markdown.rb +113 -113
  32. data/lib/jekyll/converters/smartypants.rb +70 -70
  33. data/lib/jekyll/convertible.rb +257 -257
  34. data/lib/jekyll/data_entry.rb +83 -0
  35. data/lib/jekyll/data_hash.rb +61 -0
  36. data/lib/jekyll/deprecator.rb +50 -50
  37. data/lib/jekyll/document.rb +543 -544
  38. data/lib/jekyll/drops/collection_drop.rb +20 -20
  39. data/lib/jekyll/drops/document_drop.rb +71 -70
  40. data/lib/jekyll/drops/drop.rb +293 -293
  41. data/lib/jekyll/drops/excerpt_drop.rb +23 -19
  42. data/lib/jekyll/drops/jekyll_drop.rb +32 -32
  43. data/lib/jekyll/drops/site_drop.rb +71 -66
  44. data/lib/jekyll/drops/static_file_drop.rb +14 -14
  45. data/lib/jekyll/drops/theme_drop.rb +36 -0
  46. data/lib/jekyll/drops/unified_payload_drop.rb +30 -26
  47. data/lib/jekyll/drops/url_drop.rb +140 -140
  48. data/lib/jekyll/entry_filter.rb +117 -121
  49. data/lib/jekyll/errors.rb +20 -20
  50. data/lib/jekyll/excerpt.rb +200 -201
  51. data/lib/jekyll/external.rb +75 -79
  52. data/lib/jekyll/filters/date_filters.rb +110 -110
  53. data/lib/jekyll/filters/grouping_filters.rb +64 -64
  54. data/lib/jekyll/filters/url_filters.rb +98 -98
  55. data/lib/jekyll/filters.rb +532 -535
  56. data/lib/jekyll/frontmatter_defaults.rb +238 -240
  57. data/lib/jekyll/generator.rb +5 -5
  58. data/lib/jekyll/hooks.rb +107 -107
  59. data/lib/jekyll/inclusion.rb +32 -32
  60. data/lib/jekyll/layout.rb +55 -67
  61. data/lib/jekyll/liquid_extensions.rb +22 -22
  62. data/lib/jekyll/liquid_renderer/file.rb +77 -77
  63. data/lib/jekyll/liquid_renderer/table.rb +55 -55
  64. data/lib/jekyll/liquid_renderer.rb +80 -80
  65. data/lib/jekyll/log_adapter.rb +151 -151
  66. data/lib/jekyll/mime.types +939 -866
  67. data/lib/jekyll/page.rb +215 -217
  68. data/lib/jekyll/page_excerpt.rb +25 -25
  69. data/lib/jekyll/page_without_a_file.rb +14 -14
  70. data/lib/jekyll/path_manager.rb +74 -74
  71. data/lib/jekyll/plugin.rb +92 -92
  72. data/lib/jekyll/plugin_manager.rb +123 -115
  73. data/lib/jekyll/profiler.rb +55 -58
  74. data/lib/jekyll/publisher.rb +23 -23
  75. data/lib/jekyll/reader.rb +209 -192
  76. data/lib/jekyll/readers/collection_reader.rb +23 -23
  77. data/lib/jekyll/readers/data_reader.rb +116 -79
  78. data/lib/jekyll/readers/layout_reader.rb +62 -62
  79. data/lib/jekyll/readers/page_reader.rb +25 -25
  80. data/lib/jekyll/readers/post_reader.rb +85 -85
  81. data/lib/jekyll/readers/static_file_reader.rb +25 -25
  82. data/lib/jekyll/readers/theme_assets_reader.rb +52 -52
  83. data/lib/jekyll/regenerator.rb +195 -195
  84. data/lib/jekyll/related_posts.rb +52 -52
  85. data/lib/jekyll/renderer.rb +263 -265
  86. data/lib/jekyll/site.rb +582 -551
  87. data/lib/jekyll/static_file.rb +205 -208
  88. data/lib/jekyll/stevenson.rb +60 -60
  89. data/lib/jekyll/tags/highlight.rb +114 -110
  90. data/lib/jekyll/tags/include.rb +275 -275
  91. data/lib/jekyll/tags/link.rb +42 -42
  92. data/lib/jekyll/tags/post_url.rb +106 -106
  93. data/lib/jekyll/theme.rb +90 -86
  94. data/lib/jekyll/theme_builder.rb +121 -121
  95. data/lib/jekyll/url.rb +167 -167
  96. data/lib/jekyll/utils/ansi.rb +57 -57
  97. data/lib/jekyll/utils/exec.rb +26 -26
  98. data/lib/jekyll/utils/internet.rb +37 -37
  99. data/lib/jekyll/utils/platforms.rb +67 -67
  100. data/lib/jekyll/utils/thread_event.rb +31 -31
  101. data/lib/jekyll/utils/win_tz.rb +46 -75
  102. data/lib/jekyll/utils.rb +378 -367
  103. data/lib/jekyll/version.rb +5 -5
  104. data/lib/jekyll.rb +197 -195
  105. data/lib/site_template/.gitignore +5 -5
  106. data/lib/site_template/404.html +25 -25
  107. data/lib/site_template/_config.yml +55 -55
  108. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +29 -29
  109. data/lib/site_template/about.markdown +18 -18
  110. data/lib/site_template/index.markdown +6 -6
  111. data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -74
  112. data/lib/theme_template/Gemfile +4 -4
  113. data/lib/theme_template/LICENSE.txt.erb +21 -21
  114. data/lib/theme_template/README.md.erb +50 -52
  115. data/lib/theme_template/_layouts/default.html +1 -1
  116. data/lib/theme_template/_layouts/page.html +5 -5
  117. data/lib/theme_template/_layouts/post.html +5 -5
  118. data/lib/theme_template/example/_config.yml.erb +1 -1
  119. data/lib/theme_template/example/_post.md +12 -12
  120. data/lib/theme_template/example/index.html +14 -14
  121. data/lib/theme_template/example/style.scss +7 -7
  122. data/lib/theme_template/gitignore.erb +6 -6
  123. data/lib/theme_template/theme.gemspec.erb +16 -16
  124. data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -149
  125. data/rubocop/jekyll/no_p_allowed.rb +23 -23
  126. data/rubocop/jekyll/no_puts_allowed.rb +23 -23
  127. data/rubocop/jekyll.rb +5 -5
  128. metadata +62 -14
@@ -1,195 +1,195 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- class Regenerator
5
- attr_reader :site, :metadata, :cache
6
- attr_accessor :disabled
7
- private :disabled, :disabled=
8
-
9
- def initialize(site)
10
- @site = site
11
-
12
- # Read metadata from file
13
- read_metadata
14
-
15
- # Initialize cache to an empty hash
16
- clear_cache
17
- end
18
-
19
- # Checks if a renderable object needs to be regenerated
20
- #
21
- # Returns a boolean.
22
- def regenerate?(document)
23
- return true if disabled
24
-
25
- case document
26
- when Page
27
- regenerate_page?(document)
28
- when Document
29
- regenerate_document?(document)
30
- else
31
- source_path = document.respond_to?(:path) ? document.path : nil
32
- dest_path = document.destination(@site.dest) if document.respond_to?(:destination)
33
- source_modified_or_dest_missing?(source_path, dest_path)
34
- end
35
- end
36
-
37
- # Add a path to the metadata
38
- #
39
- # Returns true, also on failure.
40
- def add(path)
41
- return true unless File.exist?(path)
42
-
43
- metadata[path] = {
44
- "mtime" => File.mtime(path),
45
- "deps" => [],
46
- }
47
- cache[path] = true
48
- end
49
-
50
- # Force a path to regenerate
51
- #
52
- # Returns true.
53
- def force(path)
54
- cache[path] = true
55
- end
56
-
57
- # Clear the metadata and cache
58
- #
59
- # Returns nothing
60
- def clear
61
- @metadata = {}
62
- clear_cache
63
- end
64
-
65
- # Clear just the cache
66
- #
67
- # Returns nothing
68
- def clear_cache
69
- @cache = {}
70
- end
71
-
72
- # Checks if the source has been modified or the
73
- # destination is missing
74
- #
75
- # returns a boolean
76
- def source_modified_or_dest_missing?(source_path, dest_path)
77
- modified?(source_path) || (dest_path && !File.exist?(dest_path))
78
- end
79
-
80
- # Checks if a path's (or one of its dependencies)
81
- # mtime has changed
82
- #
83
- # Returns a boolean.
84
- def modified?(path)
85
- return true if disabled?
86
-
87
- # objects that don't have a path are always regenerated
88
- return true if path.nil?
89
-
90
- # Check for path in cache
91
- return cache[path] if cache.key? path
92
-
93
- if metadata[path]
94
- # If we have seen this file before,
95
- # check if it or one of its dependencies has been modified
96
- existing_file_modified?(path)
97
- else
98
- # If we have not seen this file before, add it to the metadata and regenerate it
99
- add(path)
100
- end
101
- end
102
-
103
- # Add a dependency of a path
104
- #
105
- # Returns nothing.
106
- def add_dependency(path, dependency)
107
- return if metadata[path].nil? || disabled
108
-
109
- unless metadata[path]["deps"].include? dependency
110
- metadata[path]["deps"] << dependency
111
- add(dependency) unless metadata.include?(dependency)
112
- end
113
- regenerate? dependency
114
- end
115
-
116
- # Write the metadata to disk
117
- #
118
- # Returns nothing.
119
- def write_metadata
120
- unless disabled?
121
- Jekyll.logger.debug "Writing Metadata:", ".jekyll-metadata"
122
- File.binwrite(metadata_file, Marshal.dump(metadata))
123
- end
124
- end
125
-
126
- # Produce the absolute path of the metadata file
127
- #
128
- # Returns the String path of the file.
129
- def metadata_file
130
- @metadata_file ||= site.in_source_dir(".jekyll-metadata")
131
- end
132
-
133
- # Check if metadata has been disabled
134
- #
135
- # Returns a Boolean (true for disabled, false for enabled).
136
- def disabled?
137
- self.disabled = !site.incremental? if disabled.nil?
138
- disabled
139
- end
140
-
141
- private
142
-
143
- # Read metadata from the metadata file, if no file is found,
144
- # initialize with an empty hash
145
- #
146
- # Returns the read metadata.
147
- def read_metadata
148
- @metadata =
149
- if !disabled? && File.file?(metadata_file)
150
- content = File.binread(metadata_file)
151
-
152
- begin
153
- Marshal.load(content)
154
- rescue TypeError
155
- SafeYAML.load(content)
156
- rescue ArgumentError => e
157
- Jekyll.logger.warn("Failed to load #{metadata_file}: #{e}")
158
- {}
159
- end
160
- else
161
- {}
162
- end
163
- end
164
-
165
- def regenerate_page?(document)
166
- document.asset_file? || document.data["regenerate"] ||
167
- source_modified_or_dest_missing?(
168
- site.in_source_dir(document.relative_path), document.destination(@site.dest)
169
- )
170
- end
171
-
172
- def regenerate_document?(document)
173
- !document.write? || document.data["regenerate"] ||
174
- source_modified_or_dest_missing?(
175
- document.path, document.destination(@site.dest)
176
- )
177
- end
178
-
179
- def existing_file_modified?(path)
180
- # If one of this file dependencies have been modified,
181
- # set the regeneration bit for both the dependency and the file to true
182
- metadata[path]["deps"].each do |dependency|
183
- return cache[dependency] = cache[path] = true if modified?(dependency)
184
- end
185
-
186
- if File.exist?(path) && metadata[path]["mtime"].eql?(File.mtime(path))
187
- # If this file has not been modified, set the regeneration bit to false
188
- cache[path] = false
189
- else
190
- # If it has been modified, set it to true
191
- add(path)
192
- end
193
- end
194
- end
195
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class Regenerator
5
+ attr_reader :site, :metadata, :cache
6
+ attr_accessor :disabled
7
+ private :disabled, :disabled=
8
+
9
+ def initialize(site)
10
+ @site = site
11
+
12
+ # Read metadata from file
13
+ read_metadata
14
+
15
+ # Initialize cache to an empty hash
16
+ clear_cache
17
+ end
18
+
19
+ # Checks if a renderable object needs to be regenerated
20
+ #
21
+ # Returns a boolean.
22
+ def regenerate?(document)
23
+ return true if disabled
24
+
25
+ case document
26
+ when Page
27
+ regenerate_page?(document)
28
+ when Document
29
+ regenerate_document?(document)
30
+ else
31
+ source_path = document.respond_to?(:path) ? document.path : nil
32
+ dest_path = document.destination(@site.dest) if document.respond_to?(:destination)
33
+ source_modified_or_dest_missing?(source_path, dest_path)
34
+ end
35
+ end
36
+
37
+ # Add a path to the metadata
38
+ #
39
+ # Returns true, also on failure.
40
+ def add(path)
41
+ return true unless File.exist?(path)
42
+
43
+ metadata[path] = {
44
+ "mtime" => File.mtime(path),
45
+ "deps" => [],
46
+ }
47
+ cache[path] = true
48
+ end
49
+
50
+ # Force a path to regenerate
51
+ #
52
+ # Returns true.
53
+ def force(path)
54
+ cache[path] = true
55
+ end
56
+
57
+ # Clear the metadata and cache
58
+ #
59
+ # Returns nothing
60
+ def clear
61
+ @metadata = {}
62
+ clear_cache
63
+ end
64
+
65
+ # Clear just the cache
66
+ #
67
+ # Returns nothing
68
+ def clear_cache
69
+ @cache = {}
70
+ end
71
+
72
+ # Checks if the source has been modified or the
73
+ # destination is missing
74
+ #
75
+ # returns a boolean
76
+ def source_modified_or_dest_missing?(source_path, dest_path)
77
+ modified?(source_path) || (dest_path && !File.exist?(dest_path))
78
+ end
79
+
80
+ # Checks if a path's (or one of its dependencies)
81
+ # mtime has changed
82
+ #
83
+ # Returns a boolean.
84
+ def modified?(path)
85
+ return true if disabled?
86
+
87
+ # objects that don't have a path are always regenerated
88
+ return true if path.nil?
89
+
90
+ # Check for path in cache
91
+ return cache[path] if cache.key? path
92
+
93
+ if metadata[path]
94
+ # If we have seen this file before,
95
+ # check if it or one of its dependencies has been modified
96
+ existing_file_modified?(path)
97
+ else
98
+ # If we have not seen this file before, add it to the metadata and regenerate it
99
+ add(path)
100
+ end
101
+ end
102
+
103
+ # Add a dependency of a path
104
+ #
105
+ # Returns nothing.
106
+ def add_dependency(path, dependency)
107
+ return if metadata[path].nil? || disabled
108
+
109
+ unless metadata[path]["deps"].include? dependency
110
+ metadata[path]["deps"] << dependency
111
+ add(dependency) unless metadata.include?(dependency)
112
+ end
113
+ regenerate? dependency
114
+ end
115
+
116
+ # Write the metadata to disk
117
+ #
118
+ # Returns nothing.
119
+ def write_metadata
120
+ unless disabled?
121
+ Jekyll.logger.debug "Writing Metadata:", ".jekyll-metadata"
122
+ File.binwrite(metadata_file, Marshal.dump(metadata))
123
+ end
124
+ end
125
+
126
+ # Produce the absolute path of the metadata file
127
+ #
128
+ # Returns the String path of the file.
129
+ def metadata_file
130
+ @metadata_file ||= site.in_source_dir(".jekyll-metadata")
131
+ end
132
+
133
+ # Check if metadata has been disabled
134
+ #
135
+ # Returns a Boolean (true for disabled, false for enabled).
136
+ def disabled?
137
+ self.disabled = !site.incremental? if disabled.nil?
138
+ disabled
139
+ end
140
+
141
+ private
142
+
143
+ # Read metadata from the metadata file, if no file is found,
144
+ # initialize with an empty hash
145
+ #
146
+ # Returns the read metadata.
147
+ def read_metadata
148
+ @metadata =
149
+ if !disabled? && File.file?(metadata_file)
150
+ content = File.binread(metadata_file)
151
+
152
+ begin
153
+ Marshal.load(content)
154
+ rescue TypeError
155
+ SafeYAML.load(content)
156
+ rescue ArgumentError => e
157
+ Jekyll.logger.warn("Failed to load #{metadata_file}: #{e}")
158
+ {}
159
+ end
160
+ else
161
+ {}
162
+ end
163
+ end
164
+
165
+ def regenerate_page?(document)
166
+ document.asset_file? || document.data["regenerate"] ||
167
+ source_modified_or_dest_missing?(
168
+ site.in_source_dir(document.relative_path), document.destination(@site.dest)
169
+ )
170
+ end
171
+
172
+ def regenerate_document?(document)
173
+ !document.write? || document.data["regenerate"] ||
174
+ source_modified_or_dest_missing?(
175
+ document.path, document.destination(@site.dest)
176
+ )
177
+ end
178
+
179
+ def existing_file_modified?(path)
180
+ # If one of this file dependencies have been modified,
181
+ # set the regeneration bit for both the dependency and the file to true
182
+ metadata[path]["deps"].each do |dependency|
183
+ return cache[dependency] = cache[path] = true if modified?(dependency)
184
+ end
185
+
186
+ if File.exist?(path) && metadata[path]["mtime"].eql?(File.mtime(path))
187
+ # If this file has not been modified, set the regeneration bit to false
188
+ cache[path] = false
189
+ else
190
+ # If it has been modified, set it to true
191
+ add(path)
192
+ end
193
+ end
194
+ end
195
+ end
@@ -1,52 +1,52 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- class RelatedPosts
5
- class << self
6
- attr_accessor :lsi
7
- end
8
-
9
- attr_reader :post, :site
10
-
11
- def initialize(post)
12
- @post = post
13
- @site = post.site
14
- Jekyll::External.require_with_graceful_fail("classifier-reborn") if site.lsi
15
- end
16
-
17
- def build
18
- return [] unless site.posts.docs.size > 1
19
-
20
- if site.lsi
21
- build_index
22
- lsi_related_posts
23
- else
24
- most_recent_posts
25
- end
26
- end
27
-
28
- def build_index
29
- self.class.lsi ||= begin
30
- lsi = ClassifierReborn::LSI.new(:auto_rebuild => false)
31
- Jekyll.logger.info("Populating LSI...")
32
-
33
- site.posts.docs.each do |x|
34
- lsi.add_item(x)
35
- end
36
-
37
- Jekyll.logger.info("Rebuilding index...")
38
- lsi.build_index
39
- Jekyll.logger.info("")
40
- lsi
41
- end
42
- end
43
-
44
- def lsi_related_posts
45
- self.class.lsi.find_related(post, 11)
46
- end
47
-
48
- def most_recent_posts
49
- @most_recent_posts ||= (site.posts.docs.last(11).reverse! - [post]).first(10)
50
- end
51
- end
52
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class RelatedPosts
5
+ class << self
6
+ attr_accessor :lsi
7
+ end
8
+
9
+ attr_reader :post, :site
10
+
11
+ def initialize(post)
12
+ @post = post
13
+ @site = post.site
14
+ Jekyll::External.require_with_graceful_fail("classifier-reborn") if site.lsi
15
+ end
16
+
17
+ def build
18
+ return [] unless site.posts.docs.size > 1
19
+
20
+ if site.lsi
21
+ build_index
22
+ lsi_related_posts
23
+ else
24
+ most_recent_posts
25
+ end
26
+ end
27
+
28
+ def build_index
29
+ self.class.lsi ||= begin
30
+ lsi = ClassifierReborn::LSI.new(:auto_rebuild => false)
31
+ Jekyll.logger.info("Populating LSI...")
32
+
33
+ site.posts.docs.each do |x|
34
+ lsi.add_item(x)
35
+ end
36
+
37
+ Jekyll.logger.info("Rebuilding index...")
38
+ lsi.build_index
39
+ Jekyll.logger.info("")
40
+ lsi
41
+ end
42
+ end
43
+
44
+ def lsi_related_posts
45
+ self.class.lsi.find_related(post, 11)
46
+ end
47
+
48
+ def most_recent_posts
49
+ @most_recent_posts ||= (site.posts.docs.last(11).reverse! - [post]).first(10)
50
+ end
51
+ end
52
+ end