jekyll 3.10.0 → 4.0.0.pre.alpha1

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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +27 -50
  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/cache.rb +183 -0
  11. data/lib/jekyll/cleaner.rb +2 -1
  12. data/lib/jekyll/collection.rb +78 -8
  13. data/lib/jekyll/command.rb +31 -6
  14. data/lib/jekyll/commands/build.rb +11 -20
  15. data/lib/jekyll/commands/clean.rb +2 -0
  16. data/lib/jekyll/commands/doctor.rb +15 -8
  17. data/lib/jekyll/commands/help.rb +1 -1
  18. data/lib/jekyll/commands/new.rb +37 -42
  19. data/lib/jekyll/commands/new_theme.rb +30 -28
  20. data/lib/jekyll/commands/serve/live_reload_reactor.rb +6 -10
  21. data/lib/jekyll/commands/serve/servlet.rb +15 -19
  22. data/lib/jekyll/commands/serve.rb +46 -86
  23. data/lib/jekyll/configuration.rb +26 -26
  24. data/lib/jekyll/converters/identity.rb +18 -0
  25. data/lib/jekyll/converters/markdown/kramdown_parser.rb +1 -10
  26. data/lib/jekyll/converters/markdown.rb +49 -40
  27. data/lib/jekyll/converters/smartypants.rb +34 -14
  28. data/lib/jekyll/convertible.rb +11 -13
  29. data/lib/jekyll/deprecator.rb +1 -3
  30. data/lib/jekyll/document.rb +44 -41
  31. data/lib/jekyll/drops/collection_drop.rb +2 -3
  32. data/lib/jekyll/drops/document_drop.rb +2 -1
  33. data/lib/jekyll/drops/drop.rb +3 -6
  34. data/lib/jekyll/drops/excerpt_drop.rb +4 -0
  35. data/lib/jekyll/drops/site_drop.rb +4 -13
  36. data/lib/jekyll/drops/unified_payload_drop.rb +1 -0
  37. data/lib/jekyll/drops/url_drop.rb +1 -0
  38. data/lib/jekyll/entry_filter.rb +2 -1
  39. data/lib/jekyll/excerpt.rb +45 -34
  40. data/lib/jekyll/external.rb +10 -5
  41. data/lib/jekyll/filters/date_filters.rb +6 -3
  42. data/lib/jekyll/filters/grouping_filters.rb +1 -2
  43. data/lib/jekyll/filters/url_filters.rb +6 -1
  44. data/lib/jekyll/filters.rb +72 -31
  45. data/lib/jekyll/frontmatter_defaults.rb +35 -19
  46. data/lib/jekyll/hooks.rb +2 -3
  47. data/lib/jekyll/liquid_extensions.rb +0 -2
  48. data/lib/jekyll/liquid_renderer/file.rb +14 -3
  49. data/lib/jekyll/liquid_renderer/table.rb +67 -65
  50. data/lib/jekyll/liquid_renderer.rb +13 -1
  51. data/lib/jekyll/log_adapter.rb +5 -1
  52. data/lib/jekyll/mime.types +80 -195
  53. data/lib/jekyll/page.rb +10 -26
  54. data/lib/jekyll/page_without_a_file.rb +0 -4
  55. data/lib/jekyll/plugin.rb +5 -11
  56. data/lib/jekyll/plugin_manager.rb +2 -0
  57. data/lib/jekyll/reader.rb +38 -8
  58. data/lib/jekyll/readers/data_reader.rb +5 -5
  59. data/lib/jekyll/readers/layout_reader.rb +2 -12
  60. data/lib/jekyll/readers/post_reader.rb +29 -17
  61. data/lib/jekyll/readers/static_file_reader.rb +1 -1
  62. data/lib/jekyll/readers/theme_assets_reader.rb +7 -5
  63. data/lib/jekyll/regenerator.rb +4 -12
  64. data/lib/jekyll/renderer.rb +14 -25
  65. data/lib/jekyll/site.rb +78 -34
  66. data/lib/jekyll/static_file.rb +47 -11
  67. data/lib/jekyll/stevenson.rb +7 -5
  68. data/lib/jekyll/tags/highlight.rb +22 -52
  69. data/lib/jekyll/tags/include.rb +27 -48
  70. data/lib/jekyll/tags/link.rb +11 -7
  71. data/lib/jekyll/tags/post_url.rb +17 -16
  72. data/lib/jekyll/theme.rb +12 -23
  73. data/lib/jekyll/theme_builder.rb +91 -89
  74. data/lib/jekyll/url.rb +3 -2
  75. data/lib/jekyll/utils/ansi.rb +1 -1
  76. data/lib/jekyll/utils/exec.rb +0 -1
  77. data/lib/jekyll/utils/internet.rb +2 -4
  78. data/lib/jekyll/utils/platforms.rb +8 -8
  79. data/lib/jekyll/utils/thread_event.rb +1 -5
  80. data/lib/jekyll/utils/win_tz.rb +47 -18
  81. data/lib/jekyll/utils.rb +5 -4
  82. data/lib/jekyll/version.rb +1 -1
  83. data/lib/jekyll.rb +5 -0
  84. data/lib/site_template/.gitignore +2 -0
  85. data/lib/site_template/404.html +1 -0
  86. data/lib/site_template/_config.yml +17 -5
  87. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +5 -1
  88. data/lib/theme_template/gitignore.erb +1 -0
  89. data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -0
  90. metadata +70 -71
  91. data/lib/jekyll/commands/serve/mime_types_charset.json +0 -71
  92. data/lib/jekyll/converters/markdown/rdiscount_parser.rb +0 -37
  93. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +0 -112
  94. data/lib/jekyll/utils/rouge.rb +0 -22
  95. /data/lib/site_template/{about.md → about.markdown} +0 -0
  96. /data/lib/site_template/{index.md → index.markdown} +0 -0
