jekyll-assets 2.2.8 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -3
- data/README.md +114 -49
- data/lib/jekyll/assets/env.rb +9 -3
- data/lib/jekyll/assets/hooks/cache.rb +1 -1
- data/lib/jekyll/assets/liquid/context.rb +19 -0
- data/lib/jekyll/assets/liquid/drop.rb +1 -3
- data/lib/jekyll/assets/liquid/filters.rb +3 -3
- data/lib/jekyll/assets/liquid/tag/defaults/image.rb +1 -1
- data/lib/jekyll/assets/liquid/tag/proxied_asset.rb +55 -13
- data/lib/jekyll/assets/manifest.rb +2 -0
- data/lib/jekyll/assets/proxies/magick.rb +12 -4
- data/lib/jekyll/assets/version.rb +1 -1
- metadata +24 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e63acc3be463a9dcc0706d44e684dda19fcccd93
|
4
|
+
data.tar.gz: af8f2ecd22edbe9df64771322582e6de584a9a1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6287cef50ec4b2b1a2942f73588aa8ac63d5a7bb802de180ceb6fb48fd77e7c36cb66dffd13e7daf13e8ecb55042155eaaf8896db6eda583d8a9a0c1feaaa6fe
|
7
|
+
data.tar.gz: 7af1fd96801d3901e03fad0bf4fcae6bb7fabbd077d68971ad1f46470a6db5c6673edaa60a0315c9cff6e2bda69e866bf6ad977eda3a1cb8d66c6ce67ac22ae0
|
data/Gemfile
CHANGED
@@ -10,14 +10,15 @@ group :development do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
group :test do
|
13
|
-
gem "codeclimate-test-reporter", :require => false
|
14
|
-
gem "rubocop", :github => "bbatsov/rubocop", :branch => :master, :require => false
|
15
13
|
gem "luna-rubocop-formatters", :require => false
|
14
|
+
gem "codeclimate-test-reporter", :require => false
|
15
|
+
gem "rubocop", :require => false
|
16
16
|
end
|
17
17
|
|
18
18
|
gem "uglifier", :require => false
|
19
19
|
gem "sprockets-es6", "~> 0.6", :require => false
|
20
|
-
gem "autoprefixer-rails", "~>
|
20
|
+
gem "autoprefixer-rails", "~> 7.0", :require => false
|
21
|
+
gem "jekyll", "#{ENV["JEKYLL_VERSION"]}" if ENV["JEKYLL_VERSION"]
|
21
22
|
gem "font-awesome-sass", "~> 4.4", :require => false
|
22
23
|
gem "bootstrap-sass", "~> 3.3", :require => false
|
23
24
|
gem "mini_magick", "~> 4.2", :require => false
|
data/README.md
CHANGED
@@ -7,16 +7,17 @@
|
|
7
7
|
[coverage]: https://codeclimate.com/github/jekyll/jekyll-assets/coverage
|
8
8
|
[travis]: https://travis-ci.org/jekyll/jekyll-assets
|
9
9
|
|
10
|
-
# Jekyll
|
10
|
+
# Jekyll Assets
|
11
11
|
|
12
|
-
Jekyll
|
13
|
-
for Jekyll 3. It utilizes new features of both Sprockets and Jekyll to achieve
|
14
|
-
a clean and extensible assets platform for Jekyll.
|
12
|
+
Jekyll assets is an asset pipeline using Sprockets 3 to build specifically for Jekyll. It utilizes new features of both Sprockets and Jekyll to try and achieve a clean and extensible assets platform.
|
15
13
|
|
16
14
|
## Using Jekyll Assets with Jekyll
|
17
15
|
|
18
|
-
|
19
|
-
|
16
|
+
```ruby
|
17
|
+
group :plugins do
|
18
|
+
gem "jekyll-assets"
|
19
|
+
end
|
20
|
+
```
|
20
21
|
|
21
22
|
```yaml
|
22
23
|
gems:
|
@@ -25,20 +26,11 @@ gems:
|
|
25
26
|
|
26
27
|
## Configuration
|
27
28
|
|
28
|
-
A lot of our configuration transforms based on the `JEKYLL_ENV` variable
|
29
|
-
set in your environment. Such as digesting and whether or not to enable the
|
30
|
-
CDN. Some of them can be explicitly overridden but a few cannot right now.
|
31
|
-
You should set your `JEKYLL_ENV=development` on your development
|
32
|
-
machine and `JEKYLL_ENV=production` when building to push.
|
33
|
-
|
34
29
|
```yaml
|
35
30
|
assets:
|
36
31
|
compress:
|
37
32
|
css: false | true | default - development: false, production: true
|
38
33
|
js: false | true | default - development: false, production: true
|
39
|
-
|
40
|
-
#
|
41
|
-
|
42
34
|
autowrite: true
|
43
35
|
cache: false | directory | default: .asset-cache
|
44
36
|
cache_type: memory | filesystem | default: filesystem
|
@@ -47,15 +39,9 @@ assets:
|
|
47
39
|
skip_prefix_with_cdn: false
|
48
40
|
prefix: "/assets"
|
49
41
|
digest: true
|
50
|
-
|
51
|
-
#
|
52
|
-
|
53
42
|
assets:
|
54
43
|
- "*.png"
|
55
44
|
- "bundle.css"
|
56
|
-
|
57
|
-
#
|
58
|
-
|
59
45
|
sources:
|
60
46
|
- _assets/css
|
61
47
|
- _assets/images
|
@@ -64,43 +50,34 @@ assets:
|
|
64
50
|
- _assets/fonts
|
65
51
|
- _assets/img
|
66
52
|
- _assets/js
|
67
|
-
|
68
|
-
#
|
69
|
-
|
70
53
|
features:
|
71
54
|
liquid: true | false | default: false
|
72
55
|
integrity: true | false | default: false
|
56
|
+
# This will add height and width attributes for an img tag.
|
73
57
|
automatic_img_size: true | false | n(fixnum): 2,4,6,8 | default: true
|
58
|
+
# This will add the digest path as an alt attribute for an img tag.
|
74
59
|
automatic_img_alt : true | false | default: true
|
75
60
|
```
|
76
61
|
|
77
62
|
### Liquid Processing with your Jekyll context
|
78
63
|
|
79
|
-
By default (whether `features.liquid` is true or false) we will process
|
80
|
-
all files with the extension
|
64
|
+
By default (whether `features.liquid` is `true` or `false`) we will process
|
65
|
+
all files with the extension `.liquid`, so if you give us `.scss.liquid`
|
81
66
|
we will parse the liquid and then we will parse the SCSS and finally
|
82
|
-
output your
|
83
|
-
|
84
|
-
When `features.liquid` is set to true, we will process ***ALL*** files
|
85
|
-
through Liquid, regardless of whether they have the ".liquid" extension.
|
86
|
-
Use this at your own risk.
|
67
|
+
output your `.css` file. When `features.liquid` is set to `true`, we will process ***ALL*** files through Liquid, regardless of whether they have the `.liquid` extension. ***Use this at your own risk. As it can lead to some bugs, some bad output, and even some ugly edge cases... especially with things like Handlebars.***
|
87
68
|
|
88
69
|
### Cache Folder
|
89
70
|
|
90
71
|
If you plan to change the `cache` folder, please make sure to add that
|
91
|
-
folder to your `exclude` list in Jekyll or you will generate over and over
|
92
|
-
and over again, `.` folders are not ignored by default.
|
72
|
+
folder to your `exclude` list in Jekyll, or you will generate over and over
|
73
|
+
and over again, `.` folders are not ignored by default as of Jekyll 3.x, so you should take heed of ignoring your own folders.
|
93
74
|
|
94
75
|
### Sources
|
95
76
|
|
96
77
|
The listed resources in the example are all defaults. It should be noted
|
97
78
|
that we append your sources instead of replace our resources with yours. So
|
98
79
|
if you add `_assets/folder` then we will append that to our sources and
|
99
|
-
both will work.
|
100
|
-
|
101
|
-
***NOTE: if you use our `_assets` base folder container as a base folder for
|
102
|
-
your sprockets, we will not append our sources, we will only use that
|
103
|
-
folder as the sole source (base folder.)***
|
80
|
+
both will work. ***NOTE: if you use our `_assets` base folder container as a base folder for your Sprockets, we will not append our sources, we will only use that folder as the sole source (base folder.)***
|
104
81
|
|
105
82
|
### Digesting
|
106
83
|
|
@@ -115,9 +92,52 @@ folder as the sole source (base folder.)***
|
|
115
92
|
* Disable compression by default in development.
|
116
93
|
* Enable by default in production.
|
117
94
|
|
95
|
+
## Generating CSS with Jekyll Assets
|
96
|
+
|
97
|
+
The following section shows how to get started generating CSS using Jekyll
|
98
|
+
Assets. It applies to a newly generated Jekyll site, however this should helpanyone who has a Jekyll site. It should also be applicable for other types of assets.
|
99
|
+
|
100
|
+
### Create the `_assets/css` directory
|
101
|
+
|
102
|
+
The default [Jekyll Assets configuration](#configuration) expects to find all the assets in directories under `_assets`. Create a directory for the CSS:
|
103
|
+
|
104
|
+
```bash
|
105
|
+
mkdir -p _assets/css
|
106
|
+
```
|
107
|
+
|
108
|
+
### Move the CSS files to the new `_assets/css` directory
|
109
|
+
|
110
|
+
Jekyll comes with a `css` directory containing a `main.css` file and then a `_sass` directory with a few Sass imports. Move all of that to the `_assets/css` directory.
|
111
|
+
|
112
|
+
```bash
|
113
|
+
mv css/main.css _assets/css
|
114
|
+
mv _sass/* _assets/css
|
115
|
+
```
|
116
|
+
|
117
|
+
### Remove Jekyll front matter
|
118
|
+
|
119
|
+
Jekyll includes some empty [front matter](https://jekyllrb.com/docs/frontmatter/) in `main.css`. Remove that as Sprockets will not understand it.
|
120
|
+
|
121
|
+
### Update the layout
|
122
|
+
|
123
|
+
The layout will no longer be pointing to the correct `main.css` file. Jekyll Assets supplies [liquid tags](#tags) to generate the correct HTML for these assets. Open `_includes/head.html` and replace the `<link>` to the CSS with:
|
124
|
+
|
125
|
+
```liquid
|
126
|
+
{% css main %}
|
127
|
+
```
|
128
|
+
|
129
|
+
Start up your local Jekyll server and if everything is correct, your site will be serving CSS via Sprockets. Read on for more information on how to customize your Jekyll Assets setup.
|
130
|
+
|
118
131
|
## Addons
|
119
132
|
|
120
|
-
*
|
133
|
+
* Font Awesome `gem "font-awesome-sass"`
|
134
|
+
|
135
|
+
```scss
|
136
|
+
@import 'font-awesome-sprockets'
|
137
|
+
@import 'font-awesome'
|
138
|
+
```
|
139
|
+
|
140
|
+
* CSS Auto-Prefixing `gem "autoprefixer-rails"`
|
121
141
|
|
122
142
|
```yml
|
123
143
|
assets:
|
@@ -126,18 +146,19 @@ folder as the sole source (base folder.)***
|
|
126
146
|
- "last 2 versions"
|
127
147
|
- "IE > 9"
|
128
148
|
```
|
129
|
-
|
130
|
-
* ES6 Transpiler (through Babel) - add "sprockets-es6" to your Gemfile — any `.es6` files (e.g. `main.js.es6`) will be transpiled
|
131
|
-
* Bootstrap - add "bootstrap-sass" to your Gemfile, and `@import 'boostrap-sprockets'; @import 'bootstrap'`
|
132
|
-
* Font Awesome - add "font-awesome-sass" to your Gemfile, and `@import 'font-awesome-sprockets'; @import 'font-awesome'`
|
133
|
-
* Image Magick - add "mini_magick" to your Gemfile, only works with `img`, `image`.
|
134
|
-
* LESS - add "less" to your Gemfile
|
135
149
|
|
136
|
-
|
137
|
-
|
138
|
-
|
150
|
+
* Bootstrap `gem "bootstrap-sass"`
|
151
|
+
|
152
|
+
```scss
|
153
|
+
@import 'bootstrap-sprockets'
|
154
|
+
@import 'bootstrap'
|
155
|
+
```
|
139
156
|
|
140
|
-
|
157
|
+
* ES6 `gem "sprockets-es6"`
|
158
|
+
* Image Magick `gem "mini_magick"`
|
159
|
+
* LESS `gem "less"`
|
160
|
+
|
161
|
+
## Bower
|
141
162
|
|
142
163
|
Modify your `.bowerrc` file and add:
|
143
164
|
|
@@ -238,6 +259,7 @@ The current list of available accessors:
|
|
238
259
|
* `basename`
|
239
260
|
* `width`
|
240
261
|
* `height`
|
262
|
+
* `digest_path`
|
241
263
|
|
242
264
|
If you would like more, please feel free to add a pull request, at this
|
243
265
|
time we will reject all pull requests that wish to add any digested paths as
|
@@ -279,6 +301,46 @@ Jekyll::Assets::Hook.register :env, :init do
|
|
279
301
|
end
|
280
302
|
```
|
281
303
|
|
304
|
+
## Combining Multiple Scripts / Stylesheets
|
305
|
+
|
306
|
+
To minimize the number of HTTP requests, combine stylesheets and scripts into one file.
|
307
|
+
|
308
|
+
### SCSS
|
309
|
+
|
310
|
+
Use the `@import` statement. Given a list of files in `_assets/css`:
|
311
|
+
|
312
|
+
- `main.scss`
|
313
|
+
- `_responsive.scss`
|
314
|
+
- `_fonts.scss`
|
315
|
+
|
316
|
+
...have this in your `main.scss`:
|
317
|
+
|
318
|
+
```scss
|
319
|
+
@import 'responsive';
|
320
|
+
@import 'fonts';
|
321
|
+
// ...
|
322
|
+
```
|
323
|
+
|
324
|
+
Include the `main` stylesheet in your HTML: `{% css main %}`.
|
325
|
+
|
326
|
+
### JavaScript
|
327
|
+
|
328
|
+
Use `//= require` to import and bundle component scripts into one file. More from [#241](https://github.com/jekyll/jekyll-assets/issues/241).
|
329
|
+
|
330
|
+
Given a list of files in `_assets/js`:
|
331
|
+
|
332
|
+
- `main.js`
|
333
|
+
- `jquery.js`
|
334
|
+
|
335
|
+
...have this in your `main.js`:
|
336
|
+
|
337
|
+
```js
|
338
|
+
//= require jquery
|
339
|
+
// ...
|
340
|
+
```
|
341
|
+
|
342
|
+
Include the `main` script in your HTML: `{% js main %}`.
|
343
|
+
|
282
344
|
## Sass Helpers
|
283
345
|
|
284
346
|
***Our currently supported helpers are:***
|
@@ -295,6 +357,9 @@ end
|
|
295
357
|
**NOTE: You'll need the `mini_magick` gem installed for these to work**
|
296
358
|
To install `mini_magick`, add `gem "mini_magick"` to your `Gemfile`
|
297
359
|
|
360
|
+
See the [MiniMagick docs](https://github.com/minimagick/minimagick#usage)
|
361
|
+
to get an idea what `<value>` can be.
|
362
|
+
|
298
363
|
* `magick:resize:<value>`
|
299
364
|
* `magick:format:<value>`
|
300
365
|
* `magick:quality:<value>`
|
data/lib/jekyll/assets/env.rb
CHANGED
@@ -111,6 +111,12 @@ module Jekyll
|
|
111
111
|
path ? super(path) : super()
|
112
112
|
@jekyll = jekyll
|
113
113
|
|
114
|
+
# Analagous to Jekyll::Site @source and @destination paths
|
115
|
+
@cache_path = asset_config.fetch("cache", ".asset-cache")
|
116
|
+
if File.exist?(cache_path_in_source_dir = jekyll.in_source_dir(@cache_path))
|
117
|
+
@cache_path = cache_path_in_source_dir
|
118
|
+
end
|
119
|
+
|
114
120
|
# XXX: In 3.0, we need to drop anything to do with instance eval,
|
115
121
|
# and imply pass the instance, this will make our code cleaner.
|
116
122
|
|
@@ -142,9 +148,9 @@ module Jekyll
|
|
142
148
|
# @return [Pathname/Pathutil]
|
143
149
|
# --
|
144
150
|
def in_cache_dir(*paths)
|
145
|
-
|
146
|
-
|
147
|
-
|
151
|
+
paths.reduce(@cache_path) do |base, path|
|
152
|
+
Jekyll.sanitized_path(base, path)
|
153
|
+
end
|
148
154
|
end
|
149
155
|
|
150
156
|
# --
|
@@ -23,7 +23,7 @@ Jekyll::Assets::Hook.register :env, :init do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
else
|
26
|
-
Jekyll.logger.info "", "
|
26
|
+
Jekyll.logger.info "", "Asset caching is disabled by configuration. " \
|
27
27
|
"However, if you're using proxies, a cache might still be created."
|
28
28
|
end
|
29
29
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2012 - 2017 - MIT License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
module Assets
|
7
|
+
module Liquid
|
8
|
+
if defined?(::Liquid::ParseContext)
|
9
|
+
class ParseContext < ::Liquid::ParseContext
|
10
|
+
#
|
11
|
+
end
|
12
|
+
else
|
13
|
+
class ParseContext < Array
|
14
|
+
#
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
|
-
# ----------------------------------------------------------------------------
|
2
1
|
# Frozen-string-literal: true
|
3
2
|
# Copyright: 2012 - 2016 - MIT License
|
4
3
|
# Encoding: utf-8
|
5
|
-
# ----------------------------------------------------------------------------
|
6
4
|
|
7
5
|
require "fastimage"
|
8
6
|
|
@@ -57,7 +55,7 @@ module Jekyll
|
|
57
55
|
|
58
56
|
def dimensions
|
59
57
|
if image?
|
60
|
-
@dimensions ||= FastImage.
|
58
|
+
@dimensions ||= FastImage.size(asset.filename.to_s)
|
61
59
|
end
|
62
60
|
end
|
63
61
|
|
@@ -9,14 +9,14 @@ module Jekyll
|
|
9
9
|
module Liquid
|
10
10
|
module Filters
|
11
11
|
ACCEPTABLE_FILTERS = [:css, :img, :asset_path, :stylesheet,
|
12
|
-
:javascript, :style, :
|
12
|
+
:javascript, :style, :image, :js]
|
13
13
|
|
14
14
|
# --
|
15
15
|
# The base filters.
|
16
16
|
# --
|
17
17
|
ACCEPTABLE_FILTERS.each do |val|
|
18
18
|
define_method val do |path, args = ""|
|
19
|
-
Tag.send(:new, val, "#{path} #{args}",
|
19
|
+
Tag.send(:new, val, "#{path} #{args}", ParseContext.new).render(
|
20
20
|
@context
|
21
21
|
)
|
22
22
|
end
|
@@ -28,7 +28,7 @@ module Jekyll
|
|
28
28
|
# --
|
29
29
|
def jekyll_asset_multi(assets)
|
30
30
|
return Shellwords.shellsplit(assets).map { |s| s.split(":", 2) }.map do |tag, arguments|
|
31
|
-
Tag.send(:new, tag, arguments,
|
31
|
+
Tag.send(:new, tag, arguments, ParseContext.new).render(
|
32
32
|
@context
|
33
33
|
)
|
34
34
|
end \
|
@@ -55,7 +55,7 @@ module Jekyll
|
|
55
55
|
resize_image = @env.asset_config["features"]["automatic_img_size"]
|
56
56
|
|
57
57
|
if !@env || resize_image
|
58
|
-
dimensions = FastImage.
|
58
|
+
dimensions = FastImage.size(@asset.filename.to_s)
|
59
59
|
return unless dimensions
|
60
60
|
@args[:html] ||= {}
|
61
61
|
|
@@ -16,18 +16,21 @@ module Jekyll
|
|
16
16
|
|
17
17
|
# ------------------------------------------------------------------
|
18
18
|
|
19
|
+
attr_reader :content_type
|
20
|
+
|
19
21
|
def_delegator :@asset, :liquid_tags
|
20
|
-
def_delegator :@asset, :
|
21
|
-
def_delegator :@asset, :content_type
|
22
|
+
def_delegator :@asset, :source_filename
|
22
23
|
def_delegator :@asset, :mtime
|
23
24
|
|
24
25
|
# ------------------------------------------------------------------
|
25
26
|
|
26
27
|
def initialize(asset, args, env, tag)
|
27
28
|
@env = env
|
28
|
-
@asset = asset
|
29
|
+
@asset = asset.dup
|
29
30
|
@args = args
|
30
31
|
@tag = tag
|
32
|
+
@path = Pathutil.new(asset.logical_path)
|
33
|
+
@content_type = asset.content_type
|
31
34
|
|
32
35
|
cache_file
|
33
36
|
proxy_file
|
@@ -59,13 +62,15 @@ module Jekyll
|
|
59
62
|
# ------------------------------------------------------------------
|
60
63
|
|
61
64
|
def source
|
62
|
-
|
65
|
+
filename.binread
|
63
66
|
end
|
64
67
|
|
65
68
|
# ------------------------------------------------------------------
|
66
69
|
|
67
70
|
def filename
|
68
|
-
|
71
|
+
Pathutil.new(
|
72
|
+
env.in_cache_dir(digest_path)
|
73
|
+
)
|
69
74
|
end
|
70
75
|
|
71
76
|
# ------------------------------------------------------------------
|
@@ -76,6 +81,15 @@ module Jekyll
|
|
76
81
|
)
|
77
82
|
end
|
78
83
|
|
84
|
+
# ------------------------------------------------------------------
|
85
|
+
|
86
|
+
def content_type=(type)
|
87
|
+
return if @content_type == type
|
88
|
+
|
89
|
+
@path = @path.sub_ext(_ext_for(type))
|
90
|
+
@content_type = type
|
91
|
+
end
|
92
|
+
|
79
93
|
# ------------------------------------------------------------------
|
80
94
|
# We always digest a proxied asset so it's uniq based on what
|
81
95
|
# proxies you give us, it would be ignorant to treat it otherwise,
|
@@ -89,9 +103,23 @@ module Jekyll
|
|
89
103
|
# ------------------------------------------------------------------
|
90
104
|
|
91
105
|
def digest_path
|
92
|
-
|
93
|
-
|
94
|
-
|
106
|
+
"#{@path.sub_ext ""}-#{digest}#{@path.extname}"
|
107
|
+
end
|
108
|
+
|
109
|
+
# --------------------------------------------------------------------
|
110
|
+
|
111
|
+
private
|
112
|
+
def _mime_for(ext)
|
113
|
+
Sprockets.mime_exts[
|
114
|
+
ext
|
115
|
+
]
|
116
|
+
end
|
117
|
+
|
118
|
+
# --------------------------------------------------------------------
|
119
|
+
|
120
|
+
private
|
121
|
+
def _ext_for(type)
|
122
|
+
Sprockets.mime_types[type][:extensions].first
|
95
123
|
end
|
96
124
|
|
97
125
|
# ------------------------------------------------------------------
|
@@ -100,21 +128,35 @@ module Jekyll
|
|
100
128
|
def proxy_file
|
101
129
|
unless cached?
|
102
130
|
args.proxies.each do |key, val|
|
131
|
+
old_type = content_type
|
132
|
+
old_filename = filename
|
103
133
|
Proxies.get(key).first[:class].new(self, val, @args).process
|
134
|
+
old_filename.rm if old_type != content_type
|
104
135
|
end
|
105
136
|
end
|
106
137
|
end
|
107
138
|
|
108
139
|
# ------------------------------------------------------------------
|
109
140
|
|
141
|
+
private
|
142
|
+
def find_cached
|
143
|
+
glob = filename.dirname.glob(filename.basename.sub_ext('.*'))
|
144
|
+
@_cached = filename.dirname.directory? && !glob.first.nil?
|
145
|
+
if @_cached
|
146
|
+
self.content_type = _mime_for(File.extname(glob.first))
|
147
|
+
end
|
148
|
+
|
149
|
+
@_cached
|
150
|
+
end
|
151
|
+
|
152
|
+
# ------------------------------------------------------------------
|
153
|
+
|
110
154
|
private
|
111
155
|
def cache_file
|
112
|
-
@_cached
|
113
|
-
return @_cached if @_cached
|
156
|
+
return true if @_cached || find_cached
|
114
157
|
|
115
|
-
|
116
|
-
|
117
|
-
FileUtils.cp asset.filename, filename
|
158
|
+
filename.dirname.mkdir_p
|
159
|
+
Pathutil.new(asset.filename).cp filename
|
118
160
|
true
|
119
161
|
end
|
120
162
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# ----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
try_require "mini_magick" do
|
8
|
-
args = %W(resize quality rotate crop flip gravity)
|
8
|
+
args = %W(resize quality rotate crop flip format gravity)
|
9
9
|
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
11
|
@two-fourths @three-fourths)
|
@@ -26,7 +26,6 @@ try_require "mini_magick" do
|
|
26
26
|
# ------------------------------------------------------------------------
|
27
27
|
|
28
28
|
def initialize(asset, opts, args)
|
29
|
-
@path = asset.filename
|
30
29
|
@opts = opts
|
31
30
|
@asset = asset
|
32
31
|
@args = args
|
@@ -35,7 +34,7 @@ try_require "mini_magick" do
|
|
35
34
|
# ------------------------------------------------------------------------
|
36
35
|
|
37
36
|
def process
|
38
|
-
img = MiniMagick::Image.open(@
|
37
|
+
img = MiniMagick::Image.open(@asset.filename)
|
39
38
|
methods = private_methods(true).select { |v| v.to_s.start_with?("magick_") }
|
40
39
|
if img.respond_to?(:combine_options)
|
41
40
|
then img.combine_options do |cmd|
|
@@ -55,7 +54,7 @@ try_require "mini_magick" do
|
|
55
54
|
end
|
56
55
|
|
57
56
|
img.write(
|
58
|
-
@
|
57
|
+
@asset.filename
|
59
58
|
)
|
60
59
|
ensure
|
61
60
|
img.destroy!
|
@@ -116,6 +115,15 @@ try_require "mini_magick" do
|
|
116
115
|
|
117
116
|
# ------------------------------------------------------------------------
|
118
117
|
|
118
|
+
private
|
119
|
+
def magick_format(img, _)
|
120
|
+
if @opts.key?(:format)
|
121
|
+
img.format @opts[:format]
|
122
|
+
@asset.content_type = img.mime_type
|
123
|
+
end
|
124
|
+
end
|
125
|
+
# ------------------------------------------------------------------------
|
126
|
+
|
119
127
|
private
|
120
128
|
def magick_crop(_, cmd)
|
121
129
|
if @opts.key?(:crop)
|
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.3.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:
|
13
|
+
date: 2017-06-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '1'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
24
|
+
version: '3'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
version: '1'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '3'
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: sprockets
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
version: '3.3'
|
42
42
|
- - "<"
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: '3.
|
44
|
+
version: '3.8'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -51,7 +51,7 @@ dependencies:
|
|
51
51
|
version: '3.3'
|
52
52
|
- - "<"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.8'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: fastimage
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,14 +112,28 @@ dependencies:
|
|
112
112
|
requirements:
|
113
113
|
- - "~>"
|
114
114
|
- !ruby/object:Gem::Version
|
115
|
-
version: '0.
|
115
|
+
version: '0.2'
|
116
116
|
type: :runtime
|
117
117
|
prerelease: false
|
118
118
|
version_requirements: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
120
|
- - "~>"
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version: '0.
|
122
|
+
version: '0.2'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: concurrent-ruby
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '1.0'
|
130
|
+
type: :runtime
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '1.0'
|
123
137
|
- !ruby/object:Gem::Dependency
|
124
138
|
name: nokogiri
|
125
139
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,6 +214,7 @@ files:
|
|
200
214
|
- lib/jekyll/assets/hooks/sources.rb
|
201
215
|
- lib/jekyll/assets/hooks/sprockets.rb
|
202
216
|
- lib/jekyll/assets/hooks/version.rb
|
217
|
+
- lib/jekyll/assets/liquid/context.rb
|
203
218
|
- lib/jekyll/assets/liquid/drop.rb
|
204
219
|
- lib/jekyll/assets/liquid/filters.rb
|
205
220
|
- lib/jekyll/assets/liquid/tag.rb
|
@@ -239,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
254
|
version: '0'
|
240
255
|
requirements: []
|
241
256
|
rubyforge_project:
|
242
|
-
rubygems_version: 2.
|
257
|
+
rubygems_version: 2.5.1
|
243
258
|
signing_key:
|
244
259
|
specification_version: 4
|
245
260
|
summary: Assets for Jekyll
|