jekyll-assets 2.4.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +21 -17
  3. data/LICENSE +1 -1
  4. data/README.md +365 -297
  5. data/Rakefile +13 -2
  6. data/lib/jekyll/assets.rb +15 -11
  7. data/lib/jekyll/assets/config.rb +91 -55
  8. data/lib/jekyll/assets/context.rb +32 -0
  9. data/lib/jekyll/assets/default.rb +98 -0
  10. data/lib/jekyll/assets/drop.rb +62 -0
  11. data/lib/jekyll/assets/env.rb +135 -278
  12. data/lib/jekyll/assets/extensible.rb +86 -0
  13. data/lib/jekyll/assets/filters.rb +22 -0
  14. data/lib/jekyll/assets/hook.rb +115 -48
  15. data/lib/jekyll/assets/html.rb +88 -0
  16. data/lib/jekyll/assets/logger.rb +17 -59
  17. data/lib/jekyll/assets/manifest.rb +15 -126
  18. data/lib/jekyll/assets/map.rb +57 -0
  19. data/lib/jekyll/assets/map/css.rb +43 -0
  20. data/lib/jekyll/assets/map/javascript.rb +43 -0
  21. data/lib/jekyll/assets/map/writer.rb +192 -0
  22. data/lib/jekyll/assets/patches/cached_env.rb +79 -0
  23. data/lib/jekyll/assets/patches/functions.rb +31 -0
  24. data/lib/jekyll/assets/patches/obsolete_files.rb +42 -0
  25. data/lib/jekyll/assets/patches/sprockets.rb +9 -0
  26. data/lib/jekyll/assets/patches/sprockets_data_uri.rb +12 -0
  27. data/lib/jekyll/assets/plugins.rb +9 -0
  28. data/lib/jekyll/assets/plugins/bootstrap.rb +5 -0
  29. data/lib/jekyll/assets/plugins/font-awesome.rb +8 -0
  30. data/lib/jekyll/assets/plugins/frontmatter.rb +28 -0
  31. data/lib/jekyll/assets/plugins/html/audio.rb +32 -0
  32. data/lib/jekyll/assets/plugins/html/css.rb +24 -0
  33. data/lib/jekyll/assets/plugins/html/defaults/audio.rb +69 -0
  34. data/lib/jekyll/assets/plugins/html/defaults/css.rb +48 -0
  35. data/lib/jekyll/assets/plugins/html/defaults/img.rb +54 -0
  36. data/lib/jekyll/assets/plugins/html/defaults/js.rb +48 -0
  37. data/lib/jekyll/assets/plugins/html/defaults/vid.rb +63 -0
  38. data/lib/jekyll/assets/plugins/html/img.rb +76 -0
  39. data/lib/jekyll/assets/plugins/html/js.rb +30 -0
  40. data/lib/jekyll/assets/plugins/html/pic.rb +125 -0
  41. data/lib/jekyll/assets/plugins/html/svg.rb +37 -0
  42. data/lib/jekyll/assets/plugins/html/vid.rb +26 -0
  43. data/lib/jekyll/assets/plugins/liquid.rb +57 -0
  44. data/lib/jekyll/assets/plugins/magick.rb +7 -0
  45. data/lib/jekyll/assets/plugins/optim.rb +7 -0
  46. data/lib/jekyll/assets/plugins/prefixer.rb +28 -0
  47. data/lib/jekyll/assets/plugins/proxy/magick.rb +131 -0
  48. data/lib/jekyll/assets/plugins/proxy/optim.rb +64 -0
  49. data/lib/jekyll/assets/plugins/searcher.rb +72 -0
  50. data/lib/jekyll/assets/proxy.rb +109 -0
  51. data/lib/jekyll/assets/tag.rb +176 -0
  52. data/lib/jekyll/assets/url.rb +23 -0
  53. data/lib/jekyll/assets/utils.rb +348 -0
  54. data/lib/jekyll/assets/version.rb +2 -2
  55. data/lib/jekyll/assets/writer.rb +36 -0
  56. metadata +102 -81
  57. data/lib/jekyll-assets.rb +0 -7
  58. data/lib/jekyll/assets/addons/autoprefixer.rb +0 -11
  59. data/lib/jekyll/assets/addons/bootstrap.rb +0 -9
  60. data/lib/jekyll/assets/addons/fontawesome.rb +0 -9
  61. data/lib/jekyll/assets/addons/javascript.rb +0 -11
  62. data/lib/jekyll/assets/cached.rb +0 -30
  63. data/lib/jekyll/assets/helpers.rb +0 -74
  64. data/lib/jekyll/assets/hooks/cache.rb +0 -21
  65. data/lib/jekyll/assets/hooks/compression.rb +0 -25
  66. data/lib/jekyll/assets/hooks/config.rb +0 -12
  67. data/lib/jekyll/assets/hooks/erb.rb +0 -15
  68. data/lib/jekyll/assets/hooks/jekyll/drops.rb +0 -9
  69. data/lib/jekyll/assets/hooks/jekyll/setup.rb +0 -11
  70. data/lib/jekyll/assets/hooks/jekyll/write.rb +0 -11
  71. data/lib/jekyll/assets/hooks/logger.rb +0 -11
  72. data/lib/jekyll/assets/hooks/sources.rb +0 -13
  73. data/lib/jekyll/assets/hooks/sprockets.rb +0 -9
  74. data/lib/jekyll/assets/hooks/version.rb +0 -11
  75. data/lib/jekyll/assets/liquid/context.rb +0 -19
  76. data/lib/jekyll/assets/liquid/drop.rb +0 -81
  77. data/lib/jekyll/assets/liquid/filters.rb +0 -49
  78. data/lib/jekyll/assets/liquid/tag.rb +0 -244
  79. data/lib/jekyll/assets/liquid/tag/defaults.rb +0 -27
  80. data/lib/jekyll/assets/liquid/tag/defaults/image.rb +0 -81
  81. data/lib/jekyll/assets/liquid/tag/defaults/sha.rb +0 -58
  82. data/lib/jekyll/assets/liquid/tag/parser.rb +0 -202
  83. data/lib/jekyll/assets/liquid/tag/proxied_asset.rb +0 -166
  84. data/lib/jekyll/assets/liquid/tag/proxies.rb +0 -130
  85. data/lib/jekyll/assets/patches/jekyll/cleaner.rb +0 -15
  86. data/lib/jekyll/assets/patches/jekyll/site.rb +0 -5
  87. data/lib/jekyll/assets/patches/kernel.rb +0 -29
  88. data/lib/jekyll/assets/patches/sprockets/asset.rb +0 -28
  89. data/lib/jekyll/assets/processors/less.rb +0 -70
  90. data/lib/jekyll/assets/processors/liquid.rb +0 -46
  91. data/lib/jekyll/assets/proxies/image_optim.rb +0 -80
  92. data/lib/jekyll/assets/proxies/magick.rb +0 -194
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3f85683208d7c6a5e8212c0a26d86765fc44b4d
4
- data.tar.gz: ab4ab48388c30fb14de9b49884ee89f700f04948
3
+ metadata.gz: 44d89fc0d1ca6db22209873e55c1672289e5e67f
4
+ data.tar.gz: 5a3e81f94ffcf988f713e2d971f931b30c5fd09f
5
5
  SHA512:
