jekyll-assets 1.0.0 → 2.0.0.pre.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -10
  3. data/LICENSE +16 -18
  4. data/README.md +94 -554
  5. data/Rakefile +2 -8
  6. data/lib/jekyll/assets.rb +18 -12
  7. data/lib/jekyll/assets/cached.rb +12 -0
  8. data/lib/jekyll/assets/configuration.rb +43 -87
  9. data/lib/jekyll/assets/context.rb +23 -0
  10. data/lib/jekyll/assets/env.rb +181 -0
  11. data/lib/jekyll/assets/extras/es6.rb +5 -0
  12. data/lib/jekyll/assets/extras/font-awesome.rb +1 -0
  13. data/lib/jekyll/assets/extras/helpers.rb +6 -0
  14. data/lib/jekyll/assets/extras/prefix.rb +5 -0
  15. data/lib/jekyll/assets/filters.rb +9 -11
  16. data/lib/jekyll/assets/helpers.rb +37 -0
  17. data/lib/jekyll/assets/hook.rb +45 -0
  18. data/lib/jekyll/assets/hooks/post_read.rb +3 -0
  19. data/lib/jekyll/assets/hooks/post_write.rb +3 -0
  20. data/lib/jekyll/assets/logger.rb +25 -0
  21. data/lib/jekyll/assets/patches/jekyll/cleaner.rb +11 -0
  22. data/lib/jekyll/assets/patches/jekyll/site.rb +5 -0
  23. data/lib/jekyll/assets/patches/sprockets/asset.rb +13 -0
  24. data/lib/jekyll/assets/tag.rb +136 -9
  25. data/lib/jekyll/assets/tag/parser.rb +129 -0
  26. data/lib/jekyll/assets/tag/proxied_asset.rb +84 -0
  27. data/lib/jekyll/assets/tag/proxies.rb +86 -0
  28. data/lib/jekyll/assets/tag/proxies/magick.rb +101 -0
  29. data/lib/jekyll/assets/version.rb +1 -1
  30. metadata +59 -149
  31. data/.gitignore +0 -27
  32. data/.rspec +0 -1
  33. data/.rubocop.yml +0 -43
  34. data/.rubocop_todo.yml +0 -10
  35. data/.travis.yml +0 -16
  36. data/.yardopts +0 -1
  37. data/Appraisals +0 -7
  38. data/Guardfile +0 -7
  39. data/HISTORY.md +0 -297
  40. data/gemfiles/jekyll_2.gemfile +0 -17
  41. data/gemfiles/jekyll_3.gemfile +0 -17
  42. data/jekyll-assets.gemspec +0 -34
  43. data/lib/jekyll-assets.rb +0 -2
  44. data/lib/jekyll/assets/asset_path.rb +0 -39
  45. data/lib/jekyll/assets/environment.rb +0 -62
  46. data/lib/jekyll/assets/patches.rb +0 -1
  47. data/lib/jekyll/assets/patches/asset_patch.rb +0 -102
  48. data/lib/jekyll/assets/patches/bundled_asset_patch.rb +0 -16
  49. data/lib/jekyll/assets/patches/context_patch.rb +0 -31
  50. data/lib/jekyll/assets/patches/index_patch.rb +0 -25
  51. data/lib/jekyll/assets/patches/processed_asset_patch.rb +0 -59
  52. data/lib/jekyll/assets/patches/site_patch.rb +0 -62
  53. data/lib/jekyll/assets/renderer.rb +0 -122
  54. data/spec/fixtures/.gitignore +0 -2
  55. data/spec/fixtures/.jekyll-metadata +0 -0
  56. data/spec/fixtures/_assets/alert.js +0 -1
  57. data/spec/fixtures/_assets/app.css.erb +0 -5
  58. data/spec/fixtures/_assets/app.js +0 -1
  59. data/spec/fixtures/_assets/app.min.css +0 -0
  60. data/spec/fixtures/_assets/app.min.js +0 -0
  61. data/spec/fixtures/_assets/fonts/vapor.eot +0 -0
  62. data/spec/fixtures/_assets/fonts/vapor.svg +0 -0
  63. data/spec/fixtures/_assets/fonts/vapor.ttf +0 -0
  64. data/spec/fixtures/_assets/fonts/vapor.woff +0 -0
  65. data/spec/fixtures/_assets/lib/relative.css.scss +0 -12
  66. data/spec/fixtures/_assets/noise.png +0 -0
  67. data/spec/fixtures/_assets/noize.png +0 -0
  68. data/spec/fixtures/_assets/should_be_blank.css.erb +0 -1
  69. data/spec/fixtures/_assets/should_fail.css.erb +0 -1
  70. data/spec/fixtures/_assets/vapor.css.scss +0 -13
  71. data/spec/fixtures/_assets/vapor.js +0 -2
  72. data/spec/fixtures/_assets/vendor/with_bootstrap.css.sass +0 -1
  73. data/spec/fixtures/_assets/vendor/with_bourbon.css.sass +0 -4
  74. data/spec/fixtures/_assets/vendor/with_compass.css.sass +0 -4
  75. data/spec/fixtures/_assets/vendor/with_neat.css.sass +0 -5
  76. data/spec/fixtures/_assets/wowscript.js +0 -0
  77. data/spec/fixtures/_assets/wowstyle.css +0 -0
  78. data/spec/fixtures/_config.yml +0 -2
  79. data/spec/fixtures/_layouts/default.html +0 -9
  80. data/spec/fixtures/_posts/2012-10-19-hello-world.md +0 -6
  81. data/spec/fixtures/_posts/2015-02-02-duplicates.md +0 -8
  82. data/spec/fixtures/index.html +0 -0
  83. data/spec/lib/jekyll/assets/configuration_spec.rb +0 -172
  84. data/spec/lib/jekyll/assets/environment_spec.rb +0 -18
  85. data/spec/lib/jekyll/assets/filters_spec.rb +0 -112
  86. data/spec/lib/jekyll/assets/patches/site_patch_spec.rb +0 -176
  87. data/spec/lib/jekyll/assets/renderer_spec.rb +0 -286
  88. data/spec/lib/jekyll/assets/tag_spec.rb +0 -139
  89. data/spec/spec_helper.rb +0 -58
  90. data/spec/support/fixtures_helpers.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 058024b6cab174fb532c02c4d3e08b7402c439c6
