jekyll-assets 1.0.0 → 2.0.0.pre.beta1

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -10
  3. data/LICENSE +16 -18
  4. data/README.md +94 -554
  5. data/Rakefile +2 -8
  6. data/lib/jekyll/assets.rb +18 -12
  7. data/lib/jekyll/assets/cached.rb +12 -0
  8. data/lib/jekyll/assets/configuration.rb +43 -87
  9. data/lib/jekyll/assets/context.rb +23 -0
  10. data/lib/jekyll/assets/env.rb +181 -0
  11. data/lib/jekyll/assets/extras/es6.rb +5 -0
  12. data/lib/jekyll/assets/extras/font-awesome.rb +1 -0
  13. data/lib/jekyll/assets/extras/helpers.rb +6 -0
  14. data/lib/jekyll/assets/extras/prefix.rb +5 -0
  15. data/lib/jekyll/assets/filters.rb +9 -11
  16. data/lib/jekyll/assets/helpers.rb +37 -0
  17. data/lib/jekyll/assets/hook.rb +45 -0
  18. data/lib/jekyll/assets/hooks/post_read.rb +3 -0
  19. data/lib/jekyll/assets/hooks/post_write.rb +3 -0
  20. data/lib/jekyll/assets/logger.rb +25 -0
  21. data/lib/jekyll/assets/patches/jekyll/cleaner.rb +11 -0
  22. data/lib/jekyll/assets/patches/jekyll/site.rb +5 -0
  23. data/lib/jekyll/assets/patches/sprockets/asset.rb +13 -0
  24. data/lib/jekyll/assets/tag.rb +136 -9
  25. data/lib/jekyll/assets/tag/parser.rb +129 -0
  26. data/lib/jekyll/assets/tag/proxied_asset.rb +84 -0
  27. data/lib/jekyll/assets/tag/proxies.rb +86 -0
  28. data/lib/jekyll/assets/tag/proxies/magick.rb +101 -0
  29. data/lib/jekyll/assets/version.rb +1 -1
  30. metadata +59 -149
  31. data/.gitignore +0 -27
  32. data/.rspec +0 -1
  33. data/.rubocop.yml +0 -43
  34. data/.rubocop_todo.yml +0 -10
  35. data/.travis.yml +0 -16
  36. data/.yardopts +0 -1
  37. data/Appraisals +0 -7
  38. data/Guardfile +0 -7
  39. data/HISTORY.md +0 -297
  40. data/gemfiles/jekyll_2.gemfile +0 -17
  41. data/gemfiles/jekyll_3.gemfile +0 -17
  42. data/jekyll-assets.gemspec +0 -34
  43. data/lib/jekyll-assets.rb +0 -2
  44. data/lib/jekyll/assets/asset_path.rb +0 -39
  45. data/lib/jekyll/assets/environment.rb +0 -62
  46. data/lib/jekyll/assets/patches.rb +0 -1
  47. data/lib/jekyll/assets/patches/asset_patch.rb +0 -102
  48. data/lib/jekyll/assets/patches/bundled_asset_patch.rb +0 -16
  49. data/lib/jekyll/assets/patches/context_patch.rb +0 -31
  50. data/lib/jekyll/assets/patches/index_patch.rb +0 -25
  51. data/lib/jekyll/assets/patches/processed_asset_patch.rb +0 -59
  52. data/lib/jekyll/assets/patches/site_patch.rb +0 -62
  53. data/lib/jekyll/assets/renderer.rb +0 -122
  54. data/spec/fixtures/.gitignore +0 -2
  55. data/spec/fixtures/.jekyll-metadata +0 -0
  56. data/spec/fixtures/_assets/alert.js +0 -1
  57. data/spec/fixtures/_assets/app.css.erb +0 -5
  58. data/spec/fixtures/_assets/app.js +0 -1
  59. data/spec/fixtures/_assets/app.min.css +0 -0
  60. data/spec/fixtures/_assets/app.min.js +0 -0
  61. data/spec/fixtures/_assets/fonts/vapor.eot +0 -0
  62. data/spec/fixtures/_assets/fonts/vapor.svg +0 -0
  63. data/spec/fixtures/_assets/fonts/vapor.ttf +0 -0
  64. data/spec/fixtures/_assets/fonts/vapor.woff +0 -0
  65. data/spec/fixtures/_assets/lib/relative.css.scss +0 -12
  66. data/spec/fixtures/_assets/noise.png +0 -0
  67. data/spec/fixtures/_assets/noize.png +0 -0
  68. data/spec/fixtures/_assets/should_be_blank.css.erb +0 -1
  69. data/spec/fixtures/_assets/should_fail.css.erb +0 -1
  70. data/spec/fixtures/_assets/vapor.css.scss +0 -13
  71. data/spec/fixtures/_assets/vapor.js +0 -2
  72. data/spec/fixtures/_assets/vendor/with_bootstrap.css.sass +0 -1
  73. data/spec/fixtures/_assets/vendor/with_bourbon.css.sass +0 -4
  74. data/spec/fixtures/_assets/vendor/with_compass.css.sass +0 -4
  75. data/spec/fixtures/_assets/vendor/with_neat.css.sass +0 -5
  76. data/spec/fixtures/_assets/wowscript.js +0 -0
  77. data/spec/fixtures/_assets/wowstyle.css +0 -0
  78. data/spec/fixtures/_config.yml +0 -2
  79. data/spec/fixtures/_layouts/default.html +0 -9
  80. data/spec/fixtures/_posts/2012-10-19-hello-world.md +0 -6
  81. data/spec/fixtures/_posts/2015-02-02-duplicates.md +0 -8
  82. data/spec/fixtures/index.html +0 -0
  83. data/spec/lib/jekyll/assets/configuration_spec.rb +0 -172
  84. data/spec/lib/jekyll/assets/environment_spec.rb +0 -18
  85. data/spec/lib/jekyll/assets/filters_spec.rb +0 -112
  86. data/spec/lib/jekyll/assets/patches/site_patch_spec.rb +0 -176
  87. data/spec/lib/jekyll/assets/renderer_spec.rb +0 -286
  88. data/spec/lib/jekyll/assets/tag_spec.rb +0 -139
  89. data/spec/spec_helper.rb +0 -58
  90. data/spec/support/fixtures_helpers.rb +0 -7
