jekyll-assets 2.2.3 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1beb6828d5534b96a31042623acb912c13b3e38
4
- data.tar.gz: 688fabb88be88681c40954736b663d216f7ad93d
3
+ metadata.gz: d17d63ec62ef0f6e61326c18e9a01c02f249c1b4
4
+ data.tar.gz: 9c0151bbd1166ab902681c0c62786a45a76df94f
5
5
  SHA512:
6
- metadata.gz: c085055cc33ff864f394b22d0f98530f8d3d71a871baf01f7dd00d8cc59151c9907e9ce1f65b46d828fb93086fd70d80df1dd80b2115cd6961aebf05e8565f29
7
- data.tar.gz: 5b0f8f7cc6bb1010c23be8a2ffb15f744283c2ada9b56ed9010dd5fa7c9407ded47742117e2d8017fd6d415f8e9bd28d6e6937643563cd4ed2c388a7f9947d81
6
+ metadata.gz: edb70acdd15978e34169e2f16b6936ff7c54339b86520dfac287e23663d16359a5823f93caafae5a23bb7586c6bfa223b50333f20725044a39ce03fd04674ff5
7
+ data.tar.gz: 4a3d836bbff6292ecf631e96eb6f591b7b0b4b921b8283c569d039e971980a451f563180a59ebdfcf9fd67451a7d52512282d5c91e72108bfe3d997d40ac9840
data/README.md CHANGED
@@ -69,6 +69,7 @@ assets:
69
69
 
70
70
  features:
71
71
  liquid: true | false | default: false
72
+ integrity: true | false | default: false
72
73
  automatic_img_size: true | false | n(fixnum): 2,4,6,8 | default: true
73
74
  automatic_img_alt : true | false | default: true
74
75
  ```
@@ -236,6 +237,14 @@ filter by way of filter arguments, take the following example:
236
237
  {{ src | img : "magick:2x magick:quality:92" }}
237
238
  ```
238
239
 
240
+ ### Jekyll Assets Multi
241
+
242
+ 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:
243
+
244
+ ```liquid
245
+ {{ 'css:bundle.css "js:bundle.js async:true"' | jekyll_asset_multi }}
246
+ ```
247
+
239
248
  ## Hooks
240
249
 
241
250
  * `:env => [:init]`
@@ -28,6 +28,7 @@ module Jekyll
28
28
  },
29
29
 
