jekyll 3.2.0.pre.beta1 → 3.2.0.pre.beta2

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.

Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -95
  3. data/README.markdown +6 -4
  4. data/{bin → exe}/jekyll +18 -14
  5. data/lib/jekyll.rb +79 -76
  6. data/lib/jekyll/collection.rb +32 -16
  7. data/lib/jekyll/command.rb +17 -13
  8. data/lib/jekyll/commands/build.rb +7 -2
  9. data/lib/jekyll/commands/doctor.rb +3 -1
  10. data/lib/jekyll/commands/new.rb +3 -0
  11. data/lib/jekyll/commands/new_theme.rb +7 -4
  12. data/lib/jekyll/commands/serve.rb +2 -0
  13. data/lib/jekyll/commands/serve/servlet.rb +2 -2
  14. data/lib/jekyll/configuration.rb +187 -125
  15. data/lib/jekyll/converters/markdown.rb +19 -9
  16. data/lib/jekyll/converters/markdown/kramdown_parser.rb +12 -5
  17. data/lib/jekyll/converters/markdown/rdiscount_parser.rb +4 -4
  18. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +90 -84
  19. data/lib/jekyll/convertible.rb +34 -21
  20. data/lib/jekyll/deprecator.rb +11 -6
  21. data/lib/jekyll/document.rb +52 -50
  22. data/lib/jekyll/drops/document_drop.rb +40 -5
  23. data/lib/jekyll/drops/drop.rb +49 -10
  24. data/lib/jekyll/drops/excerpt_drop.rb +15 -0
  25. data/lib/jekyll/drops/jekyll_drop.rb +12 -0
  26. data/lib/jekyll/drops/site_drop.rb +4 -2
  27. data/lib/jekyll/drops/url_drop.rb +4 -4
  28. data/lib/jekyll/entry_filter.rb +9 -6
  29. data/lib/jekyll/errors.rb +4 -3
  30. data/lib/jekyll/excerpt.rb +4 -6
  31. data/lib/jekyll/external.rb +4 -4
  32. data/lib/jekyll/filters.rb +67 -34
  33. data/lib/jekyll/frontmatter_defaults.rb +45 -38
  34. data/lib/jekyll/hooks.rb +21 -21
  35. data/lib/jekyll/layout.rb +3 -1
  36. data/lib/jekyll/liquid_renderer.rb +7 -3
  37. data/lib/jekyll/liquid_renderer/file.rb +1 -1
  38. data/lib/jekyll/liquid_renderer/table.rb +11 -11
  39. data/lib/jekyll/log_adapter.rb +2 -2
  40. data/lib/jekyll/page.rb +10 -10
  41. data/lib/jekyll/plugin.rb +5 -5
  42. data/lib/jekyll/plugin_manager.rb +12 -8
  43. data/lib/jekyll/publisher.rb +1 -1
  44. data/lib/jekyll/reader.rb +11 -7
  45. data/lib/jekyll/readers/data_reader.rb +9 -9
  46. data/lib/jekyll/readers/layout_reader.rb +7 -7
  47. data/lib/jekyll/readers/page_reader.rb +3 -1
  48. data/lib/jekyll/readers/post_reader.rb +9 -10
  49. data/lib/jekyll/readers/static_file_reader.rb +3 -1
  50. data/lib/jekyll/regenerator.rb +50 -28
  51. data/lib/jekyll/related_posts.rb +1 -1
  52. data/lib/jekyll/renderer.rb +29 -20
  53. data/lib/jekyll/site.rb +92 -50
  54. data/lib/jekyll/static_file.rb +33 -26
  55. data/lib/jekyll/stevenson.rb +6 -5
  56. data/lib/jekyll/tags/highlight.rb +50 -35
  57. data/lib/jekyll/tags/include.rb +42 -31
  58. data/lib/jekyll/tags/link.rb +11 -4
  59. data/lib/jekyll/tags/post_url.rb +8 -7
  60. data/lib/jekyll/theme.rb +4 -3
  61. data/lib/jekyll/theme_builder.rb +18 -6
  62. data/lib/jekyll/url.rb +21 -14
  63. data/lib/jekyll/utils.rb +57 -28
  64. data/lib/jekyll/utils/ansi.rb +9 -9
  65. data/lib/jekyll/utils/platforms.rb +2 -2
  66. data/lib/jekyll/version.rb +1 -1
  67. data/lib/site_template/_config.yml +2 -0
  68. data/lib/site_template/css/main.scss +3 -17
  69. data/lib/theme_template/_layouts/default.html +1 -0
  70. data/lib/theme_template/_layouts/page.html +5 -0
  71. data/lib/theme_template/_layouts/post.html +5 -0
  72. data/lib/theme_template/example/_post.md +1 -2
  73. data/lib/theme_template/example/index.html +2 -2
  74. data/lib/theme_template/gitignore.erb +4 -0
  75. data/lib/theme_template/theme.gemspec.erb +2 -6
  76. metadata +10 -18
  77. data/lib/site_template/_includes/footer.html +0 -38
  78. data/lib/site_template/_includes/head.html +0 -12
  79. data/lib/site_template/_includes/header.html +0 -27
  80. data/lib/site_template/_includes/icon-github.html +0 -1
  81. data/lib/site_template/_includes/icon-github.svg +0 -1
  82. data/lib/site_template/_includes/icon-twitter.html +0 -1
  83. data/lib/site_template/_includes/icon-twitter.svg +0 -1
  84. data/lib/site_template/_layouts/default.html +0 -20
  85. data/lib/site_template/_layouts/page.html +0 -14
  86. data/lib/site_template/_layouts/post.html +0 -15
  87. data/lib/site_template/_sass/_base.scss +0 -200
  88. data/lib/site_template/_sass/_layout.scss +0 -242
  89. data/lib/site_template/_sass/_syntax-highlighting.scss +0 -71
