middleman-sprockets 4.0.0.rc.1 → 4.0.0.rc.2
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/.editorconfig +13 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +57 -0
- data/.simplecov +1 -1
- data/.travis.yml +26 -15
- data/CHANGELOG.md +15 -0
- data/Gemfile +25 -21
- data/README.md +60 -6
- data/Rakefile +31 -11
- data/docs/upgrade-3-to-4.md +118 -0
- data/features/asset_gems.feature +63 -0
- data/features/basic_usage.feature +97 -0
- data/features/bower.feature +90 -30
- data/features/linked_assets.feature +123 -0
- data/features/middleman_helpers.feature +154 -0
- data/features/step_definitions/builder_steps.rb +8 -0
- data/features/step_definitions/server_steps.rb +20 -0
- data/features/support/env.rb +0 -1
- data/features/{asset_hash.feature → test_cases/asset_hash.feature} +28 -22
- data/features/test_cases/exception_response.feature +31 -0
- data/features/test_cases/excluded_file_extensions.feature +39 -0
- data/features/test_cases/file_not_found.feature +31 -0
- data/features/test_cases/ignore_directive_is_respected.feature +90 -0
- data/features/test_cases/imported_asset_extensions.feature +77 -0
- data/features/test_cases/jst.feature +36 -0
- data/features/test_cases/long_filenames.feature +40 -0
- data/features/test_cases/path_helpers.feature +106 -0
- data/features/test_cases/processible_outside_asset_dir.feature +49 -0
- data/features/test_cases/sass_globs.feature +76 -0
- data/features/test_cases/sass_partials.feature +49 -0
- data/features/test_cases/sassc.feature +27 -0
- data/features/test_cases/use_from_templates.feature +21 -0
- data/features/test_cases/using_assets_gem_assets.feature +88 -0
- data/fixtures/asset-hash-app/config.rb +2 -0
- data/fixtures/asset-hash-app/source/stylesheets/jquery-mobile.css.scss +1 -0
- data/fixtures/asset-hash-host-app/config.rb +4 -4
- data/fixtures/base-app/config.rb +1 -0
- data/fixtures/{bower-multiple-assets-app/source/index.html → base-app/source/index.html.erb} +0 -0
- data/fixtures/gems/assets_gem/assets_gem.gemspec +16 -0
- data/fixtures/gems/assets_gem/lib/assets_gem.rb +7 -0
- data/fixtures/gems/assets_gem/vendor/assets/css/_imports/_import.scss +1 -0
- data/fixtures/{sprockets-imported-assets-match-multiple-paths-app/vendor/assets/css/test.css → gems/assets_gem/vendor/assets/css/test.scss} +1 -1
- data/fixtures/gems/assets_gem/vendor/assets/fonts/font.ttf +0 -0
- data/fixtures/gems/assets_gem/vendor/assets/images/logo.png +0 -0
- data/fixtures/gems/assets_gem/vendor/assets/javascripts/_imports/import.js +1 -0
- data/gemfiles/middleman-4.0.gemfile +7 -0
- data/gemfiles/middleman-4.1.gemfile +7 -0
- data/gemfiles/middleman-head.gemfile +7 -0
- data/gemfiles/sprockets-4.0.gemfile +6 -0
- data/lib/middleman-sprockets.rb +5 -5
- data/lib/middleman-sprockets/extension.rb +174 -215
- data/lib/middleman-sprockets/interface.rb +64 -0
- data/lib/middleman-sprockets/resource.rb +97 -0
- data/lib/middleman-sprockets/version.rb +1 -1
- data/middleman-sprockets.gemspec +16 -15
- data/tasks/matrix.rake +46 -0
- metadata +77 -237
- data/features/jst.feature +0 -14
- data/features/long_filenames.feature +0 -17
- data/features/sass_globs.feature +0 -9
- data/features/sass_partials.feature +0 -36
- data/features/sprockets.feature +0 -108
- data/features/sprockets_gems.feature +0 -48
- data/fixtures/asset-paths-app/config.rb +0 -1
- data/fixtures/asset-paths-app/derp/javascripts/vendored_js.js +0 -1
- data/fixtures/asset-paths-app/source/javascripts/vendored_include.js +0 -1
- data/fixtures/bower-app/bower.json +0 -7
- data/fixtures/bower-app/bower_components/underscore/bower.json +0 -8
- data/fixtures/bower-app/bower_components/underscore/underscore.js +0 -1343
- data/fixtures/bower-app/config.rb +0 -1
- data/fixtures/bower-app/source/javascripts/application.js +0 -1
- data/fixtures/bower-app/source/javascripts/import.js +0 -1
- data/fixtures/bower-individual-outputdir-app/bower.json +0 -7
- data/fixtures/bower-individual-outputdir-app/bower_components/underscore/bower.json +0 -8
- data/fixtures/bower-individual-outputdir-app/bower_components/underscore/underscore.js +0 -1343
- data/fixtures/bower-individual-outputdir-app/config.rb +0 -2
- data/fixtures/bower-individual-outputdir-app/source/javascripts/application.js +0 -4
- data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/.bower.json +0 -34
- data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/bower.json +0 -26
- data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/img/close.png +0 -0
- data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/js/lightbox.js +0 -2
- data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/package.json +0 -37
- data/fixtures/bower-json-app/config.rb +0 -1
- data/fixtures/bower-json-app/source/javascripts/application.js.coffee +0 -1
- data/fixtures/bower-json-app/source/javascripts/bower.json +0 -5
- data/fixtures/bower-multiple-assets-app/.bowerrc +0 -4
- data/fixtures/bower-multiple-assets-app/bower.json +0 -7
- data/fixtures/bower-multiple-assets-app/config.rb +0 -1
- data/fixtures/bower-multiple-assets-app/source/javascripts/core.js +0 -2
- data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/.bower.json +0 -34
- data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/bower.json +0 -26
- data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/img/close.png +0 -0
- data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/img/open.png +0 -0
- data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/js/lightbox.js +0 -2
- data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/package.json +0 -37
- data/fixtures/glob-app/config.rb +0 -0
- data/fixtures/glob-app/source/stylesheets/main.css.scss +0 -1
- data/fixtures/glob-app/source/stylesheets/module1/_i-am-mod.scss +0 -3
- data/fixtures/glob-app/source/stylesheets/module2/_derp.sass +0 -2
- data/fixtures/glob-app/source/stylesheets/shared/3rd-party/bootstrap.sass +0 -2
- data/fixtures/glob-app/source/stylesheets/shared/shared.scss +0 -3
- data/fixtures/jquery-mobile-app/config.rb +0 -0
- data/fixtures/jquery-mobile-app/source/javascripts/app.js +0 -1
- data/fixtures/jquery-mobile-app/source/stylesheets/base.css.scss +0 -2
- data/fixtures/long-filenames-app/config.rb +0 -0
- data/fixtures/long-filenames-app/source/images/00000000-0000-0000-0000-000000.svg +0 -3
- data/fixtures/long-filenames-app/source/images/00000000-0000-0000-0000-0000001.svg +0 -3
- data/fixtures/preview-app/config.rb +0 -0
- data/fixtures/preview-app/source/content.html.erb +0 -1
- data/fixtures/preview-app/source/layout.erb +0 -1
- data/fixtures/preview-app/source/stylesheets/_partial.sass +0 -2
- data/fixtures/preview-app/source/stylesheets/_partial2.css.sass +0 -2
- data/fixtures/preview-app/source/stylesheets/main.css.sass +0 -4
- data/fixtures/preview-app/source/stylesheets/main2.css.sass +0 -4
- data/fixtures/preview-app/source/stylesheets/plain.css.sass +0 -2
- data/fixtures/sprockets-app/config.rb +0 -2
- data/fixtures/sprockets-app/source/index.html.erb +0 -6
- data/fixtures/sprockets-app/source/library/css/bootstrap_include.css.scss +0 -1
- data/fixtures/sprockets-app/source/library/css/plain.css +0 -5
- data/fixtures/sprockets-app/source/library/css/sprockets_base1.css.scss +0 -1
- data/fixtures/sprockets-app/source/library/css/sprockets_base2.css.scss +0 -1
- data/fixtures/sprockets-app/source/library/css/sprockets_sub.css.scss +0 -1
- data/fixtures/sprockets-app/source/library/js/jquery_include.js +0 -1
- data/fixtures/sprockets-app/source/library/js/plain.js +0 -6
- data/fixtures/sprockets-app/source/library/js/sprockets_base.js +0 -5
- data/fixtures/sprockets-app/source/library/js/sprockets_sub.js +0 -3
- data/fixtures/sprockets-app/source/library/js/vendored_include.js +0 -1
- data/fixtures/sprockets-app/vendor/assets/javascripts/coffee.js.coffee +0 -2
- data/fixtures/sprockets-app/vendor/assets/javascripts/vendored_js.js +0 -1
- data/fixtures/sprockets-app/vendor/assets/stylesheets/vendored.css.scss +0 -4
- data/fixtures/sprockets-app2/config.rb +0 -0
- data/fixtures/sprockets-app2/data/test.yml +0 -4
- data/fixtures/sprockets-app2/data/test2.json +0 -4
- data/fixtures/sprockets-app2/source/javascripts/_templates/test.jst.ejs +0 -1
- data/fixtures/sprockets-app2/source/javascripts/_templates/test2.jst.eco +0 -1
- data/fixtures/sprockets-app2/source/javascripts/asset_path.js.erb +0 -3
- data/fixtures/sprockets-app2/source/javascripts/multiple_engines.js.coffee.erb +0 -1
- data/fixtures/sprockets-app2/source/javascripts/sprockets_base.js +0 -5
- data/fixtures/sprockets-app2/source/javascripts/sprockets_sub.js +0 -3
- data/fixtures/sprockets-app2/source/javascripts/templates.js +0 -1
- data/fixtures/sprockets-app2/source/stylesheets/sprockets_base1.css.scss +0 -1
- data/fixtures/sprockets-app2/source/stylesheets/sprockets_base2.css.scss +0 -1
- data/fixtures/sprockets-app2/source/stylesheets/sprockets_sub.css.scss +0 -1
- data/fixtures/sprockets-images-app/config.rb +0 -1
- data/fixtures/sprockets-images-app/source/index.html.erb +0 -10
- data/fixtures/sprockets-images-app/source/library/images/cat.jpg +0 -0
- data/fixtures/sprockets-images-app/vendor/assets/images/cat-2.jpg +0 -0
- data/fixtures/sprockets-imported-asset-path-conflicts-app/config.rb +0 -4
- data/fixtures/sprockets-imported-asset-path-conflicts-app/resources/assets/stylesheets/test.css +0 -3
- data/fixtures/sprockets-imported-assets-match-multiple-paths-app/config.rb +0 -4
- data/fixtures/sprockets-multiple-extensions-app/bower.json +0 -8
- data/fixtures/sprockets-multiple-extensions-app/config.rb +0 -1
- data/fixtures/sprockets-multiple-extensions-app/source/fonts/fontawesome-webfont-source.svg.gz +0 -0
- data/fixtures/sprockets-multiple-extensions-app/source/images/drawing-source.svg +0 -76
- data/fixtures/sprockets-multiple-extensions-app/source/stylesheets/app.css.scss +0 -3
- data/fixtures/sprockets-multiple-extensions-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg.gz +0 -0
- data/fixtures/sprockets-multiple-extensions-app/vendor/assets/components/jquery/jquery.asdf.asdf.js.min.asdf +0 -4
- data/fixtures/sprockets-multiple-extensions-app/vendor/assets/components/jquery/jquery.min.js +0 -4
- data/fixtures/sprockets-svg-font-app/bower.json +0 -8
- data/fixtures/sprockets-svg-font-app/config.rb +0 -1
- data/fixtures/sprockets-svg-font-app/source/fonts/fontawesome-webfont-source.svg +0 -504
- data/fixtures/sprockets-svg-font-app/source/fonts/fontawesome-webfont-source.svg.gz +0 -0
- data/fixtures/sprockets-svg-font-app/source/images/drawing-source.svg +0 -76
- data/fixtures/sprockets-svg-font-app/source/stylesheets/app.css.scss +0 -4
- data/fixtures/sprockets-svg-font-app/vendor/assets/components/blub/images/drawing-bower.svg +0 -76
- data/fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg +0 -504
- data/fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg.gz +0 -0
- data/fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.ttf.gz +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
activate :sprockets
|
data/fixtures/{bower-multiple-assets-app/source/index.html → base-app/source/index.html.erb}
RENAMED
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |gem|
|
2
|
+
|
3
|
+
gem.name = 'assets_gem'
|
4
|
+
gem.version = '0.0.0'
|
5
|
+
gem.platform = Gem::Platform::RUBY
|
6
|
+
|
7
|
+
gem.summary = 'dummy gem for a fixture'
|
8
|
+
gem.description = %q{ dummy gem for a fixture }
|
9
|
+
gem.authors = ["Steven Sloan"]
|
10
|
+
gem.email = ["stevenosloan@gmail.com"]
|
11
|
+
gem.license = 'MIT'
|
12
|
+
|
13
|
+
gem.files = Dir["lib/**/*.rb", "vendor/**/*"]
|
14
|
+
gem.require_path = "lib"
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
$color: #fd0;
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
alert("imported");
|
@@ -0,0 +1,7 @@
|
|
1
|
+
root_gemfile = IO.read( File.expand_path('../Gemfile', File.dirname(__FILE__)))
|
2
|
+
root_gemfile.sub! "gemspec", 'gemspec path: "../"'
|
3
|
+
root_gemfile.sub! "path: 'fixtures/gems/", "path: '../fixtures/gems/"
|
4
|
+
|
5
|
+
root_gemfile.sub! "gem 'middleman'", "gem 'middleman', '~> 4.0.0'"
|
6
|
+
|
7
|
+
eval root_gemfile, binding
|
@@ -0,0 +1,7 @@
|
|
1
|
+
root_gemfile = IO.read( File.expand_path('../Gemfile', File.dirname(__FILE__)))
|
2
|
+
root_gemfile.sub! "gemspec", 'gemspec path: "../"'
|
3
|
+
root_gemfile.sub! "path: 'fixtures/gems/", "path: '../fixtures/gems/"
|
4
|
+
|
5
|
+
root_gemfile.sub! "gem 'middleman'", "gem 'middleman', '~> 4.1.0'"
|
6
|
+
|
7
|
+
eval root_gemfile, binding
|
@@ -0,0 +1,7 @@
|
|
1
|
+
root_gemfile = IO.read( File.expand_path('../Gemfile', File.dirname(__FILE__)))
|
2
|
+
root_gemfile.sub! "gemspec", 'gemspec path: "../"'
|
3
|
+
root_gemfile.sub! "path: 'fixtures/gems/", "path: '../fixtures/gems/"
|
4
|
+
eval root_gemfile, binding
|
5
|
+
|
6
|
+
gem 'middleman-cli', github: 'middleman/middleman', branch: 'master'
|
7
|
+
gem 'middleman-core', github: 'middleman/middleman', branch: 'master'
|
@@ -0,0 +1,6 @@
|
|
1
|
+
root_gemfile = IO.read( File.expand_path('../Gemfile', File.dirname(__FILE__)))
|
2
|
+
root_gemfile.sub! "gemspec", 'gemspec path: "../"'
|
3
|
+
root_gemfile.sub! "path: 'fixtures/gems/", "path: '../fixtures/gems/"
|
4
|
+
eval root_gemfile, binding
|
5
|
+
|
6
|
+
gem 'sprockets', github: 'rails/sprockets'
|
data/lib/middleman-sprockets.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require 'middleman-core'
|
2
2
|
|
3
|
-
Middleman::Extensions.register(:sprockets
|
4
|
-
require
|
5
|
-
Middleman::
|
6
|
-
end
|
3
|
+
Middleman::Extensions.register(:sprockets) do
|
4
|
+
require 'middleman-sprockets/extension'
|
5
|
+
Middleman::Sprockets::Extension
|
6
|
+
end
|
@@ -1,257 +1,216 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'sprockets'
|
2
|
+
require 'middleman-core/contracts'
|
3
|
+
require 'middleman-core/sitemap/resource'
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
attr_reader :environment
|
7
|
-
|
8
|
-
expose_to_config sprockets: :environment
|
5
|
+
require_relative 'resource'
|
6
|
+
require_relative 'interface'
|
9
7
|
|
10
|
-
|
11
|
-
|
8
|
+
module Middleman
|
9
|
+
module Sprockets
|
10
|
+
class Extension < Extension
|
11
|
+
attr_reader :environment,
|
12
|
+
:interface
|
12
13
|
|
13
|
-
|
14
|
+
expose_to_config sprockets: :environment
|
15
|
+
expose_to_template sprockets: :environment
|
14
16
|
|
15
|
-
|
17
|
+
option :supported_output_extensions, ['.css', '.js'], 'Output extensions sprockets should process'
|
18
|
+
option :imported_asset_path, 'assets', 'Where under source imported assets should be placed.'
|
19
|
+
option :expose_middleman_helpers, false, 'Whether to expose middleman helpers to sprockets.'
|
16
20
|
|
17
|
-
|
18
|
-
|
21
|
+
Contract ::Middleman::Application, Hash, Maybe[Proc] => Any
|
22
|
+
def initialize app, options_hash={}, &block
|
23
|
+
super
|
19
24
|
|
20
|
-
|
21
|
-
|
22
|
-
|
25
|
+
@inline_asset_references = Set.new
|
26
|
+
@environment = ::Sprockets::Environment.new
|
27
|
+
@interface = Interface.new options, @environment
|
23
28
|
|
24
|
-
|
29
|
+
use_sassc_if_available
|
30
|
+
end
|
25
31
|
|
26
|
-
|
27
|
-
|
32
|
+
Contract Any
|
33
|
+
def after_configuration
|
34
|
+
@environment.append_path((app.source_dir + app.config[:js_dir]).to_s)
|
35
|
+
@environment.append_path((app.source_dir + app.config[:css_dir]).to_s)
|
36
|
+
@environment.append_path(app.source_dir.to_s)
|
37
|
+
|
38
|
+
append_paths_from_gems
|
39
|
+
|
40
|
+
the_app = app
|
41
|
+
the_env = environment
|
42
|
+
|
43
|
+
@environment.context_class.send(:define_method, :app) { the_app }
|
44
|
+
@environment.context_class.send(:define_method, :data) { the_app.data }
|
45
|
+
@environment.context_class.send(:define_method, :env) { the_env }
|
46
|
+
|
47
|
+
@environment.context_class.class_eval do
|
48
|
+
def asset_path path, options={}
|
49
|
+
# Handle people calling with the Middleman/Padrino asset path signature
|
50
|
+
if path.is_a?(::Symbol) && !options.is_a?(::Hash)
|
51
|
+
kind = path
|
52
|
+
path = options
|
53
|
+
else
|
54
|
+
kind = {
|
55
|
+
image: :images,
|
56
|
+
font: :fonts,
|
57
|
+
javascript: :js,
|
58
|
+
stylesheet: :css
|
59
|
+
}.fetch(options[:type], options[:type])
|
60
|
+
end
|
61
|
+
|
62
|
+
if File.extname(path).empty?
|
63
|
+
path << { js: '.js', css: '.css' }.fetch(kind, '')
|
64
|
+
end
|
65
|
+
|
66
|
+
if app.extensions[:sprockets].check_asset(path)
|
67
|
+
app.extensions[:sprockets].sprockets_asset_path(environment[path]).sub(/^\/?/, '/')
|
68
|
+
else
|
69
|
+
app.asset_path(kind, path)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
28
73
|
|
29
|
-
|
30
|
-
|
31
|
-
@environment.context_class.send(:define_method, :env) { the_env }
|
74
|
+
expose_app_helpers_to_sprockets! if options[:expose_middleman_helpers]
|
75
|
+
end
|
32
76
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
77
|
+
Contract ResourceList => ResourceList
|
78
|
+
def manipulate_resource_list resources
|
79
|
+
sprockets_resources = ::Middleman::Util.instrument 'sprockets', name: 'manipulator.sprockets_resources' do
|
80
|
+
resources.map do |resource|
|
81
|
+
process_candidate_sprockets_resource(resource)
|
82
|
+
end
|
83
|
+
end
|
40
84
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
when :stylesheet then :css
|
46
|
-
else options[:type]
|
47
|
-
end
|
85
|
+
linked_resources = ::Middleman::Util.instrument 'sprockets', name: 'manipulator.linked_resources' do
|
86
|
+
@inline_asset_references.map do |path|
|
87
|
+
asset = environment[path]
|
88
|
+
generate_resource(sprockets_asset_path(asset), asset.filename, asset.logical_path)
|
48
89
|
end
|
90
|
+
end
|
49
91
|
|
50
|
-
|
51
|
-
|
92
|
+
::Middleman::Util.instrument 'sprockets', name: 'manipulator.ignore_resources' do
|
93
|
+
if app.extensions[:sitemap_ignore].respond_to?(:manipulate_resource_list)
|
94
|
+
app.extensions[:sitemap_ignore].manipulate_resource_list sprockets_resources + linked_resources
|
52
95
|
else
|
53
|
-
|
96
|
+
sprockets_resources + linked_resources
|
54
97
|
end
|
55
98
|
end
|
56
99
|
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def base_resource?(r)
|
60
|
-
r.class.ancestors.first == ::Middleman::Sitemap::Resource
|
61
|
-
end
|
62
100
|
|
63
|
-
|
64
|
-
|
65
|
-
r.
|
66
|
-
rescue
|
67
|
-
require 'pry'
|
68
|
-
binding.pry
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def css?(r)
|
73
|
-
r.source_file.start_with?((app.source_dir + app.config[:css_dir]).to_s)
|
74
|
-
end
|
75
|
-
|
76
|
-
def check_asset(path)
|
77
|
-
if asset = environment[path]
|
78
|
-
@inline_asset_references << path
|
79
|
-
true
|
80
|
-
else
|
81
|
-
false
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def manipulate_resource_list(resources)
|
86
|
-
sprockets, non_sprockets = resources.partition do |r|
|
87
|
-
base_resource?(r) && (js?(r) || css?(r))
|
101
|
+
Contract ::Middleman::Sitemap::Resource => Bool
|
102
|
+
def processible? r
|
103
|
+
!r.is_a?(Resource) && interface.processible?(r.source_file)
|
88
104
|
end
|
89
105
|
|
90
|
-
|
91
|
-
|
92
|
-
|
106
|
+
Contract String => Bool
|
107
|
+
def check_asset path
|
108
|
+
if environment[path]
|
109
|
+
@inline_asset_references << path
|
110
|
+
true
|
93
111
|
else
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
sprockets_resource = generate_resource(r.path, r.source_file, sprockets_path)
|
98
|
-
sum << sprockets_resource
|
99
|
-
|
100
|
-
if sprockets_resource.respond_to?(:sprockets_asset)
|
101
|
-
sprockets_resource.sprockets_asset.links.each do |a|
|
102
|
-
asset = environment[a]
|
103
|
-
path = "#{app.config[:sprockets_imported_asset_path]}/#{asset.logical_path}"
|
104
|
-
sum << generate_resource(path, asset.filename, asset.logical_path)
|
105
|
-
end
|
112
|
+
false
|
106
113
|
end
|
114
|
+
end
|
107
115
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
path = "#{app.config[:sprockets_imported_asset_path]}/#{asset.logical_path}"
|
112
|
-
generate_resource(path, asset.filename, asset.logical_path)
|
116
|
+
Contract ::Sprockets::Asset => String
|
117
|
+
def sprockets_asset_path sprockets_asset
|
118
|
+
File.join(options[:imported_asset_path], sprockets_asset.logical_path)
|
113
119
|
end
|
114
|
-
end
|
115
120
|
|
116
|
-
|
121
|
+
private
|
117
122
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
+
def expose_app_helpers_to_sprockets!
|
124
|
+
@environment.context_class.class_eval do
|
125
|
+
def current_resource
|
126
|
+
logger.error "The use of `current_resource` in sprockets assets isn't currently implemented"
|
127
|
+
nil
|
128
|
+
end
|
123
129
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
elsif ext == '.js'
|
128
|
-
javascript_exception_response(e)
|
129
|
-
else
|
130
|
-
e.to_s
|
131
|
-
end
|
130
|
+
def mm_context
|
131
|
+
@_mm_context ||= app.template_context_class.new(app)
|
132
|
+
end
|
132
133
|
|
133
|
-
|
134
|
-
|
135
|
-
|
134
|
+
def method_missing method, *args, &block
|
135
|
+
if mm_context.respond_to?(method)
|
136
|
+
return mm_context.send method, *args, &block
|
137
|
+
end
|
136
138
|
|
137
|
-
|
138
|
-
|
139
|
-
def javascript_exception_response(exception)
|
140
|
-
err = "#{exception.class.name}: #{exception.message}\n (in #{exception.backtrace[0]})"
|
141
|
-
"throw Error(#{err.inspect})"
|
142
|
-
end
|
139
|
+
super
|
140
|
+
end
|
143
141
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
<<-CSS
|
151
|
-
html {
|
152
|
-
padding: 18px 36px;
|
153
|
-
}
|
154
|
-
|
155
|
-
head {
|
156
|
-
display: block;
|
157
|
-
}
|
158
|
-
|
159
|
-
body {
|
160
|
-
margin: 0;
|
161
|
-
padding: 0;
|
162
|
-
}
|
163
|
-
|
164
|
-
body > * {
|
165
|
-
display: none !important;
|
166
|
-
}
|
167
|
-
|
168
|
-
head:after, body:before, body:after {
|
169
|
-
display: block !important;
|
170
|
-
}
|
171
|
-
|
172
|
-
head:after {
|
173
|
-
font-family: sans-serif;
|
174
|
-
font-size: large;
|
175
|
-
font-weight: bold;
|
176
|
-
content: "Error compiling CSS asset";
|
177
|
-
}
|
178
|
-
|
179
|
-
body:before, body:after {
|
180
|
-
font-family: monospace;
|
181
|
-
white-space: pre-wrap;
|
182
|
-
}
|
183
|
-
|
184
|
-
body:before {
|
185
|
-
font-weight: bold;
|
186
|
-
content: "#{escape_css_content(message)}";
|
187
|
-
}
|
188
|
-
|
189
|
-
body:after {
|
190
|
-
content: "#{escape_css_content(backtrace)}";
|
191
|
-
}
|
192
|
-
CSS
|
193
|
-
end
|
142
|
+
def respond_to? method, include_private=false
|
143
|
+
super || mm_context.respond_to?(method, include_private)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
194
147
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
gsub('\\', '\\\\005c ').
|
199
|
-
gsub("\n", '\\\\000a ').
|
200
|
-
gsub('"', '\\\\0022 ').
|
201
|
-
gsub('/', '\\\\002f ')
|
202
|
-
end
|
148
|
+
Contract ::Middleman::Sitemap::Resource => Or[::Middleman::Sitemap::Resource, Resource]
|
149
|
+
def process_candidate_sprockets_resource resource
|
150
|
+
return resource unless processible?(resource)
|
203
151
|
|
204
|
-
|
205
|
-
|
206
|
-
#
|
207
|
-
# @private
|
208
|
-
# @return [Array] Array of latest Gem::Specification
|
209
|
-
def rubygems_latest_specs
|
210
|
-
# If newer Rubygems
|
211
|
-
if ::Gem::Specification.respond_to? :latest_specs
|
212
|
-
::Gem::Specification.latest_specs(true)
|
213
|
-
else
|
214
|
-
::Gem.source_index.latest_specs
|
215
|
-
end
|
216
|
-
end
|
152
|
+
::Middleman::Util.instrument 'sprockets', name: 'process_resource', resource: resource do
|
153
|
+
sprockets_resource = generate_resource(resource.path, resource.source_file, resource.path)
|
217
154
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
base_paths = %w[assets app app/assets vendor vendor/assets lib lib/assets]
|
222
|
-
asset_dirs = %w[javascripts js stylesheets css images img fonts]
|
155
|
+
if sprockets_resource.respond_to?(:sprockets_asset) && !sprockets_resource.errored?
|
156
|
+
@inline_asset_references.merge sprockets_resource.sprockets_asset.links
|
157
|
+
end
|
223
158
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
159
|
+
sprockets_resource
|
160
|
+
end
|
161
|
+
rescue => e
|
162
|
+
logger.error("== Sprockets Debug: #{resource}")
|
163
|
+
logger.error("== Sprockets Debug: #{sprockets_resource}") if defined?(sprockets_resource)
|
164
|
+
raise e
|
165
|
+
end
|
229
166
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
167
|
+
Contract String, String, String => Resource
|
168
|
+
def generate_resource path, source_file, sprockets_path
|
169
|
+
::Middleman::Util.instrument 'sprockets', name: 'generate_resource',
|
170
|
+
path: path,
|
171
|
+
sprockets_path: sprockets_path do
|
172
|
+
Resource.new(app.sitemap, path, source_file, sprockets_path, environment)
|
173
|
+
end
|
174
|
+
end
|
236
175
|
|
237
|
-
|
238
|
-
|
176
|
+
def use_sassc_if_available
|
177
|
+
if defined?(::SassC)
|
178
|
+
require 'sprockets/sassc_processor'
|
179
|
+
environment.register_transformer 'text/sass', 'text/css', ::Sprockets::SasscProcessor.new
|
180
|
+
environment.register_transformer 'text/scss', 'text/css', ::Sprockets::ScsscProcessor.new
|
239
181
|
|
240
|
-
|
241
|
-
|
242
|
-
|
182
|
+
logger.info '== Sprockets will render css with SassC'
|
183
|
+
end
|
184
|
+
rescue LoadError
|
185
|
+
logger.info "== Sprockets will render css with ruby sass\n" \
|
186
|
+
' consider using Sprockets 4.x to render with SassC'
|
187
|
+
end
|
243
188
|
|
244
|
-
|
245
|
-
|
246
|
-
|
189
|
+
# Backwards compatible means of finding all the latest gemspecs
|
190
|
+
# available on the system
|
191
|
+
#
|
192
|
+
# @private
|
193
|
+
# @return [Array] Array of latest Gem::Specification
|
194
|
+
def rubygems_latest_specs
|
195
|
+
# If newer Rubygems
|
196
|
+
if ::Gem::Specification.respond_to? :latest_specs
|
197
|
+
::Gem::Specification.latest_specs(true)
|
198
|
+
else
|
199
|
+
::Gem.source_index.latest_specs
|
200
|
+
end
|
201
|
+
end
|
247
202
|
|
248
|
-
|
249
|
-
|
250
|
-
|
203
|
+
# Add any directories from gems with Rails-like paths to sprockets load path
|
204
|
+
def append_paths_from_gems
|
205
|
+
root_paths = rubygems_latest_specs.map(&:full_gem_path) << app.root
|
206
|
+
base_paths = %w(assets app app/assets vendor vendor/assets lib lib/assets)
|
207
|
+
asset_dirs = %w(javascripts js stylesheets css images img fonts)
|
251
208
|
|
252
|
-
|
253
|
-
|
254
|
-
|
209
|
+
root_paths.product(base_paths.product(asset_dirs)).each do |root, (base, asset)|
|
210
|
+
path = File.join(root, base, asset)
|
211
|
+
environment.append_path(path) if File.directory?(path)
|
212
|
+
end
|
213
|
+
end
|
255
214
|
end
|
256
215
|
end
|
257
|
-
end
|
216
|
+
end
|