30
30
  "features" => {
31
+ "integrity" => false,
31
32
  "automatic_img_alt" => true,
32
33
  "automatic_img_size" => true,
33
34
  "liquid" => false
@@ -11,13 +11,32 @@ module Jekyll
11
11
  ACCEPTABLE_FILTERS = [:css, :img, :asset_path, :stylesheet,
12
12
  :javascript, :style, :img, :js]
13
13
 
14
- # --------------------------------------------------------------------
15
-
14
+ # --
15
+ # The base filters.
16
+ # --
16
17
  ACCEPTABLE_FILTERS.each do |val|
17
18
  define_method val do |path, args = ""|
18
- Tag.send(:new, val, "#{path} #{args}", "").render(@context)
19
+ Tag.send(:new, val, "#{path} #{args}", "").render(
20
+ @context
21
+ )
19
22
  end
20
23
  end
24
+
25
+ # --
26
+ # Include multiple assets.
27
+ # @return [Strings]
28
+ # --
29
+ def jekyll_asset_multi(assets)
30
+ return Shellwords.shellsplit(assets).map { |s| s.split(":", 2) }.map do |tag, arguments|
31
+ Tag.send(:new, tag, arguments, "").render(
32
+ @context
33
+ )
34
+ end \
35
+
36
+ .join(
37
+ "\n"
38
+ )
39
+ end
21
40
  end
22
41
 
23
42
  #
@@ -52,9 +52,9 @@ module Jekyll
52
52
  # --------------------------------------------------------------------
53
53
 
54
54
  Tags = {
55
- "css" => %(<link type="text/css" rel="stylesheet" href="%s" integrity="%s"%s>),
56
- "js" => %(<script type="text/javascript" src="%s" integrity="%s"%s></script>),
57
- "img" => %(<img src="%s" integrity="%s"%s>)
55
+ "css" => %(<link type="text/css" rel="stylesheet" href="%s"%s>),
56
+ "js" => %(<script type="text/javascript" src="%s"%s></script>),
57
+ "img" => %(<img src="%s"%s>)
58
58
  }.freeze
59
59
 
60
60
  # --------------------------------------------------------------------
@@ -127,7 +127,7 @@ module Jekyll
127
127
  return path if @tag == "asset_path"
128
128
  return asset.to_s if @tag == "asset" || @tag == "asset_source"
129
129
  data = args.key?(:data) && args[:data].key?(:uri) ? asset.data_uri : path
130
- format(Tags[@tag], data, asset.integrity, args.to_html)
130
+ format(Tags[@tag], data, args.to_html)
131
131
  end
132
132
 
133
133
  # --------------------------------------------------------------------
@@ -1,15 +1,19 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2012 - 2016 - MIT License
3
+ # Encoding: utf-8
4
+
1
5
  module Jekyll
2
6
  module Assets
3
7
  module Liquid
4
8
  class Tag
5
9
  module Defaults
6
10
  require_relative "defaults/image"
11
+ require_relative "defaults/sha"
7
12
 
8
- # ------------------------------------------------------------------
13
+ # --
9
14
  # TODO: In 3.0 env needs to be enforced, right now it's not
10
15
  # because it's maintain 2.0 API.
11
- # ------------------------------------------------------------------
12
-
16
+ # --
13
17
  module_function
14
18
  def set_defaults_for!(tag, args, asset, env = nil)
15
19
  constants.select { |const| const_get(const).for?(tag) }.each do |const|
@@ -0,0 +1,52 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2012 - 2016 - MIT License
3
+ # Encoding: utf-8
4
+
5
+ module Jekyll
6
+ module Assets
7
+ module Liquid
8
+ class Tag
9
+ module Defaults
10
+ class Sha
11
+
12
+ # --
13
+ # What we plan to accept for.
14
+ # --
15
+ def self.for?(tag)
16
+ return tag == "css" || tag == "js"
17
+ end
18
+
19
+ # --
20
+ # Initialize a new instance.
21
+ # --
22
+ def initialize(args, asset, env)
23
+ @args = args
24
+ @asset = asset
25
+ @env = env
26
+ end
27
+
28
+ # --
29
+ # Run the defaults.
30
+ # --
31
+ def set!
32
+ set_integrity
33
+ end
34
+
35
+ # --
36
+ # Set the integrity attribute.
37
+ # @return [nil]
38
+ # --
39
+ def set_integrity
40
+ @args.args[:html] ||= {}
41
+ if @env.asset_config["features"]["integrity"]
42
+ @args.args[:html]["integrity"] = @asset.integrity
43
+ @args.args[:html]["crossorigin"] = "anonymous" \
44
+ unless @args.args[:html]["crossorigin"]
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -4,6 +4,6 @@
4
4
 
5
5
  module Jekyll
6
6
  module Assets
7
- VERSION="2.2.3"
7
+ VERSION="2.2.4"
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
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: 2016-04-30 00:00:00.000000000 Z
13
+ date: 2016-05-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sprockets
@@ -179,6 +179,7 @@ files:
179
179
  - lib/jekyll/assets/liquid/tag.rb
180
180
  - lib/jekyll/assets/liquid/tag/defaults.rb
181
181
  - lib/jekyll/assets/liquid/tag/defaults/image.rb
182
+ - lib/jekyll/assets/liquid/tag/defaults/sha.rb
182
183
  - lib/jekyll/assets/liquid/tag/parser.rb
183
184
  - lib/jekyll/assets/liquid/tag/proxied_asset.rb
184
185
  - lib/jekyll/assets/liquid/tag/proxies.rb