jekyll 4.2.2 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +150 -26
  3. data/README.markdown +16 -19
  4. data/lib/jekyll/cache.rb +3 -7
  5. data/lib/jekyll/cleaner.rb +1 -1
  6. data/lib/jekyll/collection.rb +1 -0
  7. data/lib/jekyll/commands/build.rb +2 -13
  8. data/lib/jekyll/commands/clean.rb +1 -2
  9. data/lib/jekyll/commands/doctor.rb +13 -13
  10. data/lib/jekyll/commands/new.rb +5 -9
  11. data/lib/jekyll/commands/new_theme.rb +3 -4
  12. data/lib/jekyll/commands/serve/live_reload_reactor.rb +3 -6
  13. data/lib/jekyll/commands/serve/mime_types_charset.json +71 -0
  14. data/lib/jekyll/commands/serve/servlet.rb +13 -9
  15. data/lib/jekyll/commands/serve.rb +23 -18
  16. data/lib/jekyll/configuration.rb +2 -2
  17. data/lib/jekyll/converters/markdown/kramdown_parser.rb +13 -15
  18. data/lib/jekyll/data_entry.rb +83 -0
  19. data/lib/jekyll/data_hash.rb +61 -0
  20. data/lib/jekyll/deprecator.rb +1 -1
  21. data/lib/jekyll/document.rb +2 -3
  22. data/lib/jekyll/drops/document_drop.rb +1 -0
  23. data/lib/jekyll/drops/excerpt_drop.rb +4 -0
  24. data/lib/jekyll/drops/site_drop.rb +6 -1
  25. data/lib/jekyll/drops/theme_drop.rb +36 -0
  26. data/lib/jekyll/drops/unified_payload_drop.rb +6 -2
  27. data/lib/jekyll/entry_filter.rb +2 -6
  28. data/lib/jekyll/excerpt.rb +5 -6
  29. data/lib/jekyll/external.rb +17 -21
  30. data/lib/jekyll/filters.rb +11 -14
  31. data/lib/jekyll/frontmatter_defaults.rb +2 -4
  32. data/lib/jekyll/hooks.rb +2 -2
  33. data/lib/jekyll/layout.rb +8 -20
  34. data/lib/jekyll/mime.types +146 -73
  35. data/lib/jekyll/page.rb +2 -4
  36. data/lib/jekyll/path_manager.rb +7 -7
  37. data/lib/jekyll/plugin_manager.rb +12 -4
  38. data/lib/jekyll/profiler.rb +0 -3
  39. data/lib/jekyll/reader.rb +18 -1
  40. data/lib/jekyll/readers/data_reader.rb +51 -14
  41. data/lib/jekyll/renderer.rb +8 -10
  42. data/lib/jekyll/site.rb +52 -21
  43. data/lib/jekyll/static_file.rb +6 -9
  44. data/lib/jekyll/tags/highlight.rb +13 -9
  45. data/lib/jekyll/tags/include.rb +4 -4
  46. data/lib/jekyll/tags/post_url.rb +5 -5
  47. data/lib/jekyll/theme.rb +6 -2
  48. data/lib/jekyll/theme_builder.rb +1 -1
  49. data/lib/jekyll/url.rb +1 -1
  50. data/lib/jekyll/utils/ansi.rb +1 -1
  51. data/lib/jekyll/utils/win_tz.rb +18 -47
  52. data/lib/jekyll/utils.rb +18 -7
  53. data/lib/jekyll/version.rb +1 -1
  54. data/lib/jekyll.rb +3 -1
  55. data/lib/site_template/_config.yml +1 -1
  56. data/lib/theme_template/README.md.erb +1 -3
  57. metadata +61 -13
@@ -10,8 +10,7 @@ module Jekyll
10
10
  prog.command(:"new-theme") do |c|
11
11
  c.syntax "new-theme NAME"
12
12
  c.description "Creates a new Jekyll theme scaffold"
13
- c.option "code_of_conduct", \
14
- "-c", "--code-of-conduct", \
13
+ c.option "code_of_conduct", "-c", "--code-of-conduct",
15
14
  "Include a Code of Conduct. (defaults to false)"
16
15
 
17
16
  c.action do |args, opts|
