jekyll 3.2.1 → 3.3.0.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jekyll might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 623eb4b161f9348d78dc2ea345b5a6cc4da0297b
4
- data.tar.gz: 3420c64ceca3753c2c0830c158c8269bd6c92211
3
+ metadata.gz: 0f37d320b2fa6347d5fd020d17cf815ba0fcd32a
4
+ data.tar.gz: 6832433b42442d9eed559699b6a49078425bd537
5
5
  SHA512:
6
- metadata.gz: ca9f677cb215ab07b323ab6d8245f87c3859b57eec6b21473cc8ec21eaae5475373f0779040ff022dc187013a6cb4053e45f16d0295c12a2b054f09a30dae9bf
7
- data.tar.gz: 21301e3cc0088ef1ffba069aa0b7d19b59ffb3bfed86b575efb29fb69fb467dc51dc0a35e2ecd2db338cddc06359271d3be6a5fa25d599bf86491d82b256c00c
6
+ metadata.gz: c02a41ead91f7f078cd3333efb390623d214110523b6e86cdf5fad590e01d150629d7dea302220ffdc595eea72d53ffffea34eef2cb62173812fb833f894ff43
7
+ data.tar.gz: 521abff35bc9f59edee2737440ee700e50508da2b11e6a0af33360e4ffb31318b0cbb2ea19a94828be179d4d93fbc5d7a82b2bbb6433f373f05a30cc8fd885ae
@@ -4,8 +4,6 @@ AllCops:
4
4
  Include:
5
5
  - lib/**/*.rb
6
6
  Exclude:
7
- - lib/jekyll/convertible.rb
8
- - lib/jekyll/document.rb
9
7
  - lib/jekyll/renderer.rb
10
8
  - bin/**/*
11
9
  - benchmark/**/*
@@ -18,14 +16,14 @@ Lint/UnreachableCode:
18
16
  Lint/UselessAccessModifier:
19
17
  Enabled: false
20
18
  Metrics/AbcSize:
21
- Max: 20
19
+ Max: 21
22
20
  Metrics/ClassLength:
23
21
  Exclude:
24
22
  - !ruby/regexp /features\/.*.rb$/
25
23
  - !ruby/regexp /test\/.*.rb$/
26
24
  Max: 300
27
25
  Metrics/CyclomaticComplexity:
28
- Max: 8
26
+ Max: 9
29
27
  Metrics/LineLength:
30
28
  Exclude:
31
29
  - !ruby/regexp /features\/.*.rb/
data/exe/jekyll CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  STDOUT.sync = true
3
3
 
4
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w(.. lib)))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
5
5
 
6
6
  require "jekyll"
7
7
  require "mercenary"
@@ -41,7 +41,6 @@ module Jekyll
41
41
  autoload :Convertible, "jekyll/convertible"
42
42
  autoload :Deprecator, "jekyll/deprecator"
43
43
  autoload :Document, "jekyll/document"
44
- autoload :Draft, "jekyll/draft"
45
44
  autoload :EntryFilter, "jekyll/entry_filter"
46
45
  autoload :Errors, "jekyll/errors"
47
46
  autoload :Excerpt, "jekyll/excerpt"
@@ -55,6 +54,7 @@ module Jekyll
55
54
  autoload :PostReader, "jekyll/readers/post_reader"
56
55
  autoload :PageReader, "jekyll/readers/page_reader"
57
56
  autoload :StaticFileReader, "jekyll/readers/static_file_reader"
57
+ autoload :ThemeAssetsReader, "jekyll/readers/theme_assets_reader"
58
58
  autoload :LogAdapter, "jekyll/log_adapter"
59
59
  autoload :Page, "jekyll/page"
60
60
  autoload :PluginManager, "jekyll/plugin_manager"
@@ -160,11 +160,13 @@ module Jekyll
160
160
 
161
161
  questionable_path.insert(0, "/") if questionable_path.start_with?("~")
162
162
  clean_path = File.expand_path(questionable_path, "/")
163
- clean_path.sub!(%r!\A\w:/!, "/")
164
163
 
165
- if clean_path.start_with?(base_directory.sub(%r!\A\w:/!, "/"))
164
+ return clean_path if clean_path.eql?(base_directory)
165
+
166
+ if clean_path.start_with?(base_directory.sub(%r!\z!, "/"))
166
167
  clean_path
167
168
  else
169
+ clean_path.sub!(%r!\A\w:/!, "/")
168
170
  File.join(base_directory, clean_path)
169
171
  end
170
172
  end
@@ -71,12 +71,23 @@ module Jekyll
71
71
  #
72
72
  # Returns nothing.
73
73
  def watch(site, options)
