jekyll-assets 2.3.2 → 2.4.0
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 +2 -1
- data/README.md +55 -10
- data/Rakefile +1 -1
- data/lib/jekyll/assets.rb +4 -5
- data/lib/jekyll/assets/env.rb +4 -3
- data/lib/jekyll/assets/hooks/cache.rb +2 -10
- data/lib/jekyll/assets/liquid/tag/proxies.rb +13 -1
- data/lib/jekyll/assets/proxies/image_optim.rb +80 -0
- data/lib/jekyll/assets/proxies/magick.rb +27 -8
- data/lib/jekyll/assets/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3f85683208d7c6a5e8212c0a26d86765fc44b4d
|
4
|
+
data.tar.gz: ab4ab48388c30fb14de9b49884ee89f700f04948
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0619236826dae97812c7c9ad4e647b3ced92ac1eed4acf924fbe36163cb98270ef7a36aec3231b1bd21b1527efc4db31b8c14d8cedfb2bf564a49581c0d8a768'
|
7
|
+
data.tar.gz: a37c926b28a79d8e6be32d2067236fd63f34cb20d6bac7ff35935b8fe1387deec574cbf21254e70590db5ae37809134fdd834b5ef692335911a7879347481d52
|
data/Gemfile
CHANGED
@@ -10,7 +10,6 @@ group :development do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
group :test do
|
13
|
-
gem "luna-rubocop-formatters", :require => false
|
14
13
|
gem "codeclimate-test-reporter", :require => false
|
15
14
|
gem "rubocop", :require => false
|
16
15
|
end
|
@@ -22,4 +21,6 @@ gem "jekyll", "#{ENV["JEKYLL_VERSION"]}" if ENV["JEKYLL_VERSION"]
|
|
22
21
|
gem "font-awesome-sass", "~> 4.4", :require => false
|
23
22
|
gem "bootstrap-sass", "~> 3.3", :require => false
|
24
23
|
gem "mini_magick", "~> 4.2", :require => false
|
24
|
+
gem "image_optim", "~> 0.25", :require => false
|
25
|
+
gem "image_optim_pack", "~> 0.5", :require => false
|
25
26
|
gem "less", "~> 2.6.0", :require => false
|
data/README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
<p align=center>
|
2
|
+
<a href=https://goo.gl/BhrgjW>
|
3
|
+
<img src=https://envygeeks.io/badges/paypal-large_1.png alt=Donate>
|
4
|
+
</a>
|
5
|
+
<br>
|
6
|
+
<a href=https://travis-ci.org/jekyll/jekyll-assets>
|
7
|
+
<img src="https://travis-ci.org/jekyll/jekyll-assets.svg?branch=master" alt=Status>
|
8
|
+
</a>
|
9
|
+
</p>
|
9
10
|
|
10
11
|
# Jekyll Assets
|
11
12
|
|
@@ -14,18 +15,22 @@ Jekyll assets is an asset pipeline using Sprockets 3 to build specifically for J
|
|
14
15
|
## Using Jekyll Assets with Jekyll
|
15
16
|
|
16
17
|
```ruby
|
17
|
-
|
18
|
+
# Gemfile
|
19
|
+
group :jekyll_plugins do
|
18
20
|
gem "jekyll-assets"
|
19
21
|
end
|
20
22
|
```
|
21
23
|
|
22
24
|
```yaml
|
23
|
-
|
25
|
+
# _config.yml
|
26
|
+
plugins:
|
24
27
|
- jekyll-assets
|
25
28
|
```
|
26
29
|
|
27
30
|
## Configuration
|
28
31
|
|
32
|
+
The configuration file is the same as Jekyll's, which is _config.yml. Use the special key "assets":
|
33
|
+
|
29
34
|
```yaml
|
30
35
|
assets:
|
31
36
|
compress:
|
@@ -156,6 +161,24 @@ Start up your local Jekyll server and if everything is correct, your site will b
|
|
156
161
|
|
157
162
|
* ES6 `gem "sprockets-es6"`
|
158
163
|
* Image Magick `gem "mini_magick"`
|
164
|
+
* ImageOptim `gem "image_optim"`
|
165
|
+
|
166
|
+
```yml
|
167
|
+
assets:
|
168
|
+
image_optim:
|
169
|
+
default:
|
170
|
+
verbose: true
|
171
|
+
zero_png:
|
172
|
+
advpng:
|
173
|
+
level: 0
|
174
|
+
optipng:
|
175
|
+
level: 0
|
176
|
+
pngout:
|
177
|
+
strategy: 4
|
178
|
+
```
|
179
|
+
|
180
|
+
Check the [ImageOptim docs](https://github.com/toy/image_optim#configuration) to get idea about configuration options.
|
181
|
+
|
159
182
|
* LESS `gem "less"`
|
160
183
|
|
161
184
|
## Bower
|
@@ -266,6 +289,18 @@ time we will reject all pull requests that wish to add any digested paths as
|
|
266
289
|
those are dynamically created when a proxy is ran so we can never predict
|
267
290
|
it reliably unless we proxy and that would be a performance problem.
|
268
291
|
|
292
|
+
### Dynamically loading assets
|
293
|
+
|
294
|
+
Using Liquid Drop `assets`, you can check whether an asset is present.
|
295
|
+
|
296
|
+
```liquid
|
297
|
+
{% if assets[page.image] %}
|
298
|
+
{% img '{{ page.image }}' %}
|
299
|
+
{% else %}
|
300
|
+
{% img 'default.jpg' %}
|
301
|
+
{% endif %}
|
302
|
+
```
|
303
|
+
|
269
304
|
## ERB Support
|
270
305
|
|
271
306
|
ERB Support is removed in favor of trying to get this included on Github Pages
|
@@ -375,6 +410,16 @@ to get an idea what `<value>` can be.
|
|
375
410
|
* `magick:one-fourth`, `magick:1/4`
|
376
411
|
* `magick:half`, `magick:1/2`
|
377
412
|
|
413
|
+
### ImageOptim Proxy arguments:
|
414
|
+
|
415
|
+
**NOTE: You'll need the `image_optim` gem installed for these to work**
|
416
|
+
To install `image_optim`, add `gem "image_optim"` to your `Gemfile`
|
417
|
+
|
418
|
+
See the [ImageOptim docs](https://github.com/toy/image_optim#gem-installation) to ensure proper dependencies installation.
|
419
|
+
|
420
|
+
* `image_optim:default` same as `image_optim:preset:default`
|
421
|
+
* `image_optim:preset:<name>`
|
422
|
+
|
378
423
|
## Having trouble with our documentation?
|
379
424
|
|
380
425
|
If you do not understand something in our documentation please feel
|
data/Rakefile
CHANGED
data/lib/jekyll/assets.rb
CHANGED
@@ -9,12 +9,11 @@ require "jekyll"
|
|
9
9
|
|
10
10
|
requires = [ :liquid,
|
11
11
|
:patches, "", :hooks, :addons,
|
12
|
-
:proxies, :processors
|
13
|
-
]
|
12
|
+
:proxies, :processors]
|
14
13
|
|
15
14
|
requires.each do |part|
|
16
|
-
Pathutil.new(
|
17
|
-
.glob(
|
15
|
+
Pathutil.new(__dir__).join('assets', part.to_s)
|
16
|
+
.glob('{*,**/*}.rb').map(&method(
|
18
17
|
:require
|
19
|
-
|
18
|
+
))
|
20
19
|
end
|
data/lib/jekyll/assets/env.rb
CHANGED
@@ -6,6 +6,7 @@ module Jekyll
|
|
6
6
|
module Assets
|
7
7
|
class Env < Sprockets::Environment
|
8
8
|
attr_accessor :jekyll
|
9
|
+
attr_reader :cache_path
|
9
10
|
|
10
11
|
class << self
|
11
12
|
|
@@ -111,8 +112,8 @@ module Jekyll
|
|
111
112
|
path ? super(path) : super()
|
112
113
|
@jekyll = jekyll
|
113
114
|
|
114
|
-
#
|
115
|
-
@cache_path = asset_config.fetch("cache", ".asset-cache")
|
115
|
+
# TODO: In Jekyll-Assets 3 this should be fixed up to be a method.
|
116
|
+
@cache_path = asset_config.fetch("cache", ".asset-cache") || ".asset-cache"
|
116
117
|
if File.exist?(cache_path_in_source_dir = jekyll.in_source_dir(@cache_path))
|
117
118
|
@cache_path = cache_path_in_source_dir
|
118
119
|
end
|
@@ -148,7 +149,7 @@ module Jekyll
|
|
148
149
|
# @return [Pathname/Pathutil]
|
149
150
|
# --
|
150
151
|
def in_cache_dir(*paths)
|
151
|
-
paths.reduce(
|
152
|
+
paths.reduce(cache_path) do |base, path|
|
152
153
|
Jekyll.sanitized_path(base, path)
|
153
154
|
end
|
154
155
|
end
|
@@ -9,18 +9,10 @@ Jekyll::Assets::Hook.register :env, :init do
|
|
9
9
|
)
|
10
10
|
|
11
11
|
if cache != false && type != "memory"
|
12
|
-
self.cache =
|
13
|
-
Sprockets::Cache::FileStore.new(
|
14
|
-
jekyll.in_source_dir(
|
15
|
-
cache
|
16
|
-
)
|
17
|
-
)
|
18
|
-
end
|
12
|
+
self.cache = Sprockets::Cache::FileStore.new(cache_path)
|
19
13
|
|
20
14
|
elsif cache && type == "memory"
|
21
|
-
self.cache =
|
22
|
-
Sprockets::Cache::MemoryStore.new
|
23
|
-
end
|
15
|
+
self.cache = Sprockets::Cache::MemoryStore.new
|
24
16
|
|
25
17
|
else
|
26
18
|
Jekyll.logger.info "", "Asset caching is disabled by configuration. " \
|
@@ -24,7 +24,19 @@ module Jekyll
|
|
24
24
|
# ------------------------------------------------------------------
|
25
25
|
|
26
26
|
def self.add(name, tag, *args, &block)
|
27
|
-
|
27
|
+
if tag.is_a?(Array)
|
28
|
+
return tag.each do |v|
|
29
|
+
klass = generate_class(name, v, &block)
|
30
|
+
add_by_class(*klass,
|
31
|
+
*args
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
klass = generate_class(name, tag, &block)
|
37
|
+
add_by_class(*klass,
|
38
|
+
*args
|
39
|
+
)
|
28
40
|
end
|
29
41
|
|
30
42
|
# ------------------------------------------------------------------
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# ----------------------------------------------------------------------------
|
2
|
+
# Frozen-string-literal: true
|
3
|
+
# Copyright: 2017 - MIT License
|
4
|
+
# Encoding: utf-8
|
5
|
+
# ----------------------------------------------------------------------------
|
6
|
+
|
7
|
+
try_require "image_optim" do
|
8
|
+
IMAGE_OPTIM_ARGS = %W(preset).freeze
|
9
|
+
IMAGE_OPTIM_PRESETS = %W(@default).freeze
|
10
|
+
|
11
|
+
class JekyllAssetsImageOptim
|
12
|
+
|
13
|
+
class UnknownPresetError < RuntimeError
|
14
|
+
def initialize(presetName)
|
15
|
+
"Unknown image_optim preset '#{ presetName }'"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# ------------------------------------------------------------------------
|
20
|
+
|
21
|
+
class PresetAlreadySpecifiedError < RuntimeError
|
22
|
+
def initialize
|
23
|
+
"Specifying pre-defined preset and preset-by-name at the same time is not supported"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# ------------------------------------------------------------------------
|
28
|
+
|
29
|
+
class MultiplePredefinedPresetsSpecifiedError < RuntimeError
|
30
|
+
def initialize
|
31
|
+
"Specifying multiple pre-defined presets at the same time is not supported"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# ------------------------------------------------------------------------
|
36
|
+
|
37
|
+
def initialize(asset, opts, args)
|
38
|
+
@asset = asset
|
39
|
+
@opts = opts
|
40
|
+
@args = args
|
41
|
+
end
|
42
|
+
|
43
|
+
# ------------------------------------------------------------------------
|
44
|
+
|
45
|
+
def process
|
46
|
+
asset_config = @asset.env.asset_config || {}
|
47
|
+
image_optim_config = asset_config["image_optim"] || {}
|
48
|
+
|
49
|
+
predefinedPresets = (@opts.keys - IMAGE_OPTIM_ARGS.map(&:to_sym))
|
50
|
+
|
51
|
+
raise PresetAlreadySpecifiedError if @opts.key?(:preset) && predefinedPresets.any?
|
52
|
+
raise MultiplePredefinedPresetsSpecifiedError if predefinedPresets.count > 1
|
53
|
+
|
54
|
+
presetName = @opts[:preset]
|
55
|
+
presetName = predefinedPresets.first.to_s unless presetName || !predefinedPresets.any?
|
56
|
+
|
57
|
+
if presetName != "default" && !image_optim_config.key?(presetName)
|
58
|
+
raise UnknownPresetError, presetName
|
59
|
+
end
|
60
|
+
config = image_optim_config[presetName] || {}
|
61
|
+
|
62
|
+
image_optim = ::ImageOptim.new(config)
|
63
|
+
image_optim.optimize_image!(@asset.filename)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
Jekyll::Assets::Env.liquid_proxies.add :image_optim, [:img, :asset_path], *(IMAGE_OPTIM_ARGS + IMAGE_OPTIM_PRESETS) do
|
69
|
+
def initialize(asset, opts, args)
|
70
|
+
@imageOptim = JekyllAssetsImageOptim.new(asset, opts, args)
|
71
|
+
end
|
72
|
+
|
73
|
+
# ------------------------------------------------------------------------
|
74
|
+
|
75
|
+
def process
|
76
|
+
@imageOptim.process
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -5,14 +5,12 @@
|
|
5
5
|
# ----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
try_require "mini_magick" do
|
8
|
-
|
9
|
-
|
8
|
+
MINI_MAGICK_ARGS = %W(resize quality rotate crop flip format gravity strip).freeze
|
9
|
+
MINI_MAGICK_PRESETS = %W(@2x @4x @1/2 @1/3 @2/3 @1/4 @2/4 @3/4
|
10
10
|
@double @quadruple @half @one-third @two-thirds @one-fourth
|
11
|
-
@two-fourths @three-fourths)
|
11
|
+
@two-fourths @three-fourths).freeze
|
12
12
|
|
13
|
-
|
14
|
-
PRESETS = presets
|
15
|
-
ARGS = args
|
13
|
+
class JekyllAssetsMiniMagic
|
16
14
|
|
17
15
|
class DoubleResizeError < RuntimeError
|
18
16
|
def initialize
|
@@ -26,8 +24,8 @@ try_require "mini_magick" do
|
|
26
24
|
# ------------------------------------------------------------------------
|
27
25
|
|
28
26
|
def initialize(asset, opts, args)
|
29
|
-
@opts = opts
|
30
27
|
@asset = asset
|
28
|
+
@opts = opts
|
31
29
|
@args = args
|
32
30
|
end
|
33
31
|
|
@@ -73,7 +71,7 @@ try_require "mini_magick" do
|
|
73
71
|
|
74
72
|
private
|
75
73
|
def preset?
|
76
|
-
(@opts.keys -
|
74
|
+
(@opts.keys - MINI_MAGICK_ARGS.map(&:to_sym)).any?
|
77
75
|
end
|
78
76
|
|
79
77
|
# ------------------------------------------------------------------------
|
@@ -140,6 +138,13 @@ try_require "mini_magick" do
|
|
140
138
|
end
|
141
139
|
end
|
142
140
|
|
141
|
+
# ------------------------------------------------------------------------
|
142
|
+
|
143
|
+
private
|
144
|
+
def magick_strip(_, cmd)
|
145
|
+
cmd.strip
|
146
|
+
end
|
147
|
+
|
143
148
|
# ------------------------------------------------------------------------
|
144
149
|
# I just want you to know, we don't even care if you do multiple
|
145
150
|
# resizes or try to, we don't attempt to even attempt to attempt to care
|
@@ -171,5 +176,19 @@ try_require "mini_magick" do
|
|
171
176
|
# rubocop:enable Style/ParallelAssignment
|
172
177
|
# rubocop:enable Metrics/AbcSize
|
173
178
|
# ------------------------------------------------------------------------
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
Jekyll::Assets::Env.liquid_proxies.add :magick, [:img, :asset_path], *(MINI_MAGICK_ARGS + MINI_MAGICK_PRESETS) do
|
183
|
+
def initialize(asset, opts, args)
|
184
|
+
@miniMagick = JekyllAssetsMiniMagic.new(asset, opts, args)
|
185
|
+
end
|
186
|
+
|
187
|
+
# ------------------------------------------------------------------------
|
188
|
+
|
189
|
+
def process
|
190
|
+
@miniMagick.process
|
191
|
+
end
|
192
|
+
|
174
193
|
end
|
175
194
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordon Bedwell
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -226,6 +226,7 @@ files:
|
|
226
226
|
- lib/jekyll/assets/patches/sprockets/asset.rb
|
227
227
|
- lib/jekyll/assets/processors/less.rb
|
228
228
|
- lib/jekyll/assets/processors/liquid.rb
|
229
|
+
- lib/jekyll/assets/proxies/image_optim.rb
|
229
230
|
- lib/jekyll/assets/proxies/magick.rb
|
230
231
|
- lib/jekyll/assets/version.rb
|
231
232
|
homepage: http://github.com/jekyll/jekyll-assets/
|
@@ -248,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
249
|
version: '0'
|
249
250
|
requirements: []
|
250
251
|
rubyforge_project:
|
251
|
-
rubygems_version: 2.
|
252
|
+
rubygems_version: 2.6.13
|
252
253
|
signing_key:
|
253
254
|
specification_version: 4
|
254
255
|
summary: Assets for Jekyll
|