@@ -30,8 +29,8 @@ module Jekyll
30
29
  Jekyll.logger.abort_with "Conflict:", "#{theme.path} already exists." if theme.path.exist?
31
30
 
32
31
  theme.create!
33
- Jekyll.logger.info "Your new Jekyll theme, #{theme.name.cyan}," \
34
- " is ready for you in #{theme.path.to_s.cyan}!"
32
+ Jekyll.logger.info "Your new Jekyll theme, #{theme.name.cyan}, " \
33
+ "is ready for you in #{theme.path.to_s.cyan}!"
35
34
  Jekyll.logger.info "For help getting started, read #{theme.path}/README.md."
36
35
  end
37
36
  end
@@ -8,9 +8,7 @@ module Jekyll
8
8
  module Commands
9
9
  class Serve
10
10
  class LiveReloadReactor
11
- attr_reader :started_event
12
- attr_reader :stopped_event
13
- attr_reader :thread
11
+ attr_reader :started_event, :stopped_event, :thread
14
12
 
15
13
  def initialize
16
14
  @websockets = []
@@ -74,8 +72,7 @@ module Jekyll
74
72
  :liveCSS => true
75
73
  )
76
74
 
77
- Jekyll.logger.debug "LiveReload:", "Reloading #{p.url}"
78
- Jekyll.logger.debug "", json_message
75
+ Jekyll.logger.debug "LiveReload:", "Reloading URL #{p.url.inspect}"
79
76
  @websockets.each { |ws| ws.send(json_message) }
80
77
  end
81
78
  end
@@ -113,7 +110,7 @@ module Jekyll
113
110
 
114
111
  def log_error(error)
115
112
  Jekyll.logger.error "LiveReload experienced an error. " \
116
- "Run with --trace for more information."
113
+ "Run with --trace for more information."
117
114
  raise error
118
115
  end
119
116
  end
@@ -0,0 +1,71 @@
1
+ {
2
+ "application/javascript": "UTF-8",
3
+ "application/json": "UTF-8",
4
+ "application/manifest+json": "UTF-8",
5
+ "application/vnd.syncml+xml": "UTF-8",
6
+ "application/vnd.syncml.dm+wbxml": "UTF-8",
7
+ "application/vnd.syncml.dm+xml": "UTF-8",
8
+ "application/vnd.syncml.dmddf+xml": "UTF-8",
9
+ "application/vnd.wap.wbxml": "UTF-8",
10
+ "text/cache-manifest": "UTF-8",
11
+ "text/calendar": "UTF-8",
12
+ "text/coffeescript": "UTF-8",
13
+ "text/css": "UTF-8",
14
+ "text/csv": "UTF-8",
15
+ "text/html": "UTF-8",
16
+ "text/jade": "UTF-8",
17
+ "text/jsx": "UTF-8",
18
+ "text/less": "UTF-8",
19
+ "text/markdown": "UTF-8",
20
+ "text/mathml": "UTF-8",
21
+ "text/mdx": "UTF-8",
22
+ "text/n3": "UTF-8",
23
+ "text/plain": "UTF-8",
24
+ "text/prs.lines.tag": "UTF-8",
25
+ "text/richtext": "UTF-8",
26
+ "text/sgml": "UTF-8",
27
+ "text/shex": "UTF-8",
28
+ "text/slim": "UTF-8",
29
+ "text/spdx": "UTF-8",
30
+ "text/stylus": "UTF-8",
31
+ "text/tab-separated-values": "UTF-8",
32
+ "text/troff": "UTF-8",
33
+ "text/turtle": "UTF-8",
34
+ "text/uri-list": "UTF-8",
35
+ "text/vcard": "UTF-8",
36
+ "text/vnd.curl": "UTF-8",
37
+ "text/vnd.curl.dcurl": "UTF-8",
38
+ "text/vnd.curl.mcurl": "UTF-8",
39
+ "text/vnd.curl.scurl": "UTF-8",
40
+ "text/vnd.familysearch.gedcom": "UTF-8",
41
+ "text/vnd.fly": "UTF-8",
42
+ "text/vnd.fmi.flexstor": "UTF-8",
43
+ "text/vnd.graphviz": "UTF-8",
44
+ "text/vnd.in3d.3dml": "UTF-8",
45
+ "text/vnd.in3d.spot": "UTF-8",
46
+ "text/vnd.sun.j2me.app-descriptor": "UTF-8",
47
+ "text/vnd.wap.wml": "UTF-8",
48
+ "text/vnd.wap.wmlscript": "UTF-8",
49
+ "text/vtt": "UTF-8",
50
+ "text/x-asm": "UTF-8",
51
+ "text/x-c": "UTF-8",
52
+ "text/x-component": "UTF-8",
53
+ "text/x-fortran": "UTF-8",
54
+ "text/x-handlebars-template": "UTF-8",
55
+ "text/x-java-source": "UTF-8",
56
+ "text/x-lua": "UTF-8",
57
+ "text/x-markdown": "UTF-8",
58
+ "text/x-nfo": "UTF-8",
59
+ "text/x-opml": "UTF-8",
60
+ "text/x-pascal": "UTF-8",
61
+ "text/x-processing": "UTF-8",
62
+ "text/x-sass": "UTF-8",
63
+ "text/x-scss": "UTF-8",
64
+ "text/x-setext": "UTF-8",
65
+ "text/x-sfv": "UTF-8",
66
+ "text/x-suse-ymp": "UTF-8",
67
+ "text/x-uuencode": "UTF-8",
68
+ "text/x-vcalendar": "UTF-8",
69
+ "text/x-vcard": "UTF-8",
70
+ "text/yaml": "UTF-8"
71
+ }
@@ -101,7 +101,7 @@ module Jekyll
101
101
  @template ||= ERB.new(<<~TEMPLATE)