4
- data.tar.gz: a6af4b2d17c61481cbcb005a7e68b7f6714d7ffb
3
+ metadata.gz: b9e0ba8666a5456c4cad0827a4d99fd850a68089
4
+ data.tar.gz: b60f463be255a335521d03e7202087833198b83e
5
5
  SHA512:
6
- metadata.gz: 5868a43430640668b1656280ed95a683d0ab4289993b862502505171a2c77498b9f0989a3a6dd549c5b454fbed9b7d8c24b7226103a1af75f257325989890c9e
7
- data.tar.gz: 1fbddde69c2034155c6cc7ed7efb7fc69e841825b7ad8eac1758bba63fcf64d55871b88cdeae712a774b897b548ed008131138173abfa229205a64e86265d955
6
+ metadata.gz: 3d2930e11fdb9669d239ed370ab22a5d04430961434cd29af23448e8643d839804e92dcb51c251a11478b3014468b2c3b964eef69f6b5c10ca572302614e55bc
7
+ data.tar.gz: b52a71fe9a67787b55987d8879af857a2eb99e6f733d468af6450931fcdb7a7780f2259cec160f72955b9036eb777ae4635816e95b51d309967dcffe65053ba0
data/Gemfile CHANGED
@@ -1,16 +1,16 @@
1
1
  source "https://rubygems.org"
2
+ gemspec
2
3
 
4
+ gem "rake"
3
5
  group :development do
4
- gem "rubocop", "~>0.29.1"
5
- gem "rake"
6
- gem "rspec"
7
- gem "appraisal"
8
-
6
+ gem "pry"
7
+ gem "therubyracer", :platforms => :mri
9
8
  gem "guard-rspec"
10
-
11
- gem "coveralls", :require => false
12
- gem "simplecov", :require => false
9
+ gem "guard"
13
10
  end
14
11
 
