jekyll 4.2.1 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +474 -350
  3. data/LICENSE +21 -21
  4. data/README.markdown +83 -86
  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 +186 -190
  12. data/lib/jekyll/cleaner.rb +111 -111
  13. data/lib/jekyll/collection.rb +310 -309
  14. data/lib/jekyll/command.rb +105 -105
  15. data/lib/jekyll/commands/build.rb +82 -93
  16. data/lib/jekyll/commands/clean.rb +44 -45
  17. data/lib/jekyll/commands/doctor.rb +177 -177
  18. data/lib/jekyll/commands/help.rb +34 -34
  19. data/lib/jekyll/commands/new.rb +168 -169
  20. data/lib/jekyll/commands/new_theme.rb +39 -40
  21. data/lib/jekyll/commands/serve/live_reload_reactor.rb +119 -122
  22. data/lib/jekyll/commands/serve/livereload_assets/livereload.js +1183 -1183
  23. data/lib/jekyll/commands/serve/mime_types_charset.json +71 -0
  24. data/lib/jekyll/commands/serve/servlet.rb +206 -202
  25. data/lib/jekyll/commands/serve/websockets.rb +81 -81
  26. data/lib/jekyll/commands/serve.rb +367 -362
  27. data/lib/jekyll/configuration.rb +313 -313
  28. data/lib/jekyll/converter.rb +54 -54
  29. data/lib/jekyll/converters/identity.rb +41 -41
  30. data/lib/jekyll/converters/markdown/kramdown_parser.rb +197 -199
  31. data/lib/jekyll/converters/markdown.rb +113 -113
  32. data/lib/jekyll/converters/smartypants.rb +70 -70
  33. data/lib/jekyll/convertible.rb +257 -257
  34. data/lib/jekyll/data_entry.rb +83 -0
  35. data/lib/jekyll/data_hash.rb +61 -0
  36. data/lib/jekyll/deprecator.rb +50 -50
  37. data/lib/jekyll/document.rb +543 -544
  38. data/lib/jekyll/drops/collection_drop.rb +20 -20
  39. data/lib/jekyll/drops/document_drop.rb +71 -70
  40. data/lib/jekyll/drops/drop.rb +293 -293
  41. data/lib/jekyll/drops/excerpt_drop.rb +23 -19
  42. data/lib/jekyll/drops/jekyll_drop.rb +32 -32
  43. data/lib/jekyll/drops/site_drop.rb +71 -66
  44. data/lib/jekyll/drops/static_file_drop.rb +14 -14
  45. data/lib/jekyll/drops/theme_drop.rb +36 -0
  46. data/lib/jekyll/drops/unified_payload_drop.rb +30 -26
  47. data/lib/jekyll/drops/url_drop.rb +140 -140
  48. data/lib/jekyll/entry_filter.rb +117 -121
  49. data/lib/jekyll/errors.rb +20 -20
  50. data/lib/jekyll/excerpt.rb +200 -201
  51. data/lib/jekyll/external.rb +75 -79
  52. data/lib/jekyll/filters/date_filters.rb +110 -110
  53. data/lib/jekyll/filters/grouping_filters.rb +64 -64
  54. data/lib/jekyll/filters/url_filters.rb +98 -98
  55. data/lib/jekyll/filters.rb +532 -535
  56. data/lib/jekyll/frontmatter_defaults.rb +238 -240
  57. data/lib/jekyll/generator.rb +5 -5
  58. data/lib/jekyll/hooks.rb +107 -107
  59. data/lib/jekyll/inclusion.rb +32 -32
  60. data/lib/jekyll/layout.rb +55 -67
  61. data/lib/jekyll/liquid_extensions.rb +22 -22
  62. data/lib/jekyll/liquid_renderer/file.rb +77 -77
  63. data/lib/jekyll/liquid_renderer/table.rb +55 -55
  64. data/lib/jekyll/liquid_renderer.rb +80 -80
  65. data/lib/jekyll/log_adapter.rb +151 -151
  66. data/lib/jekyll/mime.types +939 -866
  67. data/lib/jekyll/page.rb +215 -217
  68. data/lib/jekyll/page_excerpt.rb +25 -25
  69. data/lib/jekyll/page_without_a_file.rb +14 -14
  70. data/lib/jekyll/path_manager.rb +74 -74
  71. data/lib/jekyll/plugin.rb +92 -92
  72. data/lib/jekyll/plugin_manager.rb +123 -115
  73. data/lib/jekyll/profiler.rb +55 -58
  74. data/lib/jekyll/publisher.rb +23 -23
  75. data/lib/jekyll/reader.rb +209 -192
  76. data/lib/jekyll/readers/collection_reader.rb +23 -23
  77. data/lib/jekyll/readers/data_reader.rb +116 -79
  78. data/lib/jekyll/readers/layout_reader.rb +62 -62
  79. data/lib/jekyll/readers/page_reader.rb +25 -25
  80. data/lib/jekyll/readers/post_reader.rb +85 -85
  81. data/lib/jekyll/readers/static_file_reader.rb +25 -25
  82. data/lib/jekyll/readers/theme_assets_reader.rb +52 -52
  83. data/lib/jekyll/regenerator.rb +195 -195
  84. data/lib/jekyll/related_posts.rb +52 -52
  85. data/lib/jekyll/renderer.rb +263 -265
  86. data/lib/jekyll/site.rb +582 -551
  87. data/lib/jekyll/static_file.rb +205 -208
  88. data/lib/jekyll/stevenson.rb +60 -60
  89. data/lib/jekyll/tags/highlight.rb +114 -110
  90. data/lib/jekyll/tags/include.rb +275 -275
  91. data/lib/jekyll/tags/link.rb +42 -42
  92. data/lib/jekyll/tags/post_url.rb +106 -106
  93. data/lib/jekyll/theme.rb +90 -86
  94. data/lib/jekyll/theme_builder.rb +121 -121
  95. data/lib/jekyll/url.rb +167 -167
  96. data/lib/jekyll/utils/ansi.rb +57 -57
  97. data/lib/jekyll/utils/exec.rb +26 -26
  98. data/lib/jekyll/utils/internet.rb +37 -37
  99. data/lib/jekyll/utils/platforms.rb +67 -67
  100. data/lib/jekyll/utils/thread_event.rb +31 -31
  101. data/lib/jekyll/utils/win_tz.rb +46 -75
  102. data/lib/jekyll/utils.rb +378 -367
  103. data/lib/jekyll/version.rb +5 -5
  104. data/lib/jekyll.rb +197 -195
  105. data/lib/site_template/.gitignore +5 -5
  106. data/lib/site_template/404.html +25 -25
  107. data/lib/site_template/_config.yml +55 -55
  108. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +29 -29
  109. data/lib/site_template/about.markdown +18 -18
  110. data/lib/site_template/index.markdown +6 -6
  111. data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -74
  112. data/lib/theme_template/Gemfile +4 -4
  113. data/lib/theme_template/LICENSE.txt.erb +21 -21
  114. data/lib/theme_template/README.md.erb +50 -52
  115. data/lib/theme_template/_layouts/default.html +1 -1
  116. data/lib/theme_template/_layouts/page.html +5 -5
  117. data/lib/theme_template/_layouts/post.html +5 -5
  118. data/lib/theme_template/example/_config.yml.erb +1 -1
  119. data/lib/theme_template/example/_post.md +12 -12
  120. data/lib/theme_template/example/index.html +14 -14
  121. data/lib/theme_template/example/style.scss +7 -7
  122. data/lib/theme_template/gitignore.erb +6 -6
  123. data/lib/theme_template/theme.gemspec.erb +16 -16
  124. data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -149
  125. data/rubocop/jekyll/no_p_allowed.rb +23 -23
  126. data/rubocop/jekyll/no_puts_allowed.rb +23 -23
  127. data/rubocop/jekyll.rb +5 -5
  128. metadata +62 -14