102
102
  <script>
103
103
  document.write(
104
- '<script src="http://' +
104
+ '<script src="' + location.protocol + '//' +
105
105
  (location.host || 'localhost').split(':')[0] +
106
106
  ':<%=@options["livereload_port"] %>/livereload.js?snipver=1<%= livereload_args %>"' +
107
107
  '></' +
@@ -128,12 +128,13 @@ module Jekyll
128
128
  class Servlet < WEBrick::HTTPServlet::FileHandler
129
129
  DEFAULTS = {
130
130
  "Cache-Control" => "private, max-age=0, proxy-revalidate, " \
131
- "no-store, no-cache, must-revalidate",
131
+ "no-store, no-cache, must-revalidate",
132
132
  }.freeze
133
133
 
134
134
  def initialize(server, root, callbacks)
135
135
  # So we can access them easily.
136
136
  @jekyll_opts = server.config[:JekyllOptions]
137
+ @mime_types_charset = server.config[:MimeTypesCharset]
137
138
  set_defaults
138
139
  super
139
140
  end
@@ -173,7 +174,7 @@ module Jekyll
173
174
  end
174
175
  end
175
176
 
176
- validate_and_ensure_charset(req, res)
177
+ conditionally_inject_charset(res)
177
178
  res.header.merge!(@headers)
178
179
  rtn
179
180
  end
@@ -181,13 +182,16 @@ module Jekyll
181
182
 
182
183
  private
183
184
 
184
- def validate_and_ensure_charset(_req, res)
185
- key = res.header.keys.grep(%r!content-type!i).first
186
- typ = res.header[key]
185
+ # Inject charset based on Jekyll config only if our mime-types database contains
186
+ # the charset metadata.
187
+ #
188
+ # Refer `script/vendor-mimes` in the repository for further details.
189
+ def conditionally_inject_charset(res)
190
+ typ = res.header["content-type"]
191
+ return unless @mime_types_charset.key?(typ)
192
+ return if %r!;\s*charset=!.match?(typ)
187
193
 
188
- unless %r!;\s*charset=!.match?(typ)
189
- res.header[key] = "#{typ}; charset=#{@jekyll_opts["encoding"]}"
190
- end
194
+ res.header["content-type"] = "#{typ}; charset=#{@jekyll_opts["encoding"]}"
191
195
  end
192
196
 
193
197
  def set_defaults
@@ -21,11 +21,11 @@ module Jekyll
21
21
  "ssl_key" => ["--ssl-key [KEY]", "X.509 (SSL) Private Key."],
22
22
  "port" => ["-P", "--port [PORT]", "Port to listen on"],
23
23
  "show_dir_listing" => ["--show-dir-listing",
24
- "Show a directory listing instead of loading" \
25
- " your index file.",],
24
+ "Show a directory listing instead of loading " \
25
+ "your index file.",],
26
26
  "skip_initial_build" => ["skip_initial_build", "--skip-initial-build",
27
- "Skips the initial site build which occurs before" \
28
- " the server is started.",],
27
+ "Skips the initial site build which occurs before " \
28
+ "the server is started.",],
29
29
  "livereload" => ["-l", "--livereload",
30
30
  "Use LiveReload to automatically refresh browsers",],
