jekyll-assets 3.0.3 → 3.0.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: e09e231ecd354951decf010d5f8193058bcc351e
4
- data.tar.gz: f555fc1f07628cef09203f1dbb7436349830b473
3
+ metadata.gz: 956874eaef40060f91ee70fa12d341165a14b586
4
+ data.tar.gz: 2798261d1cf3db699cfa830c77eb0f8d15acecc7
5
5
  SHA512:
6
- metadata.gz: a38a8ff2fea63684ddc9f5aea3631fad09aa13082e84c42898b7ea49a0bbaff92584ef78479eee76959de8735a9cdf9e511a5d46ba446d403ea594f9592cd0e8
7
- data.tar.gz: b0321b53da8d9de1bab59c7224bf66d9768c2c7db12a24e84d457991b6312a905d61152457b640461570c5d38ce44a3e9232a9e03cb3028c5537158e5188b875
6
+ metadata.gz: 900c2f932b8abd7a5278ade5b7da07c38df283d45add5e8f17e4ba79b83200c861567ea6d2bd246ea2e0d96fc4ddecf7956efda2747ac7216a1b6cb965c1432a
7
+ data.tar.gz: 76db8348452356b0b275089da30d2ffa93cd5e2b24634a9ebcf5e42bb90867ef65247241fc3732dfb7efa6ed0f72564d70745ba97d5c29c09006264dc95a009f
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![Code Climate](https://img.shields.io/codeclimate/maintainability/envygeeks/jekyll-assets.svg?style=for-the-badge)](https://codeclimate.com/github/envygeeks/jekyll-assets/maintainability)
2
2
  [![Code Climate](https://img.shields.io/codeclimate/coverage/github/envygeeks/jekyll-assets.svg?style=for-the-badge)](https://codeclimate.com/github/envygeeks/jekyll-assets/test_coverage)
3
3
  [![Travis CI](https://img.shields.io/travis/envygeeks/jekyll-assets/master.svg?style=for-the-badge)](https://travis-ci.org/envygeeks/jekyll-assets)
4
- [![Donate](https://img.shields.io/badge/-DONATE-yellow.svg?style=for-the-badge)](https://envygeeks.io#donate)
4
+ [![Donate](https://img.shields.io/badge/-DONATE-yellow.svg?style=for-the-badge)](https://www.paypal.com/donate/?token=2YE-4wLE2dSgtPaQqTlQgcD2BvKv_tkHUD7GJYs4OskLI0l6XFEAKpNc5rIG6-bAeMFdom)
5
5
  ![Gem Version](https://img.shields.io/gem/v/jekyll-assets.svg?style=for-the-badge)
6
6
  ![Gem DL](https://img.shields.io/gem/dt/jekyll-assets.svg?style=for-the-badge)
7
7
 
@@ -359,6 +359,7 @@ We have basic support for WebComponents when using Sprockets `~> 4.0.0.beta`, th
359
359
  |---|---|---|---|
360
360
  | `:env` | `:before_init` | ✔ | ✗ |
361
361
  | `:env` | `:after_init` | ✔ | ✗ |
362
+ | `:env` | `:after_write` | ✔ | ✗ |
362
363
  | `:config` | `:before_merge` | ✗ | `Config{}` |
363
364
  | `asset` | `:before_compile` | ✗ | `Asset`, `Manifest` |
364
365
 
data/Rakefile CHANGED
@@ -2,7 +2,7 @@
2
2
  # Copyright: 2012 - 2017 - MIT License
3
3
  # Encoding: utf-8
4
4
 
5
- task(:spec) { sh "script/test" }
6
- task(:test) { sh "script/test" }
7
- task(:rubocop) { sh "script/lint" }
8
- task(:lint) { sh "script/lint" }
5
+ task(:spec) { exec "script/test" }
6
+ task(:test) { exec "script/test" }
7
+ task(:rubocop) { exec "script/lint" }
8
+ task(:lint) { exec "script/lint" }
@@ -18,6 +18,7 @@ def require_all(*globs)
18
18
  end
19
19
 
20
20
  require_relative "assets/env"
21
- Jekyll::Hooks.register :site, :post_read do |o|
22
- Jekyll::Assets::Env.new(o)
21
+ Jekyll::Hooks.register(:site, :post_read) { |o| Jekyll::Assets::Env.new(o) }
22
+ Jekyll::Hooks.register :site, :post_write do |o|
23
+ o&.sprockets&.write_all
23
24
  end
@@ -28,6 +28,7 @@ module Jekyll
28
28
 
29
29
  # --
30
30
  attr_reader :manifest
31
+ attr_accessor :assets_to_write
31
32
  attr_reader :asset_config
32
33
  attr_reader :jekyll
33
34
 
@@ -42,6 +43,7 @@ module Jekyll
42
43
 
43
44
  super()
44
45
  @jekyll = jekyll
46
+ @assets_to_write = []
45
47
  @manifest = Manifest.new(self, in_dest_dir)
46
48
  @jekyll.sprockets = self
47
49
  @logger = Logger
@@ -116,6 +118,18 @@ module Jekyll
116
118
  end
117
119
  end
118
120
 
121
+ # --
122
+ def write_all
123
+ manifest.compile(*assets_to_write); @asset_to_write = []
124
+ Logger.debug "Calling hooks for env, after_write" do
125
+ Hook.trigger :env, :after_write do |h|
126
+ instance_eval(&h)
127
+ end
128
+ end
129
+
130
+ true
131
+ end
132
+
119
133
  # --
120
134
  private
121
135
  def ignore_caches!
@@ -147,8 +161,8 @@ module Jekyll
147
161
  def precompile!
148
162
  assets = asset_config[:precompile]
149
163
  assets.map do |v|
150
- v !~ %r!\*! ? manifest.compile(v) : glob_paths(v).each do |sv|
151
- manifest.compile(sv)
164
+ v !~ %r!\*! ? @assets_to_write |= [sv] : glob_paths(v).each do |sv|
165
+ @assets_to_write |= [sv]
152
166
  end
153
167
  end
154
168
 
@@ -15,7 +15,6 @@ module Jekyll
15
15
  def initialize(asset:, args:, ctx:)
16
16
  @args = args
17
17
  @env = ctx.registers[:site].sprockets
18
- @jekyll = ctx.registers[:site]
19
18
  @jekyll = @env.jekyll
20
19
  @asset = asset
21
20
  @ctx = ctx
@@ -30,6 +30,12 @@ module Jekyll
30
30
  2 => [],
31
31
  3 => [],
32
32
  },
33
+
34
+ after_write: {
35
+ 1 => [],
36
+ 2 => [],
37
+ 3 => [],
38
+ },
33
39
  },
34
40
 
35
41
  config: {
@@ -9,16 +9,9 @@ module Jekyll
9
9
  module Assets
10
10
  class HTML
11
11
  class Audio < HTML
12
- content_types "audio/aiff"
13
- content_types "audio/basic"
14
- content_types "audio/mpeg"
15
- content_types "audio/midi"
16
- content_types "audio/wave"
17
- content_types "audio/mp4"
18
- content_types "audio/ogg"
19
- content_types "audio/flac"
20
- content_types "audio/aac"
12
+ content_types %r!^audio/[a-zA-Z0-9\-_]+$!
21
13
 
14
+ # --
22
15
  def run
23
16
  Nokogiri::HTML::Builder.with(doc) do |d|
24
17
  d.audio("No support for audio.", args.to_h({
@@ -11,6 +11,7 @@ module Jekyll
11
11
  class CSS < HTML
12
12
  content_types "text/css"
13
13
 
14
+ # --
14
15
  def run
15
16
  Nokogiri::HTML::Builder.with(@doc) do |d|
16
17
  attr = @args.to_h(html: true, skip: HTML.skips)
@@ -8,15 +8,7 @@ module Jekyll
8
8
  module Assets
9
9
  class Default
10
10
  class Audio < Default
11
- content_types "audio/aiff"
12
- content_types "audio/basic"
13
- content_types "audio/mpeg"
14
- content_types "audio/midi"
15
- content_types "audio/wave"
16
- content_types "audio/mp4"
17
- content_types "audio/ogg"
18
- content_types "audio/flac"
19
- content_types "audio/aac"
11
+ content_types %r!^audio/[a-zA-Z0-9\-_]+$!
20
12
 
21
13
  # --
22
14
  def set_src
@@ -10,6 +10,7 @@ module Jekyll
10
10
  class Component < Default
11
11
  content_types "text/html"
12
12
 
13
+ # --
13
14
  def set_href
14
15
  dpath = @asset.digest_path
15
16
  return @args[:href] = @asset.url if @asset.is_a?(Url)
@@ -8,16 +8,18 @@ module Jekyll
8
8
  module Assets
9
9
  class Default
10
10
  class CSS < Default
11
- static rel: "stylesheet"
11
+ static rel: "stylesheet", type: "text/css"
12
12
  content_types "text/css"
13
- static type: "text/css"
14
13
 
14
+ # --
15
15
  def set_href
16
+ return if @args[:inline]
16
17
  return @args[:href] = @asset.url if @asset.is_a?(Url)
17
18
  @args[:href] = @env.prefix_url(@asset
18
19
  .digest_path)
19
20
  end
20
21
 
22
+ # --
21
23
  def set_integrity
22
24
  return unless integrity?
23
25
  @args[:integrity] = @asset.integrity
@@ -8,15 +8,9 @@ module Jekyll
8
8
  module Assets
9
9
  class Default
10
10
  class Img < Default
11
- content_types "image/bmp"
12
- content_types "image/webp"
13
- content_types "image/svg+xml"
14
- content_types "image/jpeg"
15
- content_types "image/tiff"
16
- content_types "image/gif"
17
- content_types "image/png"
18
- content_types "image/jpg"
11
+ content_types %r!^image/(?\!x-icon$)[a-zA-Z0-9\-_]+$!
19
12
 
13
+ # --
20
14
  def set_src
21
15
  dpath = @asset.digest_path
22
16
  return @args[:src] = @asset.url if @asset.is_a?(Url)
@@ -24,6 +18,7 @@ module Jekyll
24
18
  @args[:src] = @asset.data_uri
25
19
  end
26
20
 
21
+ # --
27
22
  def set_integrity
28
23
  return unless integrity?
29
24
  @args[:integrity] = @asset.integrity
@@ -8,16 +8,18 @@ module Jekyll
8
8
  module Assets
9
9
  class Default
10
10
  class JS < Default
11
- content_types "text/javascript"
12
11
  content_types "application/javascript"
13
12
  static type: "text/javascript"
14
13
 
14
+ # --
15
15
  def set_src
16
+ return if @args[:inline]
16
17
  return @args[:src] = @asset.url if @asset.is_a?(Url)
17
18
  @args[:src] = @env.prefix_url(@asset
18
19
  .digest_path)
19
20
  end
20
21
 
22
+ # --
21
23
  def set_integrity
22
24
  return unless integrity?
23
25
  @args[:integrity] = @asset.integrity
@@ -8,9 +8,7 @@ module Jekyll
8
8
  module Assets
9
9
  class Default
10
10
  class Video < Default
11
- content_types "video/avi"
12
- content_types "video/webm"
13
- content_types "video/mp4"
11
+ content_types %r!^video/.*$!
14
12
 
15
13
  # --
16
14
  def set_src
@@ -9,14 +9,7 @@ module Jekyll
9
9
  module Assets
10
10
  class HTML
11
11
  class IMG < HTML
12
- content_types "image/bmp"
13
- content_types "image/webp"
14
- content_types "image/svg+xml"
15
- content_types "image/jpeg"
16
- content_types "image/tiff"
17
- content_types "image/gif"
18
- content_types "image/png"
19
- content_types "image/jpg"
12
+ content_types %r!^image/(?\!x-icon$)[a-zA-Z0-9\-_]+$!
20
13
 
21
14
  # --
22
15
  def run
@@ -9,9 +9,9 @@ module Jekyll
9
9
  module Assets
10
10
  class HTML
11
11
  class JS < HTML
12
- content_types "application/javascript",
13
- "text/javascript"
12
+ content_types "application/javascript"
14
13
 
14
+ # --
15
15
  def run
16
16
  if @asset.is_a?(Url) && @args[:inline]
17
17
  raise Tag::MixedArg, "@external", "@inline"
@@ -9,14 +9,7 @@ module Jekyll
9
9
  module Assets
10
10
  class HTML
11
11
  class Pic < HTML
12
- content_types "image/webp"
13
- content_types "image/jpeg"
14
- content_types "image/tiff"
15
- content_types "image/svg+xml"
16
- content_types "image/bmp"
17
- content_types "image/gif"
18
- content_types "image/png"
19
- content_types "image/jpg"
12
+ content_types %r!^image/(?\!x-icon$)[a-zA-Z0-9\-_]+$!
20
13
 
21
14
  # --
22
15
  # @todo this should be reworked so we don't need to use
@@ -9,10 +9,9 @@ module Jekyll
9
9
  module Assets
10
10
  class HTML
11
11
  class Video < HTML
12
- content_types "video/avi"
13
- content_types "video/webm"
14
- content_types "video/mp4"
12
+ content_types %r!^video/.*$!
15
13
 
14
+ # --
16
15
  def run
17
16
  Nokogiri::HTML::Builder.with(doc) do |d|
18
17
  d.video("No support for video.", args.to_h({
@@ -160,7 +160,7 @@ module Jekyll
160
160
  original = env.find_asset!(args[:argv1])
161
161
  Default.set(args, ctx: ctx, asset: original)
162
162
  out = Proxy.proxy(original, args: args, ctx: ctx)
163
- env.manifest.compile(out.logical_path)
163
+ env.assets_to_write |= [out.logical_path]
164
164
 
165
165
  Default.set(args, {
166
166
  ctx: ctx, asset: out
@@ -4,6 +4,6 @@
4
4
 
5
5
  module Jekyll
6
6
  module Assets
7
- VERSION = "3.0.3"
7
+ VERSION = "3.0.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: 3.0.3
4
+ version: 3.0.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: 2017-11-29 00:00:00.000000000 Z
13
+ date: 2017-12-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: execjs