@@ -1,122 +0,0 @@
1
- # 3rd-party
2
- require "fastimage"
3
-
4
- module Jekyll
5
- module Assets
6
- class Renderer
7
- STYLESHEET = '<link rel="stylesheet" href="%{path}"%{attrs}>'
8
- JAVASCRIPT = '<script src="%{path}"%{attrs}></script>'
9
- IMAGE = '<img src="%{path}"%{attrs}>'
10
- IMAGESIZE = 'width="%d" height="%d"'
11
-
12
- URI_RE = %r{^(?:[^:]+:)?//(?:[^./]+\.)+[^./]+/}
13
- PARAMS_RE = / ^
14
- \s*
15
- (?: "(?<path>[^"]+)" | '(?<path>[^']+)' | (?<path>[^ ]+) )
16
- (?<attrs>.*?)
17
- (?: \[(?<options>.*)\] )?
18
- \s*
19
- $
20
- /x
21
-
22
- attr_reader :site, :path, :attrs, :options
23
-
24
- def initialize(context, params)
25
- @site = context.registers[:site]
26
-
27
- match = params.strip.match PARAMS_RE
28
-
29
- @path = match["path"]
30
- @attrs = match["attrs"].strip
31
- @options = match["options"].to_s.split(",").map(&:strip)
32
-
33
- @attrs = " #{@attrs}" unless @attrs.empty?
34
-
35
- resize!
36
- end
37
-
38
- def asset
39
- @asset ||= site.assets[path]
40
- end
41
-
42
- def render_asset
43
- fail "Can't render remote asset: #{path}" if remote?
44
- asset.to_s
45
- end
46
-
47
- def render_asset_path
48
- return path if remote?
49
- site.asset_path path
50
- end
51
-
52
- def render_javascript
53
- render_tag JAVASCRIPT, ".js"
54
- end
55
-
56
- def render_stylesheet
57
- render_tag STYLESHEET, ".css"
58
- end
59
-
60
- def render_image
61
- autosize!
62
- render_tag IMAGE
63
- end
64
-
65
- private
66
-
67
- # rubocop:disable Metrics/AbcSize
68
- def render_tag(template, extension = "")
69
- return format(template, :path => path, :attrs => attrs) if remote?
70
-
71
- path << extension if extension.to_s != File.extname(path)
72
-
73
- tags = (site.assets_config.debug ? asset.to_a : [asset]).map do |a|
74
- format template, :path => AssetPath.new(a).to_s, :attrs => attrs
75
- end
76
-
77
- tags.join "\n"
78
- end
79
- # rubocop:enable Metrics/AbcSize
80
-
81
- def autosize!
82
- return unless autosize?
83
-
84
- if remote?
85
- width, height = FastImage.size(path)
86
- else
87
- width, height = FastImage.size(site.assets[path].pathname)
88
- end
89
-
90
- @attrs = %(#{@attrs} width="#{width}" height="#{height}")
91
- end
92
-
93
- def autosize?
94
- if site.assets_config.autosize
95
- !options.include? "no-autosize"
96
- else
97
- options.include? "autosize"
98
- end
99
- end
100
-
101
- def make_resize_directory!
102
- FileUtils.mkdir_p site.assets.resize_cache_path
103
- end
104
-
105
- def resize!
106
- return unless resize?
107
-
108
- dimensions = options.grep(/resize/)[-1].split(":")[1]
109
-
110
- @path, @asset = asset.resize(dimensions)
111
- end
112
-
113
- def resize?
114
- options.grep(/resize:/).length > 0
115
- end
116
-
117
- def remote?
118
- path =~ URI_RE
119
- end
120
- end
121
- end
122
- end
@@ -1,2 +0,0 @@
1
- _site/
2
- .jekyll-assets-cache
Binary file
@@ -1 +0,0 @@
1
- alert('test');
@@ -1,5 +0,0 @@
1
- /**
2
- *= require vapor
3
- */
4
-
5
- body { background-image: url(<%= image_path 'noise.png' %>) }
@@ -1 +0,0 @@
1
- //= require vapor
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,12 +0,0 @@
1
- /* copy of vapor css framework to test relative asset inclusion*/
2
-
3
- @font-face {
4
- font-family: 'Vapor';
5
- src: url(font_path('../fonts/vapor.eot'));
6
- src: url(font_path('../fonts/vapor.eot?#iefix')) format("embedded-opentype"),
7
- url(font_path('../fonts/vapor.woff')) format("woff"),
8
- url(font_path('../fonts/vapor.ttf')) format("truetype"),
9
- url(font_path('../fonts/vapor.svg#iefix')) format("svg");
10
- font-weight: normal;
11
- font-style: normal;
12
- }
Binary file
Binary file
@@ -1 +0,0 @@
1
- body { background-image: url(<%= image_path '' %>) }
@@ -1 +0,0 @@
1
- body { background-image: url(<%= image_path 'not-found.png' %>) }
@@ -1,13 +0,0 @@
1
- //= require wowstyle
2
- /* vapor css framework */
3
-
4
- @font-face {
5
- font-family: 'Vapor';
6
- src: url(font_path('fonts/vapor.eot'));
7
- src: url(font_path('fonts/vapor.eot?#iefix')) format("embedded-opentype"),
8
- url(font_path('fonts/vapor.woff')) format("woff"),
9
- url(font_path('fonts/vapor.ttf')) format("truetype"),
10
- url(font_path('fonts/vapor.svg#iefix')) format("svg");
11
- font-weight: normal;
12
- font-style: normal;
13
- }
@@ -1,2 +0,0 @@
1
- //= require wowscript
2
- /* vapor js framework */
@@ -1 +0,0 @@
1
- @import "bootstrap"
@@ -1,4 +0,0 @@
1
- @import "bourbon"
2
-
3
- .photo
4
- @include linear-gradient(#1e5799, #2989d8)
@@ -1,4 +0,0 @@
1
- @import "compass"
2
-
3
- .photo
4
- @include background-image(linear-gradient(#1e5799, #2989d8))
@@ -1,5 +0,0 @@
1
- @import "bourbon"
2
- @import "neat"
3
-
4
- .container
5
- @include outer-container
File without changes
File without changes
@@ -1,2 +0,0 @@
1
- assets:
2
- sources: [ _assets ]
@@ -1,9 +0,0 @@
1
- <html>
2
- <head>
3
- <title>jekyll-assets</title>
4
- {% stylesheet app %}
5
- </head>
6
- <body>
7
- {{ content }}
8
- </body>
9
- </html>
@@ -1,6 +0,0 @@
1
- ---
2
- layout: default
3
- title: Jekyll meets assets pipeline
4
- ---
5
-
6
- Assets pipelines for Jekyll.
@@ -1,8 +0,0 @@
1
- ---
2
- layout: default
3
- title: There's nothing wrong with a duplicate
4
- ---
5
-
6
- https://github.com/ixti/jekyll-assets/issues/112#issuecomment-71850380
7
-
8
- {% image noise.png %} is {% image noize.png %}
File without changes
@@ -1,172 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Jekyll::Assets::Configuration do
4
- let(:options) { {} }
5
- subject(:config) { described_class.new(@site, options) }
6
-
7
- context "with defaults" do
8
- context "output assets dirname" do
9
- subject { config.dirname }
10
- it { is_expected.to eq described_class::DEFAULTS[:dirname] }
11
- end
12
-
13
- context "assets baseurl" do
14
- subject { config.baseurl }
15
- it { is_expected.to eq "/" + described_class::DEFAULTS[:dirname] }
16
- end
17
-
18
- context "sources list" do
19
- subject { config.sources }
20
- it { is_expected.to match_array described_class::DEFAULTS[:sources] }
21
- end
22
-
23
- context "cachebust" do
24
- subject { config.cachebust }
25
- it { is_expected.to be :hard }
26
- end
27
-
28
- context "js compressor" do
29
- subject { config.js_compressor }
30
- it { is_expected.to be_nil }
31
- end
32
-
33
- context "css compressor" do
34
- subject { config.css_compressor }
35
- it { is_expected.to be_nil }
36
- end
37
-
38
- context "autosize" do
39
- subject { config.autosize }
40
- it { is_expected.to be false }
41
- end
42
-
43
- context "gzip" do
44
- subject { config.gzip }
45
- it { is_expected.to match_array %w(text/css application/javascript) }
46
- end
47
-
48
- context "cache_assets?" do
49
- subject { config.cache_assets? }
50
- it { is_expected.to be false }
51
- end
52
-
53
- context "cache_path" do
54
- subject { config.cache_path }
55
- it { is_expected.to eq ".jekyll-assets-cache" }
56
- end
57
-
58
- context "debug" do
59
- subject { config.debug }
60
- it { is_expected.to be false }
61
- end
62
- end
63
-
64
- it "overrides specified options and leave defaults for missing" do
65
- config = described_class.new(@site, {
66
- :sources => %w(abc),
67
- :css_compressor => "sass"
68
- })
69
-
70
- expect(config.dirname).to eq "assets"
71
- expect(config.sources).to eq %w(abc)
72
- expect(config.js_compressor).to be_nil
73
- expect(config.css_compressor).to be :sass
74
- end
75
-
76
- context "#cache" do
77
- context "when specified as String" do
78
- let(:options) { { :cache => "/tmp/jekyll-assets" } }
79
-
80
- it "overrides default cache path" do
81
- expect(config.cache_path).to eq("/tmp/jekyll-assets")
82
- end
83
- end
84
- end
85
-
86
- context "#baseurl" do
87
- subject { config.baseurl }
88
-
89
- context "when given" do
90
- let(:options) { { :dirname => "foo", :baseurl => "/bar/" } }
91
- it { is_expected.to eq "/bar" }
92
- end
93
-
94
- context "when not explicitly given" do
95
- let(:options) { { :dirname => "foo" } }
96
- it { is_expected.to eq "/foo" }
97
-
98
- context "and site has baseurl config" do
99
- before { @site.config["baseurl"] = "/blog" }
100
- it { is_expected.to eq "/blog/foo" }
101
- end
102
- end
103
- end
104
-
105
- context "#js_compressor" do
106
- subject { config.js_compressor }
107
-
108
- context "when js compressor is given as `uglify`" do
109
- let(:options) { { :js_compressor => "uglify" } }
110
- it { is_expected.to be :uglify }
111
- end
112
-
113
- context "otherwise" do
114
- it { is_expected.to be_falsey }
115
- end
116
- end
117
-
118
- context "#css_compressor" do
119
- subject { config.css_compressor }
120
-
121
- context "when css compressor is given as `sass`" do
122
- let(:options) { { :css_compressor => "sass" } }
123
- it { is_expected.to be :sass }
124
- end
125
-
126
- context "otherwise" do
127
- it { is_expected.to be_falsey }
128
- end
129
- end
130
-
131
- context "#gzip" do
132
- subject { config.gzip }
133
-
134
- context "when gzip is disabled" do
135
- let(:options) { { :gzip => false } }
136
- it { is_expected.to eq [] }
137
- end
138
- end
139
-
140
- context "#version" do
141
- let(:options) { { :version => "abc" } }
142
- subject { config.version }
143
-
144
- it { is_expected.to be options.fetch(:version) }
145
- end
146
-
147
- context "Deprecated options" do
148
- context "compress" do
149
- let :options do
150
- { :compress => { :js => "uglify", :css => "sass" } }
151
- end
152
-
153
- describe "#js_compressor" do
154
- subject { config.js_compressor }
155
- it { is_expected.to be :uglify }
156
- end
157
-
158
- describe "#css_compressor" do
159
- subject { config.css_compressor }
160
- it { is_expected.to be :sass }
161
- end
162
- end
163
-
164
- context "cache_assets" do
165
- let(:options) { { :cache_assets => true } }
166
-
167
- it "sets `cache` value" do
168
- expect(config.cache_assets?).to eq true
169
- end
170
- end
171
- end
172
- end
@@ -1,18 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Jekyll::Assets::Environment do
4
- context "#asset_path of context" do
5
- it "properly handles query params" do
6
- css = @site.assets["vapor.css"].to_s
7
- expect(css).to match(/fonts\/vapor-[a-f0-9]{32}\.eot\?#iefix/)
8
- expect(css).to match(/fonts\/vapor-[a-f0-9]{32}\.svg#iefix/)
9
- end
10
-
11
- it "properly handles relative paths" do
12
- css = @site.assets["lib/relative.css"].to_s
13
- expect(css).to match(%r{/assets/fonts/vapor-[a-f0-9]{32}\.eot\?#iefix})
14
- expect(css).to match(%r{/assets/fonts/vapor-[a-f0-9]{32}\.svg#iefix})
15
- puts css
16
- end
17
- end
18
- end