31
31
  "livereload_ignore" => ["--livereload-ignore ignore GLOB1[,GLOB2[,...]]",
@@ -113,8 +113,8 @@ module Jekyll
113
113
  def validate_options(opts)
114
114
  if opts["livereload"]
115
115
  if opts["detach"]
116
- Jekyll.logger.warn "Warning:", "--detach and --livereload are mutually exclusive." \
117
- " Choosing --livereload"
116
+ Jekyll.logger.warn "Warning:", "--detach and --livereload are mutually exclusive. " \
117
+ "Choosing --livereload"
118
118
  opts["detach"] = false
119
119
  end
120
120
  if opts["ssl_cert"] || opts["ssl_key"]
@@ -132,9 +132,9 @@ module Jekyll
132
132
  livereload_max_delay
133
133
  livereload_ignore
134
134
  livereload_port).any? { |o| opts[o] }
135
- Jekyll.logger.abort_with "--livereload-min-delay, "\
136
- "--livereload-max-delay, --livereload-ignore, and "\
137
- "--livereload-port require the --livereload option."
135
+ Jekyll.logger.abort_with "--livereload-min-delay, --livereload-max-delay, " \
136
+ "--livereload-ignore, and --livereload-port require " \
137
+ "the --livereload option."
138
138
  end
139
139
  end
140
140
 
@@ -144,9 +144,9 @@ module Jekyll
144
144
  @reload_reactor = LiveReloadReactor.new
145
145
 
146
146
  Jekyll::Hooks.register(:site, :post_render) do |site|
147
- regenerator = Jekyll::Regenerator.new(site)
148
- @changed_pages = site.pages.select do |p|
149
- regenerator.regenerate?(p)
147
+ @changed_pages = []
148
+ site.each_site_file do |item|
149
+ @changed_pages << item if site.regenerator.regenerate?(item)
150
150
  end
151
151
  end
152
152
 
@@ -174,7 +174,8 @@ module Jekyll
174
174
  # Do a base pre-setup of WEBRick so that everything is in place
175
175
  # when we get ready to party, checking for an setting up an error page
176
176
  # and making sure our destination exists.
177
-
177
+ #
178
+ # rubocop:disable Security/IoMethods
178
179
  def setup(destination)
179
180
  require_relative "serve/servlet"
180
181
 
@@ -188,12 +189,14 @@ module Jekyll
188
189
  end
189
190
  end
190
191
  end
192
+ # rubocop:enable Security/IoMethods
191
193
 
192
194
  def webrick_opts(opts)