74
- External.require_with_graceful_fail "jekyll-watch"
75
- watch_method = Jekyll::Watcher.method(:watch)
76
- if watch_method.parameters.size == 1
77
- watch_method.call(options)
74
+ if Utils::Platforms.windows?
75
+ Jekyll.logger.warn "", "--watch arg is unsupported on Windows. "
76
+ Jekyll.logger.warn "", "If you are on Windows Bash, please see: " \
77
+ "https://github.com/Microsoft/BashOnWindows/issues/216"
78
+
78
79
  else
79
- watch_method.call(options, site)
80
+ External.require_with_graceful_fail "jekyll-watch"
81
+ watch_method = Jekyll::Watcher.method(:watch)
82
+ if watch_method.parameters.size == 1
83
+ watch_method.call(
84
+ options
85
+ )
86
+ else
87
+ watch_method.call(
88
+ options, site
89
+ )
90
+ end
80
91
  end
81
92
  end
82
93
  end # end of class << self
@@ -11,6 +11,7 @@ module Jekyll
11
11
 
12
12
  c.option "force", "--force", "Force creation even if PATH already exists"
13
13
  c.option "blank", "--blank", "Creates scaffolding but with empty files"
14
+ c.option "skip-bundle", "--skip-bundle", "Skip 'bundle install'"
14
15
 
15
16
  c.action do |args, options|
16
17
  Jekyll::Commands::New.process(args, options)
@@ -34,7 +35,7 @@ module Jekyll
34
35
  create_site new_blog_path
35
36
  end
36
37
 
37
- Jekyll.logger.info "New jekyll site installed in #{new_blog_path}."
38
+ after_install(new_blog_path, options)
38
39
  end
39
40
 
40
41
  def create_blank_site(path)
@@ -80,9 +81,9 @@ gem "minima"
80
81
  # gem "github-pages", group: :jekyll_plugins
81
82
 
82
83
  # If you have any plugins, put them here!
83
- # group :jekyll_plugins do
84
- # gem "jekyll-github-metadata", "~> 1.0"
85
- # end
84
+ group :jekyll_plugins do
85
+ gem "jekyll-feed", "~> 0.6"
86
+ end
86
87
  RUBY
87
88
  end
88
89
 
@@ -114,6 +115,31 @@ RUBY
114
115
  def scaffold_path
115
116
  "_posts/0000-00-00-welcome-to-jekyll.markdown.erb"
116
117
  end
118
+
119
+ # After a new blog has been created, print a success notification and
120
+ # then automatically execute bundle install from within the new blog dir
121
+ # unless the user opts to generate a blank blog or skip 'bundle install'.
122
+
123
+ def after_install(path, options = {})
124
+ Jekyll.logger.info "New jekyll site installed in #{path.cyan}."
125
+ Jekyll.logger.info "Bundle install skipped." if options["skip-bundle"]
126
+
127
+ unless options["blank"] || options["skip-bundle"]
128
+ bundle_install path
129
+ end
130
+ end
131
+
132
+ def bundle_install(path)
133
+ Jekyll::External.require_with_graceful_fail "bundler"
134
+ Jekyll.logger.info "Running bundle install in #{path.cyan}..."
135
+ Dir.chdir(path) do
136
+ if ENV["CI"]
137
+ system("bundle", "install", "--quiet")
138
+ else
139
+ system("bundle", "install")
140
+ end
141
+ end
142
+ end
117
143
  end
118
144
  end
119
145
  end
@@ -16,6 +16,7 @@ class Jekyll::Commands::NewTheme < Jekyll::Command
16
16
  end
17
17
  end
18
18
 
19
+ # rubocop:disable Metrics/AbcSize
19
20
  def process(args, opts)
20
21
  if !args || args.empty?
21
22
  raise Jekyll::Errors::InvalidThemeName, "You must specify a theme name."
@@ -28,9 +29,10 @@ class Jekyll::Commands::NewTheme < Jekyll::Command
28
29
  end
29
30
 
30
31
  theme.create!
31
- Jekyll.logger.info "Your new Jekyll theme, #{theme.name}," \
32
- " is ready for you in #{theme.path}!"
32
+ Jekyll.logger.info "Your new Jekyll theme, #{theme.name.cyan}," \
33
+ " is ready for you in #{theme.path.to_s.cyan}!"
33
34
  Jekyll.logger.info "For help getting started, read #{theme.path}/README.md."
34
35
  end
36
+ # rubocop:enable Metrics/AbcSize
35
37
  end
36
38
  end
@@ -33,6 +33,7 @@ module Jekyll
33
33
  opts["serving"] = true
34
34
  opts["watch" ] = true unless opts.key?("watch")
35
35
  config = opts["config"]
36
+ opts["url"] = default_url(opts) if Jekyll.env == "development"
36
37
  Build.process(opts)
37
38
  opts["config"] = config
38
39
  Serve.process(opts)
@@ -47,11 +48,7 @@ module Jekyll
47
48
  destination = opts["destination"]