@@ -11,35 +11,64 @@ module Jekyll
11
11
  # timezone - the IANA Time Zone specified in "_config.yml"
12
12
  #
13
13
  # Returns a string that ultimately re-defines ENV["TZ"] in Windows
14
- def calculate(timezone, now = Time.now)
14
+ def calculate(timezone)
15
15
  External.require_with_graceful_fail("tzinfo") unless defined?(TZInfo)
16
16
  tz = TZInfo::Timezone.get(timezone)
17
-
18
- #
19
- # Use period_for_utc and utc_total_offset instead of
20
- # period_for and observed_utc_offset for compatibility with tzinfo v1.
21
- offset = tz.period_for_utc(now.getutc).utc_total_offset
22
-
17
+ difference = Time.now.to_i - tz.now.to_i
23
18
  #
24
19
  # POSIX style definition reverses the offset sign.
25
20
  # e.g. Eastern Standard Time (EST) that is 5Hrs. to the 'west' of Prime Meridian
26
21
  # is denoted as:
27
22
  # EST+5 (or) EST+05:00
28
- # Reference: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
29
- sign = offset.positive? ? "-" : "+"
30
-
31
- rational_hours = offset.abs.to_r / 3600
32
- hours = rational_hours.to_i
33
- minutes = ((rational_hours - hours) * 60).to_i
34
-
23
+ # Reference: http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
24
+ sign = difference.negative? ? "-" : "+"
25
+ offset = sign == "-" ? "+" : "-" unless difference.zero?
35
26
  #
36
- # Format the hours and minutes as two-digit numbers.
37
- time = format("%<hours>02d:%<minutes>02d", :hours => hours, :minutes => minutes)
27
+ # convert the difference (in seconds) to hours, as a rational number, and perform
28
+ # a modulo operation on it.
29
+ modulo = modulo_of(rational_hour(difference))
30
+ #
31
+ # Format the hour as a two-digit number.
32
+ # Establish the minutes based on modulo expression.
33
+ hh = format("%02d", absolute_hour(difference).ceil)
34
+ mm = modulo.zero? ? "00" : "30"
38
35
 
39
- Jekyll.logger.debug "Timezone:", "#{timezone} #{sign}#{time}"
36
+ Jekyll.logger.debug "Timezone:", "#{timezone} #{offset}#{hh}:#{mm}"
40
37
  #
41
38
  # Note: The 3-letter-word below doesn't have a particular significance.