193
195
  opts = {
194
196
  :JekyllOptions => opts,
195
197
  :DoNotReverseLookup => true,
196
198
  :MimeTypes => mime_types,
199
+ :MimeTypesCharset => mime_types_charset,
197
200
  :DocumentRoot => opts["destination"],
198
201
  :StartCallback => start_callback(opts["detach"]),
199
202
  :StopCallback => stop_callback(opts["detach"]),
@@ -262,8 +265,7 @@ module Jekyll
262
265
  return system "xdg-open", address if Utils::Platforms.linux?
263
266
  return system "open", address if Utils::Platforms.osx?
264
267
 
265
- Jekyll.logger.error "Refusing to launch browser; " \
266
- "Platform launcher unknown."
268
+ Jekyll.logger.error "Refusing to launch browser. Platform launcher unknown."
267
269
  end
268
270
 
269
271
  # Keep in our area with a thread or detach the server as requested
@@ -276,9 +278,8 @@ module Jekyll
276
278
  end
277
279
 
278
280
  Process.detach(pid)
279
- Jekyll.logger.info "Server detached with pid '#{pid}'.", \
280
- "Run `pkill -f jekyll' or `kill -9 #{pid}'" \
281
- " to stop the server."
281
+ Jekyll.logger.info "Server detached with pid '#{pid}'.",
282
+ "Run `pkill -f jekyll' or `kill -9 #{pid}' to stop the server."
282
283
  else
283
284
  t = Thread.new { server.start }
284
285
  trap("INT") { server.shutdown }
@@ -353,6 +354,10 @@ module Jekyll
353
354
  WEBrick::HTTPUtils.load_mime_types(file)
354
355
  end
355
356
 
357
+ def mime_types_charset
358
+ SafeYAML.load_file(File.expand_path("serve/mime_types_charset.json", __dir__))
359
+ end
360
+
356
361
  def read_file(source_dir, file_path)
357
362
  File.read(Jekyll.sanitized_path(source_dir, file_path))
358
363
  end
@@ -304,8 +304,8 @@ module Jekyll
304
304
  return if config["plugins"].is_a?(Array)
305
305
 
306
306
  Jekyll.logger.error "'plugins' should be set as an array of gem-names, but was: " \
307
- "#{config["plugins"].inspect}. Use 'plugins_dir' instead to set the directory " \
308
- "for your non-gemified Ruby plugins."
307
+ "#{config["plugins"].inspect}. Use 'plugins_dir' instead to set " \
308
+ "the directory for your non-gemified Ruby plugins."
309
309
  raise Jekyll::Errors::InvalidConfigurationError,
310
310
  "'plugins' should be set as an array, but was: #{config["plugins"].inspect}."
311
311
  end
@@ -1,4 +1,4 @@
1
- # Frozen-string-literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Kramdown
4
4
  # A Kramdown::Document subclass meant to optimize memory usage from initializing
@@ -125,14 +125,14 @@ module Jekyll
125
125
  Jekyll::External.require_with_graceful_fail("kramdown-syntax-coderay")
126
126
  end
127
127
 
128
- # `mathjax` emgine is bundled within kramdown-2.x and will be handled by
128
+ # `mathjax` engine is bundled within kramdown-2.x and will be handled by
129
129
  # kramdown itself.
130
130
  if (math_engine = @config["math_engine"]) && math_engine != "mathjax"
131
131
  Jekyll::External.require_with_graceful_fail("kramdown-math-#{math_engine}")
132
132
  end
133
133
  end
134
134
 
135
- # config[kramdown][syntax_higlighter] >
135
+ # config[kramdown][syntax_highlighter] >
136
136
  # config[kramdown][enable_coderay] >
137
137
  # config[highlighter]
138
138
  # Where `enable_coderay` is now deprecated because Kramdown
@@ -146,23 +146,21 @@ module Jekyll
146
146
  ]
147
147
  end
148
148
 
149
- @highlighter = begin
150
- if @config.key?("enable_coderay") && @config["enable_coderay"]
151
- Jekyll::Deprecator.deprecation_message(
152
- "You are using 'enable_coderay', " \
153
- "use syntax_highlighter: coderay in your configuration file."
154
- )
149
+ @highlighter = if @config.key?("enable_coderay") && @config["enable_coderay"]
150
+ Jekyll::Deprecator.deprecation_message(
151
+ "You are using 'enable_coderay', " \
152
+ "use syntax_highlighter: coderay in your configuration file."
153
+ )
155
154
 
156
- "coderay"
157
- else
158
- @main_fallback_highlighter
159
- end
160
- end
155
+ "coderay"
156
+ else
157
+ @main_fallback_highlighter
158
+ end
161
159
  end
162
160
 
163
161
  def strip_coderay_prefix(hash)
164
162
  hash.each_with_object({}) do |(key, val), hsh|
165
- cleaned_key = key.to_s.gsub(%r!\Acoderay_!, "")
163
+ cleaned_key = key.to_s.delete_prefix("coderay_")
166
164
 
167
165
  if key != cleaned_key
