jekyll 3.8.7 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +71 -62
  3. data/LICENSE +1 -1
  4. data/README.markdown +46 -17
  5. data/lib/blank_template/_config.yml +3 -0
  6. data/lib/blank_template/_layouts/default.html +12 -0
  7. data/lib/blank_template/_sass/main.scss +9 -0
  8. data/lib/blank_template/assets/css/main.scss +4 -0
  9. data/lib/blank_template/index.md +8 -0
  10. data/lib/jekyll.rb +10 -1
  11. data/lib/jekyll/cache.rb +190 -0
  12. data/lib/jekyll/cleaner.rb +5 -4
  13. data/lib/jekyll/collection.rb +82 -10
  14. data/lib/jekyll/command.rb +33 -6
  15. data/lib/jekyll/commands/build.rb +11 -20
  16. data/lib/jekyll/commands/clean.rb +2 -0
  17. data/lib/jekyll/commands/doctor.rb +15 -8
  18. data/lib/jekyll/commands/help.rb +1 -1
  19. data/lib/jekyll/commands/new.rb +37 -35
  20. data/lib/jekyll/commands/new_theme.rb +30 -28
  21. data/lib/jekyll/commands/serve.rb +55 -81
  22. data/lib/jekyll/commands/serve/live_reload_reactor.rb +6 -10
  23. data/lib/jekyll/commands/serve/servlet.rb +22 -25
  24. data/lib/jekyll/commands/serve/websockets.rb +1 -1
  25. data/lib/jekyll/configuration.rb +61 -149
  26. data/lib/jekyll/converters/identity.rb +18 -0
  27. data/lib/jekyll/converters/markdown.rb +49 -40
  28. data/lib/jekyll/converters/markdown/kramdown_parser.rb +84 -11
  29. data/lib/jekyll/converters/smartypants.rb +34 -14
  30. data/lib/jekyll/convertible.rb +30 -31
  31. data/lib/jekyll/deprecator.rb +1 -3
  32. data/lib/jekyll/document.rb +89 -61
  33. data/lib/jekyll/drops/collection_drop.rb +2 -3
  34. data/lib/jekyll/drops/document_drop.rb +14 -1
  35. data/lib/jekyll/drops/drop.rb +17 -14
  36. data/lib/jekyll/drops/excerpt_drop.rb +4 -0
  37. data/lib/jekyll/drops/page_drop.rb +18 -0
  38. data/lib/jekyll/drops/site_drop.rb +6 -5
  39. data/lib/jekyll/drops/unified_payload_drop.rb +1 -0
  40. data/lib/jekyll/drops/url_drop.rb +53 -1
  41. data/lib/jekyll/entry_filter.rb +42 -45
  42. data/lib/jekyll/excerpt.rb +45 -34
  43. data/lib/jekyll/external.rb +10 -5
  44. data/lib/jekyll/filters.rb +200 -40
  45. data/lib/jekyll/filters/date_filters.rb +6 -3
  46. data/lib/jekyll/filters/grouping_filters.rb +1 -2
  47. data/lib/jekyll/filters/url_filters.rb +46 -14
  48. data/lib/jekyll/frontmatter_defaults.rb +46 -35
  49. data/lib/jekyll/hooks.rb +4 -8
  50. data/lib/jekyll/inclusion.rb +32 -0
  51. data/lib/jekyll/liquid_extensions.rb +0 -2
  52. data/lib/jekyll/liquid_renderer.rb +31 -16
  53. data/lib/jekyll/liquid_renderer/file.rb +24 -3
  54. data/lib/jekyll/liquid_renderer/table.rb +36 -77
  55. data/lib/jekyll/log_adapter.rb +5 -1
  56. data/lib/jekyll/mime.types +53 -11
  57. data/lib/jekyll/page.rb +54 -12
  58. data/lib/jekyll/page_excerpt.rb +26 -0
  59. data/lib/jekyll/page_without_a_file.rb +0 -4
  60. data/lib/jekyll/path_manager.rb +31 -0
  61. data/lib/jekyll/plugin.rb +5 -11
  62. data/lib/jekyll/plugin_manager.rb +2 -0
  63. data/lib/jekyll/profiler.rb +58 -0
  64. data/lib/jekyll/reader.rb +42 -9
  65. data/lib/jekyll/readers/collection_reader.rb +1 -0
  66. data/lib/jekyll/readers/data_reader.rb +8 -9
  67. data/lib/jekyll/readers/layout_reader.rb +3 -12
  68. data/lib/jekyll/readers/page_reader.rb +5 -5
  69. data/lib/jekyll/readers/post_reader.rb +31 -18
  70. data/lib/jekyll/readers/static_file_reader.rb +4 -4
  71. data/lib/jekyll/readers/theme_assets_reader.rb +8 -5
  72. data/lib/jekyll/regenerator.rb +4 -12
  73. data/lib/jekyll/renderer.rb +23 -40
  74. data/lib/jekyll/site.rb +91 -38
  75. data/lib/jekyll/static_file.rb +62 -21
  76. data/lib/jekyll/stevenson.rb +2 -3
  77. data/lib/jekyll/tags/highlight.rb +19 -51
  78. data/lib/jekyll/tags/include.rb +82 -42
  79. data/lib/jekyll/tags/link.rb +11 -7
  80. data/lib/jekyll/tags/post_url.rb +25 -21
  81. data/lib/jekyll/theme.rb +16 -18
  82. data/lib/jekyll/theme_builder.rb +91 -89
  83. data/lib/jekyll/url.rb +10 -5
  84. data/lib/jekyll/utils.rb +18 -21
  85. data/lib/jekyll/utils/ansi.rb +1 -1
  86. data/lib/jekyll/utils/exec.rb +0 -1
  87. data/lib/jekyll/utils/internet.rb +2 -4
  88. data/lib/jekyll/utils/platforms.rb +8 -8
  89. data/lib/jekyll/utils/thread_event.rb +1 -5
  90. data/lib/jekyll/utils/win_tz.rb +2 -2
  91. data/lib/jekyll/version.rb +1 -1
  92. data/lib/site_template/.gitignore +2 -0
  93. data/lib/site_template/404.html +1 -0
  94. data/lib/site_template/_config.yml +17 -5
  95. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +5 -1
  96. data/lib/site_template/{about.md → about.markdown} +0 -0
  97. data/lib/site_template/{index.md → index.markdown} +0 -0
  98. data/lib/theme_template/gitignore.erb +1 -0
  99. data/lib/theme_template/theme.gemspec.erb +1 -4
  100. data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -0
  101. metadata +69 -31
  102. data/lib/jekyll/converters/markdown/rdiscount_parser.rb +0 -37
  103. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +0 -112
  104. data/lib/jekyll/utils/rouge.rb +0 -22
