jekyll-assets 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.3.4 (2013-02-18)
2
+
3
+ * Fix assets regeneration (with --auto) issue. See #13.
4
+
5
+
1
6
  ### 0.3.3 (2013-02-16)
2
7
 
3
8
  * Respect cachebust setting on assets output filenames. (Thanks @softcrumbs)
data/README.md CHANGED
@@ -154,8 +154,8 @@ If you want to use YUI compressor for minification, install `yui-compressor`
154
154
  gem and put `yui` in place of `uglifier` and/or `sass` in the config file.
155
155
 
156
156
  Let's go crazy now! Assume you want your blog's `body` background color to be
157
- white all the time, but red in December. Just add `.erb` suffix extension and
158
- you can use ruby to "pre-process" asset, something like this:
157
+ white all the time, but red if you compiled your web-site in December. Just add
158
+ `.erb` suffix extension and you can use ruby in your asset like this:
159
159
 
160
160
  ```
161
161
  // file: _assets/stylesheets/app.css.sass.erb
@@ -164,6 +164,11 @@ body
164
164
  background-color: <%= (12 == Date.today.month) ? "red" : "white" %>
165
165
  ```
166
166
 
167
+ *Note* that all assets are pre-processed with Liquid. So if you just need to
168
+ output asset URL within your javascript/coffeescript or pure css, you don't
169
+ need to use ERB, just use `asset_path` Liquid tag same as you do it in your
170
+ layouts/pages. See "Liquid Assets Pre-processing" for more details.
171
+
167
172
  Want more? Sure, here you are. You can use JavaScript templating with EJS or ECO
168
173
  for example. Create a file `_assets/javascripts/hello.jst.ejs` with following
169
174
  contents:
@@ -204,6 +209,18 @@ assets:
204
209
  [amazon-s3]: http://aws.amazon.com/s3
205
210
 
206
211
 
212
+ ## Liquid Assets Pre-processing
213
+
214
+ All javascript and stylesheet assets are preprocessed with Liquid automagically.
215
+ That means that you can use all liquid tags available to you in Jekyll, but most
216
+ like;y you would want it for `asset_path` tag only:
217
+
218
+ ``` coffeescript
219
+ # file: _assets/javascripts/app.js.coffee
220
+ yepnope.load "{% asset_path app.css %}"
221
+ ```
222
+
223
+
207
224
  ## Custom Vendors
208
225
 
209
226
  Sometimes you would like to have some 3rd-party vendors. For this purposes,
@@ -249,8 +266,8 @@ require "jekyll-assets/compass"
249
266
 
250
267
  Now you can add `@import "compass"` in your SASS assets to get Compass goodies.
251
268
 
252
- *Notice* that if you want to use other than default Compass plugins/frameworks,
253
- you must require them BEFORE `jekyll-assets/compass`.
269
+ *Note* that if you want to use other than default Compass plugins/frameworks,
270
+ you must require them BEFORE `jekyll-assets/compass`.
254
271
 
255
272
 
256
273
  #### Bourbon Support
@@ -360,38 +377,65 @@ back by any other `require`.
360
377
 
361
378
  You can fine-tune configuration by editing your `_config.yml`:
362
379
 
363
- #
364
- # Plugin: jekyll-assets
365
- #
366
- assets:
367
- #
368
- # Pathname of the destination of generated (bundled) assets relative
369
- # to the destination of the root.
370
- #
371
- dirname: assets
372
- #
373
- # Base URL of assets paths.
374
- #
375
- baseurl: /assets/
376
- #
377
- # Pathnames where to find assets relative to the root of the site.
378
- #
379
- sources:
380
- - _assets/javascripts
381
- - _assets/stylesheets
382
- - _assets/images
383
- #
384
- # Sets compressors for the specific types of file: `js`, or `css`.
385
- # No compression by default.
386
- #
387
- # Possible variants:
388
- #
389
- # css => 'yui', 'sass', nil
390
- # js => 'yui', 'uglifier', nil
391
- #
392
- compress:
393
- js: ~
394
- css: ~
380
+ ``` yaml
381
+ #
382
+ # Plugin: jekyll-assets
383
+ #
384
+ assets:
385
+ #
386
+ # Pathname of the destination of generated (bundled) assets relative
387
+ # to the destination of the root.
388
+ #
389
+ dirname: assets
390
+ #
391
+ # Base URL of assets paths.
392
+ #
393
+ baseurl: /assets/
394
+ #
395
+ # Pathnames where to find assets relative to the root of the site.
396
+ #
397
+ sources:
398
+ - _assets/javascripts
399
+ - _assets/stylesheets
400
+ - _assets/images
401
+ #
402
+ # Sets compressors for the specific types of file: `js`, or `css`.
403
+ # No compression by default.
404
+ #
405
+ # Possible variants:
406
+ #
407
+ # css => 'yui', 'sass', nil
408
+ # js => 'yui', 'uglifier', nil
409
+ #
410
+ compress:
411
+ js: ~
412
+ css: ~
413
+ #
414
+ # Sets cachebusting policy for generated assets.
415
+ #
416
+ # Possible variants:
417
+ #
418
+ # none - disables cachebusting
419
+ #
420
+ # source file: _assets/javascripts/app.css
421
+ # output file: _site/assets/javascriptis/app.css
422
+ # output URL: /assets/javascripts/app.css
423
+ #
424
+ # soft - leave filenames as-is, but `?cb=<md5>` suffix for URLs generated
425
+ # with `asset_path`, `javascript` and `stylesheet`:
426
+ #
427
+ # source file: _assets/javascripts/app.css
428
+ # output file: _site/assets/javascriptis/app.css
429
+ # output URL: /assets/javascripts/app.css?cb=4f41243847da693a4f356c0486114bc6
430
+ #
431
+ # hard - (default) injects cachebusting checksum into processed filename:
432
+ #
433
+ # source file: _assets/javascripts/app.css
434
+ # output file: _site/assets/javascriptis/app-4f41243847da693a4f356c0486114bc6.css
435
+ # output URL: /assets/javascripts/app-4f41243847da693a4f356c0486114bc6.css
436
+ #
437
+ cachebust: hard
438
+ ```
395
439
 