168
166
  Jekyll::Deprecator.deprecation_message(
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class DataEntry
5
+ attr_accessor :context
6
+ attr_reader :data
7
+
8
+ # Create a Jekyll wrapper for given parsed data object.
9
+ #
10
+ # site - The current Jekyll::Site instance.
11
+ # abs_path - Absolute path to the data source file.
12
+ # parsed_data - Parsed representation of data source file contents.
13
+ #
14
+ # Returns nothing.
15
+ def initialize(site, abs_path, parsed_data)
16
+ @site = site
17
+ @path = abs_path
18
+ @data = parsed_data
19
+ end
20
+
21
+ # Liquid representation of current instance is the parsed data object.
22
+ #
23
+ # Mark as a dependency for regeneration here since every renderable object primarily uses the
24
+ # parsed data object while the parent resource is being rendered by Liquid. Accessing the data
25
+ # object directly via Ruby interface `#[]()` is outside the scope of regeneration.
26
+ #
27
+ # FIXME: Marking as dependency on every call is non-ideal. Optimize at later day.
28
+ #
29
+ # Returns the parsed data object.
30
+ def to_liquid
31
+ add_regenerator_dependencies if incremental_build?
32
+ @data
33
+ end
34
+
35
+ # -- Overrides to maintain backwards compatibility --
36
+
37
+ # Any missing method will be forwarded to the underlying data object stored in the instance
38
+ # variable `@data`.
39
+ def method_missing(method, *args, &block)
40
+ @data.respond_to?(method) ? @data.send(method, *args, &block) : super
41
+ end
42
+
43
+ def respond_to_missing?(method, *)
44
+ @data.respond_to?(method) || super
45
+ end
46
+
47
+ def <=>(other)
48
+ data <=> (other.is_a?(self.class) ? other.data : other)
49
+ end
50
+
51
+ def ==(other)
52
+ data == (other.is_a?(self.class) ? other.data : other)
53
+ end
54
+
55
+ # Explicitly defined to bypass re-routing from `method_missing` hook for greater performance.
56
+ #
57
+ # Returns string representation of parsed data object.
58
+ def inspect
59
+ @data.inspect
60
+ end
61
+
62
+ private
63
+
64
+ def incremental_build?
65
+ @incremental = @site.config["incremental"] if @incremental.nil?
66
+ @incremental
67
+ end
68
+
69
+ def add_regenerator_dependencies
70
+ page = context.registers[:page]
71
+ return unless page&.key?("path")
72
+
73
+ absolute_path = \
74
+ if page["collection"]
75
+ @site.in_source_dir(@site.config["collections_dir"], page["path"])
76
+ else
77
+ @site.in_source_dir(page["path"])
78
+ end
79
+
80
+ @site.regenerator.add_dependency(absolute_path, @path)
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ # A class that behaves very similar to Ruby's `Hash` class yet different in how it is handled by
5
+ # Liquid. This class emulates Hash by delegation instead of inheritance to minimize overridden
6
+ # methods especially since some Hash methods returns another Hash instance instead of the
7
+ # subclass instance.
8
+ class DataHash
9
+ #
10
+ # Delegate given (zero-arity) method(s) to the Hash object stored in instance variable
11
+ # `@registry`.
12
+ # NOTE: Avoiding the use of `Forwardable` module's `def_delegators` for preventing unnecessary
13
+ # creation of interim objects on multiple calls.
14
+ def self.delegate_to_registry(*symbols)
15
+ symbols.each { |sym| define_method(sym) { @registry.send(sym) } }
16
+ end
17
+ private_class_method :delegate_to_registry
18
+
19
+ # -- core instance methods --
20
+
21
+ attr_accessor :context
22
+
23
+ def initialize
24
+ @registry = {}
25
+ end
26
+
27
+ def [](key)
28
+ @registry[key].tap do |value|
29
+ value.context = context if value.respond_to?(:context=)
30
+ end
31
+ end
32
+
33
+ # `Hash#to_liquid` returns the Hash instance itself.
34
+ # Mimic that behavior by returning `self` instead of returning the `@registry` variable value.
35
+ def to_liquid
36
+ self
37
+ end
38
+
39
+ # -- supplementary instance methods to emulate Hash --
40
+
41
+ delegate_to_registry :freeze, :inspect
42
+
43
+ def merge(other, &block)
44
+ merged_registry = @registry.merge(other, &block)
45
+ dup.tap { |d| d.instance_variable_set(:@registry, merged_registry) }
46
+ end
47
+
48
+ def merge!(other, &block)
49
+ @registry.merge!(other, &block)
50
+ self
51
+ end
52
+
53
+ def method_missing(method, *args, &block)
54
+ @registry.send(method, *args, &block)
55
+ end
56
+
57
+ def respond_to_missing?(method, *)
58
+ @registry.respond_to?(method)
59
+ end
60
+ end
61
+ end
@@ -15,7 +15,7 @@ module Jekyll
15
15
  '--watch'."
16
16
  arg_is_present? args, "--no-auto", "To disable auto-replication, simply leave off \
17
17
  the '--watch' switch."
18
- arg_is_present? args, "--pygments", "The 'pygments'settings has been removed in \
18
+ arg_is_present? args, "--pygments", "The 'pygments' settings has been removed in \
19
19
  favour of 'highlighter'."
20
20
  arg_is_present? args, "--paginate", "The 'paginate' setting can only be set in \
21
21
  your config files."
@@ -406,9 +406,8 @@ module Jekyll
406
406
  # Override of method_missing to check in @data for the key.
407
407
  def method_missing(method, *args, &blck)
408
408
  if data.key?(method.to_s)
409
- Jekyll::Deprecator.deprecation_message "Document##{method} is now a key "\
410
- "in the #data hash."
411
- Jekyll::Deprecator.deprecation_message "Called by #{caller(0..0)}."
409
+ Jekyll::Deprecator.deprecation_message "Document##{method} is now a key in the #data hash."
410
+ Jekyll.logger.warn "", "Called by #{caller(1..1)[0]}."
412
411
  data[method.to_s]
413
412
  else
414
413
  super
@@ -12,6 +12,7 @@ module Jekyll
12
12
  mutable false
13
13
 
14
14
  delegate_method_as :relative_path, :path
15
+ delegate_method_as :basename, :name
15
16
  private delegate_method_as :data, :fallback_data
16
17
 
17
18
  delegate_methods :id, :output, :content, :to_s, :relative_path, :url, :date
@@ -14,6 +14,10 @@ module Jekyll
14
14
  def excerpt
15
15
  nil
16
16
  end
17
+
18
+ def name
19
+ @obj.doc.basename
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -7,7 +7,6 @@ module Jekyll
7
7
 
8
8
  mutable false
9
9
 
10
- delegate_method_as :site_data, :data
11
10
  delegate_methods :time, :pages, :static_files, :tags, :categories
12
11
 
13
12
  private delegate_method_as :config, :fallback_data
@@ -24,6 +23,12 @@ module Jekyll
24
23
  (key != "posts" && @obj.collections.key?(key)) || super
25
24
  end
26
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
+
27
32
  def posts
28
33
  @site_posts ||= @obj.posts.docs.sort { |a, b| b <=> a }
29
34
  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
@@ -5,8 +5,8 @@ module Jekyll
5
5
  class UnifiedPayloadDrop < Drop
6
6
  mutable true
7
7
 
8
- attr_accessor :page, :layout, :content, :paginator
9
- attr_accessor :highlighter_prefix, :highlighter_suffix
8
+ attr_accessor :content, :page, :layout, :paginator,
9
+ :highlighter_prefix, :highlighter_suffix
10
10
 
11
11
  def jekyll
12
12
  JekyllDrop.global
@@ -16,6 +16,10 @@ module Jekyll
16
16
  @site_drop ||= SiteDrop.new(@obj)
17
17
  end
18
18
 
19
+ def theme
20
+ @theme_drop ||= ThemeDrop.new(@obj.theme) if @obj.theme
21
+ end
22
+
19
23
  private
20
24
 
21
25
  def fallback_data
@@ -86,14 +86,10 @@ module Jekyll
86
86
  end
87
87
 
88
88
  # --
89
- # NOTE: Pathutil#in_path? gets the realpath.
90
- # @param [<Anything>] entry the entry you want to validate.
91
- # Check if a path is outside of our given root.
89
+ # Check if given path is outside of current site's configured source directory.
92
90
  # --
93
91
  def symlink_outside_site_source?(entry)
94
- !Pathutil.new(entry).in_path?(
95
- site.in_source_dir
96
- )
92
+ !File.realpath(entry).start_with?(site.in_source_dir)
97
93
  end
98
94
 
99
95
  # Check if an entry matches a specific pattern.