@@ -3,7 +3,7 @@
3
3
  module Jekyll
4
4
  # Handles the cleanup of a site's destination before it is built.
5
5
  class Cleaner
6
- HIDDEN_FILE_REGEX = %r!\/\.{1,2}$!
6
+ HIDDEN_FILE_REGEX = %r!\/\.{1,2}$!.freeze
7
7
  attr_reader :site
8
8
 
9
9
  def initialize(site)
@@ -45,6 +45,7 @@ module Jekyll
45
45
 
46
46
  Utils.safe_glob(site.in_dest_dir, ["**", "*"], File::FNM_DOTMATCH).each do |file|
47
47
  next if file =~ HIDDEN_FILE_REGEX || file =~ regex || dirs.include?(file)
48
+
48
49
  files << file
49
50
  end
50
51
 
@@ -65,7 +66,7 @@ module Jekyll
65
66
  #
66
67
  # Returns a Set with the directory paths
67
68
  def new_dirs
68
- @new_dirs ||= new_files.map { |file| parent_dirs(file) }.flatten.to_set
69
+ @new_dirs ||= new_files.flat_map { |file| parent_dirs(file) }.to_set
69
70
  end
70
71
 
71
72
  # Private: The list of parent directories of a given file
@@ -76,7 +77,7 @@ module Jekyll
76
77
  if parent_dir == site.dest
77
78
  []
78
79
  else
79
- [parent_dir] + parent_dirs(parent_dir)
80
+ parent_dirs(parent_dir).unshift(parent_dir)
80
81
  end
81
82
  end
82
83
 
@@ -93,7 +94,7 @@ module Jekyll
93
94
  #
94
95
  # Returns a Set with the directory paths
95
96
  def keep_dirs