42
- "WTZ#{sign}#{time}"
39
+ "WTZ#{sign}#{hh}:#{mm}"
40
+ end
41
+
42
+ private
43
+
44
+ # Private: Convert given seconds to an hour as a rational number.
45
+ #
46
+ # seconds - supplied as an integer, it is converted to a rational number.
47
+ # 3600 - no. of seconds in an hour.
48
+ #
49
+ # Returns a rational number.
50
+ def rational_hour(seconds)
51
+ seconds.to_r / 3600
52
+ end
53
+
54
+ # Private: Convert given seconds to an hour as an absolute number.
55
+ #
56
+ # seconds - supplied as an integer, it is converted to its absolute.
57
+ # 3600 - no. of seconds in an hour.
58
+ #
59
+ # Returns an integer.
60
+ def absolute_hour(seconds)
61
+ seconds.abs / 3600
62
+ end
63
+
64
+ # Private: Perform a modulo operation on a given fraction.
65
+ #
66
+ # fraction - supplied as a rational number, its numerator is divided
67
+ # by its denominator and the remainder returned.
68
+ #
69
+ # Returns an integer.
70
+ def modulo_of(fraction)
71
+ fraction.numerator % fraction.denominator
43
72
  end
44
73
  end
45
74
  end
data/lib/jekyll/utils.rb CHANGED
@@ -7,7 +7,6 @@ module Jekyll
7
7
  autoload :Exec, "jekyll/utils/exec"
8
8
  autoload :Internet, "jekyll/utils/internet"
9
9
  autoload :Platforms, "jekyll/utils/platforms"
10
- autoload :Rouge, "jekyll/utils/rouge"
11
10
  autoload :ThreadEvent, "jekyll/utils/thread_event"
12
11
  autoload :WinTZ, "jekyll/utils/win_tz"
13
12
 
@@ -153,6 +152,7 @@ module Jekyll
153
152
  # Returns true is the string contains sequences of `{%` or `{{`
154
153
  def has_liquid_construct?(content)
155
154
  return false if content.nil? || content.empty?
155
+
156
156
  content.include?("{%") || content.include?("{{")
157
157
  end
158
158
  # rubocop: enable PredicateName
@@ -222,6 +222,7 @@ module Jekyll
222
222
  slug.gsub!(%r!^\-|\-$!i, "")
223
223
 
224
224
  slug.downcase! unless cased
225
+ Jekyll.logger.warn("Warning:", "Empty `slug` generated for '#{string}'.") if slug.empty?
225
226
  slug
226
227
  end
227
228
 
@@ -293,8 +294,10 @@ module Jekyll
293
294
  # Returns matched pathes
294
295
  def safe_glob(dir, patterns, flags = 0)
295
296
  return [] unless Dir.exist?(dir)
297
+
296
298
  pattern = File.join(Array(patterns))
297
299
  return [dir] if pattern.empty?
300
+
298
301
  Dir.chdir(dir) do
299
302
  Dir.glob(pattern, flags).map { |f| File.join(dir, f) }
300
303
  end
@@ -314,6 +317,7 @@ module Jekyll
314
317
  end
315
318
 
316
319
  private
320
+
317
321
  def merge_values(target, overwrite)
318
322
  target.merge!(overwrite) do |_key, old_val, new_val|
319
323
  if new_val.nil?
@@ -326,14 +330,12 @@ module Jekyll
326
330
  end
327
331
  end
328
332
 
329
- private
330
333
  def merge_default_proc(target, overwrite)
331
334
  if target.is_a?(Hash) && overwrite.is_a?(Hash) && target.default_proc.nil?
332
335
  target.default_proc = overwrite.default_proc
333
336
  end
334
337
  end
335
338
 
336
- private
337
339
  def duplicate_frozen_values(target)
338
340
  target.each do |key, val|
339
341
  target[key] = val.dup if val.frozen? && duplicable?(val)
@@ -344,7 +346,6 @@ module Jekyll
344
346
  #
345
347
  # See Utils#slugify for a description of the character sequence specified
346
348
  # by each mode.
347
- private
348
349
  def replace_character_sequence_with_hyphen(string, mode: "default")
349
350
  replaceable_char =
350
351
  case mode
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jekyll
4
- VERSION = "3.10.0".freeze
4
+ VERSION = "4.0.0.pre.alpha1"
5
5
  end
data/lib/jekyll.rb CHANGED
@@ -54,6 +54,7 @@ module Jekyll
54
54
  autoload :FrontmatterDefaults, "jekyll/frontmatter_defaults"
55
55
  autoload :Hooks, "jekyll/hooks"