48
49
  setup(destination)
49
50
 
50
- server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") }
51
- server.mount(opts["baseurl"], Servlet, destination, file_handler_opts)
52
- Jekyll.logger.info "Server address:", server_address(server, opts)
53
- launch_browser server, opts if opts["open_url"]
54
- boot_or_detach server, opts
51
+ start_up_webrick(opts, destination)
55
52
  end
56
53
 
57
54
  # Do a base pre-setup of WEBRick so that everything is in place
@@ -101,6 +98,22 @@ module Jekyll
101
98
  opts
102
99
  end
103
100
 
101
+ #
102
+
103
+ private
104
+ def start_up_webrick(opts, destination)
105
+ server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") }
106
+ server.mount(opts["baseurl"], Servlet, destination, file_handler_opts)
107
+ Jekyll.logger.info "Server address:", server_address(
108
+ server.config[:SSLEnable],
109
+ server.config[:BindAddress],
110
+ server.config[:Port],
111
+ opts["baseurl"]
112
+ )
113
+ launch_browser server, opts if opts["open_url"]
114
+ boot_or_detach server, opts
115
+ end
116
+
104
117
  # Recreate NondisclosureName under utf-8 circumstance
105
118
 
106
119
  private
@@ -116,17 +129,29 @@ module Jekyll
116
129
  #
117
130
 
118
131
  private
119
- def server_address(server, opts)
132
+ def server_address(prefix, address, port, baseurl = nil)
120
133
  format("%{prefix}://%{address}:%{port}%{baseurl}", {
121
- :prefix => server.config[:SSLEnable] ? "https" : "http",
122
- :baseurl => opts["baseurl"] ? "#{opts["baseurl"]}/" : "",
123
- :address => server.config[:BindAddress],
124
- :port => server.config[:Port]
134
+ :prefix => prefix ? "https" : "http",
135
+ :address => address,
136
+ :port => port,
137
+ :baseurl => baseurl ? "#{baseurl}/" : ""
125
138
  })
126
139
  end
127
140
 
128
141
  #
129
142
 
143
+ private
144
+ def default_url(opts)
145
+ config = configuration_from_options(opts)
146
+ server_address(
147
+ config["ssl_cert"] && config["ssl_key"],
148
+ config["host"] == "127.0.0.1" ? "localhost" : config["host"],
149
+ config["port"]
150
+ )
151
+ end
152
+
153
+ #
154
+
130
155
  private
131
156
  def launch_browser(server, opts)
132
157
  address = server_address(server, opts)
@@ -17,7 +17,7 @@ module Jekyll
17
17
  # Handling Reading
18
18
  "safe" => false,
19
19
  "include" => [".htaccess"],
20
- "exclude" => [],
20
+ "exclude" => %w(node_modules vendor),
21
21
  "keep_files" => [".git", ".svn"],
22
22
  "encoding" => "utf-8",
23
23
  "markdown_ext" => "markdown,mkdown,mkdn,mkd,md",
@@ -104,7 +104,7 @@ module Jekyll
104
104
 
105
105
  private
106
106
  def modernize_coderay_config
