jekyll 3.9.1 → 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.
- checksums.yaml +4 -4
- data/.rubocop.yml +27 -50
- data/LICENSE +1 -1
- data/README.markdown +46 -17
- data/lib/blank_template/_config.yml +3 -0
- data/lib/blank_template/_layouts/default.html +12 -0
- data/lib/blank_template/_sass/main.scss +9 -0
- data/lib/blank_template/assets/css/main.scss +4 -0
- data/lib/blank_template/index.md +8 -0
- data/lib/jekyll.rb +5 -0
- data/lib/jekyll/cache.rb +183 -0
- data/lib/jekyll/cleaner.rb +2 -1
- data/lib/jekyll/collection.rb +78 -8
- data/lib/jekyll/command.rb +31 -6
- data/lib/jekyll/commands/build.rb +11 -20
- data/lib/jekyll/commands/clean.rb +2 -0
- data/lib/jekyll/commands/doctor.rb +15 -8
- data/lib/jekyll/commands/help.rb +1 -1
- data/lib/jekyll/commands/new.rb +37 -39
- data/lib/jekyll/commands/new_theme.rb +30 -28
- data/lib/jekyll/commands/serve.rb +46 -80
- data/lib/jekyll/commands/serve/live_reload_reactor.rb +6 -10
- data/lib/jekyll/commands/serve/servlet.rb +9 -11
- data/lib/jekyll/configuration.rb +26 -26
- data/lib/jekyll/converters/identity.rb +18 -0
- data/lib/jekyll/converters/markdown.rb +49 -40
- data/lib/jekyll/converters/markdown/kramdown_parser.rb +1 -10
- data/lib/jekyll/converters/smartypants.rb +34 -14
- data/lib/jekyll/convertible.rb +11 -13
- data/lib/jekyll/deprecator.rb +1 -3
- data/lib/jekyll/document.rb +44 -41
- data/lib/jekyll/drops/collection_drop.rb +2 -3
- data/lib/jekyll/drops/document_drop.rb +2 -1
- data/lib/jekyll/drops/drop.rb +3 -6
- data/lib/jekyll/drops/excerpt_drop.rb +4 -0
- data/lib/jekyll/drops/site_drop.rb +4 -13
- data/lib/jekyll/drops/unified_payload_drop.rb +1 -0
- data/lib/jekyll/drops/url_drop.rb +1 -0
- data/lib/jekyll/entry_filter.rb +2 -1
- data/lib/jekyll/excerpt.rb +45 -34
- data/lib/jekyll/external.rb +10 -5
- data/lib/jekyll/filters.rb +72 -31
- data/lib/jekyll/filters/date_filters.rb +6 -3
- data/lib/jekyll/filters/grouping_filters.rb +1 -2
- data/lib/jekyll/filters/url_filters.rb +6 -1
- data/lib/jekyll/frontmatter_defaults.rb +35 -19
- data/lib/jekyll/hooks.rb +2 -3
- data/lib/jekyll/liquid_extensions.rb +0 -2
- data/lib/jekyll/liquid_renderer.rb +13 -1
- data/lib/jekyll/liquid_renderer/file.rb +14 -3
- data/lib/jekyll/liquid_renderer/table.rb +67 -65
- data/lib/jekyll/log_adapter.rb +5 -1
- data/lib/jekyll/page.rb +10 -11
- data/lib/jekyll/page_without_a_file.rb +0 -4
- data/lib/jekyll/plugin.rb +5 -11
- data/lib/jekyll/plugin_manager.rb +2 -0
- data/lib/jekyll/reader.rb +38 -8
- data/lib/jekyll/readers/data_reader.rb +7 -9
- data/lib/jekyll/readers/layout_reader.rb +2 -12
- data/lib/jekyll/readers/post_reader.rb +29 -17
- data/lib/jekyll/readers/static_file_reader.rb +1 -1
- data/lib/jekyll/readers/theme_assets_reader.rb +7 -5
- data/lib/jekyll/regenerator.rb +4 -12
- data/lib/jekyll/renderer.rb +14 -25
- data/lib/jekyll/site.rb +78 -34
- data/lib/jekyll/static_file.rb +47 -11
- data/lib/jekyll/stevenson.rb +2 -3
- data/lib/jekyll/tags/highlight.rb +22 -52
- data/lib/jekyll/tags/include.rb +22 -38
- data/lib/jekyll/tags/link.rb +11 -7
- data/lib/jekyll/tags/post_url.rb +17 -16
- data/lib/jekyll/theme.rb +12 -23
- data/lib/jekyll/theme_builder.rb +91 -89
- data/lib/jekyll/url.rb +3 -2
- data/lib/jekyll/utils.rb +5 -4
- data/lib/jekyll/utils/ansi.rb +1 -1
- data/lib/jekyll/utils/exec.rb +0 -1
- data/lib/jekyll/utils/internet.rb +2 -4
- data/lib/jekyll/utils/platforms.rb +8 -8
- data/lib/jekyll/utils/thread_event.rb +1 -5
- data/lib/jekyll/utils/win_tz.rb +1 -1
- data/lib/jekyll/version.rb +1 -1
- data/lib/site_template/.gitignore +2 -0
- data/lib/site_template/404.html +1 -0
- data/lib/site_template/_config.yml +17 -5
- data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +5 -1
- data/lib/site_template/{about.md → about.markdown} +0 -0
- data/lib/site_template/{index.md → index.markdown} +0 -0
- data/lib/theme_template/gitignore.erb +1 -0
- data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -0
- metadata +85 -51
- data/lib/jekyll/converters/markdown/rdiscount_parser.rb +0 -37
- data/lib/jekyll/converters/markdown/redcarpet_parser.rb +0 -112
- data/lib/jekyll/utils/rouge.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1510de5e88a3e6d48fa5eb7686dfafc1cf94b820cd9b44fdd635bff9c306d98b
|
4
|
+
data.tar.gz: e4f444b21baf087d33f3dd7040c17b2fa00f5ed4a32f3602ee26722d4270ebc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 854691fcc3090fe0292767b7aaa5c20504d5d11c08c9f301398cc5af70d387c002ad804fdf20a1583ab4a93d326425aff205b89554860c6babb84f6154923b85
|
7
|
+
data.tar.gz: ef22dd4eea32776ef7f25748241f1236431b8fd566bb377d8d66a657ade71e5de836ea149f7c7e0ff3483f471e8da801915261c6e0a110e97a43970707b3b05c
|
data/.rubocop.yml
CHANGED
@@ -8,9 +8,10 @@ Jekyll/NoPutsAllowed:
|
|
8
8
|
- rake/*.rake
|
9
9
|
|
10
10
|
AllCops:
|
11
|
-
TargetRubyVersion: 2.
|
11
|
+
TargetRubyVersion: 2.3
|
12
12
|
Include:
|
13
13
|
- lib/**/*.rb
|
14
|
+
- test/**/*.rb
|
14
15
|
Exclude:
|
15
16
|
- bin/**/*
|
16
17
|
- exe/**/*
|
@@ -18,30 +19,14 @@ AllCops:
|
|
18
19
|
- script/**/*
|
19
20
|
- vendor/**/*
|
20
21
|
- tmp/**/*
|
21
|
-
Layout/AlignArray:
|
22
|
-
Enabled: false
|
23
22
|
Layout/AlignHash:
|
24
23
|
EnforcedHashRocketStyle: table
|
25
|
-
Layout/AlignParameters:
|
26
|
-
Enabled: false
|
27
|
-
Layout/EmptyLinesAroundAccessModifier:
|
28
|
-
Enabled: false
|
29
|
-
Layout/EmptyLinesAroundModuleBody:
|
30
|
-
Enabled: false
|
31
|
-
Layout/EndOfLine:
|
32
|
-
EnforcedStyle: native
|
33
|
-
Layout/ExtraSpacing:
|
34
|
-
AllowForAlignment: true
|
35
|
-
Layout/FirstParameterIndentation:
|
36
|
-
EnforcedStyle: consistent
|
37
24
|
Layout/IndentationWidth:
|
38
25
|
Severity: error
|
39
26
|
Layout/IndentArray:
|
40
27
|
EnforcedStyle: consistent
|
41
28
|
Layout/IndentHash:
|
42
29
|
EnforcedStyle: consistent
|
43
|
-
Layout/IndentHeredoc:
|
44
|
-
Enabled: false
|
45
30
|
Layout/MultilineMethodCallIndentation:
|
46
31
|
EnforcedStyle: indented
|
47
32
|
Layout/MultilineOperationIndentation:
|
@@ -53,14 +38,11 @@ Layout/EmptyComment:
|
|
53
38
|
Enabled: false
|
54
39
|
Layout/EndAlignment:
|
55
40
|
Severity: error
|
56
|
-
Lint/SplatKeywordArguments:
|
57
|
-
Enabled: false
|
58
41
|
Lint/UnreachableCode:
|
59
42
|
Severity: error
|
60
|
-
Lint/UselessAccessModifier:
|
61
|
-
Enabled: false
|
62
43
|
Lint/Void:
|
63
|
-
|
44
|
+
Exclude:
|
45
|
+
- lib/jekyll/site.rb
|
64
46
|
Metrics/AbcSize:
|
65
47
|
Max: 21
|
66
48
|
Metrics/BlockLength:
|
@@ -68,22 +50,26 @@ Metrics/BlockLength:
|
|
68
50
|
- test/**/*.rb
|
69
51
|
- lib/jekyll/configuration.rb
|
70
52
|
- rake/*.rake
|
71
|
-
- jekyll.gemspec
|
72
53
|
Metrics/ClassLength:
|
73
54
|
Exclude:
|
74
55
|
- !ruby/regexp /features\/.*.rb$/
|
75
56
|
- !ruby/regexp /test\/.*.rb$/
|
76
|
-
|
57
|
+
- lib/jekyll/document.rb
|
58
|
+
- lib/jekyll/site.rb
|
59
|
+
- lib/jekyll/commands/serve.rb
|
60
|
+
- lib/jekyll/configuration.rb
|
61
|
+
Max: 240
|
77
62
|
Metrics/CyclomaticComplexity:
|
78
|
-
|
63
|
+
Exclude:
|
64
|
+
- lib/jekyll/utils.rb
|
65
|
+
- lib/jekyll/commands/serve.rb
|
79
66
|
Metrics/LineLength:
|
80
67
|
Exclude:
|
81
68
|
- !ruby/regexp /features\/.*.rb/
|
82
69
|
- Rakefile
|
83
70
|
- rake/*.rake
|
84
71
|
- Gemfile
|
85
|
-
|
86
|
-
Max: 90
|
72
|
+
Max: 100
|
87
73
|
Severity: warning
|
88
74
|
Metrics/MethodLength:
|
89
75
|
CountComments: false
|
@@ -98,15 +84,14 @@ Metrics/PerceivedComplexity:
|
|
98
84
|
Naming/FileName:
|
99
85
|
Enabled: false
|
100
86
|
Naming/HeredocDelimiterNaming:
|
101
|
-
|
87
|
+
Exclude:
|
88
|
+
- test/**/*.rb
|
102
89
|
Naming/MemoizedInstanceVariableName:
|
103
90
|
Exclude:
|
104
|
-
- lib/jekyll/
|
105
|
-
- lib/jekyll/drops/unified_payload_drop.rb
|
91
|
+
- lib/jekyll/convertible.rb
|
106
92
|
- lib/jekyll/drops/site_drop.rb
|
107
|
-
|
108
|
-
|
109
|
-
- _
|
93
|
+
- lib/jekyll/drops/unified_payload_drop.rb
|
94
|
+
- lib/jekyll/page_without_a_file.rb
|
110
95
|
Security/MarshalLoad:
|
111
96
|
Exclude:
|
112
97
|
- !ruby/regexp /test\/.*.rb$/
|
@@ -115,20 +100,19 @@ Security/YAMLLoad:
|
|
115
100
|
Exclude:
|
116
101
|
- !ruby/regexp /features\/.*.rb/
|
117
102
|
- !ruby/regexp /test\/.*.rb$/
|
118
|
-
Style/
|
103
|
+
Style/AccessModifierDeclarations:
|
119
104
|
Enabled: false
|
105
|
+
Style/Alias:
|
106
|
+
EnforcedStyle: prefer_alias_method
|
120
107
|
Style/AndOr:
|
121
108
|
Severity: error
|
122
|
-
Style/BracesAroundHashParameters:
|
123
|
-
Enabled: false
|
124
109
|
Style/ClassAndModuleChildren:
|
125
|
-
|
110
|
+
Exclude:
|
111
|
+
- test/**/*.rb
|
126
112
|
Style/FrozenStringLiteralComment:
|
127
113
|
EnforcedStyle: always
|
128
114
|
Style/Documentation:
|
129
115
|
Enabled: false
|
130
|
-
Exclude:
|
131
|
-
- !ruby/regexp /features\/.*.rb$/
|
132
116
|
Style/DoubleNegation:
|
133
117
|
Enabled: false
|
134
118
|
Style/FormatStringToken:
|
@@ -139,10 +123,6 @@ Style/GuardClause:
|
|
139
123
|
Style/HashSyntax:
|
140
124
|
EnforcedStyle: hash_rockets
|
141
125
|
Severity: error
|
142
|
-
Style/IfUnlessModifier:
|
143
|
-
Enabled: false
|
144
|
-
Style/InverseMethods:
|
145
|
-
Enabled: false
|
146
126
|
Style/MixinUsage:
|
147
127
|
Exclude:
|
148
128
|
- test/helper.rb
|
@@ -159,24 +139,21 @@ Style/PercentLiteralDelimiters:
|
|
159
139
|
"%w": "()"
|
160
140
|
"%W": "()"
|
161
141
|
"%x": "()"
|
162
|
-
Style/RedundantReturn:
|
163
|
-
Enabled: false
|
164
|
-
Style/RedundantSelf:
|
165
|
-
Enabled: false
|
166
142
|
Style/RegexpLiteral:
|
167
143
|
EnforcedStyle: percent_r
|
168
144
|
Style/RescueModifier:
|
169
145
|
Enabled: false
|
146
|
+
Style/SafeNavigation:
|
147
|
+
Exclude:
|
148
|
+
- lib/jekyll/document.rb
|
170
149
|
Style/SignalException:
|
171
150
|
EnforcedStyle: only_raise
|
172
|
-
Style/SingleLineMethods:
|
173
|
-
Enabled: false
|
174
151
|
Style/StringLiterals:
|
175
152
|
EnforcedStyle: double_quotes
|
176
153
|
Style/StringLiteralsInInterpolation:
|
177
154
|
EnforcedStyle: double_quotes
|
178
155
|
Style/SymbolArray:
|
179
|
-
|
156
|
+
EnforcedStyle: brackets
|
180
157
|
Style/TrailingCommaInArrayLiteral:
|
181
158
|
EnforcedStyleForMultiline: consistent_comma
|
182
159
|
Style/TrailingCommaInHashLiteral:
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2008-
|
3
|
+
Copyright (c) 2008-present Tom Preston-Werner and Jekyll contributors
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.markdown
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
[][ruby-gems]
|
4
4
|
[][travis]
|
5
5
|
[][appveyor]
|
6
|
-
[]
|
7
|
-
[]
|
8
|
-
[][gemnasium]
|
6
|
+
[][codeclimate]
|
7
|
+
[][coverage]
|
9
8
|
[][hakiri]
|
9
|
+
[](#backers)
|
10
|
+
[](#sponsors)
|
10
11
|
|
11
12
|
[ruby-gems]: https://rubygems.org/gems/jekyll
|
12
|
-
[gemnasium]: https://gemnasium.com/jekyll/jekyll
|
13
13
|
[codeclimate]: https://codeclimate.com/github/jekyll/jekyll
|
14
14
|
[coverage]: https://codeclimate.com/github/jekyll/jekyll/coverage
|
15
15
|
[hakiri]: https://hakiri.io/github/jekyll/jekyll/master
|
@@ -24,18 +24,28 @@ Jekyll does what you tell it to do — no more, no less. It doesn't try to outs
|
|
24
24
|
|
25
25
|
See: https://jekyllrb.com/philosophy
|
26
26
|
|
27
|
-
## Having trouble?
|
28
|
-
|
29
|
-
See: https://jekyllrb.com/docs/troubleshooting/
|
30
|
-
|
31
27
|
## Getting Started
|
32
28
|
|
33
29
|
* [Install](https://jekyllrb.com/docs/installation/) the gem
|
34
30
|
* Read up about its [Usage](https://jekyllrb.com/docs/usage/) and [Configuration](https://jekyllrb.com/docs/configuration/)
|
35
|
-
* Take a gander at some existing [Sites](https://
|
31
|
+
* Take a gander at some existing [Sites](https://github.com/jekyll/jekyll/wiki/sites)
|
36
32
|
* [Fork](https://github.com/jekyll/jekyll/fork) and [Contribute](https://jekyllrb.com/docs/contributing/) your own modifications
|
37
33
|
* Have questions? Check out our official forum community [Jekyll Talk](https://talk.jekyllrb.com/) or [`#jekyll` on irc.freenode.net](https://botbot.me/freenode/jekyll/)
|
38
34
|
|
35
|
+
## Diving In
|
36
|
+
|
37
|
+
* [Migrate](http://import.jekyllrb.com/docs/home/) from your previous system
|
38
|
+
* Learn how [Front Matter](https://jekyllrb.com/docs/front-matter/) works
|
39
|
+
* Put information on your site with [Variables](https://jekyllrb.com/docs/variables/)
|
40
|
+
* Customize the [Permalinks](https://jekyllrb.com/docs/permalinks/) your posts are generated with
|
41
|
+
* Use the built-in [Liquid Extensions](https://jekyllrb.com/docs/templates/) to make your life easier
|
42
|
+
* Use custom [Plugins](https://jekyllrb.com/docs/plugins/) to generate content specific to your site
|
43
|
+
* Watch [video tutorials from Giraffe Academy](https://jekyllrb.com/tutorials/video-walkthroughs/)
|
44
|
+
|
45
|
+
## Need help?
|
46
|
+
|
47
|
+
If you don't find the answer to your problem in our [docs](https://jekyllrb.com/docs/), or in the [troubleshooting section](https://jekyllrb.com/docs/troubleshooting/), ask the [community](https://jekyllrb.com/docs/community/) for help.
|
48
|
+
|
39
49
|
## Code of Conduct
|
40
50
|
|
41
51
|
In order to have a more open and welcoming community, Jekyll adheres to a
|
@@ -45,16 +55,35 @@ conduct.
|
|
45
55
|
Please adhere to this code of conduct in any interactions you have in the
|
46
56
|
Jekyll community. It is strictly enforced on all official Jekyll
|
47
57
|
repositories, websites, and resources. If you encounter someone violating
|
48
|
-
these terms, please let one of our core team members
|
58
|
+
these terms, please let one of our [core team members](https://jekyllrb.com/team/#core-team) know and we will address it as soon as possible.
|
49
59
|
|
50
|
-
##
|
60
|
+
## Credits
|
51
61
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
62
|
+
### Sponsors
|
63
|
+
|
64
|
+
Support this project by becoming a sponsor. Your logo will show up in this README with a link to your website. [Become a sponsor!](https://opencollective.com/jekyll#sponsor)
|
65
|
+
|
66
|
+
<a href="https://opencollective.com/jekyll/sponsor/0/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/0/avatar.svg" /></a>
|
67
|
+
<a href="https://opencollective.com/jekyll/sponsor/1/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/1/avatar.svg" /></a>
|
68
|
+
<a href="https://opencollective.com/jekyll/sponsor/2/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/2/avatar.svg" /></a>
|
69
|
+
<a href="https://opencollective.com/jekyll/sponsor/3/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/3/avatar.svg" /></a>
|
70
|
+
<a href="https://opencollective.com/jekyll/sponsor/4/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/4/avatar.svg" /></a>
|
71
|
+
<a href="https://opencollective.com/jekyll/sponsor/5/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/5/avatar.svg" /></a>
|
72
|
+
<a href="https://opencollective.com/jekyll/sponsor/6/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/6/avatar.svg" /></a>
|
73
|
+
<a href="https://opencollective.com/jekyll/sponsor/7/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/7/avatar.svg" /></a>
|
74
|
+
<a href="https://opencollective.com/jekyll/sponsor/8/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/8/avatar.svg" /></a>
|
75
|
+
<a href="https://opencollective.com/jekyll/sponsor/9/website" target="_blank"><img src="https://opencollective.com/jekyll/sponsor/9/avatar.svg" /></a>
|
76
|
+
|
77
|
+
### Contributors
|
78
|
+
|
79
|
+
This project exists thanks to all the people who contribute.
|
80
|
+
<a href="../../graphs/contributors"><img src="https://opencollective.com/jekyll/contributors.svg?width=890&button=false" /></a>
|
81
|
+
|
82
|
+
### Backers
|
83
|
+
|
84
|
+
Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/jekyll#backer)
|
85
|
+
|
86
|
+
<a href="https://opencollective.com/jekyll#backers" target="_blank"><img src="https://opencollective.com/jekyll/backers.svg?width=890" /></a>
|
58
87
|
|
59
88
|
## License
|
60
89
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="{{ site.lang | default: "en-US" }}">
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<title>{{ page.title }} - {{ site.title }}</title>
|
7
|
+
<link rel="stylesheet" href="{{ "/assets/css/main.css" | relative_url }}">
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
{{ content}}
|
11
|
+
</body>
|
12
|
+
</html>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
$backgroundColor: #ffffff;
|
2
|
+
$bodyColor: #000000;
|
3
|
+
$bodyFont: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
|
4
|
+
|
5
|
+
body {
|
6
|
+
background: $backgroundColor;
|
7
|
+
color: $bodyColor;
|
8
|
+
font-family: $bodyFont;
|
9
|
+
}
|
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
|
data/lib/jekyll/cache.rb
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "digest"
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
class Cache
|
7
|
+
# rubocop:disable Style/ClassVars
|
8
|
+
@@caches = {}
|
9
|
+
@@disk_cache_enabled = true
|
10
|
+
|
11
|
+
# Get an existing named cache, or create a new one if none exists
|
12
|
+
#
|
13
|
+
# name - name of the cache
|
14
|
+
#
|
15
|
+
# Returns nothing.
|
16
|
+
def initialize(name)
|
17
|
+
@cache = @@caches[name] ||= {}
|
18
|
+
@name = name.gsub(%r![^\w\s-]!, "-")
|
19
|
+
end
|
20
|
+
|
21
|
+
# Set class-wide base_dir
|
22
|
+
def self.base_dir=(dir_path)
|
23
|
+
@@base_dir = dir_path
|
24
|
+
end
|
25
|
+
|
26
|
+
# Disable Marshaling cached items to disk
|
27
|
+
def self.disable_disk_cache!
|
28
|
+
@@disk_cache_enabled = false
|
29
|
+
end
|
30
|
+
# rubocop:enable Style/ClassVars
|
31
|
+
|
32
|
+
# Clear all caches
|
33
|
+
def self.clear
|
34
|
+
delete_cache_files
|
35
|
+
@@caches.each_value(&:clear)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Clear this particular cache
|
39
|
+
def clear
|
40
|
+
delete_cache_files
|
41
|
+
@cache.clear
|
42
|
+
end
|
43
|
+
|
44
|
+
# Retrieve a cached item
|
45
|
+
# Raises if key does not exist in cache
|
46
|
+
#
|
47
|
+
# Returns cached value
|
48
|
+
def [](key)
|
49
|
+
return @cache[key] if @cache.key?(key)
|
50
|
+
|
51
|
+
path = path_to(hash(key))
|
52
|
+
if @@disk_cache_enabled && File.file?(path) && File.readable?(path)
|
53
|
+
@cache[key] = load(path)
|
54
|
+
else
|
55
|
+
raise
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Add an item to cache
|
60
|
+
#
|
61
|
+
# Returns nothing.
|
62
|
+
def []=(key, value)
|
63
|
+
@cache[key] = value
|
64
|
+
return unless @@disk_cache_enabled
|
65
|
+
|
66
|
+
path = path_to(hash(key))
|
67
|
+
value = new Hash(value) if value.is_a?(Hash) && !value.default.nil?
|
68
|
+
dump(path, value)
|
69
|
+
rescue TypeError
|
70
|
+
Jekyll.logger.debug "Cache:", "Cannot dump object #{key}"
|
71
|
+
end
|
72
|
+
|
73
|
+
# If an item already exists in the cache, retrieve it
|
74
|
+
# Else execute code block, and add the result to the cache, and return that
|
75
|
+
# result
|
76
|
+
def getset(key)
|
77
|
+
self[key]
|
78
|
+
rescue StandardError
|
79
|
+
value = yield
|
80
|
+
self[key] = value
|
81
|
+
value
|
82
|
+
end
|
83
|
+
|
84
|
+
# Remove one particular item from the cache
|
85
|
+
#
|
86
|
+
# Returns nothing.
|
87
|
+
def delete(key)
|
88
|
+
@cache.delete(key)
|
89
|
+
return unless @@disk_cache_enabled
|
90
|
+
|
91
|
+
path = path_to(hash(key))
|
92
|
+
File.delete(path)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Check if `key` already exists in this cache
|
96
|
+
#
|
97
|
+
# Returns true if key exists in the cache, false otherwise
|
98
|
+
def key?(key)
|
99
|
+
# First, check if item is already cached in memory
|
100
|
+
return true if @cache.key?(key)
|
101
|
+
# Otherwise, it might be cached on disk
|
102
|
+
# but we should not consider the disk cache if it is disabled
|
103
|
+
return false unless @@disk_cache_enabled
|
104
|
+
|
105
|
+
path = path_to(hash(key))
|
106
|
+
File.file?(path) && File.readable?(path)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Compare the current config to the cached config
|
110
|
+
# If they are different, clear all caches
|
111
|
+
#
|
112
|
+
# Returns nothing.
|
113
|
+
def self.clear_if_config_changed(config)
|
114
|
+
config = config.inspect
|
115
|
+
cache = Jekyll::Cache.new "Jekyll::Cache"
|
116
|
+
return if cache.key?("config") && cache["config"] == config
|
117
|
+
|
118
|
+
clear
|
119
|
+
cache = Jekyll::Cache.new "Jekyll::Cache"
|
120
|
+
cache["config"] = config
|
121
|
+
nil
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
# Given a hashed key, return the path to where this item would be saved on
|
127
|
+
# disk
|
128
|
+
def path_to(hash = nil)
|
129
|
+
@base_dir ||= File.join(@@base_dir, @name)
|
130
|
+
return @base_dir if hash.nil?
|
131
|
+
|
132
|
+
File.join(@base_dir, hash[0..1], hash[2..-1]).freeze
|
133
|
+
end
|
134
|
+
|
135
|
+
# Given a key, return a SHA2 hash that can be used for caching this item to
|
136
|
+
# disk
|
137
|
+
def hash(key)
|
138
|
+
Digest::SHA2.hexdigest(key).freeze
|
139
|
+
end
|
140
|
+
|
141
|
+
# Remove all this caches items from disk
|
142
|
+
#
|
143
|
+
# Returns nothing.
|
144
|
+
def delete_cache_files
|
145
|
+
FileUtils.rm_rf(path_to) if @@disk_cache_enabled
|
146
|
+
end
|
147
|
+
|
148
|
+
# Delete all cached items from all caches
|
149
|
+
#
|
150
|
+
# Returns nothing.
|
151
|
+
def self.delete_cache_files
|
152
|
+
FileUtils.rm_rf(@@base_dir) if @@disk_cache_enabled
|
153
|
+
end
|
154
|
+
private_class_method :delete_cache_files
|
155
|
+
|
156
|
+
# Load `path` from disk and return the result
|
157
|
+
# This MUST NEVER be called in Safe Mode
|
158
|
+
# rubocop:disable Security/MarshalLoad
|
159
|
+
def load(path)
|
160
|
+
raise unless @@disk_cache_enabled
|
161
|
+
|
162
|
+
cached_file = File.open(path, "rb")
|
163
|
+
value = Marshal.load(cached_file)
|
164
|
+
cached_file.close
|
165
|
+
value
|
166
|
+
end
|
167
|
+
# rubocop:enable Security/MarshalLoad
|
168
|
+
|
169
|
+
# Given a path and a value, save value to disk at path
|
170
|
+
# This should NEVER be called in Safe Mode
|
171
|
+
#
|
172
|
+
# Returns nothing.
|
173
|
+
def dump(path, value)
|
174
|
+
return unless @@disk_cache_enabled
|
175
|
+
|
176
|
+
dir = File.dirname(path)
|
177
|
+
FileUtils.mkdir_p(dir)
|
178
|
+
File.open(path, "wb") do |cached_file|
|
179
|
+
Marshal.dump(value, cached_file)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|