jekyll-assets 2.4.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +21 -17
- data/LICENSE +1 -1
- data/README.md +365 -297
- data/Rakefile +13 -2
- data/lib/jekyll/assets.rb +15 -11
- data/lib/jekyll/assets/config.rb +91 -55
- data/lib/jekyll/assets/context.rb +32 -0
- data/lib/jekyll/assets/default.rb +98 -0
- data/lib/jekyll/assets/drop.rb +62 -0
- data/lib/jekyll/assets/env.rb +135 -278
- data/lib/jekyll/assets/extensible.rb +86 -0
- data/lib/jekyll/assets/filters.rb +22 -0
- data/lib/jekyll/assets/hook.rb +115 -48
- data/lib/jekyll/assets/html.rb +88 -0
- data/lib/jekyll/assets/logger.rb +17 -59
- data/lib/jekyll/assets/manifest.rb +15 -126
- data/lib/jekyll/assets/map.rb +57 -0
- data/lib/jekyll/assets/map/css.rb +43 -0
- data/lib/jekyll/assets/map/javascript.rb +43 -0
- data/lib/jekyll/assets/map/writer.rb +192 -0
- data/lib/jekyll/assets/patches/cached_env.rb +79 -0
- data/lib/jekyll/assets/patches/functions.rb +31 -0
- data/lib/jekyll/assets/patches/obsolete_files.rb +42 -0
- data/lib/jekyll/assets/patches/sprockets.rb +9 -0
- data/lib/jekyll/assets/patches/sprockets_data_uri.rb +12 -0
- data/lib/jekyll/assets/plugins.rb +9 -0
- data/lib/jekyll/assets/plugins/bootstrap.rb +5 -0
- data/lib/jekyll/assets/plugins/font-awesome.rb +8 -0
- data/lib/jekyll/assets/plugins/frontmatter.rb +28 -0
- data/lib/jekyll/assets/plugins/html/audio.rb +32 -0
- data/lib/jekyll/assets/plugins/html/css.rb +24 -0
- data/lib/jekyll/assets/plugins/html/defaults/audio.rb +69 -0
- data/lib/jekyll/assets/plugins/html/defaults/css.rb +48 -0
- data/lib/jekyll/assets/plugins/html/defaults/img.rb +54 -0
- data/lib/jekyll/assets/plugins/html/defaults/js.rb +48 -0
- data/lib/jekyll/assets/plugins/html/defaults/vid.rb +63 -0
- data/lib/jekyll/assets/plugins/html/img.rb +76 -0
- data/lib/jekyll/assets/plugins/html/js.rb +30 -0
- data/lib/jekyll/assets/plugins/html/pic.rb +125 -0
- data/lib/jekyll/assets/plugins/html/svg.rb +37 -0
- data/lib/jekyll/assets/plugins/html/vid.rb +26 -0
- data/lib/jekyll/assets/plugins/liquid.rb +57 -0
- data/lib/jekyll/assets/plugins/magick.rb +7 -0
- data/lib/jekyll/assets/plugins/optim.rb +7 -0
- data/lib/jekyll/assets/plugins/prefixer.rb +28 -0
- data/lib/jekyll/assets/plugins/proxy/magick.rb +131 -0
- data/lib/jekyll/assets/plugins/proxy/optim.rb +64 -0
- data/lib/jekyll/assets/plugins/searcher.rb +72 -0
- data/lib/jekyll/assets/proxy.rb +109 -0
- data/lib/jekyll/assets/tag.rb +176 -0
- data/lib/jekyll/assets/url.rb +23 -0
- data/lib/jekyll/assets/utils.rb +348 -0
- data/lib/jekyll/assets/version.rb +2 -2
- data/lib/jekyll/assets/writer.rb +36 -0
- metadata +102 -81
- data/lib/jekyll-assets.rb +0 -7
- data/lib/jekyll/assets/addons/autoprefixer.rb +0 -11
- data/lib/jekyll/assets/addons/bootstrap.rb +0 -9
- data/lib/jekyll/assets/addons/fontawesome.rb +0 -9
- data/lib/jekyll/assets/addons/javascript.rb +0 -11
- data/lib/jekyll/assets/cached.rb +0 -30
- data/lib/jekyll/assets/helpers.rb +0 -74
- data/lib/jekyll/assets/hooks/cache.rb +0 -21
- data/lib/jekyll/assets/hooks/compression.rb +0 -25
- data/lib/jekyll/assets/hooks/config.rb +0 -12
- data/lib/jekyll/assets/hooks/erb.rb +0 -15
- data/lib/jekyll/assets/hooks/jekyll/drops.rb +0 -9
- data/lib/jekyll/assets/hooks/jekyll/setup.rb +0 -11
- data/lib/jekyll/assets/hooks/jekyll/write.rb +0 -11
- data/lib/jekyll/assets/hooks/logger.rb +0 -11
- data/lib/jekyll/assets/hooks/sources.rb +0 -13
- data/lib/jekyll/assets/hooks/sprockets.rb +0 -9
- data/lib/jekyll/assets/hooks/version.rb +0 -11
- data/lib/jekyll/assets/liquid/context.rb +0 -19
- data/lib/jekyll/assets/liquid/drop.rb +0 -81
- data/lib/jekyll/assets/liquid/filters.rb +0 -49
- data/lib/jekyll/assets/liquid/tag.rb +0 -244
- data/lib/jekyll/assets/liquid/tag/defaults.rb +0 -27
- data/lib/jekyll/assets/liquid/tag/defaults/image.rb +0 -81
- data/lib/jekyll/assets/liquid/tag/defaults/sha.rb +0 -58
- data/lib/jekyll/assets/liquid/tag/parser.rb +0 -202
- data/lib/jekyll/assets/liquid/tag/proxied_asset.rb +0 -166
- data/lib/jekyll/assets/liquid/tag/proxies.rb +0 -130
- data/lib/jekyll/assets/patches/jekyll/cleaner.rb +0 -15
- data/lib/jekyll/assets/patches/jekyll/site.rb +0 -5
- data/lib/jekyll/assets/patches/kernel.rb +0 -29
- data/lib/jekyll/assets/patches/sprockets/asset.rb +0 -28
- data/lib/jekyll/assets/processors/less.rb +0 -70
- data/lib/jekyll/assets/processors/liquid.rb +0 -46
- data/lib/jekyll/assets/proxies/image_optim.rb +0 -80
- data/lib/jekyll/assets/proxies/magick.rb +0 -194
@@ -0,0 +1,79 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2012 - 2017 - MIT License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
5
|
+
require_relative "../utils"
|
6
|
+
|
7
|
+
module Jekyll
|
8
|
+
module Assets
|
9
|
+
module Patches
|
10
|
+
# --
|
11
|
+
# Patches `Sprockets::CachedEnvironment` with some of
|
12
|
+
# the stuff that we would like available. Including our
|
13
|
+
# `Util` methods, the `#manifest`, the `#asset_config`,
|
14
|
+
# and even `#jekyll`, so that we can remain fast while
|
15
|
+
# having some of the stuff that we need access to.
|
16
|
+
# --
|
17
|
+
module CachedEnv
|
18
|
+
include Utils
|
19
|
+
|
20
|
+
# --
|
21
|
+
attr_reader :manifest
|
22
|
+
attr_reader :asset_config
|
23
|
+
attr_reader :jekyll
|
24
|
+
|
25
|
+
# --
|
26
|
+
# @param [Env] env the environment.
|
27
|
+
# Patches initialize so we can give access to `#jekyll`.
|
28
|
+
# @return [self]
|
29
|
+
# --
|
30
|
+
def initialize(env)
|
31
|
+
super
|
32
|
+
|
33
|
+
@manifest = env.manifest
|
34
|
+
@asset_config = env.asset_config
|
35
|
+
@jekyll = env.jekyll
|
36
|
+
end
|
37
|
+
|
38
|
+
# --
|
39
|
+
# Conditionally creates the find_asset! method from
|
40
|
+
# Sprockets 4.x so that we don't have to change all that
|
41
|
+
# much to get things compatible between the two.
|
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
|
55
|
+
end
|
56
|
+
|
57
|
+
# --
|
58
|
+
# rubocop:disable Style/ClassAndModuleChildren
|
59
|
+
# Patches it onto the base class too.
|
60
|
+
# If it's not on cached, it's not on Env.
|
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
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# --
|
75
|
+
module Sprockets
|
76
|
+
class CachedEnvironment
|
77
|
+
prepend Jekyll::Assets::Patches::CachedEnv
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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 SassFunctions
|
9
|
+
def asset_path(path, options = {})
|
10
|
+
path, args = path.value.split(%r!\s+!, 2)
|
11
|
+
path, = URI.split(path)[5..8]
|
12
|
+
path = "#{path} #{args}"
|
13
|
+
|
14
|
+
# We strip the query string, and the fragment.
|
15
|
+
path = sprockets_context.asset_path(path, options)
|
16
|
+
Sprockets::Autoload::Sass::Script::String.new \
|
17
|
+
path, :string
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# --
|
25
|
+
module Sprockets
|
26
|
+
class SassProcessor
|
27
|
+
module Functions
|
28
|
+
prepend Jekyll::Assets::Patches::SassFunctions
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,42 @@
|
|
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
|
+
# --
|
9
|
+
# Patches Jekyll's obsolete files so that we can
|
10
|
+
# remove assets that we have used through the manifest.
|
11
|
+
# We expect the user to keep that manifest available,
|
12
|
+
# regardless of what's going on in their stuff.
|
13
|
+
# --
|
14
|
+
module ObsoleteFiles
|
15
|
+
# --
|
16
|
+
# @param [Object] args whatever Jekyll takes.
|
17
|
+
# Gives a list of files that should be removed, unless used.
|
18
|
+
# @return [Array<String>]
|
19
|
+
# --
|
20
|
+
def obsolete_files(*args)
|
21
|
+
extras = Utils.manifest_files(site.sprockets)
|
22
|
+
extras.concat(site.sprockets.raw_precompiles
|
23
|
+
.map { |v| v.values_at(:dst, :full_dst) }
|
24
|
+
.flatten.uniq)
|
25
|
+
|
26
|
+
super(*args).reject do |v|
|
27
|
+
v == site.sprockets.in_dest_dir || \
|
28
|
+
v == site.sprockets.manifest.filename || \
|
29
|
+
extras.include?(v)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# --
|
38
|
+
module Jekyll
|
39
|
+
class Cleaner
|
40
|
+
prepend Jekyll::Assets::Patches::ObsoleteFiles
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2012 - 2017 - MIT License
|
3
|
+
# Encoding: utf-8
|
4
|
+
|
5
|
+
require "jekyll"
|
6
|
+
|
7
|
+
module Jekyll
|
8
|
+
module Assets
|
9
|
+
module Plugins
|
10
|
+
class FrontMatter
|
11
|
+
REGEXP = Jekyll::Document::YAML_FRONT_MATTER_REGEXP
|
12
|
+
def call(input)
|
13
|
+
{
|
14
|
+
data: input[:data].gsub(REGEXP, ""),
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
processor = Jekyll::Assets::Plugins::FrontMatter.new
|
23
|
+
Sprockets.register_preprocessor "text/sass", processor
|
24
|
+
Sprockets.register_preprocessor "application/javascript", processor
|
25
|
+
Sprockets.register_preprocessor "application/ecmascript-6", processor
|
26
|
+
Sprockets.register_preprocessor "text/coffeescript", processor
|
27
|
+
Sprockets.register_preprocessor "text/scss", processor
|
28
|
+
Sprockets.register_preprocessor "text/css", processor
|
@@ -0,0 +1,32 @@
|
|
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 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"
|
21
|
+
|
22
|
+
def run
|
23
|
+
Nokogiri::HTML::Builder.with(doc) do |d|
|
24
|
+
d.audio("No support for audio.", args.to_h({
|
25
|
+
html: true, skip: HTML.skips
|
26
|
+
}))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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 CSS < HTML
|
12
|
+
content_types "text/css"
|
13
|
+
|
14
|
+
def run
|
15
|
+
Nokogiri::HTML::Builder.with(@doc) do |d|
|
16
|
+
attr = @args.to_h(html: true, skip: HTML.skips)
|
17
|
+
d.style(asset.to_s, attr) if @args[:inline]
|
18
|
+
d.link(attr) unless @args[:inline]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,69 @@
|
|
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 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"
|
20
|
+
|
21
|
+
# --
|
22
|
+
def set_src
|
23
|
+
dpath = asset.digest_path
|
24
|
+
return args[:src] = asset.url if asset.is_a?(Url)
|
25
|
+
return args[:src] = env.prefix_url(dpath) unless args[:inline]
|
26
|
+
# This is insanity, but who am I to judge you, and what you do.
|
27
|
+
args[:src] = asset.data_uri
|
28
|
+
end
|
29
|
+
|
30
|
+
# --
|
31
|
+
def set_controls
|
32
|
+
return if args.key?(:controls)
|
33
|
+
|
34
|
+
args[:controls] = true
|
35
|
+
unless args.key?(:controlsList) || args.key?(:controlslist)
|
36
|
+
args[:controlList] = "nodownload"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# --
|
41
|
+
def set_integrity
|
42
|
+
return unless integrity?
|
43
|
+
|
44
|
+
args[:integrity] = asset.integrity
|
45
|
+
unless args.key?(:crossorigin)
|
46
|
+
args[:crossorigin] = "anonymous"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# --
|
51
|
+
def integrity?
|
52
|
+
config[:integrity] && !asset.is_a?(Url) &&
|
53
|
+
!args.key?(:integrity)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# --
|
61
|
+
Jekyll::Assets::Hook.register :config, :before_merge do |c|
|
62
|
+
c.deep_merge!({
|
63
|
+
defaults: {
|
64
|
+
audio: {
|
65
|
+
integrity: Jekyll.production?,
|
66
|
+
},
|
67
|
+
},
|
68
|
+
})
|
69
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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 CSS < Default
|
11
|
+
static rel: "stylesheet"
|
12
|
+
content_types "text/css"
|
13
|
+
static type: "text/css"
|
14
|
+
|
15
|
+
def set_href
|
16
|
+
return @args[:href] = @asset.url if @asset.is_a?(Url)
|
17
|
+
@args[:href] = @env.prefix_url(@asset
|
18
|
+
.digest_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_integrity
|
22
|
+
return unless integrity?
|
23
|
+
@args[:integrity] = @asset.integrity
|
24
|
+
if !@args.key?(:crossorigin) && @args[:integrity]
|
25
|
+
@args[:crossorigin] = "anonymous"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# --
|
30
|
+
def integrity?
|
31
|
+
config[:integrity] && !@asset.is_a?(Url) &&
|
32
|
+
!@args.key?(:integrity)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# --
|
40
|
+
Jekyll::Assets::Hook.register :config, :before_merge do |c|
|
41
|
+
c.deep_merge!({
|
42
|
+
defaults: {
|
43
|
+
css: {
|
44
|
+
integrity: Jekyll.production?,
|
45
|
+
},
|
46
|
+
},
|
47
|
+
})
|
48
|
+
end
|
@@ -0,0 +1,54 @@
|
|
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 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"
|
19
|
+
|
20
|
+
def set_src
|
21
|
+
dpath = @asset.digest_path
|
22
|
+
return @args[:src] = @asset.url if @asset.is_a?(Url)
|
23
|
+
return @args[:src] = @env.prefix_url(dpath) unless @args[:inline]
|
24
|
+
@args[:src] = @asset.data_uri
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_integrity
|
28
|
+
return unless integrity?
|
29
|
+
@args[:integrity] = @asset.integrity
|
30
|
+
unless @args.key?(:crossorigin)
|
31
|
+
@args[:crossorigin] = "anonymous"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# --
|
36
|
+
def integrity?
|
37
|
+
config[:integrity] && !@asset.is_a?(Url) &&
|
38
|
+
!@args.key?(:integrity)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# --
|
46
|
+
Jekyll::Assets::Hook.register :config, :before_merge do |c|
|
47
|
+
c.deep_merge!({
|
48
|
+
defaults: {
|
49
|
+
img: {
|
50
|
+
integrity: Jekyll.production?,
|
51
|
+
},
|
52
|
+
},
|
53
|
+
})
|
54
|
+
end
|