96
- site.keep_files.map { |file| parent_dirs(site.in_dest_dir(file)) }.flatten.to_set
97
+ site.keep_files.flat_map { |file| parent_dirs(site.in_dest_dir(file)) }.to_set
97
98
  end
98
99
 
99
100
  # Private: Creates a regular expression from the config's keep_files array
@@ -35,7 +35,7 @@ module Jekyll
35
35
  def method_missing(method, *args, &blck)
36
36
  if docs.respond_to?(method.to_sym)
37
37
  Jekyll.logger.warn "Deprecation:",
38
- "#{label}.#{method} should be changed to #{label}.docs.#{method}."
38
+ "#{label}.#{method} should be changed to #{label}.docs.#{method}."
39
39
  Jekyll.logger.warn "", "Called by #{caller(0..0)}."
40
40
  docs.public_send(method.to_sym, *args, &blck)
41
41
  else
@@ -58,13 +58,14 @@ module Jekyll
58
58
  filtered_entries.each do |file_path|
59
59
  full_path = collection_dir(file_path)
60
60
  next if File.directory?(full_path)
61
+
61
62
  if Utils.has_yaml_header? full_path
62
63
  read_document(full_path)
63
64
  else
64
65
  read_static_file(file_path, full_path)
65
66
  end
66
67
  end
67
- docs.sort!
68
+ sort_docs!
68
69
  end
69
70
 
70
71
  # All the entries in this collection.
@@ -73,11 +74,14 @@ module Jekyll
73
74
  # relative to the collection's directory
74
75
  def entries
75
76
  return [] unless exists?
76
- @entries ||=
77
+
78
+ @entries ||= begin
79
+ collection_dir_slash = "#{collection_dir}/"
77
80
  Utils.safe_glob(collection_dir, ["**", "*"], File::FNM_DOTMATCH).map do |entry|
78
- entry["#{collection_dir}/"] = ""
81
+ entry[collection_dir_slash] = ""
79
82
  entry
80
83
  end
84
+ end
81
85
  end
82
86
 
83
87
  # Filtered version of the entries in this collection.
@@ -86,6 +90,7 @@ module Jekyll
86
90
  # Returns a list of filtered entry paths.
87
91
  def filtered_entries
88
92
  return [] unless exists?
93
+
89
94
  @filtered_entries ||=
90
95
  Dir.chdir(directory) do
91
96
  entry_filter.filter(entries).reject do |f|
@@ -124,6 +129,7 @@ module Jekyll
124
129
  # is stored on the filesystem.
125
130
  def collection_dir(*files)
126
131
  return directory if files.empty?
132
+
127
133
  site.in_source_dir(container, relative_directory, *files)
128
134
  end
129
135
 
@@ -149,7 +155,7 @@ module Jekyll
149
155
  #
150
156
  # Returns the inspect string
151
157
  def inspect
152
- "#<Jekyll::Collection @label=#{label} docs=#{docs}>"
158
+ "#<#{self.class} @label=#{label} docs=#{docs}>"
153
159
  end
154
160
 
155
161
  # Produce a sanitized label name
@@ -207,17 +213,83 @@ module Jekyll
207
213
  @container ||= site.config["collections_dir"]
208
214
  end
209
215
 
210
- private
211
-
212
216
  def read_document(full_path)
213
217
  doc = Document.new(full_path, :site => site, :collection => self)
214
218
  doc.read
215
- if site.unpublished || doc.published?
216
- docs << doc
219
+ docs << doc if site.unpublished || doc.published?
220
+ end
221
+
222
+ def sort_docs!
223
+ if metadata["order"].is_a?(Array)
224
+ rearrange_docs!
225
+ elsif metadata["sort_by"].is_a?(String)
226
+ sort_docs_by_key!
227
+ else
228
+ docs.sort!
217
229
  end
218
230
  end
219
231
 
