jekyll-assets 2.0.0.pre.beta4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +79 -9
- data/lib/jekyll-assets.rb +4 -0
- data/lib/jekyll/assets.rb +14 -15
- data/lib/jekyll/assets/addons.rb +10 -0
- data/lib/jekyll/assets/addons/autoprefixer.rb +4 -0
- data/lib/jekyll/assets/addons/bootstrap.rb +4 -0
- data/lib/jekyll/assets/addons/compass.rb +4 -0
- data/lib/jekyll/assets/addons/font_awesome.rb +4 -0
- data/lib/jekyll/assets/addons/js_es6.rb +4 -0
- data/lib/jekyll/assets/addons/proxies/magick.rb +57 -27
- data/lib/jekyll/assets/cached.rb +4 -0
- data/lib/jekyll/assets/config.rb +7 -3
- data/lib/jekyll/assets/env.rb +68 -107
- data/lib/jekyll/assets/hook.rb +19 -12
- data/lib/jekyll/assets/hooks.rb +19 -0
- data/lib/jekyll/assets/hooks/cache.rb +4 -0
- data/lib/jekyll/assets/hooks/compression.rb +4 -0
- data/lib/jekyll/assets/hooks/configuration.rb +4 -0
- data/lib/jekyll/assets/hooks/context_patches.rb +5 -0
- data/lib/jekyll/assets/hooks/disable_erb.rb +4 -0
- data/lib/jekyll/assets/hooks/helpers.rb +4 -0
- data/lib/jekyll/assets/hooks/jekyll/asset_drops.rb +7 -0
- data/lib/jekyll/assets/hooks/jekyll/ignore.rb +9 -0
- data/lib/jekyll/{hooks → assets/hooks/jekyll}/initialize.rb +4 -0
- data/lib/jekyll/{hooks → assets/hooks/jekyll}/write_assets.rb +4 -0
- data/lib/jekyll/assets/hooks/logger.rb +4 -0
- data/lib/jekyll/assets/hooks/sources.rb +5 -1
- data/lib/jekyll/assets/hooks/sprockets.rb +4 -0
- data/lib/jekyll/assets/hooks/version.rb +5 -1
- data/lib/jekyll/assets/liquid.rb +13 -0
- data/lib/jekyll/assets/liquid/drop.rb +59 -0
- data/lib/jekyll/assets/liquid/filters.rb +16 -1
- data/lib/jekyll/assets/liquid/tag.rb +61 -37
- data/lib/jekyll/assets/liquid/tag/defaults.rb +18 -0
- data/lib/jekyll/assets/liquid/tag/defaults/image.rb +51 -0
- data/lib/jekyll/assets/liquid/tag/parser.rb +56 -28
- data/lib/jekyll/assets/liquid/tag/proxied_asset.rb +14 -12
- data/lib/jekyll/assets/liquid/tag/proxies.rb +28 -24
- data/lib/jekyll/assets/logger.rb +13 -13
- data/lib/jekyll/assets/patches.rb +8 -0
- data/lib/jekyll/assets/patches/jekyll/cleaner.rb +4 -0
- data/lib/jekyll/assets/patches/jekyll/site.rb +4 -0
- data/lib/jekyll/assets/patches/kernel.rb +8 -0
- data/lib/jekyll/assets/patches/sprockets/asset.rb +6 -2
- data/lib/jekyll/assets/version.rb +5 -1
- metadata +33 -11
- data/lib/jekyll/assets/patches/hash.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03eb71fd5a47c2e0e6751282a641078cf0073323
|
4
|
+
data.tar.gz: fe08b59368965a3972b499351cbe582604d07041
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab6aedd38ebadf43e71fecd4548c254afdc7143c45dcc85f32fa2e86b6295a62eab8bcb828546dfb6d97328e07acc16a899fd0cad1d8b01b18ab7d8823717854
|
7
|
+
data.tar.gz: d1b30bbebba9a6cfe9a77a7ef563088e0d168d1d83d83a4b097f9ba46b017f77229c919c98cd592ebcb54a17062529e0af414267e0a1d9317f0d704782d472b1
|
data/README.md
CHANGED
@@ -43,7 +43,13 @@ assets:
|
|
43
43
|
- "bundle.css"
|
44
44
|
digest: true
|
45
45
|
sources:
|
46
|
-
-
|
46
|
+
- _assets/css
|
47
|
+
- _assets/images
|
48
|
+
- _assets/javascripts
|
49
|
+
- _assets/stylesheets
|
50
|
+
- _assets/fonts
|
51
|
+
- _assets/img
|
52
|
+
- _assets/js
|
47
53
|
```
|
48
54
|
|
49
55
|
### Digesting
|
@@ -57,13 +63,22 @@ assets:
|
|
57
63
|
* Disable compression by default in development.
|
58
64
|
* Enable by default in production.
|
59
65
|
|
60
|
-
***You can force digesting with `digest: true` in your `_config.yml`***
|
61
66
|
|
62
|
-
|
67
|
+
### Bower (web components support.)
|
63
68
|
|
64
|
-
|
65
|
-
|
66
|
-
|
69
|
+
Modify your `.bowerrc` file and add:
|
70
|
+
|
71
|
+
```javascript
|
72
|
+
{
|
73
|
+
"directory": "_assets/bower"
|
74
|
+
}
|
75
|
+
```
|
76
|
+
|
77
|
+
And then add `_assets/bower` to your sources list and Sprockets will do the
|
78
|
+
the rest for you... you can even `//= require bower_asset.js`. We will even
|
79
|
+
compress them for you per normal if Sprockets supports it and allows us to.
|
80
|
+
|
81
|
+
***You can force digesting with `digest: true` in your `_config.yml`***
|
67
82
|
|
68
83
|
## Tags
|
69
84
|
|
@@ -101,6 +116,49 @@ rules for our tags as a specification.
|
|
101
116
|
* `sprockets:accept:<value>`
|
102
117
|
* `sprockets:write_to:<value>`
|
103
118
|
|
119
|
+
## Liquid Variables in Arguments
|
120
|
+
|
121
|
+
You can use Liquid variables inside of your arguments, but you must quote
|
122
|
+
them to get them to work, this can be a partial argument quote a full argument
|
123
|
+
quote or otherwise, it just must be quoted or escaped.
|
124
|
+
|
125
|
+
```liquid
|
126
|
+
{% img '{{ image_path }}' %}
|
127
|
+
{% img '{{ image_path }}' proxy:key:'{{ value }}' %}
|
128
|
+
{% img {{\ image_path\ }} %}
|
129
|
+
```
|
130
|
+
|
131
|
+
## Getting a list of your assets and basic info from Liquid
|
132
|
+
|
133
|
+
We provide all *your* assets as a hash of Liquid Drops so you can get basic
|
134
|
+
info that we wish you to have access to without having to prepare the class.
|
135
|
+
|
136
|
+
```liquid
|
137
|
+
{{ assets["bundle.css"].content_type }} => "text/css"
|
138
|
+
{{ assets["images.jpg"].width }} => 62
|
139
|
+
{{ assets["images.jpg"].height }} => 62
|
140
|
+
```
|
141
|
+
|
142
|
+
The current list of available accessors:
|
143
|
+
|
144
|
+
* `logical_path`
|
145
|
+
* `content_type` -> `type`
|
146
|
+
* `filename`
|
147
|
+
* `basename`
|
148
|
+
* `width`
|
149
|
+
* `height`
|
150
|
+
|
151
|
+
If you would like more, please feel free to add a pull request, at this
|
152
|
+
time we will reject all pull requests that wish to add any digested paths as
|
153
|
+
those are dynamically created when a proxy is ran so we can never predict
|
154
|
+
it reliably unless we proxy and that would be a performance problem.
|
155
|
+
|
156
|
+
## ERB Support
|
157
|
+
|
158
|
+
ERB Support is removed in favor of trying to get this included on Github Pages
|
159
|
+
eventually (if I can.) Having ERB presents a security risk to Github because it
|
160
|
+
would allow you to use Ruby in ways they don't want you to.
|
161
|
+
|
104
162
|
## Filters
|
105
163
|
|
106
164
|
There is a full suite of filters, actually, any tag and any proxy can be a
|
@@ -122,6 +180,14 @@ Jekyll::Assets::Hook.register :env, :init do
|
|
122
180
|
end
|
123
181
|
```
|
124
182
|
|
183
|
+
## Sass Helpers
|
184
|
+
|
185
|
+
***Our currently supported helpers are:***
|
186
|
+
|
187
|
+
* asset_path
|
188
|
+
* image_path
|
189
|
+
* font_path
|
190
|
+
|
125
191
|
## Addons
|
126
192
|
|
127
193
|
* CSS Auto Prefixer - add "autoprefixer-rails" to your Gemfile.
|
@@ -143,9 +209,13 @@ that point rather than trying to fight it.***
|
|
143
209
|
* `magick:rotate:<value>`
|
144
210
|
* `magick:crop:<value>`
|
145
211
|
* `magick:flip:<value>`
|
146
|
-
* `magick:
|
147
|
-
* `magick:
|
148
|
-
* `magick:
|
212
|
+
* `magick:quadruple`, `magick:4x`
|
213
|
+
* `magick:one-third`, `magick:1/3`
|
214
|
+
* `magick:three-fourths`, `magick:3/4`
|
215
|
+
* `magick:two-fourths`, `magick:2/4`
|
216
|
+
* `magick:two-thirds`, `magick:2/3`
|
217
|
+
* `magick:one-fourth`, `magick:1/4`
|
218
|
+
* `magick:half`, `magick:1/2`
|
149
219
|
|
150
220
|
## Plugins where did they go?
|
151
221
|
|
data/lib/jekyll-assets.rb
CHANGED
data/lib/jekyll/assets.rb
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2012-2015 - MIT License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
1
5
|
require "sprockets"
|
2
6
|
require "jekyll"
|
3
7
|
|
4
|
-
Dir.glob(File.expand_path("hooks/*.rb", __dir__)).map do |file|
|
5
|
-
require file
|
6
|
-
end
|
7
|
-
|
8
8
|
module Jekyll
|
9
9
|
module Assets
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
10
|
+
require_relative "assets/version"
|
11
|
+
require_relative "assets/patches"
|
12
|
+
require_relative "assets/cached"
|
13
|
+
require_relative "assets/config"
|
14
|
+
require_relative "assets/env"
|
15
|
+
require_relative "assets/hook"
|
16
|
+
require_relative "assets/logger"
|
17
|
+
require_relative "assets/hooks"
|
18
|
+
require_relative "assets/liquid"
|
19
|
+
require_relative "assets/addons"
|
21
20
|
end
|
22
21
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2012-2015 - MIT License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
5
|
+
require_relative "addons/compass"
|
6
|
+
require_relative "addons/bootstrap"
|
7
|
+
require_relative "addons/autoprefixer"
|
8
|
+
require_relative "addons/proxies/magick"
|
9
|
+
require_relative "addons/font_awesome"
|
10
|
+
require_relative "addons/js_es6"
|
@@ -1,22 +1,32 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2012-2015 - MIT License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
1
5
|
try_require "mini_magick" do
|
2
|
-
args = %W(resize quality rotate crop flip
|
3
|
-
|
6
|
+
args = %W(resize quality rotate crop flip)
|
7
|
+
presets = %W(@2x @4x @1/2 @1/3 @2/3 @1/4 @2/4 @3/4
|
8
|
+
@double @quadruple @half @one-third @two-thirds @one-fourth
|
9
|
+
@two-fourths @three-fourths)
|
10
|
+
|
11
|
+
Jekyll::Assets::Env.liquid_proxies.add :magick, :img, *(args + presets) do
|
12
|
+
Presets, Args = presets, args
|
4
13
|
class DoubleResizeError < RuntimeError
|
5
14
|
def initialize
|
6
15
|
"Both resize and @*x provided, this is not supported."
|
7
16
|
end
|
8
17
|
end
|
9
18
|
|
10
|
-
# -----------------------------------------------------------------
|
11
19
|
# @see https://github.com/minimagick/minimagick#usage -- All but
|
12
20
|
# the boolean @ options are provided by Minimagick.
|
13
|
-
# -----------------------------------------------------------------
|
14
21
|
|
15
|
-
def initialize(asset, opts)
|
16
|
-
@
|
22
|
+
def initialize(asset, opts, args)
|
23
|
+
@path = asset.filename
|
24
|
+
@opts = opts
|
25
|
+
@asset = asset
|
26
|
+
@args = args
|
17
27
|
end
|
18
28
|
|
19
|
-
#
|
29
|
+
#
|
20
30
|
|
21
31
|
def process
|
22
32
|
img = MiniMagick::Image.open(@path)
|
@@ -31,63 +41,83 @@ try_require "mini_magick" do
|
|
31
41
|
img.destroy!
|
32
42
|
end
|
33
43
|
|
34
|
-
#
|
44
|
+
#
|
45
|
+
|
46
|
+
private
|
47
|
+
def any_preset?(*keys)
|
48
|
+
@opts.keys.any? do |key|
|
49
|
+
keys.include?(key)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
|
55
|
+
private
|
56
|
+
def preset?
|
57
|
+
(@opts.keys - Args.map(&:to_sym)).any?
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
35
61
|
|
36
62
|
private
|
37
63
|
def magick_quality(img)
|
38
64
|
if @opts.has_key?(:quality)
|
39
|
-
img.quality @opts
|
65
|
+
then img.quality @opts[:quality]
|
40
66
|
end
|
41
67
|
end
|
42
68
|
|
43
|
-
#
|
69
|
+
#
|
44
70
|
|
45
71
|
private
|
46
72
|
def magick_resize(img)
|
47
|
-
if @opts.has_key?(:resize) &&
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
elsif @opts.has_key?(:resize)
|
52
|
-
img.resize @opts.fetch(:resize)
|
73
|
+
raise DoubleResizeError if @opts.has_key?(:resize) && preset?
|
74
|
+
if @opts.has_key?(:resize)
|
75
|
+
then img.resize @opts[:resize]
|
53
76
|
end
|
54
77
|
end
|
55
78
|
|
56
|
-
#
|
79
|
+
#
|
57
80
|
|
58
81
|
private
|
59
82
|
def magick_rotate(img)
|
60
83
|
if @opts.has_key?(:rotate)
|
61
|
-
img.rotate @opts
|
84
|
+
then img.rotate @opts[:rotate]
|
62
85
|
end
|
63
86
|
end
|
64
87
|
|
65
|
-
#
|
88
|
+
#
|
66
89
|
|
67
90
|
private
|
68
91
|
def magick_flip(img)
|
69
92
|
if @opts.has_key?(:flip)
|
70
|
-
img.flip @opts
|
93
|
+
then img.flip @opts[:flip]
|
71
94
|
end
|
72
95
|
end
|
73
96
|
|
74
|
-
#
|
97
|
+
#
|
75
98
|
|
76
99
|
private
|
77
100
|
def magick_crop(img)
|
78
101
|
if @opts.has_key?(:crop)
|
79
|
-
img.crop @opts
|
102
|
+
then img.crop @opts[:crop]
|
80
103
|
end
|
81
104
|
end
|
82
105
|
|
83
|
-
#
|
106
|
+
# I just want you to know, we don't even care if you do multiple
|
107
|
+
# resizes or try to, we don't attempt to even attempt to attempt to care
|
108
|
+
# we expect you to be logical and if you aren't we will comply.
|
84
109
|
|
85
110
|
private
|
86
111
|
def magick_preset_resize(img)
|
87
|
-
return unless
|
88
|
-
width, height = img.width *
|
89
|
-
width, height = img.width *
|
90
|
-
width, height = img.width / 2, img.height / 2 if
|
112
|
+
return unless preset?
|
113
|
+
width, height = img.width * 4, img.height * 4 if any_preset?(:"4x", :quadruple)
|
114
|
+
width, height = img.width * 2, img.height * 2 if any_preset?(:"2x", :double)
|
115
|
+
width, height = img.width / 2, img.height / 2 if any_preset?(:"1/2", :half)
|
116
|
+
width, height = img.width / 3, img.height / 3 if any_preset?(:"1/3", :"one-third")
|
117
|
+
width, height = img.width / 4, img.height / 4 if any_preset?(:"1/4", :"one-fourth")
|
118
|
+
width, height = img.width / 3 * 2, img.height / 3 * 2 if any_preset?(:"2/3", :"two-thirds")
|
119
|
+
width, height = img.width / 4 * 2, img.height / 4 * 2 if any_preset?(:"2/4", :"two-fourths")
|
120
|
+
width, height = img.width / 4 * 3, img.height / 4 * 3 if any_preset?(:"3/4", :"three-fourths")
|
91
121
|
img.resize "#{width}x#{height}"
|
92
122
|
end
|
93
123
|
end
|
data/lib/jekyll/assets/cached.rb
CHANGED
data/lib/jekyll/assets/config.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2012-2015 - MIT License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
1
5
|
module Jekyll
|
2
6
|
module Assets
|
3
7
|
module Config
|
@@ -20,7 +24,7 @@ module Jekyll
|
|
20
24
|
]
|
21
25
|
}
|
22
26
|
|
23
|
-
#
|
27
|
+
#
|
24
28
|
|
25
29
|
Production = Development.merge({
|
26
30
|
"digest" => true,
|
@@ -30,13 +34,13 @@ module Jekyll
|
|
30
34
|
},
|
31
35
|
})
|
32
36
|
|
33
|
-
#
|
37
|
+
#
|
34
38
|
|
35
39
|
def self.defaults
|
36
40
|
%W(development test).include?(Jekyll.env) ? Development : Production
|
37
41
|
end
|
38
42
|
|
39
|
-
#
|
43
|
+
#
|
40
44
|
|
41
45
|
def self.merge(nhash, ohash = defaults)
|
42
46
|
ohash.merge(nhash) do |key, oval, nval|
|
data/lib/jekyll/assets/env.rb
CHANGED
@@ -1,199 +1,160 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2012-2015 - MIT License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
1
5
|
module Jekyll
|
2
6
|
module Assets
|
3
7
|
class Env < Sprockets::Environment
|
4
8
|
attr_reader :jekyll, :used
|
5
9
|
|
6
10
|
class << self
|
7
|
-
attr_accessor :
|
8
|
-
def
|
9
|
-
return
|
11
|
+
attr_accessor :past
|
12
|
+
def liquid_proxies
|
13
|
+
return Liquid::Tag::Proxies
|
10
14
|
end
|
15
|
+
end
|
11
16
|
|
12
|
-
|
17
|
+
#
|
13
18
|
|
14
|
-
|
15
|
-
|
19
|
+
def all_unparsed_assets
|
20
|
+
@unparsed_assets ||= logical_paths.select do |(_, val)|
|
21
|
+
val.start_with?(jekyll.in_source_dir)
|
16
22
|
end
|
17
23
|
end
|
18
24
|
|
19
|
-
#
|
25
|
+
#
|
20
26
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
27
|
+
def to_liquid_payload
|
28
|
+
jekyll.sprockets.all_unparsed_assets.inject({}) do |hsh, (key, val)|
|
29
|
+
hsh[key] = Jekyll::Assets::Liquid::Drop.new(val, jekyll)
|
30
|
+
hsh
|
31
|
+
end
|
25
32
|
end
|
26
33
|
|
27
|
-
#
|
34
|
+
#
|
28
35
|
|
29
36
|
def initialize(path, jekyll = nil)
|
30
37
|
jekyll, path = path, nil if path.is_a?(Jekyll::Site)
|
31
38
|
@used, @jekyll = Set.new, jekyll
|
39
|
+
|
32
40
|
path ? super(path) : super()
|
33
|
-
Hook.trigger
|
34
|
-
hook.arity > 0 || 0 > hook.arity ? hook.call(self) :
|
41
|
+
Hook.trigger :env, :init do |hook|
|
42
|
+
hook.arity > 0 || 0 > hook.arity ? hook.call(self) : \
|
43
|
+
instance_eval(&hook)
|
35
44
|
end
|
36
45
|
end
|
37
46
|
|
38
|
-
#
|
47
|
+
#
|
39
48
|
|
40
49
|
def liquid_proxies
|
41
50
|
return self.class.liquid_proxies
|
42
51
|
end
|
43
52
|
|
44
|
-
# -----------------------------------------------------------------------
|
45
53
|
# Make sure a path falls withint our cache dir.
|
46
|
-
# -----------------------------------------------------------------------
|
47
54
|
|
48
55
|
def in_cache_dir(*paths)
|
49
|
-
cache_dir = asset_config
|
56
|
+
cache_dir = asset_config["cache"] || ".asset-cache"
|
50
57
|
jekyll.in_source_dir(cache_dir, *paths)
|
51
58
|
end
|
52
59
|
|
53
|
-
#
|
54
|
-
# Whether or not we are writing from the cache.
|
55
|
-
# -----------------------------------------------------------------------
|
60
|
+
# Merged form of `#extra_assets`
|
56
61
|
|
57
|
-
def
|
58
|
-
|
62
|
+
def all_assets
|
63
|
+
Set.new(@used).merge extra_assets
|
59
64
|
end
|
60
65
|
|
61
|
-
# -----------------------------------------------------------------------
|
62
|
-
# Merged form of `#extra_assets` and `@used` assets.
|
63
|
-
# -----------------------------------------------------------------------
|
64
|
-
|
65
|
-
def all_assets(cached = false)
|
66
|
-
if !cached
|
67
|
-
then Set.new(@used).merge extra_assets
|
68
|
-
else Set.new(self.class.assets_cache).merge(extra_assets)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# -----------------------------------------------------------------------
|
73
66
|
# Assets you tell us you want to always compile, even if you do not
|
74
67
|
# use them. Just like Rails this is probably normally used.
|
75
|
-
# -----------------------------------------------------------------------
|
76
68
|
|
77
69
|
def extra_assets
|
78
|
-
|
70
|
+
assets = asset_config["assets"] ||= []
|
71
|
+
each_logical_path(*assets).map do |v|
|
79
72
|
find_asset v
|
80
73
|
end
|
81
74
|
end
|
82
75
|
|
83
|
-
#
|
76
|
+
#
|
84
77
|
|
85
78
|
def cdn?
|
86
|
-
!dev? && asset_config.has_key?("cdn") &&
|
79
|
+
!dev? && asset_config.has_key?("cdn") && \
|
80
|
+
asset_config["cdn"]
|
87
81
|
end
|
88
82
|
|
89
|
-
#
|
83
|
+
#
|
90
84
|
|
91
85
|
def baseurl
|
92
|
-
|
86
|
+
ary = []
|
87
|
+
|
88
|
+
ary << jekyll.config["baseurl"] unless cdn? && asset_config["skip_baseurl_with_cdn"]
|
89
|
+
ary << asset_config[ "prefix"] unless cdn? && asset_config[ "skip_prefix_with_cdn"]
|
90
|
+
File.join(*ary.delete_if do |val|
|
91
|
+
val.nil? || val.empty?
|
92
|
+
end)
|
93
93
|
end
|
94
94
|
|
95
|
-
#
|
95
|
+
#
|
96
96
|
|
97
97
|
def dev?
|
98
98
|
%W(development test).include?(Jekyll.env)
|
99
99
|
end
|
100
100
|
|
101
|
-
#
|
101
|
+
#
|
102
102
|
|
103
103
|
def compress?(what)
|
104
|
-
!!asset_config
|
104
|
+
!!asset_config["compress"]. \
|
105
|
+
fetch(what, false)
|
105
106
|
end
|
106
107
|
|
107
|
-
#
|
108
|
+
#
|
108
109
|
|
109
110
|
def asset_config
|
110
|
-
jekyll.config
|
111
|
+
jekyll.config["assets"] ||= {}
|
111
112
|
end
|
112
113
|
|
113
|
-
#
|
114
|
+
#
|
114
115
|
|
115
116
|
def digest?
|
116
|
-
!!asset_config
|
117
|
+
!!asset_config["digest"]
|
117
118
|
end
|
118
119
|
|
119
|
-
#
|
120
|
+
# Prefix path prefixes the path with the baseurl and the cdn if it
|
121
|
+
# exists and is in the right mode to use it. Otherwise it will only use
|
122
|
+
# the baseurl and asset prefix. All of these can be adjusted.
|
120
123
|
|
121
|
-
def
|
122
|
-
|
123
|
-
|
124
|
+
def prefix_path(path = nil)
|
125
|
+
_baseurl = baseurl
|
126
|
+
cdn = asset_config["cdn"]
|
127
|
+
_path = []
|
124
128
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
def prefix_path(path = "")
|
130
|
-
prefix = cdn? && asset_config.fetch( "skip_prefix_with_cdn") ? "" : self. prefix
|
131
|
-
baseurl = cdn? && asset_config.fetch("skip_baseurl_with_cdn") ? "" : self.baseurl
|
132
|
-
path = [baseurl, prefix, path]
|
133
|
-
|
134
|
-
cdn = asset_config.fetch("cdn") if asset_config.has_key?("cdn")
|
135
|
-
cdn? && cdn ? File.join(cdn, *path).chomp("/") : \
|
136
|
-
File.join(*path).chomp("/")
|
129
|
+
_path << _baseurl unless _baseurl.empty?
|
130
|
+
_path << path unless path.nil?
|
131
|
+
cdn? && cdn ? File.join(cdn, *_path).chomp("/") : \
|
132
|
+
File.join(*_path).chomp("/")
|
137
133
|
end
|
138
134
|
|
139
|
-
#
|
135
|
+
#
|
140
136
|
|
141
137
|
def cached
|
142
138
|
Cached.new(self)
|
143
139
|
end
|
144
140
|
|
145
|
-
#
|
141
|
+
#
|
146
142
|
|
147
143
|
def write_all
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
# -----------------------------------------------------------------------
|
154
|
-
|
155
|
-
private
|
156
|
-
def write_assets(assets = self.all_assets)
|
157
|
-
self.class.assets_cache = assets
|
158
|
-
self.class.digest_cache = Hash[assets.map do |a|
|
159
|
-
[a.logical_path, a.digest]
|
160
|
-
end]
|
161
|
-
|
162
|
-
assets.each do |v|
|
163
|
-
v.write_to as_path v
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
# -----------------------------------------------------------------------
|
168
|
-
|
169
|
-
private
|
170
|
-
def write_cached_assets(assets = all_assets(true))
|
171
|
-
assets.each do |a|
|
172
|
-
if !a.is_a?(Liquid::Tag::ProxiedAsset)
|
173
|
-
viejo = self.class.digest_cache[a.logical_path]
|
174
|
-
nuevo = find_asset(a.logical_path).digest
|
175
|
-
path = as_path a
|
176
|
-
|
177
|
-
if nuevo == viejo && File.file?(path)
|
178
|
-
next
|
179
|
-
end
|
180
|
-
else
|
181
|
-
if File.file?(a.logical_path)
|
182
|
-
next
|
183
|
-
end
|
144
|
+
past = self.class.past ||= Set.new
|
145
|
+
(@used.any?? all_assets : past).each do |obj|
|
146
|
+
if past.add(obj) && path = as_path(obj)
|
147
|
+
obj.write_to path
|
184
148
|
end
|
185
|
-
|
186
|
-
self.class.digest_cache[a.logical_path] = a.digest
|
187
|
-
a.write_to as_path a
|
188
149
|
end
|
189
150
|
end
|
190
151
|
|
191
|
-
#
|
152
|
+
#
|
192
153
|
|
193
154
|
private
|
194
155
|
def as_path(v)
|
195
156
|
path = digest?? v.digest_path : v.logical_path
|
196
|
-
jekyll.in_dest_dir(File.join(prefix, path))
|
157
|
+
jekyll.in_dest_dir(File.join(asset_config[ "prefix"], path))
|
197
158
|
end
|
198
159
|
end
|
199
160
|
end
|