@@ -32,7 +32,8 @@ module Jekyll
32
32
  # Override of method_missing to check in @data for the key.
33
33
  def method_missing(method, *args, &blck)
34
34
  if docs.respond_to?(method.to_sym)
35
- Jekyll.logger.warn "Deprecation:", "#{label}.#{method} should be changed to #{label}.docs.#{method}."
35
+ Jekyll.logger.warn "Deprecation:", "#{label}.#{method} should be changed to" \
36
+ "#{label}.docs.#{method}."
36
37
  Jekyll.logger.warn "", "Called by #{caller.first}."
37
38
  docs.public_send(method.to_sym, *args, &blck)
38
39
  else
@@ -56,16 +57,9 @@ module Jekyll
56
57
  full_path = collection_dir(file_path)
57
58
  next if File.directory?(full_path)
58
59
  if Utils.has_yaml_header? full_path
59
- doc = Jekyll::Document.new(full_path, { :site => site, :collection => self })
60
- doc.read
61
- if site.publisher.publish?(doc) || !write?
62
- docs << doc
63
- else
64
- Jekyll.logger.debug "Skipped From Publishing:", doc.relative_path
65
- end
60
+ read_document(full_path)
66
61
  else
67
- relative_dir = Jekyll.sanitized_path(relative_directory, File.dirname(file_path)).chomp("/.")
68
- files << StaticFile.new(site, site.source, relative_dir, File.basename(full_path), self)
62
+ read_static_file(file_path, full_path)
69
63
  end
70
64
  end
71
65
  docs.sort!
@@ -79,7 +73,7 @@ module Jekyll
79
73
  return [] unless exists?
80
74
  @entries ||=
81
75
  Utils.safe_glob(collection_dir, ["**", "*"]).map do |entry|
82
- entry["#{collection_dir}/"] = ''
76
+ entry["#{collection_dir}/"] = ""
83
77
  entry
84
78
  end
85
79
  end
@@ -161,7 +155,7 @@ module Jekyll
161
155
  #
162
156
  # Returns a sanitized version of the label.
163
157
  def sanitize_label(label)
164
- label.gsub(/[^a-z0-9_\-\.]/i, '')
158
+ label.gsub(%r![^a-z0-9_\-\.]!i, "")
165
159
  end
166
160
 
167
161
  # Produce a representation of this Collection for use in Liquid.
@@ -179,14 +173,14 @@ module Jekyll
179
173
  #
180
174
  # Returns true if the 'write' metadata is true, false otherwise.
181
175
  def write?
182
- !!metadata.fetch('output', false)
176
+ !!metadata.fetch("output", false)
183
177
  end
184
178
 
185
179
  # The URL template to render collection's documents at.
186
180
  #
187
181
  # Returns the URL template to render collection's documents at.
188
182
  def url_template