15
- # Specify your gem's dependencies in jekyll-assets.gemspec
16
- gemspec
12
+ gem "sprockets-es6", "~> 0.6"
13
+ gem "autoprefixer-rails", "~> 6.0"
14
+ gem "font-awesome-sass", "~> 4.4.0"
15
+ gem "mini_magick", "~> 4.2"
16
+ gem "uglifier"
data/LICENSE CHANGED
@@ -1,22 +1,20 @@
1
1
  Copyright (c) 2012-2013 Aleksey V Zapparov (http://ixti.net/)
2
+ Copyright (c) 2015 Jordon Bedwell (https://envygeeks.io)
2
3
 
3
- MIT License
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
4
10
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
12
13
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
data/README.md CHANGED
@@ -1,598 +1,138 @@
1
- # Jekyll::Assets
1
+ [![Build Status](https://travis-ci.org/jekyll-assets/jekyll-assets.png?branch=master)](https://travis-ci.org/jekyll-assets/jekyll-assets) [![Coverage Status](https://coveralls.io/repos/jekyll-assets/jekyll-assets/badge.png?branch=master)](https://coveralls.io/r/jekyll-assets/jekyll-assets) [![Code Climate](https://codeclimate.com/github/jekyll-assets/jekyll-assets/badges/gpa.svg)](https://codeclimate.com/github/jekyll-assets/jekyll-assets) [![Dependency Status](https://gemnasium.com/jekyll-assets/jekyll-assets.svg)](https://gemnasium.com/jekyll-assets/jekyll-assets)
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/jekyll-assets.svg)](http://badge.fury.io/rb/jekyll-assets)
4
- [![Build Status](https://travis-ci.org/jekyll-assets/jekyll-assets.svg?branch=master)](http://travis-ci.org/jekyll-assets/jekyll-assets)
5
- [![Dependency Status](https://gemnasium.com/jekyll-assets/jekyll-assets.svg)](https://gemnasium.com/jekyll-assets/jekyll-assets)
6
- [![Code Climate](https://codeclimate.com/github/jekyll-assets/jekyll-assets.svg)](https://codeclimate.com/github/jekyll-assets/jekyll-assets)
7
- [![Coverage Status](https://coveralls.io/repos/jekyll-assets/jekyll-assets/badge.svg?branch=master)](https://coveralls.io/r/jekyll-assets/jekyll-assets?branch=master)
8
3
 
9
- Jekyll plugin, that adds Rails-alike assets pipeline, that means that:
4
+ ## Are you looking for the docs for Jekyll Assets < 2.0.0?
10
5
 
11
- - It allows you to write javascript/css assets in other languages such as
12
- CoffeeScript, Sass, Less and ERB.
13
- - It allows you to specify dependencies between your assets and automatically
14
- concatenates them.
15
- - It allows you to minify/compress your JavaScript and CSS assets using
16
- compressor you like: YUI, SASS, Uglifier or no compression at all.
17
- - It supports JavaScript templates for client-side rendering of strings or
18
- markup. JavaScript templates have the special format extension `.jst` and are
19
- compiled to JavaScript functions.
20
- - Adds MD5 fingerprint suffix for _cache busting_. That means your `app.css`
21
- will become `app-908e25f4bf641868d8683022a5b62f54.css`. See `cachebust`
22
- configuration option for other variants.
23
- - Produce gzipped versions of assets. See `gzip` configuration option for
24
- details.
6
+ See: https://github.com/jekyll-assets/jekyll-assets/tree/legacy#jekyllassets
25
7
 
26
- [compass]: http://compass-style.org/
27
- [bourbon]: http://bourbon.io/
28
- [neat]: http://neat.bourbon.io/
29
- [autoprefixer]: https://github.com/postcss/autoprefixer
30
- [rails_assets]: https://rails-assets.org/
8
+ # Jekyll 3 Assets
31
9
 
32
- Jekyll-Assets uses fabulous [Sprockets][sprockets] under the hood, so you may
33
- refer to Rails guide about [Asset Pipeline][rails-guide] for detailed
34
- information about amazing features it gives you.
10
+ Jekyll 3 assets is an asset pipeline using Sprockets 3 to build especially
11
+ for Jekyll 3. It utilizes new features of both Sprockets and Jekyll to achieve
12
+ a clean and extensible assets platform for Jekyll.
35
13
 
36
- *Note:* You must have an [ExecJS][extjs] supported runtime in order to use
37
- CoffeeScript.
38
-
39
-
40
- [rails-guide]: http://guides.rubyonrails.org/asset_pipeline.html
41
- [sprockets]: https://github.com/sstephenson/sprockets#readme
42
- [extjs]: https://github.com/sstephenson/execjs#readme
43
-
44
- For a quick start check out [jekyll-assets introduction][jekyll-assets-intro]
45
- that shows how to use it step by step. Also you might want to take a look on
46
- [my blog sources][ixti-blog-src] as a real-world example as well.
47
-
48
- [jekyll-assets-intro]: http://ixti.net/software/2012/12/30/unleash-mr-hyde-introduction-of-jekyll-assets.html
49
- [ixti-blog-src]: https://github.com/ixti/ixti.github.com
50
-
51
-
52
- ## Installation
53
-
54
- Add this line to your application's Gemfile:
55
-
56
- gem 'jekyll-assets'
57
-
58
- And then execute:
59
-
60
- $ bundle
61
-
62
- Or install it yourself as:
63
-
64
- $ gem install jekyll-assets
65
-
66
-
67
- ## How to Use Jekyll-Assets
68
-
69
- First of all make sure to require it. Common practice is to add following line
70
- into `_plugins/ext.rb` file:
71
-
72
- ``` ruby
73
- require "jekyll-assets"
74
- ```
75
-
76
- Once plugin installed, you'll have following Liquid tags available:
77
-
78
- - `{% javascript app %}`: Generates `<script>` tag for `app.js`
79
- - `{% stylesheet app %}`: Generates `<link>` tag for `app.css`
80
- - `{% image logo.png %}`: Generates `<img>` tag for `logo.png`
81
- - `{% asset_path logo.png %}`: Returns _resulting_ URL for `logo.png`
82
- - `{% asset app.css %}`: Returns _compiled_ body of `app.css`
83
-
84
- You can pass extra attributes to `javascript`, `stylesheet` and `image` tags:
85
-
86
- ``` html
87
- {% image logo.png alt="Logo" %}
88
- {% javascript app async %}
89
- {% stylesheet app actually="anything" you might='want' %}
90
-
91
- <!-- renders to something like this (linebreaks in tags for readability here) -->
92
-
93
- <img src="/assets/logo-68b329da9893e34099c7d8ad5cb9c940.png" alt="Logo">
94
- <script src="/assets/app-6b95b1b3231c52113ca34ae9d1b5dabf.js" async></script>
95
- <link rel="stylesheet" href="/assets/app-349212fba570137adfec745e37b6d7fb.css"
96
- actually="anything" you might='want'>
97
-
98
- <!-- NOTICE !!! if your asset file contains spaces, surround it's name with quotes -->
99
-
100
- {% asset_path "my logo.png" %}
101
- {% asset_path 'my logo.png' %}
102
- ```
103
-
104
- Also you'll have complimentary Liquid filters as well:
105
-
106
- - `{{ 'app' | javascript }}`: Generates `<script>` tag for `app.js`
107
- - `{{ 'app' | stylesheet }}`: Generates `<link>` tag for `app.css`
108
- - `{{ 'logo.png' | image }}`: Generates `<img>` tag for `logo.png`
109
- - `{{ 'logo.png' | asset_path }}`: Returns _resulting_ URL for `logo.png`
110
- - `{{ 'app.css' | asset }}`: Returns _compiled_ body of `app.css`
111
-
112
- Filters are used mostly to render tag (or asset source) using variable that
113
- holds value of asset logical path rather than specifiyng it directly. Here's
114
- an example that speaks for itself:
115
-
116
- ```
117
- {% if page.custom_css %}{{ page.custom_css | stylesheet }}{% endif %}
118
- ```
119
-
120
- All compiled assets will be stored under `assets/` dir of generated site.
121
-
122
- Pipeline assets should be under your sources directory of Jekyll site. When a
123
- file is referenced with liquid tag or with helper from another asset, Sprockets
124
- searches the three default asset locations for it: `_assets/images`,
125
- `_assets/javascripts` and `_assets/stylesheets`.
126
-
127
- For example these files:
128
-
129
- ```
130
- _assets/stylesheets/app.css
131
- _assets/javascripts/app.js
132
- _assets/javascripts/vendor/jquery.js
133
- ```
134
-
135
- would be referenced like this:
136
-
137
- ``` html
138
- {% stylesheet app %}
139
- {% javascript app %}
140
- {% javascript vendor/jquery %}
141
- ```
142
-
143
- You might want to require `vendor/jquery.js` into your `app.js`. To do so, just
144
- put following line in the beginning of your `app.js` to get it concatenated:
145
-
146
- ``` javascript
147
- //= require vendor/jquery
148
-
149
- $(function () {
150
- alert('I love BIG BOOKS!');
151
- });
152
- ```
153
-
154
- If you want to use CoffeScript, just add `.coffee` suffix to the file you want
155
- and you're good to go. For example, here's how your `app.js.coffe` might look
156
- like:
157
-
158
- ``` coffeescript
159
- #= require vendor/jquery
160
-
161
- $ ->
162
- alert 'I love BIG BOOKS! And small ones too!'
163
- ```
164
-
165
- Notice, that `vendor/jquery` is not required to be coffee script. You can easily
166
- mix CoffeeScript and vanilla JavaScript, CSS and SCSS and SASS and LESS. The
167
- difference is only in comments styles used with _directives_.
168
-
169
- See detailed information about these _directives_ below.
170
-
171
- You might also want your stylesheets and javascripts to be minified. In this
172
- case just install the `uglifier` gem and any other gems you will be using, e.g.
173
- `sass`, `coffee-script`. Then add following lines into your `config.yml`:
174
-
175
- ``` yaml
176
- assets:
177
- js_compressor: uglifier
178
- css_compressor: sass
179
- ```
180
-
181
- If you want to use YUI compressor for minification, install `yui-compressor`
182
- gem and put `yui` in place of `uglifier` and/or `sass` in the config file.
183
- You can also define and use your own compressor, see "Custom Compressors".
184
-
185
- Let's go crazy now! Assume you want your blog's `body` background color to be
186
- white all the time, but red if you compiled your web-site in December. Just add
187
- `.erb` suffix extension and you can use ruby in your asset like this:
188
-
189
- ```
190
- // file: _assets/stylesheets/app.css.sass.erb
191
-
192
- body
193
- background-color: <%= (12 == Date.today.month) ? "red" : "white" %>
194
- ```
195
-
196
- Want more? Sure, here you are. You can use JavaScript templating with EJS or ECO
197
- for example. Create a file `_assets/javascripts/hello.jst.ejs` with following
198
- contents:
199
-
200
- ``` html
201
- <p>Hello, <span><%= name %></span>!</p>
202
- <p><%= info %></p>
203
- ```
204
-
205
- Then use it in your `app.js` file like this:
206
-
207
- ``` coffeescript
208
- #= require vendor/jquery
209
- #= require hello
210
-
211
- $ ->
212
- $("body").html JST["hello"]
213
- name: "ixti"
214
- info: "I love BIG BOOKS! And small ones too!"
215
- ```
216
-
217
- Finally, you might want to store your assets on [Amazon S3][amazon-s3] or any
218
- CDN service you like. As said previously, all compiled/processed assets got
219
- special MD5 checksum appended to their original filenames. So, for example,
220
- your `app.js.coffee` will become something like:
221
-
222
- app-4f41243847da693a4f356c0486114bc6.js
223
-
224
- By default, generated URLs will have `/assets/` prefixes, but you will want to
225
- change this if you are going to host assets somewhere else. This can be easily
226
- changed via configuration:
14
+ ## Configuration
227
15
 
228
- ``` yaml
16
+ ```yaml
229
17
  assets:
230
- baseurl: http://my.super-cool-cdn.com/assets
231
- ```
232
-
233
- [amazon-s3]: http://aws.amazon.com/s3
234
-
235
-
236
- ### Images size (dimension) auto-guessing
237
-
238
- The image helper accepts options param (in square brackets) with `autosize`
239
- switch. If given, then image dimension will be calculated and
240
- apropriate attributes set:
241
-
242
- ``` html
243
- {% image logo.png alt="Logo" [autosize] %}
244
-
245
- <!-- assuming logo.png is 50x50, the above will render -->
246
-
247
- <img src="/assets/logo-68b329da9893e34099c7d8ad5cb9c940.png" alt="Logo"
248
- width="50" height="50">
18
+ cache: false | directory | default: .asset-cache
19
+ cdn: https://cdn.example.com
20
+ skip_prefix_with_cdn: false
21
+ prefix: "/assets"
22
+ assets:
23
+ - "*.png"
24
+ - "bundle.css"
25
+ digest: true
26
+ sources:
27
+ - "_assets/folder"
249
28
  ```
250
29
 
251
- You can also globally enable `autosize` in config (see `autosize` config option
252
- below). In this case, `image` tag will alway render dimension attributes unless
253
- you specify `no-autosize` switch. Assume you have `autosize` option enabled in
254
- config, then:
30
+ ## Asset Digesting
255
31
 
256
- ``` html
257
- {% image logo.png [no-autosize] %}
258
- {% image logo.png %}
32
+ * Disable digesting by default in development.
33
+ * Digest by default in production
259
34
 
260
- <!-- assuming logo.png is 50x50, the above will render -->
35
+ ***You can force digesting with `digest: true` in your `_config.yml`***
261
36
 
262
- <img src="/assets/logo-68b329da9893e34099c7d8ad5cb9c940.png">
263
- <img src="/assets/logo-68b329da9893e34099c7d8ad5cb9c940.png"
264
- width="50" height="50">
265
- ```
37
+ ## ERB Support
266
38
 
267
- ### Images resizing
39
+ ERB Support is removed in favor of trying to get this included on Github Pages
40
+ eventually (if I can.) Having ERB presents a security risk to Github because it
41
+ would allow you to use Ruby in ways they don't want you to.
268
42
 
269
- The image helper accepts an option param with [resize:dimension] switch.
270
- If given the image will be resized to the appropriate dimensions.
43
+ ## Tags
271
44
 
272
- ``` html
273
- {% image huge-logo.png [resize:50x50] %}
45
+ * stylesheet, css, style
46
+ * javascript, js
47
+ * image, img
48
+ * asset_path
274
49
 
275
- <!-- which will render something like: -->
276
- <img src="/assets/logo-50x50-68b329da9893e34099c7d8ad5cb9c940.png">
277
- ```
50
+ ### Tag Example:
278
51
 
279
- You can also mix auto resizing with dimension guessing
280
-
281
- ``` html
282
- {% image huge-logo.png [resize:50x50, autosize] %}
283
-
284
- <!-- Will be rendered like: -->
285
- <img src="/assets/logo-50x50-68b329da9893e34099c7d8ad5cb9c940.png" width="50" height="50">
52
+ ```liquid
53
+ {% img src magick:2x alt:'This is my alt' %}
54
+ {% img src magick:2x alt:'This is my alt' sprockets:accept:image/gif %}
286
55
  ```
287
56
 
288
- This feature requires imagemagick to be installed, and the dimension is any
289
- format that imagemagick understands: [Resize documentation][resize-doc].
290
-
291
- More examples:
292
- ``` html
293
- {% image image.png [resize:400x400] %} <!-- Fit whole image in these dimensions -->
294
- {% image image.png [resize:!300x150] %} <!-- Ignore aspect ratio -->
295
- {% image image.png [resize:200%] %} <!-- Resize by percentage -->
296
- {% image image.png [resize:500@] %} <!-- Resize to specific pixel count -->
297
- {% image image.png [resize:200x100^] %} <!-- Resize to fill area -->
298
- {% image image.png [resize:<200x10] %} <!-- Only enlarge small image -->
299
- {% image image.png [resize:>200x10] %} <!-- Only shrink large image -->
300
- ```
57
+ ### What do the colons mean? Proxies/Tags
301
58
 
302
- [resize-doc]: http://www.imagemagick.org/Usage/resize/#resize
59
+ * `argument` is a boolean HTML argument.
60
+ * `key:value` is an HTML key="value" if no proxy exists.
61
+ * `proxy:key:value` will set a proxy key with the given value.
62
+ * `proxy:key` is a boolean argument if the proxy and key exists.
63
+ * `unknown:key:value` will raise `DoubleColonError`, escape it.
64
+ * `proxy:unknown:value` will raise a `UnknownProxyError`.
303
65
 
304
- ### Custom Compressors
66
+ Lets say we have `sprockets` proxies and sprockets allows you to proxy accept,
67
+ if you send `{% img src sprockets:accept:image/gif }` then Sprockets find_asset
68
+ will get `{ :accept => "image/gif" }` but if you try to proxy "unknown" on
69
+ sprockets we will raise a Proxy error. For more information then look at
70
+ `parser_spec.rb` in the spec folder because it literally lays out the ground
71
+ rules for our tags as a specification.
305
72
 
306
- Sprockets comes with good set of preconfigured compressors, but imagine you are
307
- not satisfied with default settings. For example you want to strip all comments
308
- but copyrights info. In this case you can define and use your own compressor.
73
+ ### Current Proxies:
309
74
 
310
- To do so, first let's define new compressor in `_plugins/ext.rb`:
75
+ * `sprockets:accept:<value>` - Tell Sprockets your preferred content type.
76
+ * `sprockets:write_to:<value>` - The filename you wish us to write your file to.
77
+ * `magick:resize:<value>` - Takes standard ImageMagick resize values.
78
+ * `magick:format:<value>` - Takes standard ImageMagick format values.
79
+ * `magick:rotate:<value>` - Takes standard ImageMagick resize values.
80
+ * `magick:crop:<value>` - Takes standard ImageMagick crop values.
81
+ * `magick:flip:<value>` - Takes standard ImageMagick flip values.
82
+ * `magick:2x` - Tells us to write a double width/height image.
83
+ * `magick:4x` - Tells us to write a quadruple width/height image.
84
+ * `magick:half` - Tells us to shrink the image to half.
311
85
 
312
- ``` ruby
313
- require "jekyll-assets"
314
- require "sprockets"
315
-
316
- Sprockets.register_compressor 'application/javascript',
317
- :my_uglifier, Uglifier.new(:comments => :copyright)
318
- ```
86
+ ## Filters
319
87
 
320
- Once it's done, just tell assets to use `my_uglifier` as js compressor:
88
+ There is a full suite of filters, actually, any tag and any proxy can be a
89
+ filter by way of filter arguments, take the following example:
321
90
 
322
- ``` yaml
323
- assets:
324
- js_compressor: my_uglifier
91
+ ```liquid
92
+ {{ src | img : "magick:2x" }}
325
93
  ```
326
94
 
95
+ ## Hooks
327
96
 
328
- ### Compilation Cache
97
+ * `:env => [
98
+ :pre_init, :post_init
99
+ ]`
329
100
 
330
- To improve build time, you can enabled compiled assets cache:
101
+ You can register and trigger hooks like so:
331
102
 
332
- ``` yaml
333
- assets:
334
- cache: true
103
+ ```ruby
104
+ Jekyll::Assets::Hook.trigger :env, :post_init
105
+ Jekyll::Assets::Hook.register :env, :post_init do
106
+ # Your Work
107
+ end
335
108
  ```
336
109
 
337
- This will keep cache of compiled assets in `.jekyll-assets-cache` under source
338
- of your jekyl site. If you want to use different location specify it instead of
339
- `true`, in this case it should be an absolute path or path relative to source
340
- path of your jekyl site.
341
-
342
-
343
- ## Custom Vendors
344
-
345
- Sometimes you would like to have some 3rd-party vendors. For this purposes,
346
- normally all you have to do is to override default assets sources in config:
347
-
348
- ``` yaml
349
- assets:
350
- sources:
351
- - _assets/images
352
- - _assets/javascripts
353
- - _assets/stylesheets
354
- - _vendors/bootstrap/stylesheets
355
- - _vendors/bootstrap/javascripts
356
- ```
357
-
358
- But sometimes this is not enough. For example, with compass. As jekyll-assets
359
- uses Sprockets internally, you can simply append "global" paths into it. Just
360
- add following line into your `_plugins/ext.rb` file:
361
-
362
- ``` ruby
363
- require "sprockets"
364
-
365
- Sprockets.append_path "/my/vendor"
366
- ```
367
-
368
- That's it, now jekyll-assets will try to look for assets inside `/my/vendor`
369
- path first.
370
-
371
-
372
- ## The Directive Processor
373
-
374
- *Note:* This section extracted from [Sprockets][sprockets] README.
375
-
376
- Sprockets runs the *directive processor* on each CSS and JavaScript
377
- source file. The directive processor scans for comment lines beginning
378
- with `=` in comment blocks at the top of the file.
379
-
380
- //= require jquery
381
- //= require jquery-ui
382
- //= require backbone
383
- //= require_tree .
384
-
385
- The first word immediately following `=` specifies the directive
386
- name. Any words following the directive name are treated as
387
- arguments. Arguments may be placed in single or double quotes if they
388
- contain spaces, similar to commands in the Unix shell.
389
-
390
- **Note**: Non-directive comment lines will be preserved in the final
391
- asset, but directive comments are stripped after
392
- processing. Sprockets will not look for directives in comment blocks
393
- that occur after the first line of code.
394
-
110
+ ## Optional Processing Engines
395
111
 
396
- ### Supported Comment Types
112
+ * ES6 Transpiler (through Babel) - add "sprockets-es6" to your Gemfile.
113
+ * CSS Auto Prefixer - add "autoprefixer-rails" to your Gemfile.
397
114
 
398
- The directive processor understands comment blocks in three formats:
115
+ ***Please note that some of these (if not all) have trouble with Rhino --
116
+ `therubyrhino` so you would probably be best to just use Node.js or io.js at
117
+ that point rather than trying to fight it.***
399
118
 
400
- /* Multi-line comment blocks (CSS, SCSS, JavaScript)
401
- *= require foo
402
- */
119
+ ### Engine Settings
403
120
 
404
- // Single-line comment blocks (SCSS, JavaScript)
405
- //= require foo
121
+ Some engines take settings, if they do you can add them like so:
406
122
 
407
- # Single-line comment blocks (CoffeeScript)
408
- #= require foo
409
-
410
-
411
- ### Sprockets Directives
412
-
413
- You can use the following directives to declare dependencies in asset
414
- source files.
415
-
416
- For directives that take a *path* argument, you may specify either a
417
- logical path or a relative path. Relative paths begin with `./` and
418
- reference files relative to the location of the current file.
419
-
420
- #### The `require` Directive
421
-
422
- `require` *path* inserts the contents of the asset source file
423
- specified by *path*. If the file is required multiple times, it will
424
- appear in the bundle only once.
425
-
426
- #### The `include` Directive
427
-
428
- `include` *path* works like `require`, but inserts the contents of the
429
- specified source file even if it has already been included or
430
- required.
431
-
432
- #### The `require_directory` Directive
433
-
434
- `require_directory` *path* requires all source files of the same
435
- format in the directory specified by *path*. Files are required in
436
- alphabetical order.
437
-
438
- #### The `require_tree` Directive
439
-
440
- `require_tree` *path* works like `require_directory`, but operates
441
- recursively to require all files in all subdirectories of the
442
- directory specified by *path*.
443
-
444
- #### The `require_self` Directive
445
-
446
- `require_self` tells Sprockets to insert the body of the current
447
- source file before any subsequent `require` or `include` directives.
448
-
449
- #### The `depend_on` Directive
450
-
451
- `depend_on` *path* declares a dependency on the given *path* without
452
- including it in the bundle. This is useful when you need to expire an
453
- asset's cache in response to a change in another file.
454
-
455
- #### The `stub` Directive
456
-
457
- `stub` *path* allows dependency to be excluded from the asset bundle.
458
- The *path* must be a valid asset and may or may not already be part
459
- of the bundle. Once stubbed, it is blacklisted and can't be brought
460
- back by any other `require`.
461
-
462
-
463
- ## Configuration
464
-
465
- You can fine-tune configuration by editing your `_config.yml`:
466
-
467
- ``` yaml
468
- #
469
- # Plugin: jekyll-assets
470
- #
123
+ ```YAML
471
124
  assets:
472
- #
473
- # Pathname of the destination of generated (bundled) assets relative
474
- # to the destination of the root.
475
- #
476
- dirname: assets
477
- #
478
- # Base URL of assets paths.
479
- #
480
- baseurl: /assets/
481
- #
482
- # Pathnames where to find assets relative to the root of the site.
483
- #
484
- sources:
485
- - _assets/javascripts
486
- - _assets/stylesheets
487
- - _assets/images
488
- #
489
- # Sets JS compressor. No compression by default.
490
- # Possible variants: 'yui', 'uglifier', nil
491
- #
492
- js_compressor: ~
493
- #
494
- # Sets CSS compressor. No compression by default.
495
- # Possible variants: 'yui', 'sass', nil
496
- #
497
- css_compressor: ~
498
- #
499
- # Globally enables adding image width and height attributes to image tags.
500
- # Does nothing if either width or height attribute already set.
501
- # Disabled by default.
502
- #
503
- autosize: false
504
- #
505
- # Sets cachebusting policy for generated assets.
506
- #
507
- # Possible variants:
508
- #
509
- # none - disables cachebusting
510
- #
511
- # source file: _assets/javascripts/app.css
512
- # output file: _site/assets/javascriptis/app.css
513
- # output URL: /assets/javascripts/app.css
514
- #
515
- # soft - leave filenames as-is, but `?cb=<md5>` suffix for URLs generated
516
- # with `asset_path`, `javascript` and `stylesheet`:
517
- #
518
- # source file: _assets/javascripts/app.css
519
- # output file: _site/assets/javascriptis/app.css
520
- # output URL: /assets/javascripts/app.css?cb=4f41243847da693a4f356c0486114bc6
521
- #
522
- # hard - (default) injects cachebusting checksum into processed filename:
523
- #
524
- # source file: _assets/javascripts/app.css
525
- # output file: _site/assets/javascriptis/app-4f41243847da693a4f356c0486114bc6.css
526
- # output URL: /assets/javascripts/app-4f41243847da693a4f356c0486114bc6.css
527
- #
528
- cachebust: hard
529
- #
530
- # Whenever or not cache compiled assets (disabled by default).
531
- # See `Compilation Cache` section of README for details.
532
- #
533
- cache: false
534
- #
535
- # Specifies list of MIME types that needs to have gzipped versions.
536
- # You can set it to `false` to disable gzipping. Only javascripts and
537
- # stylesheets are gzipped by default.
538
- #
539
- gzip: [ text/css, application/javascript ]
540
- #
541
- # Does not concatenates files requested by `javascript` and `stylesheet`
542
- # helpers. Instead outputs multiple files in order they are required.
543
- # Default: false
544
- #
545
- debug: false
546
- #
547
- # Configuration version. Used to force cache invalidation.
548
- # Default: 1
549
- #
550
- version: 1
125
+ engines:
126
+ engine_name:
127
+ option: value
551
128
  ```
552
129
 
130
+ Only whitelisted options are allowed by default, so that we can guard against
131
+ using paths we don't want to be used. If you wish to have an option
132
+ whitelisted please file a ticket or submit a pull request.
553
133
 
554
- ## "Th-th-th-that's all folks!"
555
-
556
- Feel free to follow me on [twitter][twitter], chat via [jabber][jabber] or
557
- write an [e-mail][e-mail]. :D
558
-
559
- [twitter]: https://twitter.com/zapparov
560
- [jabber]: xmpp://zapparov@jabber.ru
561
- [e-mail]: mailto://ixti@member.fsf.org
562
-
563
-
564
- ## Contributing
565
-
566
- * Fork [jekyll-assets][] on GitHub
567
- * Make your changes
568
- * Ensure all tests pass (`bundle exec rake`)
569
- * Send a pull request
570
- * If we like them we'll merge them
571
- * If we've accepted a patch, feel free to ask for commit access!
572
-
573
- [jekyll-assets]: https://github.com/ixti/jekyll-assets
574
-
575
-
576
- ## License
577
-
578
- Copyright (C) 2012-2015 Aleksey V Zapparov
579
-
580
- The MIT License
581
-
582
- Permission is hereby granted, free of charge, to any person obtaining a copy of
583
- this software and associated documentation files (the “Software”), to deal in
584
- the Software without restriction, including without limitation the rights to
585
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
586
- of the Software, and to permit persons to whom the Software is furnished to do
587
- so, subject to the following conditions:
588
-
589
- The above copyright notice and this permission notice shall be included in all
590
- copies or substantial portions of the Software.
134
+ ## Plugins where did they go?
591
135
 
592
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
593
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
594
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
595
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
596
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
597
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
598
- SOFTWARE.
136
+ They're dead, in the way that they were, use Hooks, they require less
137
+ patching and give more flexibility to us because we can trigger them every
138
+ time we have a new environment not just occasionally.