56
56
  autoload :Layout, "jekyll/layout"
57
+ autoload :Cache, "jekyll/cache"
57
58
  autoload :CollectionReader, "jekyll/readers/collection_reader"
58
59
  autoload :DataReader, "jekyll/readers/data_reader"
59
60
  autoload :LayoutReader, "jekyll/readers/layout_reader"
@@ -175,6 +176,10 @@ module Jekyll
175
176
 
176
177
  return clean_path if clean_path.eql?(base_directory)
177
178
 
179
+ # remove any remaining extra leading slashes not stripped away by calling
180
+ # `File.expand_path` above.
181
+ clean_path.squeeze!("/")
182
+
178
183
  if clean_path.start_with?(base_directory.sub(%r!\z!, "/"))
179
184
  clean_path
180
185
  else
@@ -1,3 +1,5 @@
1
1
  _site
2
2
  .sass-cache
3
+ .jekyll-cache
3
4
  .jekyll-metadata
5
+ vendor
@@ -1,4 +1,5 @@
1
1
  ---
2
+ permalink: /404.html
2
3
  layout: default
3
4
  ---
4
5
 
@@ -7,12 +7,17 @@
7
7
  #
8
8
  # For technical reasons, this file is *NOT* reloaded automatically when you use
9
9
  # 'bundle exec jekyll serve'. If you change this file, please restart the server process.
10
-
10
+ #
11
+ # If you need help with YAML syntax, here are some quick references for you:
12
+ # https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml
13
+ # https://learnxinyminutes.com/docs/yaml/
14
+ #
11
15
  # Site settings
12
16
  # These are used to personalize your new site. If you look in the HTML files,
13
17
  # you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
14
18
  # You can create any custom variable you would like, and they will be accessible
15
19
  # in the templates via {{ site.myvariable }}.
20
+
16
21
  title: Your awesome title
17
22
  email: your-email@example.com
18
23
  description: >- # this means to ignore newlines until "baseurl:"
@@ -25,18 +30,25 @@ twitter_username: jekyllrb
25
30
  github_username: jekyll
26
31
 
27
32
  # Build settings
28
- markdown: kramdown
29
33
  theme: minima
30
34
  plugins:
31
35
  - jekyll-feed
32
36
 
33
37
  # Exclude from processing.
34
- # The following items will not be processed, by default. Create a custom list
35
- # to override the default setting.
38
+ # The following items will not be processed, by default.
39
+ # Any item listed under the `exclude:` key here will be automatically added to
40
+ # the internal "default list".
41
+ #
42
+ # Excluded items can be processed by explicitly listing the directories or
43
+ # their entries' file path in the `include:` list.
44
+ #
36
45
  # exclude:
46
+ # - .sass-cache/
47
+ # - .jekyll-cache/
48
+ # - gemfiles/
37
49
  # - Gemfile
38
50
  # - Gemfile.lock
39
- # - node_modules
51
+ # - node_modules/
40
52
  # - vendor/bundle/
41
53
  # - vendor/cache/
42
54
  # - vendor/gems/
@@ -6,7 +6,11 @@ categories: jekyll update
6
6
  ---
7
7
  You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated.
8
8
 
9
- To add new posts, simply add a file in the `_posts` directory that follows the convention `YYYY-MM-DD-name-of-post.ext` and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.
9
+ Jekyll requires blog post files to be named according to the following format:
10
+
11
+ `YEAR-MONTH-DAY-title.MARKUP`
12
+
13
+ Where `YEAR` is a four-digit number, `MONTH` and `DAY` are both two-digit numbers, and `MARKUP` is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works.
10
14
 
11
15
  Jekyll also offers powerful support for code snippets:
12
16
 
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  .bundle
3
+ .jekyll-cache
3
4
  .sass-cache
4
5
  _site
5
6
  Gemfile.lock