6
- metadata.gz: '0619236826dae97812c7c9ad4e647b3ced92ac1eed4acf924fbe36163cb98270ef7a36aec3231b1bd21b1527efc4db31b8c14d8cedfb2bf564a49581c0d8a768'
7
- data.tar.gz: a37c926b28a79d8e6be32d2067236fd63f34cb20d6bac7ff35935b8fe1387deec574cbf21254e70590db5ae37809134fdd834b5ef692335911a7879347481d52
6
+ metadata.gz: 45850b5a84a5cacfb3257789b39f0e3b5ff66c47f006c342c3fb4f5d71f465d9a8264c518f3a68005cbec2e452ac038387e75e21138c0d5452fcaba01ebb4fa8
7
+ data.tar.gz: 52ce19c278b2901eb63f12c0d5240294065a0c72a2711e1b5d8fe7a46d104abbfcf2f89bb4e1d6a476c2dc3d15544ca7379903421f118b3a3c492efae2ec33c9
data/Gemfile CHANGED
@@ -1,26 +1,30 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2012 - 2017 - MIT License
3
+ # Encoding: utf-8
4
+
1
5
  source "https://rubygems.org"
2
6
  gemspec
3
7
 
4
- gem "rake"
8
+ gem "rake", require: false
5
9
  group :development do
6
- gem "therubyracer", :platforms => :mri, :require => false
7
- gem "therubyrhino", :platforms => :jruby, :require => false
8
- gem "stackprof", :platforms => :mri, :require => false
9
- gem "pry", :require => false
10
+ gem "mini_racer", require: false if RUBY_PLATFORM != "java"
11
+ gem "therubyrhino", require: false if RUBY_PLATFORM == "java"
12
+ gem "pry", require: false if RUBY_PLATFORM != "java"
10
13
  end
11
14
 
12
15
  group :test do
13
- gem "codeclimate-test-reporter", :require => false
14
- gem "rubocop", :require => false
16
+ gem "simplecov", require: false
17
+ gem "luna-rspec-formatters", require: false
18
+ gem "rubocop", require: false
15
19
  end
16
20
 