107
- if highlighter == "coderay"
107
+ unless @config["coderay"].empty?
108
108
  Jekyll::Deprecator.deprecation_message(
109
109
  "You are using 'kramdown.coderay' in your configuration, " \
110
110
  "please use 'syntax_highlighter_opts' instead."
@@ -35,6 +35,7 @@ module Jekyll
35
35
  # opts - optional parameter to File.read, default at site configs
36
36
  #
37
37
  # Returns nothing.
38
+ # rubocop:disable Metrics/AbcSize
38
39
  def read_yaml(base, name, opts = {})
39
40
  filename = File.join(base, name)
40
41
 
@@ -58,6 +59,7 @@ module Jekyll
58
59
 
59
60
  self.data
60
61
  end
62
+ # rubocop:enable Metrics/AbcSize
61
63
 
62
64
  def validate_data!(filename)
63
65
  unless self.data.is_a?(Hash)
@@ -76,18 +78,7 @@ module Jekyll
76
78
  #
77
79
  # Returns the transformed contents.
78
80
  def transform
79
- converters.reduce(content) do |output, converter|
80
- begin
81
- converter.convert output
82
- rescue => e
83
- Jekyll.logger.error(
84
- "Conversion error:",
85
- "#{converter.class} encountered an error while converting '#{path}':"
86
- )
87
- Jekyll.logger.error("", e.to_s)
88
- raise e
89
- end
90
- end
81
+ _renderer.transform
91
82
  end
92
83
 
93
84
  # Determine the extension depending on content_type.
@@ -95,7 +86,7 @@ module Jekyll
95
86
  # Returns the String extension for the output file.
96
87
  # e.g. ".html" for an HTML output file.
97
88
  def output_ext
98
- Jekyll::Renderer.new(site, self).output_ext
89
+ _renderer.output_ext
99
90
  end
100
91
 
101
92
  # Determine which converter to use based on this convertible's
@@ -103,7 +94,7 @@ module Jekyll
103
94
  #
104
95
  # Returns the Converter instance.
105
96
  def converters
106
- @converters ||= site.converters.select { |c| c.matches(ext) }.sort
97
+ _renderer.converters
107
98
  end
108
99
 
109
100
  # Render Liquid in the content
@@ -114,17 +105,7 @@ module Jekyll
114
105
  #
115
106
  # Returns the converted content
116
107
  def render_liquid(content, payload, info, path)
117
- template = site.liquid_renderer.file(path).parse(content)
118
- template.warnings.each do |e|
119
- Jekyll.logger.warn "Liquid Warning:",
120
- LiquidRenderer.format_error(e, path || self.path)
121
- end
122
- template.render!(payload, info)
123
- # rubocop: disable RescueException
124
- rescue Exception => e
125
- Jekyll.logger.error "Liquid Exception:",
126
- LiquidRenderer.format_error(e, path || self.path)
127
- raise e
108
+ _renderer.render_liquid(content, payload, info, path)
128
109
  end
129
110
  # rubocop: enable RescueException
130
111
 
@@ -211,40 +192,10 @@ module Jekyll
211
192
  #
212
193
  # Returns nothing
213
194
  def render_all_layouts(layouts, payload, info)
214
- # recursively render layouts
215
- layout = layouts[data["layout"]]
216
-
217
- Jekyll.logger.warn(
218
- "Build Warning:",
219
- "Layout '#{data["layout"]}' requested in #{path} does not exist."
220
- ) if invalid_layout? layout
221
-
222
- used = Set.new([layout])
223
-
224
- # Reset the payload layout data to ensure it starts fresh for each page.
225
- payload["layout"] = nil
226
-
227
- while layout
228
- Jekyll.logger.debug "Rendering Layout:", path
229
- payload["content"] = output
230
- payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {})
231
-
232
- self.output = render_liquid(layout.content,
233
- payload,
234
- info,
235
- layout.relative_path)
236
-
237
- # Add layout to dependency tree
238
- site.regenerator.add_dependency(
239
- site.in_source_dir(path),
240
- site.in_source_dir(layout.path)
241
- )
242
-
243
- if (layout = layouts[layout.data["layout"]])
244
- break if used.include?(layout)
245
- used << layout
246
- end
247
- end
195
+ _renderer.layouts = layouts
196
+ self.output = _renderer.place_in_layouts(output, payload, info)
197
+ ensure
198
+ @_renderer = nil # this will allow the modifications above to disappear
248
199
  end
249
200
 
250
201
  # Add any necessary layouts to this convertible document.
@@ -254,32 +205,15 @@ module Jekyll
254
205
  #
255
206
  # Returns nothing.
256
207
  def do_layout(payload, layouts)
257
- Jekyll.logger.debug "Rendering:", self.relative_path
258
-
259
- Jekyll.logger.debug "Pre-Render Hooks:", self.relative_path
260
- Jekyll::Hooks.trigger hook_owner, :pre_render, self, payload
261
- info = {
262
- :filters => [Jekyll::Filters],
263
- :registers => { :site => site, :page => payload["page"] }
264
- }
208
+ self.output = _renderer.tap do |renderer|
209
+ renderer.layouts = layouts
210
+ renderer.payload = payload
211
+ end.run
265
212
 
266
- # render and transform content (this becomes the final content of the object)
267
- payload["highlighter_prefix"] = converters.first.highlighter_prefix
268
- payload["highlighter_suffix"] = converters.first.highlighter_suffix
269
-
270
- if render_with_liquid?
271
- Jekyll.logger.debug "Rendering Liquid:", self.relative_path
272
- self.content = render_liquid(content, payload, info, path)
273
- end
274
- Jekyll.logger.debug "Rendering Markup:", self.relative_path
275
- self.content = transform
276
-
277
- # output keeps track of what will finally be written
278
- self.output = content
279
-
280
- render_all_layouts(layouts, payload, info) if place_in_layout?
281
213
  Jekyll.logger.debug "Post-Render Hooks:", self.relative_path
282
214
  Jekyll::Hooks.trigger hook_owner, :post_render, self
215
+ ensure
216
+ @_renderer = nil # this will allow the modifications above to disappear
283
217
  end
284
218
 
285
219
  # Write the generated page file to the destination directory.
@@ -306,5 +240,10 @@ module Jekyll
306
240
  data[property]
307
241
  end
308
242
  end
243
+
244
+ private
245
+ def _renderer
246
+ @_renderer ||= Jekyll::Renderer.new(site, self)
247
+ end
309
248
  end
310
249
  end