jekyll-assets 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +27 -16
- data/README.md +71 -2
- data/Rakefile +4 -11
- data/lib/jekyll/assets/config.rb +4 -1
- data/lib/jekyll/assets/env.rb +9 -1
- data/lib/jekyll/assets/html.rb +1 -2
- data/lib/jekyll/assets/patches/asset.rb +34 -0
- data/lib/jekyll/assets/patches/{cached_env.rb → cached.rb} +8 -26
- data/lib/jekyll/assets/patches/find_asset.rb +13 -0
- data/lib/jekyll/assets/patches/functions.rb +1 -1
- data/lib/jekyll/assets/patches/{obsolete_files.rb → obsolete.rb} +0 -0
- data/lib/jekyll/assets/patches/{sprockets.rb → site.rb} +0 -0
- data/lib/jekyll/assets/plugins/html/component.rb +25 -0
- data/lib/jekyll/assets/plugins/html/defaults/component.rb +53 -0
- data/lib/jekyll/assets/plugins/searcher.rb +5 -4
- data/lib/jekyll/assets/proxy.rb +15 -9
- data/lib/jekyll/assets/tag.rb +8 -7
- data/lib/jekyll/assets/utils.rb +22 -39
- data/lib/jekyll/assets/version.rb +1 -1
- metadata +9 -7
- data/lib/jekyll/assets/patches/sprockets_data_uri.rb +0 -12
- data/lib/jekyll/assets/writer.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e09e231ecd354951decf010d5f8193058bcc351e
|
4
|
+
data.tar.gz: f555fc1f07628cef09203f1dbb7436349830b473
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a38a8ff2fea63684ddc9f5aea3631fad09aa13082e84c42898b7ea49a0bbaff92584ef78479eee76959de8735a9cdf9e511a5d46ba446d403ea594f9592cd0e8
|
7
|
+
data.tar.gz: b0321b53da8d9de1bab59c7224bf66d9768c2c7db12a24e84d457991b6312a905d61152457b640461570c5d38ce44a3e9232a9e03cb3028c5537158e5188b875
|
data/Gemfile
CHANGED
@@ -5,26 +5,37 @@
|
|
5
5
|
source "https://rubygems.org"
|
6
6
|
gemspec
|
7
7
|
|
8
|
+
sv = "~> 4.0.beta"
|
9
|
+
gem "sprockets", ENV["SPROCKETS_VERSION"] || sv, require: false
|
10
|
+
gem "jekyll", ENV["JEKYLL_VERSION"], require: false if ENV["JEKYLL_VERSION"]
|
8
11
|
gem "rake", require: false
|
12
|
+
|
13
|
+
# --
|
9
14
|
group :development do
|
15
|
+
gem "travis", require: false
|
10
16
|
gem "mini_racer", require: false if RUBY_PLATFORM != "java"
|
11
17
|
gem "therubyrhino", require: false if RUBY_PLATFORM == "java"
|
12
|
-
gem "pry", require: false
|
13
|
-
end
|
18
|
+
gem "pry", require: false
|
14
19
|
|
15
|
-
group :test do
|
16
|
-
|
17
|
-
|
18
|
-
|
20
|
+
group :test do
|
21
|
+
gem "simplecov", require: false
|
22
|
+
gem "luna-rspec-formatters", require: false
|
23
|
+
gem "rubocop", require: false
|
24
|
+
end
|
19
25
|
end
|
20
26
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
gem "
|
28
|
-
gem "
|
29
|
-
gem "
|
30
|
-
gem "
|
27
|
+
# --
|
28
|
+
# Anything within this group is considered optional.
|
29
|
+
# You don't need it to run Jekyll-Assets, but they may
|
30
|
+
# provide more features for you to use.
|
31
|
+
# --
|
32
|
+
group :optionals do
|
33
|
+
gem "uglifier", require: false
|
34
|
+
gem "autoprefixer-rails", require: false
|
35
|
+
gem "font-awesome-sass", "~> 4.4", require: false
|
36
|
+
gem "image_optim_pack", "~> 0.5", require: false
|
37
|
+
gem "image_optim", "~> 0.25", require: false
|
38
|
+
gem "mini_magick", "~> 4.2", require: false
|
39
|
+
gem "babel-transpiler", require: false
|
40
|
+
gem "bootstrap", require: false
|
41
|
+
end
|
data/README.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
[](https://codeclimate.com/github/envygeeks/jekyll-assets/maintainability)
|
1
|
+
[](https://codeclimate.com/github/envygeeks/jekyll-assets/maintainability)
|
2
|
+
[](https://codeclimate.com/github/envygeeks/jekyll-assets/test_coverage)
|
3
|
+
[](https://travis-ci.org/envygeeks/jekyll-assets)
|
4
|
+
[](https://envygeeks.io#donate)
|
5
|
+

|
6
|
+

|
2
7
|
|
3
8
|
# Jekyll Assets
|
4
9
|
|
@@ -31,7 +36,6 @@ gem "sprockets", "~> 4.0.beta", {
|
|
31
36
|
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.
|
32
37
|
|
33
38
|
```yaml
|
34
|
-
digest: false
|
35
39
|
source_maps: true # false on JEKYLL_ENV=production
|
36
40
|
destination: "/assets"
|
37
41
|
compression: true
|
@@ -44,11 +48,29 @@ caching:
|
|
44
48
|
path: ".jekyll-cache/assets"
|
45
49
|
type: file # Possible values: memory, file
|
46
50
|
enabled: true
|
51
|
+
# --
|
52
|
+
# Assets you wish to always have compiled.
|
53
|
+
# This can also be combined with raw_precompile which
|
54
|
+
# copies assets without running through the pipeline
|
55
|
+
# making them ultra fast.
|
56
|
+
# --
|
47
57
|
precompile: []
|
58
|
+
raw_precompile: [
|
59
|
+
#
|
60
|
+
]
|
61
|
+
# --
|
62
|
+
# baseurl: whether or not to append site.baseurl
|
63
|
+
# destination: the folder you store them in on the CDN.
|
64
|
+
# url: the CDN url (fqdn, or w/ identifier).
|
65
|
+
# --
|
48
66
|
cdn:
|
49
67
|
baseurl: false
|
50
68
|
destination: false
|
51
69
|
url: null
|
70
|
+
# --
|
71
|
+
# These are all default. No need to add them
|
72
|
+
# Only use this if you have more.
|
73
|
+
# --
|
52
74
|
sources:
|
53
75
|
- assets/css
|
54
76
|
- assets/fonts
|
@@ -284,6 +306,53 @@ Using Liquid Drop `assets`, you can check whether an asset is present.
|
|
284
306
|
{{ src | asset:"@magick:2x magick:quality:92" }}
|
285
307
|
```
|
286
308
|
|
309
|
+
## Polymer WebComponents
|
310
|
+
|
311
|
+
We have basic support for WebComponents when using Sprockets `~> 4.0.0.beta`, this will allow you to place your HTML in the `_assets/components` folder, `{% asset myComponent.html %}`, and get an import, you can place your regular JS files inside of the normal structure.
|
312
|
+
|
313
|
+
### Example
|
314
|
+
|
315
|
+
***test.html***
|
316
|
+
|
317
|
+
```html
|
318
|
+
<!DOCTYPE html>
|
319
|
+
<html>
|
320
|
+
<head>
|
321
|
+
{% asset webcomponents.js %}
|
322
|
+
{% asset test.html %}
|
323
|
+
</head>
|
324
|
+
<body>
|
325
|
+
<contact-card starred>
|
326
|
+
{% asset profile.jpg %}
|
327
|
+
<span>Your Name</span>
|
328
|
+
</contact-card>
|
329
|
+
</body>
|
330
|
+
</body>
|
331
|
+
```
|
332
|
+
|
333
|
+
***_assets/components/test.html***
|
334
|
+
|
335
|
+
```html
|
336
|
+
<dom-module id="contact-card">
|
337
|
+
<template>
|
338
|
+
<style>/* ... */</style>
|
339
|
+
<slot></slot>
|
340
|
+
<iron-icon icon="star" hidden$="{{!starred}}"></iron-icon>
|
341
|
+
</template>
|
342
|
+
<script>
|
343
|
+
class ContactCard extends Polymer.Element {
|
344
|
+
static get is() { return "contact-card"; }
|
345
|
+
static get properties() {
|
346
|
+
return {
|
347
|
+
starred: { type: Boolean, value: false }
|
348
|
+
}
|
349
|
+
}
|
350
|
+
}
|
351
|
+
customElements.define(ContactCard.is, ContactCard);
|
352
|
+
</script>
|
353
|
+
</dom-module>
|
354
|
+
```
|
355
|
+
|
287
356
|
## Hooks
|
288
357
|
|
289
358
|
| Point | Name | Instance | Args |
|
data/Rakefile
CHANGED
@@ -2,14 +2,7 @@
|
|
2
2
|
# Copyright: 2012 - 2017 - MIT License
|
3
3
|
# Encoding: utf-8
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
$stderr = STDERR
|
10
|
-
|
11
|
-
# --
|
12
|
-
RSpec::Core::RakeTask.new(:spec)
|
13
|
-
RuboCop::RakeTask.new(:rubocop) { |t| t.options = %w(--format=e --parallel) }
|
14
|
-
Rake::Task[:spec].enhance { Rake::Task[:rubocop].invoke }
|
15
|
-
task default: %i(spec rubocop)
|
5
|
+
task(:spec) { sh "script/test" }
|
6
|
+
task(:test) { sh "script/test" }
|
7
|
+
task(:rubocop) { sh "script/lint" }
|
8
|
+
task(:lint) { sh "script/lint" }
|
data/lib/jekyll/assets/config.rb
CHANGED
@@ -12,7 +12,7 @@ module Jekyll
|
|
12
12
|
module Assets
|
13
13
|
class Config < HashWithIndifferentAccess
|
14
14
|
DEVELOPMENT = {
|
15
|
-
digest:
|
15
|
+
digest: true,
|
16
16
|
precompile: [],
|
17
17
|
source_maps: true,
|
18
18
|
destination: "/assets",
|
@@ -46,6 +46,7 @@ module Jekyll
|
|
46
46
|
assets/images
|
47
47
|
assets/videos
|
48
48
|
assets/audios
|
49
|
+
assets/components
|
49
50
|
assets/javascript
|
50
51
|
assets/video
|
51
52
|
assets/audio
|
@@ -58,6 +59,7 @@ module Jekyll
|
|
58
59
|
_assets/images
|
59
60
|
_assets/videos
|
60
61
|
_assets/audios
|
62
|
+
_assets/components
|
61
63
|
_assets/javascript
|
62
64
|
_assets/video
|
63
65
|
_assets/audio
|
@@ -70,6 +72,7 @@ module Jekyll
|
|
70
72
|
images
|
71
73
|
videos
|
72
74
|
audios
|
75
|
+
components
|
73
76
|
javascript
|
74
77
|
audio
|
75
78
|
video
|
data/lib/jekyll/assets/env.rb
CHANGED
@@ -49,6 +49,7 @@ module Jekyll
|
|
49
49
|
|
50
50
|
setup_sources!
|
51
51
|
enable_compression!
|
52
|
+
ignore_caches!
|
52
53
|
setup_drops!
|
53
54
|
precompile!
|
54
55
|
copy_raw!
|
@@ -115,6 +116,14 @@ module Jekyll
|
|
115
116
|
end
|
116
117
|
end
|
117
118
|
|
119
|
+
# --
|
120
|
+
private
|
121
|
+
def ignore_caches!
|
122
|
+
jekyll.config["exclude"] ||= []
|
123
|
+
jekyll.config["exclude"].push(asset_config[:caching][:path])
|
124
|
+
jekyll.config["exclude"].uniq!
|
125
|
+
end
|
126
|
+
|
118
127
|
# --
|
119
128
|
private
|
120
129
|
def enable_compression!
|
@@ -173,7 +182,6 @@ module Jekyll
|
|
173
182
|
require_all "plugins/html/defaults/*"
|
174
183
|
require_all "plugins/html/*"
|
175
184
|
require_relative "context"
|
176
|
-
require_relative "writer"
|
177
185
|
|
178
186
|
require_relative "map" unless old_sprockets?
|
179
187
|
Hook.register :env, :after_init, priority: 3 do
|
data/lib/jekyll/assets/html.rb
CHANGED
@@ -80,8 +80,7 @@ module Jekyll
|
|
80
80
|
def self.make_doc(builders, asset:)
|
81
81
|
wants = builders.map(&:wants_xml?).uniq
|
82
82
|
raise "incompatible wants xml/html for builders" if wants.size > 1
|
83
|
-
!wants[0] ?
|
84
|
-
Nokogiri::XML.parse(asset.to_s)
|
83
|
+
!wants[0] ? Utils.html_fragment("") : Utils.xml(asset.to_s)
|
85
84
|
end
|
86
85
|
end
|
87
86
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2012 - 2017 - MIT License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
module Assets
|
7
|
+
module Patches
|
8
|
+
module Sprockets
|
9
|
+
module Asset
|
10
|
+
attr_accessor :environment
|
11
|
+
|
12
|
+
# --
|
13
|
+
def digest_path
|
14
|
+
environment.asset_config[:digest] ? \
|
15
|
+
super : logical_path
|
16
|
+
end
|
17
|
+
|
18
|
+
# --
|
19
|
+
def data_uri
|
20
|
+
"data:#{content_type};base64,#{Rack::Utils.escape(
|
21
|
+
Base64.encode64(to_s))}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# --
|
30
|
+
module Sprockets
|
31
|
+
class Asset
|
32
|
+
prepend Jekyll::Assets::Patches::Sprockets::Asset
|
33
|
+
end
|
34
|
+
end
|
@@ -36,34 +36,16 @@ module Jekyll
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# --
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
# --
|
43
|
-
unless Sprockets::CachedEnvironment.method_defined?(:find_asset!)
|
44
|
-
|
45
|
-
# --
|
46
|
-
# Copyright 2017 Sprockets.
|
47
|
-
# @url https://github.com/rails/sprockets
|
48
|
-
# @license MIT
|
49
|
-
# --
|
50
|
-
def find_asset!(*args)
|
51
|
-
uri, = resolve!(*args)
|
52
|
-
if uri
|
53
|
-
load(uri)
|
54
|
-
end
|
39
|
+
def find_asset(*)
|
40
|
+
super.tap do |v|
|
41
|
+
v.environment = self
|
55
42
|
end
|
43
|
+
end
|
56
44
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
# So we need to add it there.
|
62
|
-
# --
|
63
|
-
class Sprockets::Base
|
64
|
-
def find_asset!(*args)
|
65
|
-
cached.send(__method__, *args)
|
66
|
-
end
|
45
|
+
# --
|
46
|
+
def find_asset!(*args)
|
47
|
+
load(resolve!(*args).first).tap do |v|
|
48
|
+
v.environment = self
|
67
49
|
end
|
68
50
|
end
|
69
51
|
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2012 - 2017 - MIT License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
5
|
+
require "jekyll/assets"
|
6
|
+
require "nokogiri"
|
7
|
+
|
8
|
+
module Jekyll
|
9
|
+
module Assets
|
10
|
+
class HTML
|
11
|
+
class Component < HTML
|
12
|
+
content_types "text/html"
|
13
|
+
|
14
|
+
# --
|
15
|
+
def run
|
16
|
+
Nokogiri::HTML::Builder.with(doc) do |d|
|
17
|
+
d.link args.to_h({
|
18
|
+
html: true, skip: HTML.skips
|
19
|
+
})
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2012 - 2017 - MIT License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
5
|
+
require "jekyll/assets"
|
6
|
+
|
7
|
+
module Jekyll
|
8
|
+
module Assets
|
9
|
+
class Default
|
10
|
+
class Component < Default
|
11
|
+
content_types "text/html"
|
12
|
+
|
13
|
+
def set_href
|
14
|
+
dpath = @asset.digest_path
|
15
|
+
return @args[:href] = @asset.url if @asset.is_a?(Url)
|
16
|
+
return @args[:href] = @env.prefix_url(dpath) unless @args[:inline]
|
17
|
+
@args[:href] = @asset.data_uri
|
18
|
+
end
|
19
|
+
|
20
|
+
# --
|
21
|
+
def set_rel
|
22
|
+
@args[:rel] = "import"
|
23
|
+
end
|
24
|
+
|
25
|
+
# --
|
26
|
+
def set_integrity
|
27
|
+
return unless integrity?
|
28
|
+
@args[:integrity] = @asset.integrity
|
29
|
+
unless @args.key?(:crossorigin)
|
30
|
+
@args[:crossorigin] = "anonymous"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# --
|
35
|
+
def integrity?
|
36
|
+
config[:integrity] && !@asset.is_a?(Url) &&
|
37
|
+
!@args.key?(:integrity)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# --
|
45
|
+
Jekyll::Assets::Hook.register :config, :before_merge do |c|
|
46
|
+
c.deep_merge!({
|
47
|
+
defaults: {
|
48
|
+
component: {
|
49
|
+
integrity: Jekyll.production?,
|
50
|
+
},
|
51
|
+
},
|
52
|
+
})
|
53
|
+
end
|
@@ -57,9 +57,8 @@ module Jekyll
|
|
57
57
|
# @see https://github.com/sparklemotion/nokogiri/issues/553
|
58
58
|
good, buggy = Encoding::UTF_8, Encoding::ASCII_8BIT
|
59
59
|
out = out.encode good if out.encoding == buggy
|
60
|
-
|
61
|
-
|
62
|
-
:fragment), out)
|
60
|
+
Utils.send((@doc.output.strip =~ %r!<\!doctype\s+!i ? \
|
61
|
+
:html : :html_fragment), out)
|
63
62
|
end
|
64
63
|
end
|
65
64
|
end
|
@@ -68,5 +67,7 @@ module Jekyll
|
|
68
67
|
end
|
69
68
|
|
70
69
|
Jekyll::Hooks.register [:pages, :documents, :posts], :post_render do |d|
|
71
|
-
|
70
|
+
if d.output_ext == ".html"
|
71
|
+
Jekyll::Assets::Plugins::Searcher.new(d).run
|
72
|
+
end
|
72
73
|
end
|
data/lib/jekyll/assets/proxy.rb
CHANGED
@@ -11,8 +11,6 @@ module Jekyll
|
|
11
11
|
module Assets
|
12
12
|
class Proxy < Extensible
|
13
13
|
attr_reader :file
|
14
|
-
DIG = Digest::SHA256
|
15
|
-
DIR = "proxied"
|
16
14
|
|
17
15
|
class Deleted < StandardError
|
18
16
|
def initialize(obj)
|
@@ -68,18 +66,26 @@ module Jekyll
|
|
68
66
|
# --
|
69
67
|
def self.copy(asset, ctx:, args:)
|
70
68
|
env = ctx.registers[:site].sprockets
|
71
|
-
raw = args.instance_variable_get(:@raw)
|
72
|
-
key = DIG.hexdigest(raw)[0, 6]
|
73
69
|
|
74
|
-
path = env.in_cache_dir(
|
70
|
+
path = env.in_cache_dir("proxied")
|
75
71
|
extname = File.extname(args[:argv1])
|
76
|
-
out = Pathutil.new(path).join(
|
77
|
-
|
78
|
-
|
72
|
+
out = Pathutil.new(path).join(digest(args))
|
73
|
+
.sub_ext(extname)
|
74
|
+
|
75
|
+
unless out.file?
|
76
|
+
out.dirname.mkdir_p
|
77
|
+
Pathutil.new(asset.filename)
|
78
|
+
.cp(out)
|
79
|
+
end
|
79
80
|
|
80
81
|
out
|
81
82
|
end
|
82
83
|
|
84
|
+
def self.digest(args)
|
85
|
+
Digest::SHA256.hexdigest(args.instance_variable_get(
|
86
|
+
:@raw))[0, 6]
|
87
|
+
end
|
88
|
+
|
83
89
|
# --
|
84
90
|
# @return [Symbol] the argument key.
|
85
91
|
# Allows you to tell the proxier which args are yours.
|
@@ -105,5 +111,5 @@ module Jekyll
|
|
105
111
|
end
|
106
112
|
|
107
113
|
Jekyll::Assets::Hook.register :env, :after_init do
|
108
|
-
append_path(in_cache_dir(
|
114
|
+
append_path(in_cache_dir("proxied"))
|
109
115
|
end
|
data/lib/jekyll/assets/tag.rb
CHANGED
@@ -42,19 +42,20 @@ module Jekyll
|
|
42
42
|
# --
|
43
43
|
def initialize(tag, args, tokens)
|
44
44
|
@tag = tag.to_sym
|
45
|
-
@args = Liquid::Tag::Parser.new(args)
|
46
45
|
@tokens = tokens
|
47
|
-
@
|
46
|
+
@args = args
|
48
47
|
super
|
49
48
|
end
|
50
49
|
|
51
50
|
# --
|
52
51
|
def render_raw(ctx)
|
53
|
-
env
|
54
|
-
|
52
|
+
env = ctx.registers[:site].sprockets
|
53
|
+
|
54
|
+
args = Liquid::Tag::Parser.new(@args)
|
55
|
+
args = env.parse_liquid(args, ctx: ctx)
|
55
56
|
raise Sprockets::FileNotFound, "UNKNOWN" unless args.key?(:argv1)
|
56
57
|
asset = external(ctx, args: args) if env.external?(args)
|
57
|
-
asset ||= internal(ctx)
|
58
|
+
asset ||= internal(ctx, args: args)
|
58
59
|
[args, asset]
|
59
60
|
end
|
60
61
|
|
@@ -81,7 +82,7 @@ module Jekyll
|
|
81
82
|
# --
|
82
83
|
rescue ExecJS::RuntimeError => e
|
83
84
|
env.logger.error e.message
|
84
|
-
env.logger.efile
|
85
|
+
env.logger.efile args[:argv1]
|
85
86
|
raise ExecJS::RuntimeError, \
|
86
87
|
"JS Error"
|
87
88
|
# --
|
@@ -154,7 +155,7 @@ module Jekyll
|
|
154
155
|
# Set's up an internal asset using `Sprockets::Asset`
|
155
156
|
# @return [Sprockets::Asset]
|
156
157
|
# --
|
157
|
-
def internal(ctx)
|
158
|
+
def internal(ctx, args:)
|
158
159
|
env = ctx.registers[:site].sprockets
|
159
160
|
original = env.find_asset!(args[:argv1])
|
160
161
|
Default.set(args, ctx: ctx, asset: original)
|
data/lib/jekyll/assets/utils.rb
CHANGED
@@ -5,6 +5,28 @@
|
|
5
5
|
module Jekyll
|
6
6
|
module Assets
|
7
7
|
module Utils
|
8
|
+
def self.html_fragment(*a)
|
9
|
+
Nokogiri::HTML.fragment(*a) do |c|
|
10
|
+
c.options = Nokogiri::XML::ParseOptions::NONET | \
|
11
|
+
Nokogiri::XML::ParseOptions::NOENT
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# --
|
16
|
+
def self.html(*a)
|
17
|
+
Nokogiri::HTML.parse(*a) do |c|
|
18
|
+
c.options = Nokogiri::XML::ParseOptions::NONET | \
|
19
|
+
Nokogiri::XML::ParseOptions::NOENT
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# --
|
24
|
+
def self.xml(*a)
|
25
|
+
Nokogiri::XML.parse(*a) do |c|
|
26
|
+
c.options = Nokogiri::XML::ParseOptions::NONET
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
8
30
|
def raw_precompiles
|
9
31
|
asset_config[:raw_precompile].each_with_object([]) do |v, a|
|
10
32
|
if v.is_a?(Hash)
|
@@ -304,45 +326,6 @@ module Jekyll
|
|
304
326
|
rescue ExecJS::RuntimeUnavailable
|
305
327
|
nil
|
306
328
|
end
|
307
|
-
|
308
|
-
# --
|
309
|
-
# @param [Jekyll::Site] site
|
310
|
-
# @param [Hash<Symbol,Object>] payload
|
311
|
-
# Try to replicate and run hooks the Jekyll would normally run.
|
312
|
-
# rubocop:disable Metrics/LineLength
|
313
|
-
# @return nil
|
314
|
-
# --
|
315
|
-
def run_liquid_hooks(payload, site)
|
316
|
-
Hook.trigger(:liquid, :pre_render) { |h| h.call(payload, site) }
|
317
|
-
post, page, doc = get_liquid_obj(payload, site)
|
318
|
-
|
319
|
-
# I would assume most people set in :pre_render logically?
|
320
|
-
Jekyll::Hooks.trigger(:posts, :pre_render, post, payload) if post
|
321
|
-
Jekyll::Hooks.trigger(:documents, :pre_render, post || doc, payload) if post || doc
|
322
|
-
Jekyll::Hooks.trigger(:pages, :pre_render, page, payload) if page
|
323
|
-
end
|
324
|
-
|
325
|
-
# --
|
326
|
-
# @param [Jekyll::Site] site
|
327
|
-
# @param [Hash<Symbol,Object>] payload
|
328
|
-
# Discovers the Jekyll object, corresponding to the type.
|
329
|
-
# @note this allows us to trigger hooks that Jekyll would trigger.
|
330
|
-
# @return [Jekyll::Document, Jekyll::Page]
|
331
|
-
# rubocop:disable Layout/ExtraSpacing
|
332
|
-
# --
|
333
|
-
def get_liquid_obj(payload, site)
|
334
|
-
path = payload["path"]
|
335
|
-
|
336
|
-
post = site.posts.docs.find { |v| v.relative_path == path }
|
337
|
-
docs = site. documents.find { |v| v.relative_path == path } unless post
|
338
|
-
page = site. pages.find { |v| v.relative_path == path } unless docs
|
339
|
-
|
340
|
-
[
|
341
|
-
post,
|
342
|
-
page,
|
343
|
-
docs,
|
344
|
-
]
|
345
|
-
end
|
346
329
|
end
|
347
330
|
end
|
348
331
|
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.
|
4
|
+
version: 3.0.3
|
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-
|
13
|
+
date: 2017-11-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: execjs
|
@@ -217,18 +217,21 @@ files:
|
|
217
217
|
- lib/jekyll/assets/map/css.rb
|
218
218
|
- lib/jekyll/assets/map/javascript.rb
|
219
219
|
- lib/jekyll/assets/map/writer.rb
|
220
|
-
- lib/jekyll/assets/patches/
|
220
|
+
- lib/jekyll/assets/patches/asset.rb
|
221
|
+
- lib/jekyll/assets/patches/cached.rb
|
222
|
+
- lib/jekyll/assets/patches/find_asset.rb
|
221
223
|
- lib/jekyll/assets/patches/functions.rb
|
222
|
-
- lib/jekyll/assets/patches/
|
223
|
-
- lib/jekyll/assets/patches/
|
224
|
-
- lib/jekyll/assets/patches/sprockets_data_uri.rb
|
224
|
+
- lib/jekyll/assets/patches/obsolete.rb
|
225
|
+
- lib/jekyll/assets/patches/site.rb
|
225
226
|
- lib/jekyll/assets/plugins.rb
|
226
227
|
- lib/jekyll/assets/plugins/bootstrap.rb
|
227
228
|
- lib/jekyll/assets/plugins/font-awesome.rb
|
228
229
|
- lib/jekyll/assets/plugins/frontmatter.rb
|
229
230
|
- lib/jekyll/assets/plugins/html/audio.rb
|
231
|
+
- lib/jekyll/assets/plugins/html/component.rb
|
230
232
|
- lib/jekyll/assets/plugins/html/css.rb
|
231
233
|
- lib/jekyll/assets/plugins/html/defaults/audio.rb
|
234
|
+
- lib/jekyll/assets/plugins/html/defaults/component.rb
|
232
235
|
- lib/jekyll/assets/plugins/html/defaults/css.rb
|
233
236
|
- lib/jekyll/assets/plugins/html/defaults/favicon.rb
|
234
237
|
- lib/jekyll/assets/plugins/html/defaults/img.rb
|
@@ -252,7 +255,6 @@ files:
|
|
252
255
|
- lib/jekyll/assets/url.rb
|
253
256
|
- lib/jekyll/assets/utils.rb
|
254
257
|
- lib/jekyll/assets/version.rb
|
255
|
-
- lib/jekyll/assets/writer.rb
|
256
258
|
homepage: http://github.com/jekyll/jekyll-assets/
|
257
259
|
licenses:
|
258
260
|
- MIT
|
data/lib/jekyll/assets/writer.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2012 - 2017 - MIT License
|
3
|
-
# Encoding: utf-8
|
4
|
-
|
5
|
-
unless Jekyll::Assets::Env.old_sprockets?
|
6
|
-
require "sprockets/exporters/base"
|
7
|
-
|
8
|
-
module Sprockets
|
9
|
-
module Exporters
|
10
|
-
class FileExporter < Exporters::Base
|
11
|
-
def skip?(logger)
|
12
|
-
dest = environment.in_dest_dir + "/"
|
13
|
-
out, pth = nil, target.sub(dest, "")
|
14
|
-
|
15
|
-
if File.exist?(target)
|
16
|
-
logger.debug "Skips #{pth}" do
|
17
|
-
out = true
|
18
|
-
end
|
19
|
-
else
|
20
|
-
logger.debug "Write #{pth}" do
|
21
|
-
out = false
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
out
|
26
|
-
end
|
27
|
-
|
28
|
-
def call
|
29
|
-
write target do |f|
|
30
|
-
f.write asset.source
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|