189
- @url_template ||= metadata.fetch('permalink') do
183
+ @url_template ||= metadata.fetch("permalink") do
190
184
  Utils.add_permalink_suffix("/:collection/:path", site.permalink_style)
191
185
  end
192
186
  end
@@ -195,11 +189,33 @@ module Jekyll
195
189
  #
196
190
  # Returns the metadata for this collection
197
191
  def extract_metadata
198
- if site.config['collections'].is_a?(Hash)
199
- site.config['collections'][label] || {}
192
+ if site.config["collections"].is_a?(Hash)
193
+ site.config["collections"][label] || {}
200
194
  else
201
195
  {}
202
196
  end
203
197
  end
198
+
199
+ private
200
+ def read_document(full_path)
201
+ doc = Jekyll::Document.new(full_path, :site => site, :collection => self)
202
+ doc.read
203
+ if site.publisher.publish?(doc) || !write?
204
+ docs << doc
205
+ else
206
+ Jekyll.logger.debug "Skipped From Publishing:", doc.relative_path
207
+ end
208
+ end
209
+
210
+ private
211
+ def read_static_file(file_path, full_path)
212
+ relative_dir = Jekyll.sanitized_path(
213
+ relative_directory,
214
+ File.dirname(file_path)
215
+ ).chomp("/.")
216
+
217
+ files << StaticFile.new(site, site.source, relative_dir,
218
+ File.basename(full_path), self)
219
+ end
204
220
  end
205
221
  end
@@ -46,19 +46,23 @@ module Jekyll
46
46
  #
47
47
  # Returns nothing
48
48
  def add_build_options(c)
49
- c.option 'config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
50
- c.option 'destination', '-d', '--destination DESTINATION', 'The current folder will be generated into DESTINATION'
51
- c.option 'source', '-s', '--source SOURCE', 'Custom source directory'
52
- c.option 'future', '--future', 'Publishes posts with a future date'
53
- c.option 'limit_posts', '--limit_posts MAX_POSTS', Integer, 'Limits the number of posts to parse and publish'
54
- c.option 'watch', '-w', '--[no-]watch', 'Watch for changes and rebuild'
55
- c.option 'force_polling', '--force_polling', 'Force watch to use polling'
56
- c.option 'lsi', '--lsi', 'Use LSI for improved related posts'
57
- c.option 'show_drafts', '-D', '--drafts', 'Render posts in the _drafts folder'
58
- c.option 'unpublished', '--unpublished', 'Render posts that were marked as unpublished'
59
- c.option 'quiet', '-q', '--quiet', 'Silence output.'
60
- c.option 'verbose', '-V', '--verbose', 'Print verbose output.'
61
- c.option 'incremental', '-I', '--incremental', 'Enable incremental rebuild.'
49
+ c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]",
50
+ Array, "Custom configuration file"
51
+ c.option "destination", "-d", "--destination DESTINATION",
52
+ "The current folder will be generated into DESTINATION"
53
+ c.option "source", "-s", "--source SOURCE", "Custom source directory"
54
+ c.option "future", "--future", "Publishes posts with a future date"
55
+ c.option "limit_posts", "--limit_posts MAX_POSTS", Integer,
56
+ "Limits the number of posts to parse and publish"
57
+ c.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild"
58
+ c.option "force_polling", "--force_polling", "Force watch to use polling"
59
+ c.option "lsi", "--lsi", "Use LSI for improved related posts"
60
+ c.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder"
61
+ c.option "unpublished", "--unpublished",
62
+ "Render posts that were marked as unpublished"
63
+ c.option "quiet", "-q", "--quiet", "Silence output."
64
+ c.option "verbose", "-V", "--verbose", "Print verbose output."
65
+ c.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
62
66
  end
63
67
  end
64
68
  end
@@ -70,9 +70,14 @@ module Jekyll
70
70
  # options - A Hash of options passed to the command
71
71
  #
72
72
  # Returns nothing.
73
- def watch(_site, options)
73
+ def watch(site, options)
74
74
  External.require_with_graceful_fail "jekyll-watch"
75
- Jekyll::Watcher.watch(options)
75
+ watch_method = Jekyll::Watcher.method(:watch)
76
+ if watch_method.parameters.size == 1
77
+ watch_method.call(options)
78
+ else
79
+ watch_method.call(options, site)
80
+ end
76
81
  end
77
82
  end # end of class << self
78
83
  end