220
- private
232
+ # A custom sort function based on Schwartzian transform
233
+ # Refer https://byparker.com/blog/2017/schwartzian-transform-faster-sorting/ for details
234
+ def sort_docs_by_key!
235
+ meta_key = metadata["sort_by"]
236
+ # Modify `docs` array to cache document's property along with the Document instance
237
+ docs.map! { |doc| [doc.data[meta_key], doc] }.sort! do |apples, olives|
238
+ order = determine_sort_order(meta_key, apples, olives)
239
+
240
+ # Fall back to `Document#<=>` if the properties were equal or were non-sortable
241
+ # Otherwise continue with current sort-order
242
+ if order.nil? || order.zero?
243
+ apples[-1] <=> olives[-1]
244
+ else
245
+ order
246
+ end
247
+
248
+ # Finally restore the `docs` array with just the Document objects themselves
249
+ end.map!(&:last)
250
+ end
251
+
252
+ def determine_sort_order(sort_key, apples, olives)
253
+ apple_property, apple_document = apples
254
+ olive_property, olive_document = olives
255
+
256
+ if apple_property.nil? && !olive_property.nil?
257
+ order_with_warning(sort_key, apple_document, 1)
258
+ elsif !apple_property.nil? && olive_property.nil?
259
+ order_with_warning(sort_key, olive_document, -1)
260
+ else
261
+ apple_property <=> olive_property
262
+ end
263
+ end
264
+
265
+ def order_with_warning(sort_key, document, order)
266
+ Jekyll.logger.warn "Sort warning:", "'#{sort_key}' not defined in #{document.relative_path}"
267
+ order
268
+ end
269
+
270
+ # Rearrange documents within the `docs` array as listed in the `metadata["order"]` array.
271
+ #
272
+ # Involves converting the two arrays into hashes based on relative_paths as keys first, then
273
+ # merging them to remove duplicates and finally retrieving the Document instances from the
274
+ # merged array.
275
+ def rearrange_docs!
276
+ docs_table = {}
277
+ custom_order = {}
278
+
279
+ # pre-sort to normalize default array across platforms and then proceed to create a Hash
280
+ # from that sorted array.
281
+ docs.sort.each do |doc|
282
+ docs_table[doc.relative_path] = doc
283
+ end
284
+
285
+ metadata["order"].each do |entry|
286
+ custom_order[File.join(relative_directory, entry)] = nil
287
+ end
288
+
289
+ result = Jekyll::Utils.deep_merge_hashes(custom_order, docs_table).values
290
+ result.compact!
291
+ self.docs = result
292
+ end
221
293
 
222
294
  def read_static_file(file_path, full_path)
223
295
  relative_dir = Jekyll.sanitized_path(
@@ -40,6 +40,7 @@ module Jekyll
40
40
  # Returns a full Jekyll configuration
41
41
  def configuration_from_options(options)
42
42
  return options if options.is_a?(Jekyll::Configuration)
43
+
43
44
  Jekyll.configuration(options)
44
45
  end
45
46
 
@@ -51,28 +52,54 @@ module Jekyll
51
52
  # rubocop:disable Metrics/MethodLength
52
53
  def add_build_options(cmd)
53
54
  cmd.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]",
54
- Array, "Custom configuration file"
55
+ Array, "Custom configuration file"
55
56
  cmd.option "destination", "-d", "--destination DESTINATION",
56
- "The current folder will be generated into DESTINATION"
57
+ "The current folder will be generated into DESTINATION"
57
58
  cmd.option "source", "-s", "--source SOURCE", "Custom source directory"
58
59
  cmd.option "future", "--future", "Publishes posts with a future date"
59
60
  cmd.option "limit_posts", "--limit_posts MAX_POSTS", Integer,
60
- "Limits the number of posts to parse and publish"
61
+ "Limits the number of posts to parse and publish"
61
62
  cmd.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild"
62
63
  cmd.option "baseurl", "-b", "--baseurl URL",
63
- "Serve the website from the given base URL"
64
+ "Serve the website from the given base URL"
64
65
  cmd.option "force_polling", "--force_polling", "Force watch to use polling"
65
66
  cmd.option "lsi", "--lsi", "Use LSI for improved related posts"
66
67
  cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder"
67
68
  cmd.option "unpublished", "--unpublished",
68
- "Render posts that were marked as unpublished"
69
+ "Render posts that were marked as unpublished"
70
+ cmd.option "disable_disk_cache", "--disable-disk-cache",
71
+ "Disable caching to disk in non-safe mode"
69
72
  cmd.option "quiet", "-q", "--quiet", "Silence output."
70
73
  cmd.option "verbose", "-V", "--verbose", "Print verbose output."
71
74
  cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
72
75
  cmd.option "strict_front_matter", "--strict_front_matter",