396
440
 
397
441
  ## Contributing
@@ -57,8 +57,8 @@ module Jekyll
57
57
 
58
58
  def == other
59
59
  case other
60
- when AssetFile then same_asset? other.asset
61
- when Sprockets::Asset then same_asset? other
60
+ when AssetFile then @asset == other.asset
61
+ when Sprockets::Asset then @asset == other
62
62
  else false
63
63
  end
64
64
  end
@@ -68,14 +68,6 @@ module Jekyll
68
68
  "#<Jekyll::AssetsPlugin::AssetFile:#{asset.logical_path}>"
69
69
  end
70
70
 
71
-
72
- protected
73
-
74
-
75
- def same_asset? other
76
- other.pathname.cleanpath == asset.pathname.cleanpath
77
- end
78
-
79
71
  end
80
72
  end
81
73
  end
@@ -4,14 +4,8 @@ module Jekyll
4
4
  module IndexPatch
5
5
 
6
6
  def find_asset path, options = {}
7
- site = @environment.site
8
- asset = super
9
- bundle = options[:bundle]
10
-
11
- if asset and bundle and not site.static_files.include? asset
12
- site.static_files << AssetFile.new(site, asset)
13
- end
14
-
7
+ asset = super
8
+ @environment.site.bundle_asset! asset if asset and options[:bundle]
15
9
  asset
16
10
  end
17
11
 
@@ -11,6 +11,14 @@ module Jekyll
11
11
  module AssetsPlugin
12
12
  module SitePatch
13
13
 
14
+ def self.included base
15
+ base.class_eval do
16
+ alias_method :write_without_assets, :write
17
+ alias_method :write, :write_with_assets
18
+ end
19
+ end
20
+
21
+
14
22
  def assets_config
15
23
  @assets_config ||= Configuration.new(self.config["assets"] || {})
16
24
  end
@@ -21,6 +29,11 @@ module Jekyll
21
29
  end
22
30
 
23
31
 
32
+ def asset_files
33
+ @asset_files ||= []
34
+ end
35
+
36
+
24
37
  def asset_path *args
25
38
  asset = assets[*args]
26
39
  baseurl = "#{assets_config.baseurl}/"
@@ -34,6 +47,22 @@ module Jekyll
34
47
  end
35
48
  end
36
49
 
50
+
51
+ def bundle_asset! asset
52
+ if not asset_files.include? asset
53
+ file = AssetFile.new self, asset
54
+
55
+ asset_files << file
56
+ static_files << file
57
+ end
58
+ end
59
+
60
+
61
+ def write_with_assets
62
+ static_files.push(*asset_files).uniq!
63
+ write_without_assets
64
+ end
65
+
37
66
  end
38
67
  end
39
68
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module AssetsPlugin
3
- VERSION = "0.3.3"
3
+ VERSION = "0.3.4"
4
4
  end
5
5
  end
@@ -45,7 +45,7 @@ module Jekyll::AssetsPlugin
45
45
  site.assets["app.css"].to_s.should match(noise_img_re)
46
46
  end
47
47
 
48
- it "should be appended to the static files list" do
48
+ it "should be appended to the static_files list" do
49
49
  asset = site.assets["app.css"] # make sure main asset was compiled
50
50
  asset = site.assets["noise.png"]
51
51
 
@@ -88,6 +88,7 @@ module Jekyll::AssetsPlugin
88
88
  end
89
89
  end
90
90
 
91
+
91
92
  context "#assets_config" do
92
93
  subject { site.assets_config }
93
94
  it { should be_an_instance_of Configuration }
@@ -98,6 +99,15 @@ module Jekyll::AssetsPlugin
98
99
  end
99
100
  end
100
101
 
102
+
103
+ it "should regenerate assets upon multiple #process" do
104
+ @site.assets_config.cachebust = :none
105
+ 2.times { @site.process }
106
+
107
+ @dest.join("assets", "app.css").exist?.should be_true
108
+ end
109
+
110
+
101
111
  it "should be included into Jekyll::Site" do
102
112
  Jekyll::Site.included_modules.should include SitePatch
103
113
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-16 00:00:00.000000000 Z
12
+ date: 2013-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jekyll
@@ -219,7 +219,7 @@ rubyforge_project:
219
219
  rubygems_version: 1.8.23
220
220
  signing_key:
221
221
  specification_version: 3
222
- summary: jekyll-assets-0.3.3
222
+ summary: jekyll-assets-0.3.4
223
223
  test_files:
224
224
  - spec/fixtures/.gitignore
225
225
  - spec/fixtures/_assets/app.css.erb