@@ -19,7 +19,9 @@ module Jekyll
19
19
 
20
20
  def process(options)
21
21
  site = Jekyll::Site.new(configuration_from_options(options))
22
+ site.reset
22
23
  site.read
24
+ site.generate
23
25
 
24
26
  if healthy?(site)
25
27
  Jekyll.logger.info "Your test results", "are in. Everything looks fine."
@@ -63,7 +65,7 @@ module Jekyll
63
65
  def fsnotify_buggy?(_site)
64
66
  return true unless Utils::Platforms.osx?
65
67
  if Dir.pwd != `pwd`.strip
66
- Jekyll.logger.error " " + <<-STR.strip.gsub(/\n\s+/, "\n ")
68
+ Jekyll.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ")
67
69
  We have detected that there might be trouble using fsevent on your
68
70
  operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug)
69
71
  for possible work arounds or you can work around it immediately
@@ -72,6 +72,9 @@ ruby RUBY_VERSION
72
72
  # Happy Jekylling!
73
73
  gem "jekyll", "#{Jekyll::VERSION}"
74
74
 
75
+ # This is the default theme for new Jekyll sites. You may change this to anything you like.
76
+ gem "minima"
77
+
75
78
  # If you want to use GitHub Pages, remove the "gem "jekyll"" above and
76
79
  # uncomment the line below. To upgrade, run `bundle update github-pages`.
77
80
  # gem "github-pages", group: :jekyll_plugins
@@ -6,20 +6,23 @@ class Jekyll::Commands::NewTheme < Jekyll::Command
6
6
  prog.command(:"new-theme") do |c|
7
7
  c.syntax "new-theme NAME"
8
8
  c.description "Creates a new Jekyll theme scaffold"
9
+ c.option "code_of_conduct", \
10
+ "-c", "--code-of-conduct", \
11
+ "Include a Code of Conduct. (defaults to false)"
9
12
 
10
- c.action do |args, _|
11
- Jekyll::Commands::NewTheme.process(args)
13
+ c.action do |args, opts|
14
+ Jekyll::Commands::NewTheme.process(args, opts)
12
15
  end
13
16
  end
14
17
  end
15
18
 
16
- def process(args)
19
+ def process(args, opts)
17
20
  if !args || args.empty?
18
21
  raise Jekyll::Errors::InvalidThemeName, "You must specify a theme name."
19
22
  end
20
23
 
21
24
  new_theme_name = args.join("_")
22
- theme = Jekyll::ThemeBuilder.new(new_theme_name)
25
+ theme = Jekyll::ThemeBuilder.new(new_theme_name, opts)
23
26
  if theme.path.exist?
24
27
  Jekyll.logger.abort_with "Conflict:", "#{theme.path} already exists."
25
28
  end
@@ -33,7 +33,9 @@ module Jekyll
33
33
  cmd.action do |_, opts|
34
34
  opts["serving"] = true
35
35
  opts["watch" ] = true unless opts.key?("watch")
36
+ config = opts["config"]
36
37
  Build.process(opts)
38
+ opts["config"] = config
37
39
  Serve.process(opts)
38
40
  end
39
41
  end
@@ -37,10 +37,10 @@ module Jekyll
37
37
 
38
38
  private
39
39
  def validate_and_ensure_charset(_req, res)
40
- key = res.header.keys.grep(/content-type/i).first
40
+ key = res.header.keys.grep(%r!content-type!i).first
41
41
  typ = res.header[key]
42
42
 
43
- unless typ =~ /;\s*charset=/
43
+ unless typ =~ %r!;\s*charset=!
44
44
  res.header[key] = "#{typ}; charset=#{@jekyll_opts["encoding"]}"
45
45
  end
46
46
  end
@@ -6,73 +6,94 @@ module Jekyll
6
6
  # Strings rather than symbols are used for compatibility with YAML.