73
- "Fail if errors are present in front matter"
76
+ "Fail if errors are present in front matter"
74
77
  end
75
78
  # rubocop:enable Metrics/MethodLength
79
+
80
+ # Run ::process method in a given set of Jekyll::Command subclasses and suggest
81
+ # re-running the associated command with --trace switch to obtain any additional
82
+ # information or backtrace regarding the encountered Exception.
83
+ #
84
+ # cmd - the Jekyll::Command to be handled
85
+ # options - configuration overrides
86
+ # klass - an array of Jekyll::Command subclasses associated with the command
87
+ #
88
+ # Note that all exceptions are rescued..
89
+ # rubocop: disable Lint/RescueException
90
+ def process_with_graceful_fail(cmd, options, *klass)
91
+ klass.each { |k| k.process(options) if k.respond_to?(:process) }
92
+ rescue Exception => e
93
+ raise e if cmd.trace
94
+
95
+ msg = " Please append `--trace` to the `#{cmd.name}` command "
96
+ dashes = "-" * msg.length
97
+ Jekyll.logger.error "", dashes
98
+ Jekyll.logger.error "Jekyll #{Jekyll::VERSION} ", msg
99
+ Jekyll.logger.error "", " for any additional information or backtrace. "
100
+ Jekyll.logger.abort_with "", dashes
101
+ end
102
+ # rubocop: enable Lint/RescueException
76
103
  end
77
104
  end
78
105
  end
@@ -15,7 +15,7 @@ module Jekyll
15
15
 
16
16
  c.action do |_, options|
17
17
  options["serving"] = false
18
- Jekyll::Commands::Build.process(options)
18
+ process_with_graceful_fail(c, options, self)
19
19
  end
20
20
  end
21
21
  end
@@ -31,14 +31,14 @@ module Jekyll
31
31
 
32
32
  if options.fetch("skip_initial_build", false)
33
33
  Jekyll.logger.warn "Build Warning:", "Skipping the initial build." \
34
- " This may result in an out-of-date site."
34
+ " This may result in an out-of-date site."
35
35
  else
36
36
  build(site, options)
37
37
  end
38
38
 
39
39
  if options.fetch("detach", false)
40
40
  Jekyll.logger.info "Auto-regeneration:",
41
- "disabled when running server detached."
41
+ "disabled when running server detached."
42
42
  elsif options.fetch("watch", false)
43
43
  watch(site, options)
44
44
  else
@@ -54,13 +54,13 @@ module Jekyll
54
54
  # Returns nothing.
55
55
  def build(site, options)
56
56
  t = Time.now
57
- source = options["source"]
58
- destination = options["destination"]
57
+ source = File.expand_path(options["source"])
58
+ destination = File.expand_path(options["destination"])
59
59
  incremental = options["incremental"]
60
60
  Jekyll.logger.info "Source:", source
61
61
  Jekyll.logger.info "Destination:", destination
62
62
  Jekyll.logger.info "Incremental build:",
63
- (incremental ? "enabled" : "disabled. Enable with --incremental")
63
+ (incremental ? "enabled" : "disabled. Enable with --incremental")
64
64
  Jekyll.logger.info "Generating..."
65
65
  process_site(site)
66
66
  Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds."
@@ -76,25 +76,16 @@ module Jekyll
76
76
  # Warn Windows users that they might need to upgrade.
77
77
  if Utils::Platforms.bash_on_windows?
78
78
  Jekyll.logger.warn "",
79
- "Auto-regeneration may not work on some Windows versions."
79
+ "Auto-regeneration may not work on some Windows versions."
80
80
  Jekyll.logger.warn "",
81
- "Please see: https://github.com/Microsoft/BashOnWindows/issues/216"
81
+ "Please see: https://github.com/Microsoft/BashOnWindows/issues/216"
82
82
  Jekyll.logger.warn "",
83
- "If it does not work, please upgrade Bash on Windows or "\
84
- "run Jekyll with --no-watch."
83
+ "If it does not work, please upgrade Bash on Windows or "\
84
+ "run Jekyll with --no-watch."
85
85
  end
86
86
 
87
87
  External.require_with_graceful_fail "jekyll-watch"