@@ -1,122 +1,119 @@
1
- # frozen_string_literal: true
2
-
3
- require "em-websocket"
4
-
5
- require_relative "websockets"
6
-
7
- module Jekyll
8
- module Commands
9
- class Serve
10
- class LiveReloadReactor
11
- attr_reader :started_event
12
- attr_reader :stopped_event
13
- attr_reader :thread
14
-
15
- def initialize
16
- @websockets = []
17
- @connections_count = 0
18
- @started_event = Utils::ThreadEvent.new
19
- @stopped_event = Utils::ThreadEvent.new
20
- end
21
-
22
- def stop
23
- # There is only one EventMachine instance per Ruby process so stopping
24
- # it here will stop the reactor thread we have running.
25
- EM.stop if EM.reactor_running?
26
- Jekyll.logger.debug "LiveReload Server:", "halted"
27
- end
28
-
29
- def running?
30
- EM.reactor_running?
31
- end
32
-
33
- def handle_websockets_event(websocket)
34
- websocket.onopen { |handshake| connect(websocket, handshake) }
35
- websocket.onclose { disconnect(websocket) }
36
- websocket.onmessage { |msg| print_message(msg) }
37
- websocket.onerror { |error| log_error(error) }
38
- end
39
-
40
- def start(opts)
41
- @thread = Thread.new do
42
- # Use epoll if the kernel supports it
43
- EM.epoll
44
- EM.run do
45
- EM.error_handler { |e| log_error(e) }
46
-
47
- EM.start_server(
48
- opts["host"],
49
- opts["livereload_port"],
50
- HttpAwareConnection,
51
- opts
52
- ) do |ws|
53
- handle_websockets_event(ws)
54
- end
55
-
56
- # Notify blocked threads that EventMachine has started or shutdown
57
- EM.schedule { @started_event.set }
58
- EM.add_shutdown_hook { @stopped_event.set }
59
-
60
- Jekyll.logger.info "LiveReload address:",
61
- "http://#{opts["host"]}:#{opts["livereload_port"]}"
62
- end
63
- end
64
- @thread.abort_on_exception = true
65
- end
66
-
67
- # For a description of the protocol see
68
- # http://feedback.livereload.com/knowledgebase/articles/86174-livereload-protocol
69
- def reload(pages)
70
- pages.each do |p|
71
- json_message = JSON.dump(
72
- :command => "reload",
73
- :path => p.url,
74
- :liveCSS => true
75
- )
76
-
77
- Jekyll.logger.debug "LiveReload:", "Reloading #{p.url}"
78
- Jekyll.logger.debug "", json_message
79
- @websockets.each { |ws| ws.send(json_message) }
80
- end
81
- end
82
-
83
- private
84
-
85
- def connect(websocket, handshake)
86
- @connections_count += 1
87
- if @connections_count == 1
88
- message = "Browser connected"
89
- message += " over SSL/TLS" if handshake.secure?
90
- Jekyll.logger.info "LiveReload:", message
91
- end
92
- websocket.send(
93
- JSON.dump(
94
- :command => "hello",
95
- :protocols => ["http://livereload.com/protocols/official-7"],
96
- :serverName => "jekyll"
97
- )
98
- )
99
-
100
- @websockets << websocket
101
- end
102
-
103
- def disconnect(websocket)
104
- @websockets.delete(websocket)
105
- end
106
-
107
- def print_message(json_message)
108
- msg = JSON.parse(json_message)
109
- # Not sure what the 'url' command even does in LiveReload. The spec is silent
110
- # on its purpose.
111
- Jekyll.logger.info "LiveReload:", "Browser URL: #{msg["url"]}" if msg["command"] == "url"
112
- end
113
-
114
- def log_error(error)
115
- Jekyll.logger.error "LiveReload experienced an error. " \
116
- "Run with --trace for more information."
117
- raise error
118
- end
119
- end
120
- end
121
- end
122
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "em-websocket"
4
+
5
+ require_relative "websockets"
6
+
7
+ module Jekyll
8
+ module Commands
9
+ class Serve
10
+ class LiveReloadReactor
11
+ attr_reader :started_event, :stopped_event, :thread
12
+
13
+ def initialize
14
+ @websockets = []
15
+ @connections_count = 0
16
+ @started_event = Utils::ThreadEvent.new
17
+ @stopped_event = Utils::ThreadEvent.new
18
+ end
19
+
20
+ def stop
21
+ # There is only one EventMachine instance per Ruby process so stopping
22
+ # it here will stop the reactor thread we have running.
23
+ EM.stop if EM.reactor_running?
24
+ Jekyll.logger.debug "LiveReload Server:", "halted"
25
+ end
26
+
27
+ def running?
28
+ EM.reactor_running?
29
+ end
30
+
31
+ def handle_websockets_event(websocket)
32
+ websocket.onopen { |handshake| connect(websocket, handshake) }
33
+ websocket.onclose { disconnect(websocket) }
34
+ websocket.onmessage { |msg| print_message(msg) }
35
+ websocket.onerror { |error| log_error(error) }
36
+ end
37
+
38
+ def start(opts)
39
+ @thread = Thread.new do
40
+ # Use epoll if the kernel supports it
41
+ EM.epoll
42
+ EM.run do
43
+ EM.error_handler { |e| log_error(e) }
44
+
45
+ EM.start_server(
46
+ opts["host"],
47
+ opts["livereload_port"],
48
+ HttpAwareConnection,
49
+ opts
50
+ ) do |ws|
51
+ handle_websockets_event(ws)
52
+ end
53
+
54
+ # Notify blocked threads that EventMachine has started or shutdown
55
+ EM.schedule { @started_event.set }
56
+ EM.add_shutdown_hook { @stopped_event.set }
57
+
58
+ Jekyll.logger.info "LiveReload address:",
59
+ "http://#{opts["host"]}:#{opts["livereload_port"]}"
60
+ end
61
+ end
62
+ @thread.abort_on_exception = true
63
+ end
64
+
65
+ # For a description of the protocol see
66
+ # http://feedback.livereload.com/knowledgebase/articles/86174-livereload-protocol
67
+ def reload(pages)
68
+ pages.each do |p|
69
+ json_message = JSON.dump(
70
+ :command => "reload",
71
+ :path => p.url,
72
+ :liveCSS => true
73
+ )
74
+
75
+ Jekyll.logger.debug "LiveReload:", "Reloading URL #{p.url.inspect}"
76
+ @websockets.each { |ws| ws.send(json_message) }
77
+ end
78
+ end
79
+
80
+ private
81
+
82
+ def connect(websocket, handshake)
83
+ @connections_count += 1
84
+ if @connections_count == 1
85
+ message = "Browser connected"
86
+ message += " over SSL/TLS" if handshake.secure?
87
+ Jekyll.logger.info "LiveReload:", message
88
+ end
89
+ websocket.send(
90
+ JSON.dump(
91
+ :command => "hello",
92
+ :protocols => ["http://livereload.com/protocols/official-7"],
93
+ :serverName => "jekyll"
94
+ )
95
+ )
96
+
97
+ @websockets << websocket
98
+ end
99
+
100
+ def disconnect(websocket)
101
+ @websockets.delete(websocket)
102
+ end
103
+
104
+ def print_message(json_message)
105
+ msg = JSON.parse(json_message)
106
+ # Not sure what the 'url' command even does in LiveReload. The spec is silent
107
+ # on its purpose.
108
+ Jekyll.logger.info "LiveReload:", "Browser URL: #{msg["url"]}" if msg["command"] == "url"
109
+ end
110
+
111
+ def log_error(error)
112
+ Jekyll.logger.error "LiveReload experienced an error. " \
113
+ "Run with --trace for more information."
114
+ raise error
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end