jekyll-assets 2.0.0 → 2.0.1
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/README.md +10 -0
- data/lib/jekyll/assets/config.rb +18 -10
- data/lib/jekyll/assets/hooks/configuration.rb +4 -1
- data/lib/jekyll/assets/liquid/tag.rb +9 -9
- data/lib/jekyll/assets/liquid/tag/parser.rb +30 -22
- data/lib/jekyll/assets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7573064d37c19cca2f804d107adb47c71f242be
|
4
|
+
data.tar.gz: a0f730bae06638cdcd539dbea963c9da1e06d481
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 114f38166acfaeb87c0759bedc1db1e3f74cae7e9db6f89705770a5bf060ed5eec11cc6de78dfae69b016fccc676f1e42223d32479ff20538bed5d8550f4e77a
|
7
|
+
data.tar.gz: d84348b7a34237abc041c106e7bff9f684f592854c70b08aea694b841f5ea8470a5e4146acab4bccabbd42f71c9b6cc6cbc7b5eb1403d6d003b29cbc38d698fc
|
data/README.md
CHANGED
@@ -13,6 +13,10 @@ Jekyll 3 assets is an asset pipeline using Sprockets 3 to build especially
|
|
13
13
|
for Jekyll 3. It utilizes new features of both Sprockets and Jekyll to achieve
|
14
14
|
a clean and extensible assets platform for Jekyll.
|
15
15
|
|
16
|
+
## Having trouble with our documentation?
|
17
|
+
|
18
|
+
If you do not understand something in our documentation please feel free to file a ticket and it will be explained and the documentation updated, however... if you have already figured out the problem please feel free to submit a pull request with clarification in the documentation and we'll happily work with you on updating it.
|
19
|
+
|
16
20
|
## Using Jekyll Assets with Jekyll
|
17
21
|
|
18
22
|
When you are using a Gemfile and bundler you need to do nothing special to get
|
@@ -28,6 +32,8 @@ gems:
|
|
28
32
|
|
29
33
|
## Configuration
|
30
34
|
|
35
|
+
A lot of our configuration transforms based on the `JEKYLL_ENV` variable set in your environment. Such as digesting and whether or not to enable the CDN. Some of them can be explictly overriden but a few cannot right now. You should set your `JEKYLL_ENV=development` on your development machine and `JEKYLL_ENV=production` when building to push.
|
36
|
+
|
31
37
|
```yaml
|
32
38
|
assets:
|
33
39
|
compress:
|
@@ -52,6 +58,10 @@ assets:
|
|
52
58
|
- _assets/js
|
53
59
|
```
|
54
60
|
|
61
|
+
### Sources
|
62
|
+
|
63
|
+
The listed resources in the example are all defaults. It should be noted that we append your sources instead of replace our resources with yours. So if you add "_assets/folder" then we will append that to our sources and both will work.
|
64
|
+
|
55
65
|
### Digesting
|
56
66
|
|
57
67
|
* Disable digesting by default in development.
|
data/lib/jekyll/assets/config.rb
CHANGED
@@ -5,6 +5,12 @@
|
|
5
5
|
module Jekyll
|
6
6
|
module Assets
|
7
7
|
module Config
|
8
|
+
DefaultSources = %W(
|
9
|
+
_assets/css _assets/stylesheets
|
10
|
+
_assets/images _assets/img _assets/fonts
|
11
|
+
_assets/javascripts _assets/js
|
12
|
+
)
|
13
|
+
|
8
14
|
Development = {
|
9
15
|
"skip_baseurl_with_cdn" => false,
|
10
16
|
"skip_prefix_with_cdn" => false,
|
@@ -15,13 +21,7 @@ module Jekyll
|
|
15
21
|
"compress" => {
|
16
22
|
"css" => false,
|
17
23
|
"js" => false
|
18
|
-
}
|
19
|
-
|
20
|
-
"sources" => [
|
21
|
-
"_assets/css", "_assets/stylesheets",
|
22
|
-
"_assets/images", "_assets/img", "_assets/fonts",
|
23
|
-
"_assets/javascripts", "_assets/js"
|
24
|
-
]
|
24
|
+
}
|
25
25
|
}
|
26
26
|
|
27
27
|
#
|
@@ -36,15 +36,23 @@ module Jekyll
|
|
36
36
|
|
37
37
|
#
|
38
38
|
|
39
|
+
def self.merge_sources(jekyll, config)
|
40
|
+
config["sources"] = (DefaultSources + (config["sources"] ||= [])).map do |val|
|
41
|
+
jekyll.in_source_dir(val)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
|
39
47
|
def self.defaults
|
40
48
|
%W(development test).include?(Jekyll.env) ? Development : Production
|
41
49
|
end
|
42
50
|
|
43
51
|
#
|
44
52
|
|
45
|
-
def self.merge(
|
46
|
-
|
47
|
-
|
53
|
+
def self.merge(new_hash, old_hash = defaults)
|
54
|
+
old_hash.merge(new_hash) do |key, old_val, new_val|
|
55
|
+
old_val.is_a?(Hash) && new_val.is_a?(Hash) ? merge(new_val, old_val) : new_val
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
@@ -3,5 +3,8 @@
|
|
3
3
|
# Encoding: utf-8
|
4
4
|
|
5
5
|
Jekyll::Assets::Hook.register :env, :init, :early do
|
6
|
-
jekyll.config
|
6
|
+
jekyll.config["assets"] = Jekyll::Assets::Config.merge(asset_config)
|
7
|
+
Jekyll::Assets::Config.merge_sources(
|
8
|
+
jekyll, asset_config
|
9
|
+
)
|
7
10
|
end
|
@@ -74,7 +74,7 @@ module Jekyll
|
|
74
74
|
# because of a single asset change.
|
75
75
|
|
76
76
|
def render(context)
|
77
|
-
|
77
|
+
args = Parser.parse_liquid(@args, context)
|
78
78
|
site = context.registers[:site]
|
79
79
|
page = context.registers.fetch(:page, {})
|
80
80
|
sprockets = site.sprockets
|
@@ -82,7 +82,7 @@ module Jekyll
|
|
82
82
|
|
83
83
|
asset = find_asset(sprockets)
|
84
84
|
add_as_jekyll_dependency(site, sprockets, page, asset)
|
85
|
-
process_tag(sprockets, asset)
|
85
|
+
process_tag(args, sprockets, asset)
|
86
86
|
rescue => e
|
87
87
|
capture_and_out_error \
|
88
88
|
site, e
|
@@ -98,30 +98,30 @@ module Jekyll
|
|
98
98
|
#
|
99
99
|
|
100
100
|
private
|
101
|
-
def process_tag(sprockets, asset)
|
101
|
+
def process_tag(args, sprockets, asset)
|
102
102
|
sprockets.used.add(asset) unless @tag == "asset_source"
|
103
|
-
Defaults.set_defaults_for!(@tag,
|
104
|
-
build_html(sprockets, asset)
|
103
|
+
Defaults.set_defaults_for!(@tag, args ||= {}, asset)
|
104
|
+
build_html(args, sprockets, asset)
|
105
105
|
end
|
106
106
|
|
107
107
|
#
|
108
108
|
|
109
109
|
private
|
110
|
-
def build_html(sprockets, asset, path = get_path(sprockets, asset))
|
110
|
+
def build_html(args, sprockets, asset, path = get_path(sprockets, asset))
|
111
111
|
if @tag == "asset_path"
|
112
112
|
return path
|
113
113
|
|
114
114
|
elsif @tag == "asset" || @tag == "asset_source"
|
115
115
|
return asset.to_s
|
116
116
|
|
117
|
-
elsif
|
117
|
+
elsif args.has_key?(:data) && args[:data].has_key?(:uri)
|
118
118
|
return Tags[@tag] % [
|
119
|
-
asset.data_uri,
|
119
|
+
asset.data_uri, Parser.to_html(args)
|
120
120
|
]
|
121
121
|
|
122
122
|
else
|
123
123
|
return Tags[@tag] % [
|
124
|
-
path,
|
124
|
+
path, Parser.to_html(args)
|
125
125
|
]
|
126
126
|
end
|
127
127
|
end
|
@@ -61,17 +61,43 @@ module Jekyll
|
|
61
61
|
set_accept
|
62
62
|
end
|
63
63
|
|
64
|
-
#
|
64
|
+
# TODO: In 3.0 this needs to be removed and put on the class,
|
65
|
+
# but because we need to work around the way that Liquid currently
|
66
|
+
# works it needs to remain.
|
65
67
|
|
66
68
|
def parse_liquid!(context)
|
67
|
-
|
68
|
-
@args = _parse_liquid(@args, context)
|
69
|
+
@args = self.class.parse_liquid(@args, context)
|
69
70
|
end
|
70
71
|
|
71
72
|
#
|
72
73
|
|
74
|
+
def self.parse_liquid(hash, context)
|
75
|
+
hash = hash.to_h if hash.is_a?(self)
|
76
|
+
return hash unless context.is_a?(::Liquid::Context)
|
77
|
+
liquid = context.registers[:site].liquid_renderer.file( \
|
78
|
+
"(jekyll:assets)")
|
79
|
+
|
80
|
+
hash.inject({}) do |hash_, (key, val)|
|
81
|
+
val = liquid.parse(val).render(context) if val.is_a?(String)
|
82
|
+
val = parse_liquid(val, context) if val.is_a?(Hash)
|
83
|
+
hash_.update(
|
84
|
+
key => val
|
85
|
+
)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# TODO: In 3.0 this needs to be put on the class, but because
|
90
|
+
# we need to work around the way that Liquid currently works in
|
91
|
+
# 2.0.1 it needs to stay.
|
92
|
+
|
73
93
|
def to_html
|
74
|
-
@args
|
94
|
+
self.class.to_html(@args)
|
95
|
+
end
|
96
|
+
|
97
|
+
#
|
98
|
+
|
99
|
+
def self.to_html(hash)
|
100
|
+
hash.fetch(:html, {}).map do |key, val|
|
75
101
|
%Q{ #{key}="#{val}"}
|
76
102
|
end. \
|
77
103
|
join
|
@@ -166,24 +192,6 @@ module Jekyll
|
|
166
192
|
def from_shellwords
|
167
193
|
Shellwords.shellwords(@raw_args)
|
168
194
|
end
|
169
|
-
|
170
|
-
#
|
171
|
-
|
172
|
-
def _parse_liquid(hash, context)
|
173
|
-
lqd = context.registers[:site].liquid_renderer. \
|
174
|
-
file(raw_args)
|
175
|
-
|
176
|
-
hash.inject({}) do |hsh, (key, val)|
|
177
|
-
if val.is_a?(Hash) || val.is_a?(String)
|
178
|
-
val = val.is_a?(Hash) ? _parse_liquid(val, context) : \
|
179
|
-
lqd.parse(val).render!(context)
|
180
|
-
end
|
181
|
-
|
182
|
-
hsh.update(
|
183
|
-
key => val
|
184
|
-
)
|
185
|
-
end
|
186
|
-
end
|
187
195
|
end
|
188
196
|
end
|
189
197
|
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.0.
|
4
|
+
version: 2.0.1
|
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: 2015-11-
|
13
|
+
date: 2015-11-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sprockets
|