88
- watch_method = Jekyll::Watcher.method(:watch)
89
- if watch_method.parameters.size == 1
90
- watch_method.call(
91
- options
92
- )
93
- else
94
- watch_method.call(
95
- options, site
96
- )
97
- end
88
+ Jekyll::Watcher.watch(options, site)
98
89
  end
99
90
  end
100
91
  end
@@ -22,10 +22,12 @@ module Jekyll
22
22
  options = configuration_from_options(options)
23
23
  destination = options["destination"]
24
24
  metadata_file = File.join(options["source"], ".jekyll-metadata")
25
+ cache_dir = File.join(options["source"], options["cache_dir"])
25
26
  sass_cache = ".sass-cache"
26
27
 
27
28
  remove(destination, :checker_func => :directory?)
28
29
  remove(metadata_file, :checker_func => :file?)
30
+ remove(cache_dir, :checker_func => :directory?)
29
31
  remove(sass_cache, :checker_func => :directory?)
30
32
  end
31
33
 
@@ -11,7 +11,7 @@ module Jekyll
11
11
  c.alias(:hyde)
12
12
 
13
13
  c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array,
14
- "Custom configuration file"
14
+ "Custom configuration file"
15
15
 
16
16
  c.action do |_, options|
17
17
  Jekyll::Commands::Doctor.process(options)
@@ -45,22 +45,23 @@ module Jekyll
45
45
 
46
46
  def properly_gathered_posts?(site)
47
47
  return true if site.config["collections_dir"].empty?
48
+
48
49
  posts_at_root = site.in_source_dir("_posts")
49
50
  return true unless File.directory?(posts_at_root)
51
+
50
52
  Jekyll.logger.warn "Warning:",
51
- "Detected '_posts' directory outside custom `collections_dir`!"
53
+ "Detected '_posts' directory outside custom `collections_dir`!"
52
54
  Jekyll.logger.warn "",
53
- "Please move '#{posts_at_root}' into the custom directory at " \
55
+ "Please move '#{posts_at_root}' into the custom directory at " \
54
56
  "'#{site.in_source_dir(site.config["collections_dir"])}'"
55
57
  false
56
58
  end
57
59
 
58
60
  def deprecated_relative_permalinks(site)
59
61
  if site.config["relative_permalinks"]
60
- Jekyll::Deprecator.deprecation_message "Your site still uses relative" \
61
- " permalinks, which was removed in" \
62
- " Jekyll v3.0.0."
63
- return true
62
+ Jekyll::Deprecator.deprecation_message "Your site still uses relative permalinks," \
63
+ " which was removed in Jekyll v3.0.0."
64
+ true
64
65
  end
65
66
  end
66
67
 
@@ -71,6 +72,7 @@ module Jekyll
71
72
  urls = collect_urls(urls, site.posts.docs, site.dest)
72
73
  urls.each do |url, paths|
73
74
  next unless paths.size > 1
75
+
74
76
  conflicting_urls = true
75
77
  Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
76
78
  " for the following pages: #{paths.join(", ")}"
@@ -80,6 +82,7 @@ module Jekyll
80
82
 
81
83
  def fsnotify_buggy?(_site)
82
84
  return true unless Utils::Platforms.osx?
85
+
83
86
  if Dir.pwd != `pwd`.strip
84
87
  Jekyll.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ")
85
88
  We have detected that there might be trouble using fsevent on your
@@ -99,6 +102,7 @@ module Jekyll
99
102
  urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
100
103
  urls.each_value do |real_urls|
101
104
  next unless real_urls.uniq.size > 1
105
+
102
106
  urls_only_differ_by_case = true
103
107
  Jekyll.logger.warn "Warning:", "The following URLs only differ" \
104
108
  " by case. On a case-insensitive file system one of the URLs" \
@@ -117,6 +121,7 @@ module Jekyll
117
121
  end
118
122
 
119
123
  private
124
+
120
125
  def collect_urls(urls, things, destination)
121
126
  things.each do |thing|
122
127
  dest = thing.destination(destination)
@@ -138,6 +143,7 @@ module Jekyll
138
143
 
139
144
  def url_exists?(url)
140
145
  return true unless url.nil? || url.empty?
146
+
141
147
  Jekyll.logger.warn "Warning:", "You didn't set an URL in the config file, "\
142
148
  "you may encounter problems with some plugins."
143
149
  false
@@ -155,7 +161,8 @@ module Jekyll
155
161
  end
156
162
 
