jekyll 4.0.1 → 4.2.1

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 (124) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +350 -163
  3. data/LICENSE +21 -21
  4. data/README.markdown +86 -90
  5. data/exe/jekyll +57 -57
  6. data/lib/blank_template/_config.yml +3 -3
  7. data/lib/blank_template/_layouts/default.html +12 -12
  8. data/lib/blank_template/_sass/main.scss +9 -9
  9. data/lib/blank_template/assets/css/main.scss +4 -4
  10. data/lib/blank_template/index.md +8 -8
  11. data/lib/jekyll/cache.rb +190 -190
  12. data/lib/jekyll/cleaner.rb +111 -111
  13. data/lib/jekyll/collection.rb +309 -309
  14. data/lib/jekyll/command.rb +105 -103
  15. data/lib/jekyll/commands/build.rb +93 -93
  16. data/lib/jekyll/commands/clean.rb +45 -45
  17. data/lib/jekyll/commands/doctor.rb +177 -173
  18. data/lib/jekyll/commands/help.rb +34 -34
  19. data/lib/jekyll/commands/new.rb +169 -169
  20. data/lib/jekyll/commands/new_theme.rb +40 -42
  21. data/lib/jekyll/commands/serve/live_reload_reactor.rb +122 -122
  22. data/lib/jekyll/commands/serve/livereload_assets/livereload.js +1183 -1183
  23. data/lib/jekyll/commands/serve/servlet.rb +202 -202
  24. data/lib/jekyll/commands/serve/websockets.rb +81 -81
  25. data/lib/jekyll/commands/serve.rb +362 -354
  26. data/lib/jekyll/configuration.rb +313 -316
  27. data/lib/jekyll/converter.rb +54 -54
  28. data/lib/jekyll/converters/identity.rb +41 -41
  29. data/lib/jekyll/converters/markdown/kramdown_parser.rb +199 -130
  30. data/lib/jekyll/converters/markdown.rb +113 -113
  31. data/lib/jekyll/converters/smartypants.rb +70 -70
  32. data/lib/jekyll/convertible.rb +257 -254
  33. data/lib/jekyll/deprecator.rb +50 -50
  34. data/lib/jekyll/document.rb +544 -522
  35. data/lib/jekyll/drops/collection_drop.rb +20 -20
  36. data/lib/jekyll/drops/document_drop.rb +70 -69
  37. data/lib/jekyll/drops/drop.rb +293 -215
  38. data/lib/jekyll/drops/excerpt_drop.rb +19 -19
  39. data/lib/jekyll/drops/jekyll_drop.rb +32 -32
  40. data/lib/jekyll/drops/site_drop.rb +66 -66
  41. data/lib/jekyll/drops/static_file_drop.rb +14 -14
  42. data/lib/jekyll/drops/unified_payload_drop.rb +26 -26
  43. data/lib/jekyll/drops/url_drop.rb +140 -132
  44. data/lib/jekyll/entry_filter.rb +121 -110
  45. data/lib/jekyll/errors.rb +20 -20
  46. data/lib/jekyll/excerpt.rb +201 -201
  47. data/lib/jekyll/external.rb +79 -79
  48. data/lib/jekyll/filters/date_filters.rb +110 -110
  49. data/lib/jekyll/filters/grouping_filters.rb +64 -64
  50. data/lib/jekyll/filters/url_filters.rb +98 -68
  51. data/lib/jekyll/filters.rb +535 -454
  52. data/lib/jekyll/frontmatter_defaults.rb +240 -245
  53. data/lib/jekyll/generator.rb +5 -5
  54. data/lib/jekyll/hooks.rb +107 -106
  55. data/lib/jekyll/inclusion.rb +32 -0
  56. data/lib/jekyll/layout.rb +67 -62
  57. data/lib/jekyll/liquid_extensions.rb +22 -22
  58. data/lib/jekyll/liquid_renderer/file.rb +77 -77
  59. data/lib/jekyll/liquid_renderer/table.rb +55 -75
  60. data/lib/jekyll/liquid_renderer.rb +80 -77
  61. data/lib/jekyll/log_adapter.rb +151 -151
  62. data/lib/jekyll/mime.types +866 -866
  63. data/lib/jekyll/page.rb +217 -186
  64. data/lib/jekyll/page_excerpt.rb +25 -0
  65. data/lib/jekyll/page_without_a_file.rb +14 -14
  66. data/lib/jekyll/path_manager.rb +74 -31
  67. data/lib/jekyll/plugin.rb +92 -92
  68. data/lib/jekyll/plugin_manager.rb +115 -115
  69. data/lib/jekyll/profiler.rb +58 -0
  70. data/lib/jekyll/publisher.rb +23 -23
  71. data/lib/jekyll/reader.rb +192 -187
  72. data/lib/jekyll/readers/collection_reader.rb +23 -22
  73. data/lib/jekyll/readers/data_reader.rb +79 -75
  74. data/lib/jekyll/readers/layout_reader.rb +62 -61
  75. data/lib/jekyll/readers/page_reader.rb +25 -24
  76. data/lib/jekyll/readers/post_reader.rb +85 -84
  77. data/lib/jekyll/readers/static_file_reader.rb +25 -24
  78. data/lib/jekyll/readers/theme_assets_reader.rb +52 -51
  79. data/lib/jekyll/regenerator.rb +195 -195
  80. data/lib/jekyll/related_posts.rb +52 -52
  81. data/lib/jekyll/renderer.rb +265 -267
  82. data/lib/jekyll/site.rb +551 -527
  83. data/lib/jekyll/static_file.rb +208 -203
  84. data/lib/jekyll/stevenson.rb +60 -60
  85. data/lib/jekyll/tags/highlight.rb +110 -110
  86. data/lib/jekyll/tags/include.rb +275 -221
  87. data/lib/jekyll/tags/link.rb +42 -41
  88. data/lib/jekyll/tags/post_url.rb +106 -107
  89. data/lib/jekyll/theme.rb +86 -80
  90. data/lib/jekyll/theme_builder.rb +121 -121
  91. data/lib/jekyll/url.rb +167 -164
  92. data/lib/jekyll/utils/ansi.rb +57 -57
  93. data/lib/jekyll/utils/exec.rb +26 -26
  94. data/lib/jekyll/utils/internet.rb +37 -37
  95. data/lib/jekyll/utils/platforms.rb +67 -82
  96. data/lib/jekyll/utils/thread_event.rb +31 -31
  97. data/lib/jekyll/utils/win_tz.rb +75 -75
  98. data/lib/jekyll/utils.rb +367 -367
  99. data/lib/jekyll/version.rb +5 -5
  100. data/lib/jekyll.rb +195 -206
  101. data/lib/site_template/.gitignore +5 -5
  102. data/lib/site_template/404.html +25 -25
  103. data/lib/site_template/_config.yml +55 -55
  104. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +29 -29
  105. data/lib/site_template/about.markdown +18 -18
  106. data/lib/site_template/index.markdown +6 -6
  107. data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -74
  108. data/lib/theme_template/Gemfile +4 -4
  109. data/lib/theme_template/LICENSE.txt.erb +21 -21
  110. data/lib/theme_template/README.md.erb +52 -52
  111. data/lib/theme_template/_layouts/default.html +1 -1
  112. data/lib/theme_template/_layouts/page.html +5 -5
  113. data/lib/theme_template/_layouts/post.html +5 -5
  114. data/lib/theme_template/example/_config.yml.erb +1 -1
  115. data/lib/theme_template/example/_post.md +12 -12
  116. data/lib/theme_template/example/index.html +14 -14
  117. data/lib/theme_template/example/style.scss +7 -7
  118. data/lib/theme_template/gitignore.erb +6 -6
  119. data/lib/theme_template/theme.gemspec.erb +16 -19
  120. data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -149
  121. data/rubocop/jekyll/no_p_allowed.rb +23 -23
  122. data/rubocop/jekyll/no_puts_allowed.rb +23 -23
  123. data/rubocop/jekyll.rb +5 -5
  124. metadata +20 -38