17
- gem "uglifier", :require => false
18
- gem "sprockets-es6", "~> 0.6", :require => false
19
- gem "autoprefixer-rails", "~> 7.0", :require => false
20
- gem "jekyll", "#{ENV["JEKYLL_VERSION"]}" if ENV["JEKYLL_VERSION"]
21
- gem "font-awesome-sass", "~> 4.4", :require => false
22
- gem "bootstrap-sass", "~> 3.3", :require => false
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
26
- gem "less", "~> 2.6.0", :require => false
21
+ gem "uglifier", require: false
22
+ gem "autoprefixer-rails", require: false
23
+ gem "font-awesome-sass", "~> 4.4", require: false
24
+ gem "sprockets", ENV["SPROCKETS_VERSION"] || "~> 4.0.beta", require: false
25
+ gem "jekyll", ENV["JEKYLL_VERSION"], require: false if ENV["JEKYLL_VERSION"]
26
+ gem "image_optim_pack", "~> 0.5", require: false
27
+ gem "image_optim", "~> 0.25", require: false
28
+ gem "mini_magick", "~> 4.2", require: false
29
+ gem "babel-transpiler", require: false
30
+ gem "bootstrap", require: false
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2012 - 2015 Aleksey V Zapparov (http://ixti.net/)
2
- Copyright (c) 2015 - 2016 Jordon Bedwell (https://envygeeks.io)
2
+ Copyright (c) 2015 - 2017 Jordon Bedwell (https://envygeeks.io)
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,272 +1,289 @@
1
1
  <p align=center>
2
2
  <a href=https://goo.gl/BhrgjW>
3
- <img src=https://envygeeks.io/badges/paypal-large_1.png alt=Donate>
3
+ <img src=https://envygeeks.io/badges/paypal-large_1.png>
4
4
  </a>
5
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>
6
+ <a href=https://travis-ci.org/envygeeks/jekyll-assets>
7
+ <img src="https://travis-ci.org/envygeeks/jekyll-assets.svg?branch=master">
8
+ </a>
9
+ <a href="https://codeclimate.com/github/envygeeks/jekyll-assets/test_coverage">
10
+ <img src="https://api.codeclimate.com/v1/badges/56f67324553069bf51e7/test_coverage" />
11
+ </a>
12
+ <a href="https://codeclimate.com/github/envygeeks/jekyll-assets/maintainability">
13
+ <img src="https://api.codeclimate.com/v1/badges/56f67324553069bf51e7/maintainability" />
8
14
  </a>
9
15
  </p>
10
16
 
17
+ [1]:http://guides.rubyonrails.org/asset_pipeline.html
18
+ [2]:https://github.com/rails/sprockets
19
+ [3]:https://jekyllrb.com
20
+
21
+ # Jekyll Assets 3.x
22
+
23
+ ***Jekyll Assets 3.x is currently unreleased. It is scheduled to released sometime in October. If you are looking for documentation, for the current release (2.x) please see: https://github.com/jekyll/jekyll-assets/tree/2.4-legacy it should have what you are looking for.***
24
+
25
+ ## What's new
26
+
27
+ - [x] Jekyll like tag arguments.
28
+ - [x] Support for `<img>` srcset.
29
+ - [x] Proxies in `asset()` for SASS.
30
+ - [x] Expanded source directories by default.
31
+ - [x] Support for `srcset`, width, and density.
32
+ - [x] Support for building HTML for external assets.
33
+ - [x] Stripping of FrontMatter (`---`) before processing.
34
+ - [x] Extensible/customizable decoupled HTML builders for tags.
35
+ - [x] Support for `<audio>`, `<video>`, `<img>` discovery in Markdown.
36
+ - [x] Responsive images with `srcset` `<picture>` tag support.
37
+ - [x] Support for audio assets (using `assets` tag.)
38
+ - [x] Support for video assets (using `assets` tag.)
39
+ - [x] Easier proxies, with rolling proxies.
40
+ - [x] Customizable HTML defaults.
41
+ - [x] Configurable GZipping.
42
+ - [x] Proxies via `<img>`.
43
+ - [x] SourceMaps.
44
+
11
45
  # Jekyll Assets
12
46
 
13
- 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.
47
+ Jekyll Assets is a drop in [asset pipeline][1] that uses [Sprockets][2] to build specifically for Jekyll. It utilizes [Sprockets][2], and [Jekyll][3] to try and achieve a clean and extensible assets platform that supports plugins, caching, converting your assets, and even the proxy of said assets in a way that does not interfere with either [Sprockets][2], or [Jekyll][3], and your own source. By default you can add Jekyll Assets to your Gemfile, as a plugin, and have it act as a drop-in replacement for Jekyll's basic SASS/CoffeeScript processors, with you only having to add it to your Gemfile, and updating your `<img>`, and `<link>`.
14
48
 
15
49
  ## Using Jekyll Assets with Jekyll
16
50
 
17
51
  ```ruby
18
- # Gemfile
19
- group :jekyll_plugins do
20
- gem "jekyll-assets"
21
- end
52
+ gem "jekyll-assets", group: :jekyll_plugins
53
+ gem "jekyll-assets", git: "https://github.com/envygeeks/jekyll-assets", group: :jekyll_plugins
54
+ gem "jekyll-assets", "~> x.x.alpha", group: :jekyll_plugins
22
55
  ```
23
56
 
24
- ```yaml
25
- # _config.yml
26
- plugins:
27
- - jekyll-assets
28
- ```
57
+ ### Requirments
29
58
 
30
- ## Configuration
59
+ * Ruby ***2.3+***
60
+ * Jekyll ***3.5+***
61
+ * Sprockets ***3.3+***
31
62
 
32
- The configuration file is the same as Jekyll's, which is _config.yml. Use the special key "assets":
63
+ ***If you would like SourceMap support, or faster Sprockets, you should prefer to use Sprockets "~> 4.0.beta", we support SourceMaps in this version of Sprockets because it supports them. It's manifest an other features are also much better inside of this version of Sprockets.***
33
64
 
34
- ```yaml
35
- assets:
36
- compress:
37
- css: false | true | default - development: false, production: true
38
- js: false | true | default - development: false, production: true
39
- autowrite: true
40
- cache: false | directory | default: .asset-cache
41
- cache_type: memory | filesystem | default: filesystem
42
- cdn: https://cdn.example.com
43
- skip_baseurl_with_cdn: false
44
- skip_prefix_with_cdn: false
45
- prefix: "/assets"
46
- digest: true
47
- assets:
48
- - "*.png"
49
- - "bundle.css"
50
- sources:
51
- - _assets/css
52
- - _assets/images
53
- - _assets/javascripts
54
- - _assets/stylesheets
55
- - _assets/fonts
56
- - _assets/img
57
- - _assets/js
58
- features:
59
- liquid: true | false | default: false
60
- integrity: true | false | default: false
61
- # This will add height and width attributes for an img tag.
62
- automatic_img_size: true | false | n(fixnum): 2,4,6,8 | default: true
63
- # This will add the digest path as an alt attribute for an img tag.
64
- automatic_img_alt : true | false | default: true
65
+ ```ruby
66
+ gem "sprockets", "~> 4.0.beta", {
67
+ require: false
68
+ }
65
69
  ```
66
70
 
67
- ### Liquid Processing with your Jekyll context
68
-
69
- By default (whether `features.liquid` is `true` or `false`) we will process
70
- all files with the extension `.liquid`, so if you give us `.scss.liquid`
71
- we will parse the liquid and then we will parse the SCSS and finally
72
- 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.***
73
-
74
- ### Cache Folder
75
-
76
- If you plan to change the `cache` folder, please make sure to add that
77
- folder to your `exclude` list in Jekyll, or you will generate over and over
78
- and over again, `.` folders are not ignored by default as of Jekyll 3.x, so you should take heed of ignoring your own folders.
79
-
80
- ### Sources
81
-
82
- The listed resources in the example are all defaults. It should be noted
83
- that we append your sources instead of replace our resources with yours. So
84
- if you add `_assets/folder` then we will append that to our sources and
85
- 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.)***
86
-
87
- ### Digesting
88
-
89
- * Disable digesting by default in development.
90
- * Digest by default in production.
91
-
92
- ***You can force digesting with `digest: true` in your `_config.yml`***
93
-
94
- ### Compression
95
-
96
- * Requires sass and uglifier.
97
- * Disable compression by default in development.
98
- * Enable by default in production.
99
-
100
- ## Generating CSS with Jekyll Assets
71
+ ## Configuration
101
72
 
102
- The following section shows how to get started generating CSS using Jekyll
103
- 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.
73
+ The configuration file is the same as Jekyll's, which is `_config.yml`. Except we use the special key "assets" inside of that file. Any environment variable noted as "val on `JEKYLL_ENV`" is only overridden when not explicitly set. All values listed below are default, you need not copy these into your configuration file unless you plan to change a value.
104
74
 
105
- ### Create the `_assets/css` directory
75
+ ```yaml
76
+ digest: false
77
+ source_maps: true # false on JEKYLL_ENV=production
78
+ destination: "/assets"
79
+ compression: true
80
+ gzip: false
81
+ defaults:
82
+ js: { integrity: false } # true on JEKYLL_ENV=production
83
+ css: { integrity: false } # true on JEKYLL_ENV=production
84
+ img: { integrity: false } # true on JEKYLL_ENV=production
85
+ caching:
86
+ path: ".jekyll-cache/assets"
87
+ type: file # Possible values: memory, file
88
+ enabled: true
89
+ precompile: []
90
+ cdn:
91
+ baseurl: false
92
+ destination: false
93
+ url: null
94
+ sources:
95
+ - assets/css
96
+ - assets/fonts
97
+ - assets/images
98
+ - assets/videos
99
+ - assets/javascript
100
+ - assets/video
101
+ - assets/image
102
+ - assets/img
103
+ - assets/js
104
+ - _assets/css
105
+ - _assets/fonts
106
+ - _assets/images
107
+ - _assets/videos
108
+ - _assets/javascript
109
+ - _assets/video
110
+ - _assets/image
111
+ - _assets/img
112
+ - _assets/js
113
+ - css
114
+ - fonts
115
+ - images
116
+ - videos
117
+ - javascript
118
+ - video
119
+ - image
120
+ - img
121
+ - js
122
+ plugins:
123
+ css: { autoprefixer: {}}
124
+ img: { optim: {}}
125
+ ```
106
126
 
107
- The default [Jekyll Assets configuration](#configuration) expects to find all the assets in directories under `_assets`. Create a directory for the CSS:
127
+ ## Tag
128
+ ### Usage
129
+ #### Liquid
108
130
 
109
- ```bash
110
- mkdir -p _assets/css
131
+ ```liquid
132
+ {% asset src @magick:2x alt='This is my alt' %}
133
+ {% asset src @magick:2x alt='This is my alt' %}
111
134
  ```
112
135
 
113
- ### Move the CSS files to the new `_assets/css` directory
136
+ #### HTML
114
137
 
115
- 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.
116
-
117
- ```bash
118
- mv css/main.css _assets/css
119
- mv _sass/* _assets/css
138
+ ```html
139
+ <img src="src" asset="@magick:2x" alt="This is my alt">
140
+ <img src="src" alt="This is my alt" asset>
120
141
  ```
121
142
 
122
- ### Remove Jekyll front matter
123
-
124
- Jekyll includes some empty [front matter](https://jekyllrb.com/docs/frontmatter/) in `main.css`. Remove that as Sprockets will not understand it.
143
+ ### Defaults
125
144
 
126
- ### Update the layout
145
+ We provide several defaults that get set when you run an asset, depending on content type, this could be anything from type, all the way to integrity. If there is a default attribute you do not wish to be included, you can disable the attribute with `!attribute`, and it will be skipped over.
127
146
 
128
- 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:
147
+ #### Usage
129
148
 
130
149
  ```liquid
131
- {% css main %}
150
+ {% asset img.png !integrity %}
151
+ {% asset bundle.css !type %}
132
152
  ```
133
153
 
134
- 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.
154
+ ### Arguments
135
155
 
136
- ## Addons
156
+ Our tags will take any number of arguments, and convert them to HTML, and even attach them to your output if the HTML processor you use accepts that kind of data. ***This applies to anything but hashes, and arrays.*** So adding say, a class, or id, is as easy as doing `id="val"` inside of your tag arguments.
137
157
 
138
- * Font Awesome `gem "font-awesome-sass"`
158
+ #### Builtins
139
159
 
140
- ```scss
141
- @import 'font-awesome-sprockets'
142
- @import 'font-awesome'
143
- ```
160
+ | Arg | Description | Type | Return Type |
161
+ |---|---|---|---|
162
+ | `@path` | Path | `*/*` | `text`
163
+ | `@data` | `data` URI | `*/*` | `text` |
164
+ | `@inline` | CSS `<style>` | `text/css` | `text/html` |
165
+ | | `text/svg+xml` XML | `image/svg+xml` | `text/svg+xml` |
166
+ | | JavaScript `<script>` | `application/javascript` | `text/html` |
167
+ | | Image `<img>` | `image/*` | `text/html` |
168
+ | `srcset` | [Responsive]() `<img>` | `image/*` | `text/html` |
169
+ | `srcset` + `@pic` | [Responsive]() `<pic>` | `image/*` | `text/html` |
144
170
 
145
- * CSS Auto-Prefixing `gem "autoprefixer-rails"`
171
+ ***Jekyll Assets uses [@envygeeks](https://github.com/envygeeks) `liquid-tag-parser` which supports advanced arguments (hash based arguments) as well as array based arguments. When you see something like `k1:sk1=val` it will get converted to `k1 = { sk1: "val" }` in Ruby. To find out more about how we process tags you should visit the documentation for [`liquid-tag-parser`](https://github.com/envygeeks/liquid-tag-parser)***
146
172
 
147
- ```yml
148
- assets:
149
- autoprefixer:
150
- browsers:
151
- - "last 2 versions"
152
- - "IE > 9"
153
- ```
173
+ #### Responsive Images
154
174
 
155
- * Bootstrap `gem "bootstrap-sass"`
175
+ Jekyll Assets has the concept of responsive images, using the `picture` (when using `@pic` w/ `srcset`) and the `<img>` tag when using `srcset`. If you ship multiple `srcset` with your image, we will proxy, build and then ship out a `picture/img` tag with any number of `source/srcset`, and in the case of picture, with the original image being the `image`.
156
176
 
157
- ```scss
158
- @import 'bootstrap-sprockets'
159
- @import 'bootstrap'
160
- ```
177
+ ##### `<picture>` usage, requires `@pic`
178
+ ###### Example
161
179
 
162
- * ES6 `gem "sprockets-es6"`
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.
180
+ ```liquid
181
+ {% asset img.png @pic
182
+ srcset:max-width="800 2x"
183
+ srcset:max-width="600 1.5x"
184
+ srcset:max-width="400 1x"
185
+ %}
186
+ ```
181
187
 
182
- * LESS `gem "less"`
188
+ ```html
189
+ <picture>
190
+ <source srcset="1.png 2x" media="(max-width:800px)">
191
+ <source srcset="2.png 1.5x" media="(max-width:600px)">
192
+ <source srcset="3.png 1x" media="(max-width:400px)">
193
+ <img src="img.png">
194
+ </picture>
195
+ ```
183
196
 
184
- ## Bower
197
+ ##### `<img>` usage
198
+ ###### Example
185
199
 
186
- Modify your `.bowerrc` file and add:
200
+ ```liquid
201
+ {% asset img.png
202
+ srcset:width="400 2x"
203
+ srcset:width="600 1.5x"
204
+ srcset:width="800 1x"
205
+ %}
206
+
207
+ {% asset img.png
208
+ srcset:width=400
209
+ srcset:width=600
210
+ srcset:width=800
211
+ %}
212
+ ```
187
213
 
188
- ```json
189
- {
190
- "directory": "_assets/bower"
191
- }
214
+ ```html
215
+ <img srcset="1.png 2x, 2.png 1.5x, 3.png 1x">
216
+ <img srcset="1.png 400w, 2.png 600w, 3.pnx 800w">
192
217
  ```
193
218
 
194
- And then add `_assets/bower` to your sources list and Sprockets will do the
195
- the rest for you... you can even `//= require bower_asset.js`. We will even
196
- compress them for you per normal if Sprockets supports it and allows us to.
219
+ ##### Args
220
+
221
+ | Arg | Type | Description | `@pic` Only |
222
+ | --- | ---- | ------------| ----------- |
223
+ | `width` | Width [Density] | Resize, set `srcset="<Src> <<Width>px/Density>"` | ✗ |
224
+ | `min-width` | Width [Density] | Resize, set `media="(min-width: <Width>px)"` | ✔ |
225
+ | `max-width` | Width [Density] | Resize, set `media="(max-width: <Width>px)"` | ✔ |
226
+ | `sizes` | Any | Your value, unaltered, unparsed. | ✗ |
227
+ | `media` | Any | Your value, unaltered, unparsed. | ✗ |
197
228
 
198
- ***You do not need to modify your `.bowerrc` file, you can optionally just
199
- add it to your sources list and it will work that way too! As long as it's in
200
- your Jekyll folder.***
229
+ ***If you set `media`, w/ `max-width`, `min-width`, we will not ship `media`, we will simply resize and assume you know what you're doing. Our parser is not complex, and does not make a whole lot of assumptions on your behalf, it's simple and only meant to make your life easier. In the future we may make it more advanced.***
201
230
 
202
- ## Tags
231
+ ## Liquid
203
232
 
204
- * image, img
205
- * javascript, js
206
- * stylesheet, css, style
207
- * asset, asset_source
208
- * asset_path
233
+ We support liquid arguments for tag values (but not tag keys), and we also support Liquid pre-processing (with your Jekyll context) of most files if they end with `.liquid`. This will also give you access to our filters as well as their filters, and Jekyll's filters.
209
234
 
210
- ### Tag Example:
235
+ ### Usage
211
236
 
212
237
  ```liquid
213
- {% img src magick:2x alt:'This is my alt' %}
214
- {% img src magick:2x alt:'This is my alt' sprockets:accept:image/gif %}
238
+ {% img '{{ image_path }}' %}
239
+ {% img '{{ image_path }}' proxy:key='{{ value }}' %}
240
+ {% img {{\ image_path\ }} %}
215
241
  ```
216
242
 
217
- ### What do the colons mean? Proxies/Tags
243
+ #### `.liquid.ext`, and `.ext.liquid`
218
244
 
219
- * `argument` is a boolean HTML argument.
220
- * `key:value` is an HTML key="value" if no proxy exists.
221
- * `proxy:key:value` will set a proxy key with the given value.
222
- * `proxy:key` is a boolean argument if the proxy and key exists.
223
- * `unknown:key:value` will raise `DoubleColonError`, escape it.
224
- * `proxy:unknown:value` will raise a `UnknownProxyError`.
245
+ ```scss
246
+ .bg {
247
+ background: url(asset_path("{{ site.background_image }}"));
248
+ }
249
+ ```
225
250
 
226
- Lets say we have `sprockets` proxies and sprockets allows you to proxy accept,
227
- if you send `{% img src sprockets:accept:image/gif }` then Sprockets find_asset
228
- will get `{ :accept => "image/gif" }` but if you try to proxy "unknown" on
229
- sprockets we will raise a Proxy error. For more information then look at
230
- `parser_spec.rb` in the spec folder because it literally lays out the ground
231
- rules for our tags as a specification.
251
+ You have full access to your entire Jekyll context from any liquid
252
+ processing we do, so you can do whatever you like, and be as dynamic as you like, including full loops, and conditional Liquid based CSS/JavaScript since we pre-process your text files. ***On Sprockets 4.x you can use `.liquid.ext` and `.ext.liquid`, but because of the way Sprockets 3.x works, we have opted to only allow the default extension of `.ext.liquid` when running on "Old Sprockets" (AKA 3.x.) If you would like Syntax + Liquid you should opt to install Sprockets 4.x so you can get the more advanced features.***
232
253
 
233
- ### Current Proxies:
254
+ ##### Importing
234
255
 
235
- * `sprockets:accept:<value>`
236
- * `sprockets:write_to:<value>`
256
+ ***In order to import your Liquid pre-processed assets inside of Liquid or JS you should use a Sprockets `//require=`, Sprockets does not integrate that deeply into JavaScript and SASS to allow you to `@import` and pre-process.***
237
257
 
238
- ## Liquid Variables
258
+ ## Sass/SCSS Helpers
239
259
 
240
- We support liquid arguments for tag values (but not tag keys), and we also
241
- support Liquid pre-processing (with your Jekyll context) sass/less/css files
242
- you need do nothing special for the preprocessing an entire file, it's
243
- always done.
260
+ We provide two helpers, `asset_path` to return the path of an asset, and `asset_url` which will wrap `asset_path` into a `url()` for you, making it easy for you to extract your assets and their paths inside of SCSS.
244
261
 
245
- An example of using Liquid in your tags:
262
+ ### Usage
246
263
 
247
- ```liquid
248
- {% img '{{ image_path }}' %}
249
- {% img '{{ image_path }}' proxy:key:'{{ value }}' %}
250
- {% img {{\ image_path\ }} %}
264
+ ```scss
265
+ body {
266
+ background-image: asset_url("img.png");
267
+ }
251
268
  ```
252
269
 
253
- An example of using Liquid in your SCSS:
270
+ #### Proxies, and Other Arguments
271
+
272
+ Any argument that is supported by our regular tags, is also supported by our Sass/SCSS helpers, with a few obvious exceptions (like `srcset`). This means that you can wrap your assets into `magick` if you wish, or `imageoptim` or any other proxy that is able to spit out a path for you to use.
273
+
274
+ ##### Usage
254
275
 
255
276
  ```scss
256
- .bg {
257
- background: url(asset_path("{{ site.background_image }}"));
277
+ body {
278
+ background-image: asset_url("img.png @magick:half")
258
279
  }
259
280
  ```
260
281
 
261
- You have full access to your entire Jekyll context from any liquid
262
- processing we do, so you can do whatever you like and be as dynamic as you
263
- like, including full loops and conditional Liquid based CSS since we
264
- pre-process your text files.
282
+ ***Not we do not validate your arguments, so if you send a conflicting argument that results in invalid CSS, you are responsible for that, in that if you ship us `srcset` we won't throw, we will spit out HTML for you, and it will break your CSS, this is by design.***
265
283
 
266
- ## Getting a list of your assets and basic info from Liquid
284
+ ## List
267
285
 
268
- We provide all *your* assets as a hash of Liquid Drops so you can get basic
269
- info that we wish you to have access to without having to prepare the class.
286
+ We provide all *your* assets as a hash of Liquid Drops so you can get basic info that we wish you to have access to without having to prepare the class.
270
287
 
271
288
  ```liquid
272
289
  {{ assets["bundle.css"].content_type }} => "text/css"
@@ -276,154 +293,205 @@ info that we wish you to have access to without having to prepare the class.
276
293
 
277
294
  The current list of available accessors:
278
295
 
279
- * `logical_path`
280
- * `content_type` -> `type`
281
- * `filename`
282
- * `basename`
283
- * `width`
284
- * `height`
285
- * `digest_path`
296
+ | Method | Description |
297
+ |---|---|
298
+ | `content_type` | The RFC content type |
299
+ | `height` | The asset height ***(if available)*** |
300
+ | `filename` | The full path to the assets actual file |
301
+ | `width` | The asset width ***(if available)*** |
302
+ | `digest_path` | The prefixed path |
286
303
 
287
- If you would like more, please feel free to add a pull request, at this
288
- time we will reject all pull requests that wish to add any digested paths as
289
- those are dynamically created when a proxy is ran so we can never predict
290
- it reliably unless we proxy and that would be a performance problem.
304
+ ### Looping
291
305
 
292
- ### Dynamically loading assets
306
+ ```liquid
307
+ {% for k,v in assets %}
308
+ {{ k }}
309
+ {% endfor %}
310
+ ```
311
+
312
+ ### Dynamic
293
313
 
294
314
  Using Liquid Drop `assets`, you can check whether an asset is present.
295
315
 
296
316
  ```liquid
297
- {% if assets[page.image] %}
298
- {% img '{{ page.image }}' %}
317
+ {% if assets[page.image] %}{% img '{{ page.image }}' %}
299
318
  {% else %}
300
- {% img 'default.jpg' %}
319
+ {% img default.jpg %}
301
320
  {% endif %}
302
321
  ```
303
322
 
304
- ## ERB Support
305
-
306
- ERB Support is removed in favor of trying to get this included on Github Pages
307
- eventually (if I can.) Having ERB presents a security risk to Github because it
308
- would allow you to use Ruby in ways they don't want you to.
309
-
310
- ## Filters
311
-
312
- There is a full suite of filters, actually, any tag and any proxy can be a
313
- filter by way of filter arguments, take the following example:
323
+ ## Filter
314
324
 
315
325
  ```liquid
316
- {{ src | img : "magick:2x magick:quality:92" }}
326
+ {{ src | asset:"@magick:2x magick:quality:92" }}
317
327
  ```
318
328
 
319
- ### Jekyll Assets Multi
329
+ ## Hooks
320
330
 
321
- Jekyll Assets has a special called `jekyll_asset_multi` which is meant to be used for things like the header, where it would be nice to be able to include multiple assets at once. You can use it like so:
331
+ | Point | Name | Instance | Args |
332
+ |---|---|---|---|
333
+ | `:env` | `:before_init` | ✔ | ✗ |
334
+ | `:env` | `:after_init` | ✔ | ✗ |
335
+ | `:config` | `:before_merge` | ✗ | `Config{}` |
336
+ | `asset` | `:before_compile` | ✗ | `Asset`, `Manifest` |
322
337
 
323
- ```liquid
324
- {{ 'css:bundle.css "js:bundle.js async:true"' | jekyll_asset_multi }}
338
+ ### Usage
339
+
340
+ ```ruby
341
+ Jekyll::Assets::Hook.register :env, :before_init do
342
+ append_path "myPluginsCustomPath"
343
+ end
325
344
  ```
326
345
 
327
- ## Hooks
346
+ ```ruby
347
+ Jekyll::Assets::Hook.register :config, :init do |c|
348
+ c.deep_merge!({
349
+ plugins: {
350
+ my_plugin: {
351
+ opt: true
352
+ }
353
+ }
354
+ })
355
+ end
356
+ ```
328
357
 
329
- * `:env => [:init]`
358
+ #### Plugin Hooks
330
359
 
331
- You can register and trigger hooks like so:
360
+ Your plugin can also register it's own hooks on our Hook system, so that you can trigger hooks around your stuff as well, this is useful for extensive plugins that want more power.
361
+
362
+ ##### Usage
363
+
364
+ ```ruby
365
+ Jekyll::Assets::Hook.add_point(:plugin, :hook)
366
+ ```
332
367
 
333
368
  ```ruby
334
- Jekyll::Assets::Hook.register :env, :init do
335
- # Your Work
369
+ Jekyll::Assets::Hook.trigger(:plugin, :hook) { |v| v.call(:arg) }
370
+ Jekyll::Assets::Hook.trigger(:plugin, :hook) do |v|
371
+ instance_eval(&v)
336
372
  end
337
373
  ```
338
374
 
339
- ## Combining Multiple Scripts / Stylesheets
375
+ ## Default Plugins
376
+ ### Font Awesome
377
+ #### Installation
340
378
 
341
- To minimize the number of HTTP requests, combine stylesheets and scripts into one file.
379
+ ```ruby
380
+ gem "font-awesome-sass"
381
+ ```
342
382
 
343
- ### SCSS
383
+ #### Usage
344
384
 
345
- Use the `@import` statement. Given a list of files in `_assets/css`:
385
+ ```scss
386
+ @import "font-awesome-sprockets"
387
+ @import "font-awesome"
388
+ ```
389
+
390
+ ### CSS Auto-Prefixing
391
+ #### Installation
392
+
393
+ ```ruby
394
+ gem "autoprefixer-rails"
395
+ ```
396
+
397
+ #### Config
346
398
 
347
- - `main.scss`
348
- - `_responsive.scss`
349
- - `_fonts.scss`
399
+ ```yml
400
+ assets:
401
+ autoprefixer:
402
+ browsers:
403
+ - "last 2 versions"
404
+ - "IE > 9"
405
+ ```
406
+
407
+ ### Bootstrap
408
+ #### Installation
409
+
410
+ ```ruby
411
+ gem "bootstrap-sass"
412
+ ```
350
413
 
351
- ...have this in your `main.scss`:
414
+ #### Usage
352
415
 
353
416
  ```scss
354
- @import 'responsive';
355
- @import 'fonts';
356
- // ...
417
+ @import 'bootstrap'
357
418
  ```
358
419
 
359
- Include the `main` stylesheet in your HTML: `{% css main %}`.
420
+ ### ImageMagick
421
+ #### Installation
360
422
 
361
- ### JavaScript
423
+ ```ruby
424
+ gem "mini_magick"
425
+ ```
426
+
427
+ #### Tag Args
362
428
 
363
- Use `//= require` to import and bundle component scripts into one file. More from [#241](https://github.com/jekyll/jekyll-assets/issues/241).
429
+ See the [MiniMagick docs](https://github.com/minimagick/minimagick#usage)
430
+ to get an idea what `<value>` can be.
364
431
 
365
- Given a list of files in `_assets/js`:
432
+ | Name | Accepts Value |
433
+ |---|---|
434
+ | `magick:compress` | ✔ |
435
+ | `magick:resize` | ✔ |
436
+ | `magick:format`<sup>*</sup> | ✔ |
437
+ | `magick:quality` | ✔ |
438
+ | `magick:rotate` | ✔ |
439
+ | `magick:gravity` | ✔ |
440
+ | `magick:crop` | ✔ |
441
+ | `magick:flip` | ✔ |
442
+ | `@magick:double` | ✗ |
443
+ | `@magick:half` | ✗ |
366
444
 
367
- - `main.js`
368
- - `jquery.js`
445
+ <sup>\*</sup> ***`magick:format` requires an ext or a valid MIME content type like `image/jpeg` or `.jpg`. We will `ImageMagick -format` on your behalf with that information by getting the extension.***
369
446
 
370
- ...have this in your `main.js`:
447
+ ### ImageOptim
448
+ #### Installation
371
449
 
372
- ```js
373
- //= require jquery
374
- // ...
450
+ ```ruby
451
+ gem "image_optim"
375
452
  ```
376
453
 
377
- Include the `main` script in your HTML: `{% js main %}`.
454
+ #### Config
378
455
 
379
- ## Sass Helpers
456
+ Check the [ImageOptim](https://github.com/toy/image_optim#configuration) to get idea about configuration options.
380
457
 
381
- ***Our currently supported helpers are:***
458
+ ```yml
459
+ assets:
460
+ plugins:
461
+ img:
462
+ optim:
463
+ default:
464
+ verbose: true
465
+ zero_png:
466
+ advpng:
467
+ level: 0
468
+ optipng:
469
+ level: 0
470
+ pngout:
471
+ strategy: 4
472
+ ```
382
473
 
383
- * asset_url
384
- * asset_path
385
- * image_path
386
- * font_path
387
- * image_url
388
- * font_url
474
+ #### Tag Args
389
475
 
390
- ### Image Magick Proxy arguments:
476
+ | Name | Accepts Value |
477
+ |---|---|
478
+ | `@image_optim:preset`<sup>*</sup> | ✗ |
391
479
 
392
- **NOTE: You'll need the `mini_magick` gem installed for these to work**
393
- To install `mini_magick`, add `gem "mini_magick"` to your `Gemfile`
480
+ <sup>\*</sup>***Where `preset` is the name of the preset.***
394
481
 
395
- See the [MiniMagick docs](https://github.com/minimagick/minimagick#usage)
396
- to get an idea what `<value>` can be.
482
+ ### Building Your Own Plugins
483
+ #### Global Instance Vars
484
+
485
+ | Name | Class |
486
+ |---|---|
487
+ | `@env` | `Jekyll::Assets::Env` |
488
+ | `@args` | `Liquid::Tag::Parser{}` |
489
+ | `@jekyll` | `Jekyll::Site` |
490
+ | `@asset` | `Sprockets::Asset` |
491
+
492
+ ##### HTML Instance Vars
397
493
 
398
- * `magick:resize:<value>`
399
- * `magick:format:<value>`
400
- * `magick:quality:<value>`
401
- * `magick:rotate:<value>`
402
- * `magick:gravity:<value>`
403
- * `magick:crop:<value>`
404
- * `magick:flip:<value>`
405
- * `magick:quadruple`, `magick:4x`
406
- * `magick:one-third`, `magick:1/3`
407
- * `magick:three-fourths`, `magick:3/4`
408
- * `magick:two-fourths`, `magick:2/4`
409
- * `magick:two-thirds`, `magick:2/3`
410
- * `magick:one-fourth`, `magick:1/4`
411
- * `magick:half`, `magick:1/2`
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
-
423
- ## Having trouble with our documentation?
424
-
425
- If you do not understand something in our documentation please feel
426
- free to file a ticket and it will be explained and the documentation updated,
427
- however... if you have already figured out the problem please feel free to
428
- submit a pull request with clarification in the documentation and we'll
429
- happily work with you on updating it.
494
+ | Name | Class | Type |
495
+ |---|---|---|
496
+ | `@doc` | `Nokogiri:: XML::Document` | `image/svg+xml` |
497
+ | `@doc` | `Nokogiri::HTML::Document` | `image/*` |