7
7
  DEFAULTS = Configuration[{
8
8
  # Where things are
9
- 'source' => Dir.pwd,
10
- 'destination' => File.join(Dir.pwd, '_site'),
11
- 'plugins_dir' => '_plugins',
12
- 'layouts_dir' => '_layouts',
13
- 'data_dir' => '_data',
14
- 'includes_dir' => '_includes',
15
- 'collections' => {},
9
+ "source" => Dir.pwd,
10
+ "destination" => File.join(Dir.pwd, "_site"),
11
+ "plugins_dir" => "_plugins",
12
+ "layouts_dir" => "_layouts",
13
+ "data_dir" => "_data",
14
+ "includes_dir" => "_includes",
15
+ "collections" => {},
16
16
 
17
17
  # Handling Reading
18
- 'safe' => false,
19
- 'include' => ['.htaccess'],
20
- 'exclude' => [],
21
- 'keep_files' => ['.git', '.svn'],
22
- 'encoding' => 'utf-8',
23
- 'markdown_ext' => 'markdown,mkdown,mkdn,mkd,md',
18
+ "safe" => false,
19
+ "include" => [".htaccess"],
20
+ "exclude" => [],
21
+ "keep_files" => [".git", ".svn"],
22
+ "encoding" => "utf-8",
23
+ "markdown_ext" => "markdown,mkdown,mkdn,mkd,md",
24
24
 
25
25
  # Filtering Content
26
- 'show_drafts' => nil,
27
- 'limit_posts' => 0,
28
- 'future' => false,
29
- 'unpublished' => false,
26
+ "show_drafts" => nil,
27
+ "limit_posts" => 0,
28
+ "future" => false,
29
+ "unpublished" => false,
30
30
 
31
31
  # Plugins
32
- 'whitelist' => [],
33
- 'gems' => [],
32
+ "whitelist" => [],
33
+ "gems" => [],
34
34
 
35
35
  # Conversion
36
- 'markdown' => 'kramdown',
37
- 'highlighter' => 'rouge',
38
- 'lsi' => false,
39
- 'excerpt_separator' => "\n\n",
40
- 'incremental' => false,
36
+ "markdown" => "kramdown",
37
+ "highlighter" => "rouge",
38
+ "lsi" => false,
39
+ "excerpt_separator" => "\n\n",
40
+ "incremental" => false,
41
41
 
42
42
  # Serving
43
- 'detach' => false, # default to not detaching the server
44
- 'port' => '4000',
45
- 'host' => '127.0.0.1',
46
- 'baseurl' => '',
47
- 'show_dir_listing' => false,
43
+ "detach" => false, # default to not detaching the server
44
+ "port" => "4000",
45
+ "host" => "127.0.0.1",
46
+ "baseurl" => "",
47
+ "show_dir_listing" => false,
48
48
 
49
49
  # Output Configuration
50
- 'permalink' => 'date',
51
- 'paginate_path' => '/page:num',
52
- 'timezone' => nil, # use the local timezone
50
+ "permalink" => "date",
51
+ "paginate_path" => "/page:num",
52
+ "timezone" => nil, # use the local timezone
53
53
 
54
- 'quiet' => false,
55
- 'verbose' => false,
56
- 'defaults' => [],
54
+ "quiet" => false,
55
+ "verbose" => false,
56
+ "defaults" => [],
57
57
 
58
- 'rdiscount' => {
59
- 'extensions' => []
58
+ "liquid" => {
59
+ "error_mode" => "warn"
60
60
  },
61
61
 
62
- 'redcarpet' => {
63
- 'extensions' => []
62
+ "rdiscount" => {
63
+ "extensions" => []
64
64
  },
65
65
 
66
- 'kramdown' => {
67
- 'auto_ids' => true,
68
- 'toc_levels' => '1..6',
69
- 'entity_output' => 'as_char',
70
- 'smart_quotes' => 'lsquo,rsquo,ldquo,rdquo',
71
- 'input' => "GFM",
72
- 'hard_wrap' => false,
73
- 'footnote_nr' => 1
66
+ "redcarpet" => {
67
+ "extensions" => []
68
+ },
69
+
70
+ "kramdown" => {
71
+ "auto_ids" => true,
72
+ "toc_levels" => "1..6",
73
+ "entity_output" => "as_char",
74
+ "smart_quotes" => "lsquo,rsquo,ldquo,rdquo",
75
+ "input" => "GFM",
76
+ "hard_wrap" => false,
77
+ "footnote_nr" => 1
74
78
  }
75
- }]
79
+ }.map { |k, v| [k, v.freeze] }].freeze
80
+
81
+ class << self
82
+ # Static: Produce a Configuration ready for use in a Site.
83
+ # It takes the input, fills in the defaults where values do not
84
+ # exist, and patches common issues including migrating options for
85
+ # backwards compatiblity. Except where a key or value is being fixed,
86
+ # the user configuration will override the defaults.
87
+ #
88
+ # user_config - a Hash or Configuration of overrides.
89
+ #
90
+ # Returns a Configuration filled with defaults and fixed for common
91
+ # problems and backwards-compatibility.
92
+ def from(user_config)
93
+ Utils.deep_merge_hashes(DEFAULTS, Configuration[user_config].stringify_keys)
94
+ .fix_common_issues.add_default_collections
95
+ end
96
+ end
76
97
 
77
98
  # Public: Turn all keys into string
78
99
  #
@@ -91,28 +112,29 @@ module Jekyll
91
112
  #
92
113
  # Returns the path to the Jekyll source directory
93
114
  def source(override)
94
- get_config_value_with_override('source', override)
115
+ get_config_value_with_override("source", override)
95
116
  end
96
117
 
97
118
  def quiet(override = {})
98
- get_config_value_with_override('quiet', override)
119
+ get_config_value_with_override("quiet", override)
99
120
  end
100
121
  alias_method :quiet?, :quiet
101
122
 
102
123
  def verbose(override = {})
103
- get_config_value_with_override('verbose', override)
124
+ get_config_value_with_override("verbose", override)
104
125
  end
105
126
  alias_method :verbose?, :verbose
106
127
 
107
128
  def safe_load_file(filename)
108
129
  case File.extname(filename)
109
- when /\.toml/i
110
- Jekyll::External.require_with_graceful_fail('toml') unless defined?(TOML)
130
+ when %r!\.toml!i
131
+ Jekyll::External.require_with_graceful_fail("toml") unless defined?(TOML)
111
132
  TOML.load_file(filename)
112
- when /\.ya?ml/i
133
+ when %r!\.ya?ml!i
113
134
  SafeYAML.load_file(filename) || {}
114
135
  else
115
- raise ArgumentError, "No parser for '#{filename}' is available. Use a .toml or .y(a)ml file instead."
136
+ raise ArgumentError, "No parser for '#{filename}' is available.
137
+ Use a .toml or .y(a)ml file instead."
116
138
  end
117
139
  end
118
140
 
@@ -123,12 +145,15 @@ module Jekyll
123
145
  # Returns an Array of config files
124
146
  def config_files(override)
125
147
  # Adjust verbosity quickly
126
- Jekyll.logger.adjust_verbosity(:quiet => quiet?(override), :verbose => verbose?(override))
148
+ Jekyll.logger.adjust_verbosity(
149
+ :quiet => quiet?(override),
150
+ :verbose => verbose?(override)
151
+ )
127
152
 
128
153
  # Get configuration from <source>/_config.yml or <source>/<config_file>
129
- config_files = override.delete('config')
154
+ config_files = override.delete("config")
130
155
  if config_files.to_s.empty?
131
- default = %w(yml yaml).find(-> { 'yml' }) do |ext|
156
+ default = %w(yml yaml).find(-> { "yml" }) do |ext|
132
157
  File.exist?(Jekyll.sanitized_path(source(override), "_config.#{ext}"))
133
158
  end
134
159
  config_files = Jekyll.sanitized_path(source(override), "_config.#{default}")
@@ -153,7 +178,8 @@ module Jekyll
153
178
  Jekyll.logger.warn "Configuration file:", "none"
154
179
  {}
155
180
  else
156
- Jekyll.logger.error "Fatal:", "The configuration file '#{file}' could not be found."
181
+ Jekyll.logger.error "Fatal:", "The configuration file '#{file}'
182
+ could not be found."
157
183
  raise LoadError, "The Configuration file '#{file}' could not be found."
158
184
  end
159
185
  end
@@ -169,13 +195,14 @@ module Jekyll
169
195
 
170
196
  begin
171
197
  files.each do |config_file|
198
+ next if config_file.nil? || config_file.empty?
172
199
  new_config = read_config_file(config_file)
173
200
  configuration = Utils.deep_merge_hashes(configuration, new_config)
174
201
  end
175
202
  rescue ArgumentError => err
176
203
  Jekyll.logger.warn "WARNING:", "Error reading configuration. " \
177
204
  "Using defaults (and options)."
178
- $stderr.puts "#{err}"
205
+ $stderr.puts err
179
206
  end
180
207
 
181
208
  configuration.fix_common_issues.backwards_compatibilize.add_default_collections
@@ -197,61 +224,18 @@ module Jekyll
197
224
  def backwards_compatibilize
198
225
  config = clone
199
226
  # Provide backwards-compatibility
200
- if config.key?('auto') || config.key?('watch')
201
- Jekyll::Deprecator.deprecation_message "Auto-regeneration can no longer" \
202
- " be set from your configuration file(s). Use the"\
203
- " --[no-]watch/-w command-line option instead."
204
- config.delete('auto')
205
- config.delete('watch')
206
- end
207
-
208
- if config.key? 'server'
209
- Jekyll::Deprecator.deprecation_message "The 'server' configuration option" \
210
- " is no longer accepted. Use the 'jekyll serve'" \
211
- " subcommand to serve your site with WEBrick."
212
- config.delete('server')
213
- end
227
+ check_auto(config)
228
+ check_server(config)
214
229
 
215
- renamed_key 'server_port', 'port', config
216
- renamed_key 'plugins', 'plugins_dir', config
217
- renamed_key 'layouts', 'layouts_dir', config
218
- renamed_key 'data_source', 'data_dir', config
230
+ renamed_key "server_port", "port", config
231
+ renamed_key "plugins", "plugins_dir", config
232
+ renamed_key "layouts", "layouts_dir", config
233
+ renamed_key "data_source", "data_dir", config
219
234
 
220
- if config.key? 'pygments'
221
- Jekyll::Deprecator.deprecation_message "The 'pygments' configuration option" \
222
- " has been renamed to 'highlighter'. Please update your" \
223
- " config file accordingly. The allowed values are 'rouge', " \
224
- "'pygments' or null."
225
-
226
- config['highlighter'] = 'pygments' if config['pygments']
227
- config.delete('pygments')
228
- end
229
-
230
- %w(include exclude).each do |option|
231
- config[option] ||= []
232
- if config[option].is_a?(String)
233
- Jekyll::Deprecator.deprecation_message "The '#{option}' configuration option" \
234
- " must now be specified as an array, but you specified" \
235
- " a string. For now, we've treated the string you provided" \
236
- " as a list of comma-separated values."
237
- config[option] = csv_to_array(config[option])
238
- end
239
- config[option].map!(&:to_s)
240
- end
241
-
242
- if (config['kramdown'] || {}).key?('use_coderay')
243
- Jekyll::Deprecator.deprecation_message "Please change 'use_coderay'" \
244
- " to 'enable_coderay' in your configuration file."
245
- config['kramdown']['use_coderay'] = config['kramdown'].delete('enable_coderay')
246
- end
247
-
248
- if config.fetch('markdown', 'kramdown').to_s.downcase.eql?("maruku")
249
- Jekyll.logger.abort_with "Error:", "You're using the 'maruku' " \
250
- "Markdown processor, which has been removed as of 3.0.0. " \
251
- "We recommend you switch to Kramdown. To do this, replace " \
252
- "`markdown: maruku` with `markdown: kramdown` in your " \
253
- "`_config.yml` file."
254
- end
235
+ check_pygments(config)
236
+ check_include_exclude(config)
237
+ check_coderay(config)
238
+ check_maruku(config)
255
239
 
256
240
  config
257
241
  end
@@ -259,10 +243,12 @@ module Jekyll
259
243
  def fix_common_issues
260
244
  config = clone
261
245
 
262
- if config.key?('paginate') && (!config['paginate'].is_a?(Integer) || config['paginate'] < 1)
263
- Jekyll.logger.warn "Config Warning:", "The `paginate` key must be a" \
264
- " positive integer or nil. It's currently set to '#{config['paginate'].inspect}'."
265
- config['paginate'] = nil
246
+ if config.key?("paginate") && (!config["paginate"].is_a?(Integer) ||
247
+ config["paginate"] < 1)
248
+
249
+ Jekyll.logger.warn "Config Warning:", "The `paginate` key must be a positive" \
250
+ " integer or nil. It's currently set to '#{config["paginate"].inspect}'."
251
+ config["paginate"] = nil
266
252
  end
267
253
 
268
254
  config
@@ -271,14 +257,22 @@ module Jekyll
271
257
  def add_default_collections
272
258
  config = clone
273
259
 
274
- return config if config['collections'].nil?
260
+ # It defaults to `{}`, so this is only if someone sets it to null manually.
261
+ return config if config["collections"].nil?
275
262
 
276
- if config['collections'].is_a?(Array)
277
- config['collections'] = Hash[config['collections'].map { |c| [c, {}] }]
263
+ # Ensure we have a hash.
264
+ if config["collections"].is_a?(Array)
265
+ config["collections"] = Hash[config["collections"].map { |c| [c, {}] }]
266
+ end
267
+
268
+ config["collections"] = Utils.deep_merge_hashes(
269
+ { "posts" => {} }, config["collections"]
270
+ ).tap do |collections|
271
+ collections["posts"]["output"] = true
272
+ if config["permalink"]
273
+ collections["posts"]["permalink"] ||= style_to_permalink(config["permalink"])
274
+ end
278
275
  end
279
- config['collections']['posts'] ||= {}
280
- config['collections']['posts']['output'] = true
281
- config['collections']['posts']['permalink'] = style_to_permalink(config['permalink'])
282
276
 
283
277
  config
284
278
  end
@@ -293,7 +287,6 @@ module Jekyll
293
287
  end
294
288
 
295
289
  private
296
-
297
290
  def style_to_permalink(permalink_style)
298
291
  case permalink_style.to_sym
299
292
  when :pretty
@@ -315,9 +308,78 @@ module Jekyll
315
308
  # file - the file from which the config was extracted
316
309
  #
317
310
  # Raises an ArgumentError if given config is not a hash
311
+ private
318
312
  def check_config_is_hash!(extracted_config, file)
319
313
  unless extracted_config.is_a?(Hash)
320
- raise ArgumentError.new("Configuration file: (INVALID) #{file}".yellow)
314
+ raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow
315
+ end
316
+ end
317
+
318
+ private
319
+ def check_auto(config)
320
+ if config.key?("auto") || config.key?("watch")
321
+ Jekyll::Deprecator.deprecation_message "Auto-regeneration can no longer" \
322
+ " be set from your configuration file(s). Use the" \
323
+ " --[no-]watch/-w command-line option instead."
324
+ config.delete("auto")
325
+ config.delete("watch")
326
+ end
327
+ end
328
+
329
+ private
330
+ def check_server(config)
331
+ if config.key?("server")
332
+ Jekyll::Deprecator.deprecation_message "The 'server' configuration option" \
333
+ " is no longer accepted. Use the 'jekyll serve'" \
334
+ " subcommand to serve your site with WEBrick."
335
+ config.delete("server")
336
+ end
337
+ end
338
+
339
+ private
340
+ def check_pygments(config)
341
+ if config.key?("pygments")
342
+ Jekyll::Deprecator.deprecation_message "The 'pygments' configuration option" \
343
+ " has been renamed to 'highlighter'. Please update your" \
344
+ " config file accordingly. The allowed values are 'rouge', " \
345
+ "'pygments' or null."
346
+
347
+ config["highlighter"] = "pygments" if config["pygments"]
348
+ config.delete("pygments")
349
+ end
350
+ end
351
+
352
+ private
353
+ def check_include_exclude(config)
354
+ %w(include exclude).each do |option|
355
+ if config[option].is_a?(String)
356
+ Jekyll::Deprecator.deprecation_message "The '#{option}' configuration option" \
357
+ " must now be specified as an array, but you specified" \
358
+ " a string. For now, we've treated the string you provided" \
359
+ " as a list of comma-separated values."
360
+ config[option] = csv_to_array(config[option])
361
+ end
362
+ config[option].map!(&:to_s) if config[option]
363
+ end
364
+ end
365
+
366
+ private
367
+ def check_coderay(config)
368
+ if (config["kramdown"] || {}).key?("use_coderay")
369
+ Jekyll::Deprecator.deprecation_message "Please change 'use_coderay'" \
370
+ " to 'enable_coderay' in your configuration file."
371
+ config["kramdown"]["use_coderay"] = config["kramdown"].delete("enable_coderay")
372
+ end
373
+ end
374
+
375
+ private
376
+ def check_maruku(config)
377
+ if config.fetch("markdown", "kramdown").to_s.casecmp("maruku") == 0
378
+ Jekyll.logger.abort_with "Error:", "You're using the 'maruku' " \
379
+ "Markdown processor, which has been removed as of 3.0.0. " \
380
+ "We recommend you switch to Kramdown. To do this, replace " \
381
+ "`markdown: maruku` with `markdown: kramdown` in your " \
382
+ "`_config.yml` file."
321
383
  end
322
384
  end
323
385
  end