@@ -1,61 +1,62 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- class LayoutReader
5
- attr_reader :site
6
- def initialize(site)
7
- @site = site
8
- @layouts = {}
9
- end
10
-
11
- def read
12
- layout_entries.each do |layout_file|
13
- @layouts[layout_name(layout_file)] = \
14
- Layout.new(site, layout_directory, layout_file)
15
- end
16
-
17
- theme_layout_entries.each do |layout_file|
18
- @layouts[layout_name(layout_file)] ||= \
19
- Layout.new(site, theme_layout_directory, layout_file)
20
- end
21
-
22
- @layouts
23
- end
24
-
25
- def layout_directory
26
- @layout_directory ||= site.in_source_dir(site.config["layouts_dir"])
27
- end
28
-
29
- def theme_layout_directory
30
- @theme_layout_directory ||= site.theme.layouts_path if site.theme
31
- end
32
-
33
- private
34
-
35
- def layout_entries
36
- entries_in layout_directory
37
- end
38
-
39
- def theme_layout_entries
40
- theme_layout_directory ? entries_in(theme_layout_directory) : []
41
- end
42
-
43
- def entries_in(dir)
44
- entries = []
45
- within(dir) do
46
- entries = EntryFilter.new(site).filter(Dir["**/*.*"])
47
- end
48
- entries
49
- end
50
-
51
- def layout_name(file)
52
- file.split(".")[0..-2].join(".")
53
- end
54
-
55
- def within(directory)
56
- return unless File.exist?(directory)
57
-
58
- Dir.chdir(directory) { yield }
59
- end
60
- end
61
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class LayoutReader
5
+ attr_reader :site
6
+
7
+ def initialize(site)
8
+ @site = site
9
+ @layouts = {}
10
+ end
11
+
12
+ def read
13
+ layout_entries.each do |layout_file|
14
+ @layouts[layout_name(layout_file)] = \
15
+ Layout.new(site, layout_directory, layout_file)
16
+ end
17
+
18
+ theme_layout_entries.each do |layout_file|
19
+ @layouts[layout_name(layout_file)] ||= \
20
+ Layout.new(site, theme_layout_directory, layout_file)
21
+ end
22
+
23
+ @layouts
24
+ end
25
+
26
+ def layout_directory
27
+ @layout_directory ||= site.in_source_dir(site.config["layouts_dir"])
28
+ end
29
+
30
+ def theme_layout_directory
31
+ @theme_layout_directory ||= site.theme.layouts_path if site.theme
32
+ end
33
+
34
+ private
35
+
36
+ def layout_entries
37
+ entries_in layout_directory
38
+ end
39
+
40
+ def theme_layout_entries
41
+ theme_layout_directory ? entries_in(theme_layout_directory) : []
42
+ end
43
+
44
+ def entries_in(dir)
45
+ entries = []
46
+ within(dir) do
47
+ entries = EntryFilter.new(site).filter(Dir["**/*.*"])
48
+ end
49
+ entries
50
+ end
51
+
52
+ def layout_name(file)
53
+ file.split(".")[0..-2].join(".")
54
+ end
55
+
56
+ def within(directory)
57
+ return unless File.exist?(directory)
58
+
59
+ Dir.chdir(directory) { yield }
60
+ end
61
+ end
62
+ end
@@ -1,24 +1,25 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- class PageReader
5
- attr_reader :site, :dir, :unfiltered_content
6
- def initialize(site, dir)
7
- @site = site
8
- @dir = dir
9
- @unfiltered_content = []
10
- end
11
-
12
- # Create a new `Jekyll::Page` object for each entry in a given array.
13
- #
14
- # files - An array of file names inside `@dir`
15
- #
16
- # Returns an array of publishable `Jekyll::Page` objects.
17
- def read(files)
18
- files.each do |page|
19
- @unfiltered_content << Page.new(@site, @site.source, @dir, page)
20
- end
21
- @unfiltered_content.select { |page| site.publisher.publish?(page) }
22
- end
23
- end
24
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class PageReader
5
+ attr_reader :site, :dir, :unfiltered_content
6
+
7
+ def initialize(site, dir)
8
+ @site = site
9
+ @dir = dir
10
+ @unfiltered_content = []
11
+ end
12
+
13
+ # Create a new `Jekyll::Page` object for each entry in a given array.
14
+ #
15
+ # files - An array of file names inside `@dir`
16
+ #
17
+ # Returns an array of publishable `Jekyll::Page` objects.
18
+ def read(files)
19
+ files.each do |page|
20
+ @unfiltered_content << Page.new(@site, @site.source, @dir, page)
21
+ end
22
+ @unfiltered_content.select { |page| site.publisher.publish?(page) }
23
+ end
24
+ end
25
+ end
@@ -1,84 +1,85 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- class PostReader
5
- attr_reader :site, :unfiltered_content
6
- def initialize(site)
7
- @site = site
8
- end
9
-
10
- # Read all the files in <source>/<dir>/_drafts and create a new
11
- # Document object with each one.
12
- #
13
- # dir - The String relative path of the directory to read.
14
- #
15
- # Returns nothing.
16
- def read_drafts(dir)
17
- read_publishable(dir, "_drafts", Document::DATELESS_FILENAME_MATCHER)
18
- end
19
-
20
- # Read all the files in <source>/<dir>/_posts and create a new Document
21
- # object with each one.
22
- #
23
- # dir - The String relative path of the directory to read.
24
- #
25
- # Returns nothing.
26
- def read_posts(dir)
27
- read_publishable(dir, "_posts", Document::DATE_FILENAME_MATCHER)
28
- end
29
-
30
- # Read all the files in <source>/<dir>/<magic_dir> and create a new
31
- # Document object with each one insofar as it matches the regexp matcher.
32
- #
33
- # dir - The String relative path of the directory to read.
34
- #
35
- # Returns nothing.
36
- def read_publishable(dir, magic_dir, matcher)
37
- read_content(dir, magic_dir, matcher)
38
- .tap { |docs| docs.each(&:read) }
39
- .select { |doc| processable?(doc) }
40
- end
41
-
42
- # Read all the content files from <source>/<dir>/magic_dir
43
- # and return them with the type klass.
44
- #
45
- # dir - The String relative path of the directory to read.
46
- # magic_dir - The String relative directory to <dir>,
47
- # looks for content here.
48
- # klass - The return type of the content.
49
- #
50
- # Returns klass type of content files
51
- def read_content(dir, magic_dir, matcher)
52
- @site.reader.get_entries(dir, magic_dir).map do |entry|
53
- next unless matcher.match?(entry)
54
-
55
- path = @site.in_source_dir(File.join(dir, magic_dir, entry))
56
- Document.new(path,
57
- :site => @site,
58
- :collection => @site.posts)
59
- end.reject(&:nil?)
60
- end
61
-
62
- private
63
-
64
- def processable?(doc)
65
- if doc.content.nil?
66
- Jekyll.logger.debug "Skipping:", "Content in #{doc.relative_path} is nil"
67
- false
68
- elsif !doc.content.valid_encoding?
69
- Jekyll.logger.debug "Skipping:", "#{doc.relative_path} is not valid UTF-8"
70
- false
71
- else
72
- publishable?(doc)
73
- end
74
- end
75
-
76
- def publishable?(doc)
77
- site.publisher.publish?(doc).tap do |will_publish|
78
- if !will_publish && site.publisher.hidden_in_the_future?(doc)
79
- Jekyll.logger.warn "Skipping:", "#{doc.relative_path} has a future date"
80
- end
81
- end
82
- end
83
- end
84
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class PostReader
5
+ attr_reader :site, :unfiltered_content
6
+
7
+ def initialize(site)
8
+ @site = site
9
+ end
10
+
11
+ # Read all the files in <source>/<dir>/_drafts and create a new
12
+ # Document object with each one.
13
+ #
14
+ # dir - The String relative path of the directory to read.
15
+ #
16
+ # Returns nothing.
17
+ def read_drafts(dir)
18
+ read_publishable(dir, "_drafts", Document::DATELESS_FILENAME_MATCHER)
19
+ end
20
+
21
+ # Read all the files in <source>/<dir>/_posts and create a new Document
22
+ # object with each one.
23
+ #
24
+ # dir - The String relative path of the directory to read.
25
+ #
26
+ # Returns nothing.
27
+ def read_posts(dir)
28
+ read_publishable(dir, "_posts", Document::DATE_FILENAME_MATCHER)
29
+ end
30
+
31
+ # Read all the files in <source>/<dir>/<magic_dir> and create a new
32
+ # Document object with each one insofar as it matches the regexp matcher.
33
+ #
34
+ # dir - The String relative path of the directory to read.
35
+ #
36
+ # Returns nothing.
37
+ def read_publishable(dir, magic_dir, matcher)
38
+ read_content(dir, magic_dir, matcher)
39
+ .tap { |docs| docs.each(&:read) }
40
+ .select { |doc| processable?(doc) }
41
+ end
42
+
43
+ # Read all the content files from <source>/<dir>/magic_dir
44
+ # and return them with the type klass.
45
+ #
46
+ # dir - The String relative path of the directory to read.
47
+ # magic_dir - The String relative directory to <dir>,
48
+ # looks for content here.
49
+ # klass - The return type of the content.
50
+ #
51
+ # Returns klass type of content files
52
+ def read_content(dir, magic_dir, matcher)
53
+ @site.reader.get_entries(dir, magic_dir).map do |entry|
54
+ next unless matcher.match?(entry)
55
+
56
+ path = @site.in_source_dir(File.join(dir, magic_dir, entry))
57
+ Document.new(path,
58
+ :site => @site,
59
+ :collection => @site.posts)
60
+ end.tap(&:compact!)
61
+ end
62
+
63
+ private
64
+
65
+ def processable?(doc)
66
+ if doc.content.nil?
67
+ Jekyll.logger.debug "Skipping:", "Content in #{doc.relative_path} is nil"
68
+ false
69
+ elsif !doc.content.valid_encoding?
70
+ Jekyll.logger.debug "Skipping:", "#{doc.relative_path} is not valid UTF-8"
71
+ false
72
+ else
73
+ publishable?(doc)
74
+ end
75
+ end
76
+
77
+ def publishable?(doc)
78
+ site.publisher.publish?(doc).tap do |will_publish|
79
+ if !will_publish && site.publisher.hidden_in_the_future?(doc)
80
+ Jekyll.logger.warn "Skipping:", "#{doc.relative_path} has a future date"
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -1,24 +1,25 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- class StaticFileReader
5
- attr_reader :site, :dir, :unfiltered_content
6
- def initialize(site, dir)
7
- @site = site
8
- @dir = dir
9
- @unfiltered_content = []
10
- end
11
-
12
- # Create a new StaticFile object for every entry in a given list of basenames.
13
- #
14
- # files - an array of file basenames.
15
- #
16
- # Returns an array of static files.
17
- def read(files)
18
- files.each do |file|
19
- @unfiltered_content << StaticFile.new(@site, @site.source, @dir, file)
20
- end
21
- @unfiltered_content
22
- end
23
- end
24
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class StaticFileReader
5
+ attr_reader :site, :dir, :unfiltered_content
6
+
7
+ def initialize(site, dir)
8
+ @site = site
9
+ @dir = dir
10
+ @unfiltered_content = []
11
+ end
12
+
13
+ # Create a new StaticFile object for every entry in a given list of basenames.
14
+ #
15
+ # files - an array of file basenames.
16
+ #
17
+ # Returns an array of static files.
18
+ def read(files)
19
+ files.each do |file|
20
+ @unfiltered_content << StaticFile.new(@site, @site.source, @dir, file)
21
+ end
22
+ @unfiltered_content
23
+ end
24
+ end
25
+ end
@@ -1,51 +1,52 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- class ThemeAssetsReader
5
- attr_reader :site
6
- def initialize(site)
7
- @site = site
8
- end
9
-
10
- def read
11
- return unless site.theme&.assets_path
12
-
13
- Find.find(site.theme.assets_path) do |path|
14
- next if File.directory?(path)
15
-
16
- if File.symlink?(path)
17
- Jekyll.logger.warn "Theme reader:", "Ignored symlinked asset: #{path}"
18
- else
19
- read_theme_asset(path)
20
- end
21
- end
22
- end
23
-
24
- private
25
-
26
- def read_theme_asset(path)
27
- base = site.theme.root
28
- dir = File.dirname(path.sub("#{site.theme.root}/", ""))
29
- name = File.basename(path)
30
-
31
- if Utils.has_yaml_header?(path)
32
- append_unless_exists site.pages,
33
- Jekyll::Page.new(site, base, dir, name)
34
- else
35
- append_unless_exists site.static_files,
36
- Jekyll::StaticFile.new(site, base, "/#{dir}", name)
37
- end
38
- end
39
-
40
- def append_unless_exists(haystack, new_item)
41
- if haystack.any? { |file| file.relative_path == new_item.relative_path }
42
- Jekyll.logger.debug "Theme:",
43
- "Ignoring #{new_item.relative_path} in theme due to existing file " \
44
- "with that path in site."
45
- return
46
- end
47
-
48
- haystack << new_item
49
- end
50
- end
51
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class ThemeAssetsReader
5
+ attr_reader :site
6
+
7
+ def initialize(site)
8
+ @site = site
9
+ end
10
+
11
+ def read
12
+ return unless site.theme&.assets_path
13
+
14
+ Find.find(site.theme.assets_path) do |path|
15
+ next if File.directory?(path)
16
+
17
+ if File.symlink?(path)
18
+ Jekyll.logger.warn "Theme reader:", "Ignored symlinked asset: #{path}"
19
+ else
20
+ read_theme_asset(path)
21
+ end
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def read_theme_asset(path)
28
+ base = site.theme.root
29
+ dir = File.dirname(path.sub("#{site.theme.root}/", ""))
30
+ name = File.basename(path)
31
+
32
+ if Utils.has_yaml_header?(path)
33
+ append_unless_exists site.pages,
34
+ Jekyll::Page.new(site, base, dir, name)
35
+ else
36
+ append_unless_exists site.static_files,
37
+ Jekyll::StaticFile.new(site, base, "/#{dir}", name)
38
+ end
39
+ end
40
+
41
+ def append_unless_exists(haystack, new_item)
42
+ if haystack.any? { |file| file.relative_path == new_item.relative_path }
43
+ Jekyll.logger.debug "Theme:",
44
+ "Ignoring #{new_item.relative_path} in theme due to existing file " \
45
+ "with that path in site."
46
+ return
47
+ end
48
+
49
+ haystack << new_item
50
+ end
51
+ end
52
+ end