157
163
  def url_absolute(url)
158
- return true if Addressable::URI.parse(url).absolute?
164
+ return true if url.is_a?(String) && Addressable::URI.parse(url).absolute?
165
+
159
166
  Jekyll.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
160
167
  "check the value of `url` in your config file."
161
168
  false
@@ -25,7 +25,7 @@ module Jekyll
25
25
 
26
26
  def invalid_command(prog, cmd)
27
27
  Jekyll.logger.error "Error:",
28
- "Hmm... we don't know what the '#{cmd}' command is."
28
+ "Hmm... we don't know what the '#{cmd}' command is."
29
29
  Jekyll.logger.info "Valid commands:", prog.commands.keys.join(", ")
30
30
  end
31
31
  end
@@ -41,10 +41,16 @@ module Jekyll
41
41
  after_install(new_blog_path, options)
42
42
  end
43
43
 
44
+ def blank_template
45
+ File.expand_path("../../blank_template", __dir__)
46
+ end
47
+
44
48
  def create_blank_site(path)
49
+ FileUtils.cp_r blank_template + "/.", path
50
+ FileUtils.chmod_R "u+w", path
51
+
45
52
  Dir.chdir(path) do
46
- FileUtils.mkdir(%w(_layouts _posts _drafts))
47
- FileUtils.touch("index.html")
53
+ FileUtils.mkdir(%w(_data _drafts _includes _posts))
48
54
  end
49
55
  end
50
56
 
@@ -62,42 +68,38 @@ module Jekyll
62
68
  private
63
69
 
64
70
  def gemfile_contents
65
- <<-RUBY
66
- source "https://rubygems.org"
67
-
68
- # Hello! This is where you manage which Jekyll version is used to run.
69
- # When you want to use a different version, change it below, save the
70
- # file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
71
- #
72
- # bundle exec jekyll serve
73
- #
74
- # This will help ensure the proper Jekyll version is running.
75
- # Happy Jekylling!
76
- gem "jekyll", "~> #{Jekyll::VERSION}"
77
-
78
- # This is the default theme for new Jekyll sites. You may change this to anything you like.
79
- gem "minima", "~> 2.0"
80
-
81
- # If you want to use GitHub Pages, remove the "gem "jekyll"" above and
82
- # uncomment the line below. To upgrade, run `bundle update github-pages`.
83
- # gem "github-pages", group: :jekyll_plugins
84
-
85
- # If you have any plugins, put them here!
86
- group :jekyll_plugins do
87
- gem "jekyll-feed", "~> 0.6"
88
- end
71
+ <<~RUBY
72
+ source "https://rubygems.org"
73
+ # Hello! This is where you manage which Jekyll version is used to run.
74
+ # When you want to use a different version, change it below, save the
75
+ # file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
76
+ #
77
+ # bundle exec jekyll serve
78
+ #
79
+ # This will help ensure the proper Jekyll version is running.
80
+ # Happy Jekylling!
81
+ gem "jekyll", "~> #{Jekyll::VERSION}"
82
+ # This is the default theme for new Jekyll sites. You may change this to anything you like.
83
+ gem "minima", "~> 2.5"
84
+ # If you want to use GitHub Pages, remove the "gem "jekyll"" above and
85
+ # uncomment the line below. To upgrade, run `bundle update github-pages`.
86
+ # gem "github-pages", group: :jekyll_plugins
87
+ # If you have any plugins, put them here!
88
+ group :jekyll_plugins do
89
+ gem "jekyll-feed", "~> 0.12"
90
+ end
89
91
 
90
- # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
91
- # and associated library.
92
- install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do
93
- gem "tzinfo", "~> 1.2"
94
- gem "tzinfo-data"
95
- end
92
+ # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
93
+ # and associated library.
94
+ platforms :mingw, :x64_mingw, :mswin, :jruby do
95
+ gem "tzinfo", "~> 1.2"
96
+ gem "tzinfo-data"
97
+ end
96
98
 
97
- # Performance-booster for watching directories on Windows
98
- gem "wdm", "~> 0.1.0", :install_if => Gem.win_platform?
99
+ # Performance-booster for watching directories on Windows
100
+ gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
99
101
 
100
- RUBY
102
+ RUBY
101
103
  end
102
104
 
103
105
  def create_site(new_blog_path)