@@ -0,0 +1,149 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Jekyll
6
+ # Checks for `assert_equal(exp, act, msg = nil)` calls containing literal values as
7
+ # second argument. The second argument should ideally be a method called on the tested
8
+ # instance.
9
+ #
10
+ # @example
11
+ # # bad
12
+ # assert_equal @foo.bar, "foobar"
13
+ # assert_equal @alpha.beta, { "foo" => "bar", "lorem" => "ipsum" }
14
+ # assert_equal @alpha.omega, ["foobar", "lipsum"]
15
+ #
16
+ # # good
17
+ # assert_equal "foobar", @foo.bar
18
+ #
19
+ # assert_equal(
20
+ # { "foo" => "bar", "lorem" => "ipsum" },
21
+ # @alpha.beta
22
+ # )
23
+ #
24
+ # assert_equal(
25
+ # ["foobar", "lipsum"],
26
+ # @alpha.omega
27
+ # )
28
+ #
29
+ class AssertEqualLiteralActual < Cop
30
+ MSG = "Provide the 'expected value' as the first argument to `assert_equal`.".freeze
31
+
32
+ SIMPLE_LITERALS = %i(
33
+ true
34
+ false
35
+ nil
36
+ int
37
+ float
38
+ str
39
+ sym
40
+ complex
41
+ rational
42
+ regopt
43
+ ).freeze
44
+
45
+ COMPLEX_LITERALS = %i(
46
+ array
47
+ hash
48
+ pair
49
+ irange
50
+ erange
51
+ regexp
52
+ ).freeze
53
+
54
+ def_node_matcher :literal_actual?, <<-PATTERN
55
+ (send nil? :assert_equal $(send ...) $#literal?)
56
+ PATTERN
57
+
58
+ def_node_matcher :literal_actual_with_msg?, <<-PATTERN
59
+ (send nil? :assert_equal $(send ...) $#literal? $#opt_msg?)
60
+ PATTERN
61
+
62
+ def on_send(node)
63
+ return unless literal_actual?(node) || literal_actual_with_msg?(node)
64
+ add_offense(node, location: :expression)
65
+ end
66
+
67
+ def autocorrect(node)
68
+ lambda do |corrector|
69
+ corrector.replace(node.loc.expression, replacement(node))
70
+ end
71
+ end
72
+
73
+ private
74
+
75
+ def opt_msg?(node)
76
+ node&.source
77
+ end
78
+
79
+ # This is not implement using a NodePattern because it seems
80
+ # to not be able to match against an explicit (nil) sexp
81
+ def literal?(node)
82
+ node && (simple_literal?(node) || complex_literal?(node))
83
+ end
84
+
85
+ def simple_literal?(node)
86
+ SIMPLE_LITERALS.include?(node.type)
87
+ end
88
+
89
+ def complex_literal?(node)
90
+ COMPLEX_LITERALS.include?(node.type) &&
91
+ node.each_child_node.all?(&method(:literal?))
92
+ end
93
+
94
+ def replacement(node)
95
+ _, _, first_param, second_param, optional_param = *node
96
+
97
+ replaced_text = \
98
+ if second_param.type == :hash
99
+ replace_hash_with_variable(first_param.source, second_param.source)
100
+ elsif second_param.type == :array && second_param.source != "[]"
101
+ replace_array_with_variable(first_param.source, second_param.source)
102
+ else
103
+ replace_based_on_line_length(first_param.source, second_param.source)
104
+ end
105
+
106
+ return "#{replaced_text}, #{optional_param.source}" if optional_param
107
+ replaced_text
108
+ end
109
+
110
+ def replace_based_on_line_length(first_expression, second_expression)
111
+ result = "assert_equal #{second_expression}, #{first_expression}"
112
+ return result if result.length < 80
113
+
114
+ # fold long lines independent of Rubocop configuration for better readability
115
+ <<~TEXT
116
+ assert_equal(
117
+ #{second_expression},
118
+ #{first_expression}
119
+ )
120
+ TEXT
121
+ end
122
+
123
+ def replace_hash_with_variable(first_expression, second_expression)
124
+ expect_expression = if second_expression.start_with?("{")
125
+ second_expression
126
+ else
127
+ "{#{second_expression}}"
128
+ end
129
+ <<~TEXT
130
+ expected = #{expect_expression}
131
+ assert_equal expected, #{first_expression}
132
+ TEXT
133
+ end
134
+
135
+ def replace_array_with_variable(first_expression, second_expression)
136
+ expect_expression = if second_expression.start_with?("%")
137
+ second_expression
138
+ else
139
+ Array(second_expression)
140
+ end
141
+ <<~TEXT
142
+ expected = #{expect_expression}
143
+ assert_equal expected, #{first_expression}
144
+ TEXT
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end