jekyll-assets 2.0.0.pre.beta2 → 2.0.0.pre.beta3
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/Gemfile +4 -4
- data/README.md +33 -40
- data/lib/jekyll/assets.rb +18 -16
- data/lib/jekyll/assets/addons/autoprefixer.rb +5 -0
- data/lib/jekyll/assets/addons/bootstrap.rb +1 -0
- data/lib/jekyll/assets/addons/compass.rb +7 -0
- data/lib/jekyll/assets/addons/font_awesome.rb +1 -0
- data/lib/jekyll/assets/{extras/es6.rb → addons/js_es6.rb} +1 -1
- data/lib/jekyll/assets/addons/proxies/magick.rb +92 -0
- data/lib/jekyll/assets/config.rb +48 -0
- data/lib/jekyll/assets/env.rb +110 -91
- data/lib/jekyll/assets/hook.rb +42 -25
- data/lib/jekyll/assets/hooks/cache.rb +5 -0
- data/lib/jekyll/assets/hooks/compression.rb +11 -0
- data/lib/jekyll/assets/hooks/configuration.rb +3 -0
- data/lib/jekyll/assets/hooks/context_patches.rb +12 -0
- data/lib/jekyll/assets/hooks/disable_erb.rb +6 -0
- data/lib/jekyll/assets/hooks/helpers.rb +8 -0
- data/lib/jekyll/assets/hooks/logger.rb +3 -0
- data/lib/jekyll/assets/hooks/sources.rb +5 -0
- data/lib/jekyll/assets/hooks/sprockets.rb +3 -0
- data/lib/jekyll/assets/hooks/version.rb +3 -0
- data/lib/jekyll/assets/liquid/filters.rb +16 -0
- data/lib/jekyll/assets/liquid/tag.rb +162 -0
- data/lib/jekyll/assets/liquid/tag/parser.rb +163 -0
- data/lib/jekyll/assets/liquid/tag/proxied_asset.rb +98 -0
- data/lib/jekyll/assets/liquid/tag/proxies.rb +122 -0
- data/lib/jekyll/assets/logger.rb +34 -11
- data/lib/jekyll/assets/patches/hash.rb +5 -0
- data/lib/jekyll/assets/patches/jekyll/cleaner.rb +2 -2
- data/lib/jekyll/assets/patches/kernel.rb +31 -0
- data/lib/jekyll/assets/patches/sprockets/asset.rb +6 -6
- data/lib/jekyll/assets/version.rb +1 -1
- data/lib/jekyll/hooks/initialize.rb +3 -0
- data/lib/jekyll/hooks/write_assets.rb +3 -0
- metadata +28 -17
- data/lib/jekyll/assets/configuration.rb +0 -51
- data/lib/jekyll/assets/context.rb +0 -23
- data/lib/jekyll/assets/extras/font-awesome.rb +0 -1
- data/lib/jekyll/assets/extras/helpers.rb +0 -6
- data/lib/jekyll/assets/extras/prefix.rb +0 -5
- data/lib/jekyll/assets/filters.rb +0 -17
- data/lib/jekyll/assets/helpers.rb +0 -37
- data/lib/jekyll/assets/hooks/post_read.rb +0 -3
- data/lib/jekyll/assets/hooks/post_write.rb +0 -3
- data/lib/jekyll/assets/tag.rb +0 -148
- data/lib/jekyll/assets/tag/parser.rb +0 -129
- data/lib/jekyll/assets/tag/proxied_asset.rb +0 -84
- data/lib/jekyll/assets/tag/proxies.rb +0 -86
- data/lib/jekyll/assets/tag/proxies/magick.rb +0 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b637a94a5115e155d2c7a33811f8d61bbdc60be
|
4
|
+
data.tar.gz: a1c781f2d2902d9c748a5ab9ada53e0d2753a610
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a722a4ed9f298f846bc0d3f63cdb7059f50dbc59946fbe386f794c8fcfda876ba00909859c4489d6d045b1439dbd1b20c78f66dd5e57f4619585fd1f02e9ec2
|
7
|
+
data.tar.gz: 2f072f5cecab004b8bdc03da5a032a9b33cfd6108215287e9d062c955711f22781342e4f3278fef97a4a863fbde2b3dfffcfe5803fea1abccdab27b9d4a6ad42
|
data/Gemfile
CHANGED
@@ -3,14 +3,14 @@ gemspec
|
|
3
3
|
|
4
4
|
gem "rake"
|
5
5
|
group :development do
|
6
|
-
gem "pry"
|
7
6
|
gem "therubyracer", :platforms => :mri
|
8
|
-
gem "
|
9
|
-
gem "guard"
|
7
|
+
gem "pry"
|
10
8
|
end
|
11
9
|
|
10
|
+
gem "uglifier"
|
12
11
|
gem "sprockets-es6", "~> 0.6"
|
13
12
|
gem "autoprefixer-rails", "~> 6.0"
|
14
13
|
gem "font-awesome-sass", "~> 4.4.0"
|
14
|
+
gem "bootstrap-sass", "~> 3.3"
|
15
15
|
gem "mini_magick", "~> 4.2"
|
16
|
-
gem "
|
16
|
+
gem "compass-core"
|
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
[][travis]
|
2
|
+
[][coveralls]
|
3
|
+
[][code-climate] [][gemnasium]
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
[gemnasium]: https://gemnasium.com/jekyll/jekyll-assets
|
6
|
+
[code-climate]: https://codeclimate.com/github/jekyll/jekyll-assets
|
7
|
+
[coveralls]: https://coveralls.io/r/jekyll/jekyll-assets
|
8
|
+
[travis]: https://travis-ci.org/jekyll/jekyll-assets
|
7
9
|
|
8
10
|
# Jekyll 3 Assets
|
9
11
|
|
@@ -33,7 +35,8 @@ assets:
|
|
33
35
|
js: false | true | default - development: false, production: true
|
34
36
|
cache: false | directory | default: .asset-cache
|
35
37
|
cdn: https://cdn.example.com
|
36
|
-
|
38
|
+
skip_baseurl_with_cdn: false
|
39
|
+
skip_prefix_with_cdn: false
|
37
40
|
prefix: "/assets"
|
38
41
|
assets:
|
39
42
|
- "*.png"
|
@@ -43,12 +46,12 @@ assets:
|
|
43
46
|
- "_assets/folder"
|
44
47
|
```
|
45
48
|
|
46
|
-
|
49
|
+
### Digesting
|
47
50
|
|
48
51
|
* Disable digesting by default in development.
|
49
52
|
* Digest by default in production
|
50
53
|
|
51
|
-
|
54
|
+
### Compression
|
52
55
|
|
53
56
|
* Requires sass and uglify.
|
54
57
|
* Disable compression by default in development.
|
@@ -95,16 +98,8 @@ rules for our tags as a specification.
|
|
95
98
|
|
96
99
|
### Current Proxies:
|
97
100
|
|
98
|
-
* `sprockets:accept:<value>`
|
99
|
-
* `sprockets:write_to:<value>`
|
100
|
-
* `magick:resize:<value>` - Takes standard ImageMagick resize values.
|
101
|
-
* `magick:format:<value>` - Takes standard ImageMagick format values.
|
102
|
-
* `magick:rotate:<value>` - Takes standard ImageMagick resize values.
|
103
|
-
* `magick:crop:<value>` - Takes standard ImageMagick crop values.
|
104
|
-
* `magick:flip:<value>` - Takes standard ImageMagick flip values.
|
105
|
-
* `magick:2x` - Tells us to write a double width/height image.
|
106
|
-
* `magick:4x` - Tells us to write a quadruple width/height image.
|
107
|
-
* `magick:half` - Tells us to shrink the image to half.
|
101
|
+
* `sprockets:accept:<value>`
|
102
|
+
* `sprockets:write_to:<value>`
|
108
103
|
|
109
104
|
## Filters
|
110
105
|
|
@@ -112,47 +107,45 @@ There is a full suite of filters, actually, any tag and any proxy can be a
|
|
112
107
|
filter by way of filter arguments, take the following example:
|
113
108
|
|
114
109
|
```liquid
|
115
|
-
{{ src | img : "magick:2x" }}
|
110
|
+
{{ src | img : "magick:2x magick:quality:92" }}
|
116
111
|
```
|
117
112
|
|
118
113
|
## Hooks
|
119
114
|
|
120
|
-
* `:env => [
|
121
|
-
:pre_init, :post_init
|
122
|
-
]`
|
115
|
+
* `:env => [:init]`
|
123
116
|
|
124
117
|
You can register and trigger hooks like so:
|
125
118
|
|
126
119
|
```ruby
|
127
|
-
Jekyll::Assets::Hook.
|
128
|
-
Jekyll::Assets::Hook.register :env, :post_init do
|
120
|
+
Jekyll::Assets::Hook.register :env, :init do
|
129
121
|
# Your Work
|
130
122
|
end
|
131
123
|
```
|
132
124
|
|
133
|
-
##
|
125
|
+
## Addons
|
134
126
|
|
135
|
-
* ES6 Transpiler (through Babel) - add "sprockets-es6" to your Gemfile.
|
136
127
|
* CSS Auto Prefixer - add "autoprefixer-rails" to your Gemfile.
|
128
|
+
* ES6 Transpiler (through Babel) - add "sprockets-es6" to your Gemfile.
|
129
|
+
* Image Magick - add "mini_magick" to your Gemfile, only works with `img`, `image`.
|
130
|
+
* Bootstrap - add "bootstrap-sass" to your Gemfile and "@import 'bootstrap'"
|
131
|
+
* Compass - add "compass-core" to your Gemfile and "@import 'compass'"
|
132
|
+
* Font Awesome - add "font-awesome-sass" to your Gemfile.
|
137
133
|
|
138
134
|
***Please note that some of these (if not all) have trouble with Rhino --
|
139
135
|
`therubyrhino` so you would probably be best to just use Node.js or io.js at
|
140
136
|
that point rather than trying to fight it.***
|
141
137
|
|
142
|
-
###
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
Only whitelisted options are allowed by default, so that we can guard against
|
154
|
-
using paths we don't want to be used. If you wish to have an option
|
155
|
-
whitelisted please file a ticket or submit a pull request.
|
138
|
+
### Image Magick Proxy arguments:
|
139
|
+
|
140
|
+
* `magick:resize:<value>`
|
141
|
+
* `magick:format:<value>`
|
142
|
+
* `magick:quality:<value>`
|
143
|
+
* `magick:rotate:<value>`
|
144
|
+
* `magick:crop:<value>`
|
145
|
+
* `magick:flip:<value>`
|
146
|
+
* `magick:half`
|
147
|
+
* `magick:2x`
|
148
|
+
* `magick:4x`
|
156
149
|
|
157
150
|
## Plugins where did they go?
|
158
151
|
|
data/lib/jekyll/assets.rb
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
require "sprockets"
|
2
|
-
require "sprockets/helpers"
|
3
2
|
require "jekyll"
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
require_relative "assets/extras/font-awesome"
|
9
|
-
require_relative "assets/extras/helpers"
|
10
|
-
require_relative "assets/extras/prefix"
|
4
|
+
Dir.glob(File.expand_path("hooks/*.rb", __dir__)).map do |file|
|
5
|
+
require file
|
6
|
+
end
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
require_relative "assets
|
18
|
-
|
19
|
-
|
20
|
-
|
8
|
+
module Jekyll
|
9
|
+
module Assets
|
10
|
+
%W(patches/**/* cached config env hook logger version liquid/*
|
11
|
+
hooks/* addons/{*,**/*}).each do |path|
|
12
|
+
if path !~ /\*/
|
13
|
+
require_relative "assets/#{path}"
|
14
|
+
else
|
15
|
+
Dir.glob(File.expand_path("assets/#{path}.rb", __dir__)). \
|
16
|
+
map do |file|
|
17
|
+
require file
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
try_require "bootstrap-sass"
|
@@ -0,0 +1 @@
|
|
1
|
+
try_require "font-awesome-sass"
|
@@ -0,0 +1,92 @@
|
|
1
|
+
try_require "mini_magick" do
|
2
|
+
args = %W(resize quality rotate crop flip @2x @4x @half)
|
3
|
+
Jekyll::Assets::Env.liquid_proxies.add :magick, :img, *args do
|
4
|
+
class DoubleResizeError < RuntimeError
|
5
|
+
def initialize
|
6
|
+
"Both resize and @*x provided, this is not supported."
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# -----------------------------------------------------------------
|
11
|
+
# @see https://github.com/minimagick/minimagick#usage -- All but
|
12
|
+
# the boolean @ options are provided by Minimagick.
|
13
|
+
# -----------------------------------------------------------------
|
14
|
+
|
15
|
+
def initialize(asset, opts)
|
16
|
+
@asset, @path, @opts = asset, asset.filename, opts
|
17
|
+
end
|
18
|
+
|
19
|
+
# ---------------------------------------------------------------
|
20
|
+
|
21
|
+
def process
|
22
|
+
img = MiniMagick::Image.open(@path)
|
23
|
+
private_methods(true).select { |v| v =~ /\Amagick_/ }.each do |method|
|
24
|
+
send(method, img)
|
25
|
+
end
|
26
|
+
|
27
|
+
img.write(
|
28
|
+
@path
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
# ---------------------------------------------------------------
|
33
|
+
|
34
|
+
private
|
35
|
+
def magick_quality(img)
|
36
|
+
if @opts.has_key?(:quality)
|
37
|
+
img.quality @opts.fetch(:quality)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# ---------------------------------------------------------------
|
42
|
+
|
43
|
+
private
|
44
|
+
def magick_resize(img)
|
45
|
+
if @opts.has_key?(:resize) && (@opts.has_key?(:"2x") || \
|
46
|
+
@opts.has_key?(:"4x") || @opts.has_key?(:half))
|
47
|
+
raise DoubleResizeError
|
48
|
+
|
49
|
+
elsif @opts.has_key?(:resize)
|
50
|
+
img.resize @opts.fetch(:resize)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# ---------------------------------------------------------------
|
55
|
+
|
56
|
+
private
|
57
|
+
def magick_rotate(img)
|
58
|
+
if @opts.has_key?(:rotate)
|
59
|
+
img.rotate @opts.fetch(:rotate)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# ---------------------------------------------------------------
|
64
|
+
|
65
|
+
private
|
66
|
+
def magick_flip(img)
|
67
|
+
if @opts.has_key?(:flip)
|
68
|
+
img.flip @opts.fetch(:flip)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# ---------------------------------------------------------------
|
73
|
+
|
74
|
+
private
|
75
|
+
def magick_crop(img)
|
76
|
+
if @opts.has_key?(:crop)
|
77
|
+
img.crop @opts.fetch(:crop)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# ---------------------------------------------------------------
|
82
|
+
|
83
|
+
private
|
84
|
+
def magick_preset_resize(img)
|
85
|
+
return unless @opts.has_key?(:"2x") || @opts.has_key?(:"4x") || @opts.has_key?(:half)
|
86
|
+
width, height = img.width * 2, img.height * 2 if @opts.has_key?(:"2x")
|
87
|
+
width, height = img.width * 4, img.height * 4 if @opts.has_key?(:"4x")
|
88
|
+
width, height = img.width / 2, img.height / 2 if @opts.has_key?(:half)
|
89
|
+
img.resize "#{width}x#{height}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Assets
|
3
|
+
module Config
|
4
|
+
Development = {
|
5
|
+
"skip_baseurl_with_cdn" => false,
|
6
|
+
"skip_prefix_with_cdn" => false,
|
7
|
+
"prefix" => "/assets",
|
8
|
+
"digest" => false,
|
9
|
+
"assets" => [],
|
10
|
+
|
11
|
+
"compress" => {
|
12
|
+
"css" => false,
|
13
|
+
"js" => false
|
14
|
+
},
|
15
|
+
|
16
|
+
"sources" => [
|
17
|
+
"_assets/css", "_assets/stylesheets",
|
18
|
+
"_assets/images", "_assets/img", "_assets/fonts",
|
19
|
+
"_assets/javascripts", "_assets/js"
|
20
|
+
]
|
21
|
+
}
|
22
|
+
|
23
|
+
# -----------------------------------------------------------------------
|
24
|
+
|
25
|
+
Production = Development.merge({
|
26
|
+
"digest" => true,
|
27
|
+
"compress" => {
|
28
|
+
"css" => true,
|
29
|
+
"js" => true
|
30
|
+
},
|
31
|
+
})
|
32
|
+
|
33
|
+
# -----------------------------------------------------------------------
|
34
|
+
|
35
|
+
def self.defaults
|
36
|
+
%W(development test).include?(Jekyll.env) ? Development : Production
|
37
|
+
end
|
38
|
+
|
39
|
+
# -----------------------------------------------------------------------
|
40
|
+
|
41
|
+
def self.merge(nhash, ohash = defaults)
|
42
|
+
ohash.merge(nhash) do |key, oval, nval|
|
43
|
+
oval.is_a?(Hash) && nval.is_a?(Hash) ? merge(nval, oval) : nval
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/jekyll/assets/env.rb
CHANGED
@@ -1,88 +1,157 @@
|
|
1
|
-
require_relative "logger"
|
2
|
-
require_relative "configuration"
|
3
|
-
require_relative "context"
|
4
|
-
require_relative "cached"
|
5
|
-
|
6
1
|
module Jekyll
|
7
2
|
module Assets
|
8
3
|
class Env < Sprockets::Environment
|
9
4
|
attr_reader :jekyll, :used
|
5
|
+
|
10
6
|
class << self
|
11
|
-
attr_accessor :
|
7
|
+
attr_accessor :assets_cache, :digest_cache
|
12
8
|
def digest_cache
|
13
|
-
@
|
14
|
-
|
9
|
+
return @digest_cache ||= {}
|
10
|
+
end
|
11
|
+
|
12
|
+
# ---------------------------------------------------------------------
|
13
|
+
|
14
|
+
def liquid_proxies
|
15
|
+
return Liquid::Tag::Proxies
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
19
|
+
# -----------------------------------------------------------------------
|
20
|
+
|
21
|
+
def inspect
|
22
|
+
"<#{self.class.name} compress_js=#{compress?("js")} compress_css=#{compress?("css")} asset_path=#{
|
23
|
+
path
|
24
|
+
}>"
|
25
|
+
end
|
26
|
+
|
27
|
+
# -----------------------------------------------------------------------
|
28
|
+
|
18
29
|
def initialize(path, jekyll = nil)
|
19
30
|
jekyll, path = path, nil if path.is_a?(Jekyll::Site)
|
20
31
|
@used, @jekyll = Set.new, jekyll
|
21
32
|
path ? super(path) : super()
|
22
|
-
|
33
|
+
Hook.trigger(:env, :init) do |hook|
|
34
|
+
hook.arity > 0 || 0 > hook.arity ? hook.call(self) : instance_eval(&hook)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# -----------------------------------------------------------------------
|
23
39
|
|
24
|
-
|
25
|
-
|
26
|
-
Hook.trigger :env, :post_init, self
|
27
|
-
jekyll.sprockets = self
|
40
|
+
def liquid_proxies
|
41
|
+
return self.class.liquid_proxies
|
28
42
|
end
|
29
43
|
|
44
|
+
# -----------------------------------------------------------------------
|
45
|
+
# Make sure a path falls withint our cache dir.
|
46
|
+
# -----------------------------------------------------------------------
|
47
|
+
|
30
48
|
def in_cache_dir(*paths)
|
31
49
|
cache_dir = asset_config.fetch("cache", ".asset-cache") || nil
|
32
|
-
jekyll.in_source_dir(
|
33
|
-
cache_dir, *paths
|
34
|
-
)
|
50
|
+
jekyll.in_source_dir(cache_dir, *paths)
|
35
51
|
end
|
36
52
|
|
53
|
+
# -----------------------------------------------------------------------
|
54
|
+
# Whether or not we are writing from the cache.
|
55
|
+
# -----------------------------------------------------------------------
|
56
|
+
|
37
57
|
def cached_write?
|
38
58
|
!@used.any?
|
39
59
|
end
|
40
60
|
|
61
|
+
# -----------------------------------------------------------------------
|
62
|
+
# Merged form of `#extra_assets` and `@used` assets.
|
63
|
+
# -----------------------------------------------------------------------
|
64
|
+
|
41
65
|
def all_assets(cached = false)
|
42
66
|
if !cached
|
43
67
|
then Set.new(@used).merge extra_assets
|
44
|
-
else Set.new(self.class.assets_cache).merge
|
68
|
+
else Set.new(self.class.assets_cache).merge(extra_assets)
|
45
69
|
end
|
46
70
|
end
|
47
71
|
|
72
|
+
# -----------------------------------------------------------------------
|
73
|
+
# Assets you tell us you want to always compile, even if you do not
|
74
|
+
# use them. Just like Rails this is probably normally used.
|
75
|
+
# -----------------------------------------------------------------------
|
76
|
+
|
48
77
|
def extra_assets
|
49
78
|
each_logical_path(*asset_config.fetch("assets", [])).map do |v|
|
50
79
|
find_asset v
|
51
80
|
end
|
52
81
|
end
|
53
82
|
|
54
|
-
|
55
|
-
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
83
|
+
# -----------------------------------------------------------------------
|
84
|
+
|
85
|
+
def cdn?
|
86
|
+
!dev? && asset_config.has_key?("cdn") && asset_config.fetch("cdn")
|
87
|
+
end
|
88
|
+
|
89
|
+
# -----------------------------------------------------------------------
|
90
|
+
|
91
|
+
def baseurl
|
92
|
+
jekyll.config.fetch("baseurl", "")
|
93
|
+
end
|
94
|
+
|
95
|
+
# -----------------------------------------------------------------------
|
96
|
+
|
97
|
+
def dev?
|
98
|
+
%W(development test).include?(Jekyll.env)
|
99
|
+
end
|
100
|
+
|
101
|
+
# -----------------------------------------------------------------------
|
102
|
+
|
103
|
+
def compress?(what)
|
104
|
+
!!asset_config.fetch("compress").fetch(what, false)
|
105
|
+
end
|
106
|
+
|
107
|
+
# -----------------------------------------------------------------------
|
108
|
+
|
109
|
+
def asset_config
|
110
|
+
jekyll.config.fetch_or_store("assets", {})
|
111
|
+
end
|
112
|
+
|
113
|
+
# -----------------------------------------------------------------------
|
114
|
+
|
115
|
+
def digest?
|
116
|
+
!!asset_config.fetch("digest")
|
117
|
+
end
|
118
|
+
|
119
|
+
# -----------------------------------------------------------------------
|
120
|
+
|
121
|
+
def prefix
|
122
|
+
asset_config.fetch("prefix", "")
|
123
|
+
end
|
124
|
+
|
125
|
+
# -----------------------------------------------------------------------
|
126
|
+
# Prefixes a path with both the #base_url, the prefix and the CDN.
|
127
|
+
# -----------------------------------------------------------------------
|
61
128
|
|
62
129
|
def prefix_path(path = "")
|
63
|
-
prefix
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
File.join(*path).chomp(
|
71
|
-
"/"
|
72
|
-
)
|
73
|
-
end
|
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("/")
|
74
137
|
end
|
75
138
|
|
139
|
+
# -----------------------------------------------------------------------
|
140
|
+
|
76
141
|
def cached
|
77
142
|
Cached.new(self)
|
78
143
|
end
|
79
144
|
|
145
|
+
# -----------------------------------------------------------------------
|
146
|
+
|
80
147
|
def write_all
|
81
148
|
if cached_write?
|
82
|
-
|
149
|
+
write_cached_assets else write_assets
|
83
150
|
end
|
84
151
|
end
|
85
152
|
|
153
|
+
# -----------------------------------------------------------------------
|
154
|
+
|
86
155
|
private
|
87
156
|
def write_assets(assets = self.all_assets)
|
88
157
|
self.class.assets_cache = assets
|
@@ -95,10 +164,12 @@ module Jekyll
|
|
95
164
|
end
|
96
165
|
end
|
97
166
|
|
167
|
+
# -----------------------------------------------------------------------
|
168
|
+
|
98
169
|
private
|
99
170
|
def write_cached_assets(assets = all_assets(true))
|
100
171
|
assets.each do |a|
|
101
|
-
if !a.is_a?(Tag::ProxiedAsset)
|
172
|
+
if !a.is_a?(Liquid::Tag::ProxiedAsset)
|
102
173
|
viejo = self.class.digest_cache[a.logical_path]
|
103
174
|
nuevo = find_asset(a.logical_path).digest
|
104
175
|
path = as_path a
|
@@ -117,65 +188,13 @@ module Jekyll
|
|
117
188
|
end
|
118
189
|
end
|
119
190
|
|
191
|
+
# -----------------------------------------------------------------------
|
192
|
+
|
120
193
|
private
|
121
194
|
def as_path(v)
|
122
195
|
path = digest?? v.digest_path : v.logical_path
|
123
196
|
jekyll.in_dest_dir(File.join(prefix, path))
|
124
197
|
end
|
125
|
-
|
126
|
-
def disable_erb
|
127
|
-
self.config = hash_reassoc(config, :engines) do |h|
|
128
|
-
h.delete(".erb")
|
129
|
-
h
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
private
|
134
|
-
def setup_css_compressor
|
135
|
-
if compress?("css")
|
136
|
-
self.css_compressor = :sass
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
private
|
141
|
-
def setup_js_compressor
|
142
|
-
if compress?("js")
|
143
|
-
Helpers.try_require "uglifier" do
|
144
|
-
self.js_compressor = :uglify
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
private
|
150
|
-
def setup_context
|
151
|
-
Context.new(context_class)
|
152
|
-
end
|
153
|
-
|
154
|
-
private
|
155
|
-
def setup_version
|
156
|
-
self.version = Digest::MD5.hexdigest \
|
157
|
-
jekyll.config.fetch("assets", {}).to_s
|
158
|
-
end
|
159
|
-
|
160
|
-
private
|
161
|
-
def setup_sources
|
162
|
-
asset_config["sources"].each do |v|
|
163
|
-
append_path jekyll.in_source_dir(v)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
private
|
168
|
-
def setup_logger
|
169
|
-
self.logger = Logger.new
|
170
|
-
end
|
171
|
-
|
172
|
-
private
|
173
|
-
def setup_cache
|
174
|
-
if cache_dir = asset_config.fetch("cache", ".asset-cache")
|
175
|
-
self.cache = Sprockets::Cache::FileStore.new \
|
176
|
-
jekyll.in_source_dir(cache_dir)
|
177
|
-
end
|
178
|
-
end
|
179
198
|
end
|
180
199
|
end
|
181
200
|
end
|