middleman-sprockets 3.0.10 → 3.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +0 -1
- data/Gemfile +9 -5
- data/Rakefile +8 -3
- data/features/asset_hash.feature +19 -16
- data/features/sass_partials.feature +3 -1
- data/features/sprockets.feature +11 -1
- data/features/sprockets_gems.feature +28 -5
- data/features/step_definitions/server_steps.rb +9 -1
- data/features/support/env.rb +4 -1
- data/fixtures/asset-hash-app/source/stylesheets/jquery-mobile.css.scss +1 -0
- data/fixtures/asset-paths-app/config.rb +4 -1
- data/fixtures/jquery-mobile-app/config.rb +0 -0
- data/fixtures/jquery-mobile-app/source/stylesheets/base.css.scss +2 -0
- data/fixtures/sprockets-images-app/config.rb +1 -0
- data/fixtures/sprockets-images-app/source/index.html.erb +10 -0
- 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/lib/middleman-sprockets/extension.rb +122 -30
- data/lib/middleman-sprockets/version.rb +1 -1
- data/middleman-sprockets.gemspec +1 -1
- metadata +19 -18
- data/lib/middleman-sprockets/sass.rb +0 -86
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
git "git://github.com/middleman/middleman.git", :branch => "
|
3
|
+
git "git://github.com/middleman/middleman.git", :branch => "master" do
|
4
4
|
gem "middleman"
|
5
5
|
gem "middleman-core"
|
6
6
|
gem "middleman-more"
|
7
7
|
end
|
8
|
+
#gem "middleman", :path => '../middleman'
|
8
9
|
|
9
10
|
# Specify your gem's dependencies in middleman-blog.gemspec
|
10
11
|
gemspec
|
@@ -14,13 +15,16 @@ gem "rake", "~> 10.0.3"
|
|
14
15
|
gem "yard", "~> 0.8.0"
|
15
16
|
|
16
17
|
# Test tools
|
17
|
-
gem "cucumber"
|
18
|
+
gem "cucumber"
|
18
19
|
gem "fivemat", "~> 1.1.0"
|
19
|
-
gem "aruba"
|
20
|
+
gem "aruba"
|
20
21
|
gem "rspec", "~> 2.12"
|
22
|
+
gem 'gherkin', '<= 2.11.6'
|
21
23
|
|
22
24
|
# For actual tests
|
23
|
-
gem "jquery-rails",
|
25
|
+
gem "jquery-rails", '2.0.1', :require => false
|
26
|
+
gem "bootstrap-sass", :require => false
|
24
27
|
gem "ejs", "~> 1.1.1"
|
25
28
|
gem "eco", "~> 1.0.0"
|
26
|
-
gem "erubis", "~> 2.7.0"
|
29
|
+
gem "erubis", "~> 2.7.0"
|
30
|
+
gem 'jquery_mobile_rails', '~>1.2.0', :require => false
|
data/Rakefile
CHANGED
@@ -4,16 +4,21 @@ Bundler::GemHelper.install_tasks
|
|
4
4
|
require 'cucumber/rake/task'
|
5
5
|
|
6
6
|
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
7
|
-
ENV["TEST"] = "true"
|
8
|
-
ENV["AUTOLOAD_SPROCKETS"] = "true"
|
9
7
|
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
|
10
8
|
end
|
11
9
|
|
12
10
|
require 'rake/clean'
|
13
11
|
|
14
|
-
task :test => ["cucumber"]
|
12
|
+
task :test => [:destroy_sass_cache, "cucumber"]
|
15
13
|
|
16
14
|
desc "Build HTML documentation"
|
17
15
|
task :doc do
|
18
16
|
sh 'bundle exec yard'
|
19
17
|
end
|
18
|
+
|
19
|
+
desc "Destroy the sass cache from fixtures in case it messes with results"
|
20
|
+
task :destroy_sass_cache do
|
21
|
+
Dir["fixtures/*/.sass-cache"].each do |dir|
|
22
|
+
rm_rf dir
|
23
|
+
end
|
24
|
+
end
|
data/features/asset_hash.feature
CHANGED
@@ -8,7 +8,7 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|
8
8
|
| images/100px-5fd6fb90.jpg |
|
9
9
|
| images/100px-5fd6fb90.gif |
|
10
10
|
| javascripts/application-df677242.js |
|
11
|
-
| stylesheets/site-
|
11
|
+
| stylesheets/site-b7f4d02f.css |
|
12
12
|
| index.html |
|
13
13
|
| subdir/index.html |
|
14
14
|
| other/index.html |
|
@@ -20,50 +20,51 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|
20
20
|
| stylesheets/site.css |
|
21
21
|
|
22
22
|
And the file "javascripts/application-df677242.js" should contain "img.src = '/images/100px-5fd6fb90.jpg'"
|
23
|
-
And the file "stylesheets/site-
|
24
|
-
And the file "index.html" should contain 'href="stylesheets/site-
|
23
|
+
And the file "stylesheets/site-b7f4d02f.css" should contain 'background-image: url("../images/100px-5fd6fb90.jpg")'
|
24
|
+
And the file "index.html" should contain 'href="stylesheets/site-b7f4d02f.css"'
|
25
25
|
And the file "index.html" should contain 'src="javascripts/application-df677242.js"'
|
26
26
|
And the file "index.html" should contain 'src="images/100px-5fd6fb90.jpg"'
|
27
|
-
And the file "subdir/index.html" should contain 'href="../stylesheets/site-
|
27
|
+
And the file "subdir/index.html" should contain 'href="../stylesheets/site-b7f4d02f.css"'
|
28
28
|
And the file "subdir/index.html" should contain 'src="../javascripts/application-df677242.js"'
|
29
29
|
And the file "subdir/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
30
|
-
And the file "other/index.html" should contain 'href="../stylesheets/site-
|
30
|
+
And the file "other/index.html" should contain 'href="../stylesheets/site-b7f4d02f.css"'
|
31
31
|
And the file "other/index.html" should contain 'src="../javascripts/application-df677242.js"'
|
32
32
|
And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
33
33
|
|
34
34
|
Scenario: Hashed assets work in preview server
|
35
35
|
Given the Server is running at "asset-hash-app"
|
36
36
|
When I go to "/"
|
37
|
-
Then I should see 'href="stylesheets/site-
|
37
|
+
Then I should see 'href="stylesheets/site-b7f4d02f.css"'
|
38
38
|
And I should see 'src="javascripts/application-df677242.js"'
|
39
39
|
And I should see 'src="images/100px-5fd6fb90.jpg"'
|
40
40
|
When I go to "/subdir/"
|
41
|
-
Then I should see 'href="../stylesheets/site-
|
41
|
+
Then I should see 'href="../stylesheets/site-b7f4d02f.css"'
|
42
42
|
And I should see 'src="../javascripts/application-df677242.js"'
|
43
43
|
And I should see 'src="../images/100px-5fd6fb90.jpg"'
|
44
44
|
When I go to "/other/"
|
45
|
-
Then I should see 'href="../stylesheets/site-
|
45
|
+
Then I should see 'href="../stylesheets/site-b7f4d02f.css"'
|
46
46
|
And I should see 'src="../javascripts/application-df677242.js"'
|
47
47
|
And I should see 'src="../images/100px-5fd6fb90.jpg"'
|
48
48
|
When I go to "/javascripts/application-df677242.js"
|
49
49
|
Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
|
50
|
-
When I go to "/stylesheets/site-
|
51
|
-
Then I should see
|
50
|
+
When I go to "/stylesheets/site-b7f4d02f.css"
|
51
|
+
Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg")'
|
52
|
+
When I go to "/stylesheets/jquery-mobile-67e48856.css"
|
53
|
+
Then I should see 'background-image: url("../images/jquery-mobile/icons-18-white-4a0ff57b.png")'
|
52
54
|
|
53
55
|
Scenario: Enabling an asset host still produces hashed files and references
|
54
56
|
Given the Server is running at "asset-hash-host-app"
|
55
57
|
When I go to "/"
|
56
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
58
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-1fdf4fb5.css"'
|
57
59
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
58
60
|
When I go to "/subdir/"
|
59
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
61
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-1fdf4fb5.css"'
|
60
62
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
61
63
|
When I go to "/other/"
|
62
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
64
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-1fdf4fb5.css"'
|
63
65
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
64
|
-
|
65
|
-
|
66
|
-
# Then I should see "background-image: url('http://middlemanapp.com/images/100px-5fd6fb90.jpg')"
|
66
|
+
When I go to "/stylesheets/site-1fdf4fb5.css"
|
67
|
+
Then I should see 'background-image: url("http://middlemanapp.com/images/100px-5fd6fb90.jpg")'
|
67
68
|
|
68
69
|
Scenario: The asset hash should change when a SASS partial changes
|
69
70
|
Given the Server is running at "asset-hash-app"
|
@@ -74,6 +75,7 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|
74
75
|
"""
|
75
76
|
When I go to "/partials/"
|
76
77
|
Then I should see 'href="../stylesheets/uses_partials-423a00f7.css'
|
78
|
+
And wait a second
|
77
79
|
And the file "source/stylesheets/_partial.sass" has the contents
|
78
80
|
"""
|
79
81
|
body
|
@@ -92,6 +94,7 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|
92
94
|
Then I should see 'src="../javascripts/sprockets_base-0252a861.js'
|
93
95
|
When I go to "/javascripts/sprockets_base-0252a861.js"
|
94
96
|
Then I should see "sprockets_sub_function"
|
97
|
+
And wait a second
|
95
98
|
And the file "source/javascripts/sprockets_sub.js" has the contents
|
96
99
|
"""
|
97
100
|
function sprockets_sub2_function() { }
|
@@ -17,6 +17,7 @@ Feature: Sass partials should work with Sprockets
|
|
17
17
|
When I go to "/stylesheets/main2.css"
|
18
18
|
Then I should see "color: red;"
|
19
19
|
Then I should see "font-size: 14px"
|
20
|
+
And wait a second
|
20
21
|
And the file "source/stylesheets/main2.css.sass" has the contents
|
21
22
|
"""
|
22
23
|
//= require "_partial2.css.sass"
|
@@ -30,5 +31,6 @@ Feature: Sass partials should work with Sprockets
|
|
30
31
|
font-size: 18px
|
31
32
|
"""
|
32
33
|
When I go to "/stylesheets/main2.css"
|
33
|
-
|
34
|
+
When I go to "/stylesheets/main2.css"
|
35
|
+
Then I should see "color: blue;"
|
34
36
|
Then I should see "font-size: 18px"
|
data/features/sprockets.feature
CHANGED
@@ -73,4 +73,14 @@ Feature: Sprockets
|
|
73
73
|
Scenario: Sprockets CSS require with custom :css_dir @import
|
74
74
|
Given the Server is running at "sprockets-app"
|
75
75
|
When I go to "/library/css/sprockets_base2.css"
|
76
|
-
Then I should see "hello"
|
76
|
+
Then I should see "hello"
|
77
|
+
|
78
|
+
Scenario: Sprockets inline Images with asset_path and image_path helpers
|
79
|
+
Given the Server is running at "sprockets-images-app"
|
80
|
+
When I go to "/"
|
81
|
+
Then I should see 'src="/library/images/cat.jpg"'
|
82
|
+
And I should see 'src="/library/images/cat-2.jpg"'
|
83
|
+
When I go to "/library/images/cat.jpg"
|
84
|
+
Then I should get a response with status "200"
|
85
|
+
When I go to "/library/images/cat-2.jpg"
|
86
|
+
Then I should get a response with status "200"
|
@@ -4,10 +4,10 @@ Feature: Sprockets Gems
|
|
4
4
|
When I go to "/library/js/jquery_include.js"
|
5
5
|
Then I should see "var jQuery ="
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
Scenario: Sprockets can pull CSS from gem
|
8
|
+
Given the Server is running at "sprockets-app"
|
9
|
+
When I go to "/library/css/bootstrap_include.css"
|
10
|
+
Then I should see ".btn-mini"
|
11
11
|
|
12
12
|
Scenario: Sprockets can pull js from vendored assets
|
13
13
|
Given the Server is running at "sprockets-app"
|
@@ -17,4 +17,27 @@ Feature: Sprockets Gems
|
|
17
17
|
Scenario: Sprockets can pull js from custom vendor dir
|
18
18
|
Given the Server is running at "asset-paths-app"
|
19
19
|
When I go to "/javascripts/vendored_include.js"
|
20
|
-
Then I should see "var vendored_js_included = true;"
|
20
|
+
Then I should see "var vendored_js_included = true;"
|
21
|
+
|
22
|
+
Scenario: Proper reference to images from a gem, in preview
|
23
|
+
Given the Server is running at "jquery-mobile-app"
|
24
|
+
When I go to "/stylesheets/base.css"
|
25
|
+
Then I should see 'url("/images/jquery-mobile/icons-36-white.png")'
|
26
|
+
|
27
|
+
Scenario: Proper reference to images from a gem, in build
|
28
|
+
Given a successfully built app at "jquery-mobile-app"
|
29
|
+
When I cd to "build"
|
30
|
+
Then the following files should exist:
|
31
|
+
| stylesheets/base.css |
|
32
|
+
| images/jquery-mobile/icons-36-white.png |
|
33
|
+
And the file "stylesheets/base.css" should contain 'url("/images/jquery-mobile/icons-36-white.png")'
|
34
|
+
|
35
|
+
Scenario: Same thing, but with :relative_assets on
|
36
|
+
Given a fixture app "jquery-mobile-app"
|
37
|
+
And a file named "config.rb" with:
|
38
|
+
"""
|
39
|
+
activate :relative_assets
|
40
|
+
"""
|
41
|
+
Given the Server is running at "jquery-mobile-app"
|
42
|
+
When I go to "/stylesheets/base.css"
|
43
|
+
Then I should see 'url("../images/jquery-mobile/icons-36-white.png")'
|
@@ -1,3 +1,11 @@
|
|
1
1
|
Then /^I should see$/ do |contents|
|
2
2
|
@browser.last_response.body.should include(contents)
|
3
|
-
end
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^I should get a response with status "(.*?)"$/ do |status|
|
6
|
+
@browser.last_response.status.should == status.to_i
|
7
|
+
end
|
8
|
+
|
9
|
+
Given /^wait a second$/ do
|
10
|
+
sleep(1)
|
11
|
+
end
|
data/features/support/env.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
|
2
|
+
ENV['TEST'] = 'true'
|
3
|
+
ENV["AUTOLOAD_SPROCKETS"] = "true"
|
2
4
|
require "middleman-core"
|
3
5
|
require "middleman-core/step_definitions"
|
4
6
|
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-sprockets')
|
5
|
-
require "erubis"
|
7
|
+
require "erubis"
|
8
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require jquery.mobile.theme
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
set :images_dir, "library/images"
|
Binary file
|
Binary file
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "sprockets"
|
2
|
+
require "sprockets-sass"
|
2
3
|
|
3
4
|
# Sprockets extension
|
4
5
|
module Middleman::Sprockets
|
@@ -8,25 +9,15 @@ module Middleman::Sprockets
|
|
8
9
|
|
9
10
|
# Once registered
|
10
11
|
def registered(app)
|
11
|
-
# Location of javascripts external to source directory.
|
12
|
-
# @return [Array]
|
13
|
-
# set :js_assets_paths, ["#{root}/assets/javascripts/", "/path/2/external/js/repository/"]
|
14
|
-
|
15
12
|
# Add class methods to context
|
16
13
|
app.send :include, InstanceMethods
|
17
|
-
|
18
|
-
require "middleman-sprockets/sass"
|
19
|
-
app.register Middleman::Sprockets::Sass
|
20
14
|
|
21
15
|
app.after_configuration do
|
22
16
|
helpers JavascriptTagHelper
|
23
|
-
end
|
24
17
|
|
25
|
-
# Once Middleman is setup
|
26
|
-
app.after_configuration do
|
27
18
|
::Tilt.register ::Sprockets::EjsTemplate, 'ejs'
|
28
19
|
::Tilt.register ::Sprockets::EcoTemplate, 'eco'
|
29
|
-
|
20
|
+
|
30
21
|
# Add any gems with (vendor|app|.)/assets/javascripts to paths
|
31
22
|
# also add similar directories from project root (like in rails)
|
32
23
|
try_paths = [
|
@@ -38,7 +29,12 @@ module Middleman::Sprockets
|
|
38
29
|
%w{ lib },
|
39
30
|
%w{ lib assets }
|
40
31
|
].inject([]) do |sum, v|
|
41
|
-
sum + [
|
32
|
+
sum + [
|
33
|
+
File.join(v, 'javascripts'),
|
34
|
+
File.join(v, 'stylesheets'),
|
35
|
+
File.join(v, 'images'),
|
36
|
+
File.join(v, 'fonts')
|
37
|
+
]
|
42
38
|
end
|
43
39
|
|
44
40
|
([root] + ::Middleman.rubygems_latest_specs.map(&:full_gem_path)).each do |root_path|
|
@@ -52,9 +48,14 @@ module Middleman::Sprockets
|
|
52
48
|
|
53
49
|
# Intercept requests to /javascripts and /stylesheets and pass to sprockets
|
54
50
|
our_sprockets = sprockets
|
55
|
-
|
51
|
+
|
56
52
|
map("/#{js_dir}") { run our_sprockets }
|
57
53
|
map("/#{css_dir}") { run our_sprockets }
|
54
|
+
map("/#{images_dir}") { run our_sprockets }
|
55
|
+
map("/#{fonts_dir}") { run our_sprockets }
|
56
|
+
|
57
|
+
# register resource list manipulator to add assets_load_paths to sitemap
|
58
|
+
sitemap.register_resource_list_manipulator(:assets_load_paths, SitemapExtension.new(self), false)
|
58
59
|
end
|
59
60
|
end
|
60
61
|
alias :included :registered
|
@@ -78,23 +79,59 @@ module Middleman::Sprockets
|
|
78
79
|
context_class.send(:define_method, :app) { app }
|
79
80
|
|
80
81
|
context_class.class_eval do
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
def asset_path(path, options={})
|
83
|
+
# Handle people calling with the Middleman/Padrino asset path signature
|
84
|
+
if path.is_a?(::Symbol) && !options.is_a?(::Hash)
|
85
|
+
return app.asset_path(path, options)
|
86
|
+
end
|
87
|
+
|
88
|
+
kind = case options[:type]
|
89
|
+
when :image then :images
|
90
|
+
when :font then :fonts
|
91
|
+
when :javascript then :js
|
92
|
+
when :stylesheet then :css
|
93
|
+
else options[:type]
|
94
|
+
end
|
95
|
+
|
96
|
+
app.asset_path(kind, path)
|
97
|
+
end
|
98
|
+
|
99
|
+
# These helpers are already defined in later versions of Sprockets, but we define
|
100
|
+
# them ourself to help older versions and to provide extra options that Sass wants.
|
101
|
+
|
102
|
+
# Expand logical image asset path.
|
103
|
+
def image_path(path, options={})
|
104
|
+
asset_path(path, :type => :image)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Expand logical font asset path.
|
108
|
+
def font_path(path, options={})
|
109
|
+
asset_path(path, :type => :font)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Expand logical javascript asset path.
|
113
|
+
def javascript_path(path, options={})
|
114
|
+
asset_path(path, :type => :javascript)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Expand logical stylesheet asset path.
|
118
|
+
def stylesheet_path(path, options={})
|
119
|
+
asset_path(path, :type => :stylesheet)
|
84
120
|
end
|
85
121
|
|
86
122
|
def method_missing(*args)
|
87
123
|
name = args.first
|
88
124
|
if app.respond_to?(name)
|
89
|
-
# Set the middleman application current path, since it won't
|
90
|
-
# be set if the request came in through Sprockets and helpers
|
91
|
-
# won't work without it.
|
92
|
-
app.current_path = mm_path unless app.current_path
|
93
125
|
app.send(*args)
|
94
126
|
else
|
95
127
|
super
|
96
128
|
end
|
97
129
|
end
|
130
|
+
|
131
|
+
# Needed so that method_missing makes sense
|
132
|
+
def respond_to?(method, include_private = false)
|
133
|
+
super || app.respond_to?(method, include_private)
|
134
|
+
end
|
98
135
|
end
|
99
136
|
|
100
137
|
# Remove compressors, we handle these with middleware
|
@@ -104,14 +141,16 @@ module Middleman::Sprockets
|
|
104
141
|
# configure search paths
|
105
142
|
append_path app.js_dir
|
106
143
|
append_path app.css_dir
|
144
|
+
append_path app.images_dir
|
145
|
+
append_path app.fonts_dir
|
107
146
|
|
108
147
|
# add custom assets paths to the scope
|
109
|
-
|
110
148
|
app.js_assets_paths.each do |p|
|
149
|
+
warn ":js_assets_paths is deprecated. Call sprockets.append_path instead."
|
111
150
|
append_path p
|
112
151
|
end if app.respond_to?(:js_assets_paths)
|
113
152
|
|
114
|
-
# Stylus support
|
153
|
+
# Stylus support
|
115
154
|
if defined?(::Stylus)
|
116
155
|
require 'stylus/sprockets'
|
117
156
|
::Stylus.setup(self, app.styl)
|
@@ -128,18 +167,42 @@ module Middleman::Sprockets
|
|
128
167
|
@digest.dup
|
129
168
|
end
|
130
169
|
|
131
|
-
#
|
170
|
+
# Invalidate sitemap when users mess with the sprockets load paths
|
171
|
+
def append_path(*args)
|
172
|
+
@app.sitemap.rebuild_resource_list!(:sprockets_paths)
|
173
|
+
super
|
174
|
+
end
|
175
|
+
|
176
|
+
def prepend_path(*args)
|
177
|
+
@app.sitemap.rebuild_resource_list!(:sprockets_paths)
|
178
|
+
super
|
179
|
+
end
|
180
|
+
|
181
|
+
def clear_paths
|
182
|
+
@app.sitemap.rebuild_resource_list!(:sprockets_paths)
|
183
|
+
super
|
184
|
+
end
|
185
|
+
|
186
|
+
def css_exception_response(exception)
|
187
|
+
raise exception if @app.build?
|
188
|
+
super
|
189
|
+
end
|
190
|
+
|
132
191
|
def javascript_exception_response(exception)
|
133
|
-
|
134
|
-
super
|
192
|
+
raise exception if @app.build?
|
193
|
+
super
|
135
194
|
end
|
136
195
|
|
137
|
-
|
138
|
-
|
196
|
+
def call(env)
|
197
|
+
# Set the app current path based on the full URL so that helpers work
|
198
|
+
full_path = File.join(env['SCRIPT_NAME'], env['PATH_INFO'])
|
199
|
+
@app.current_path = ::Middleman::Util.normalize_path(full_path)
|
200
|
+
super
|
201
|
+
end
|
139
202
|
end
|
140
|
-
|
203
|
+
|
141
204
|
module JavascriptTagHelper
|
142
|
-
|
205
|
+
|
143
206
|
# extend padrinos javascript_include_tag with debug functionality
|
144
207
|
# splits up script dependencies in individual files when
|
145
208
|
# configuration variable :debug_assets is set to true
|
@@ -153,7 +216,7 @@ module Middleman::Sprockets
|
|
153
216
|
dependencies_paths = sprockets[source].to_a.map do |dependency|
|
154
217
|
# if sprockets sees "?body=1" it only gives back the body
|
155
218
|
# of the script without the dependencies included
|
156
|
-
dependency.logical_path << "?body=1"
|
219
|
+
dependency.logical_path << "?body=1" unless dependency.logical_path.end_with?("?body=1")
|
157
220
|
end
|
158
221
|
|
159
222
|
super(dependencies_paths, options)
|
@@ -163,4 +226,33 @@ module Middleman::Sprockets
|
|
163
226
|
end
|
164
227
|
end
|
165
228
|
end
|
229
|
+
|
230
|
+
class SitemapExtension
|
231
|
+
def initialize(app)
|
232
|
+
@app = app
|
233
|
+
end
|
234
|
+
|
235
|
+
# Add sitemap resource for every image in the sprockets load path
|
236
|
+
def manipulate_resource_list(resources)
|
237
|
+
resources_list = []
|
238
|
+
@app.sprockets.paths.each do |load_path|
|
239
|
+
output_dir = nil
|
240
|
+
if load_path.end_with?('/images')
|
241
|
+
output_dir = @app.images_dir
|
242
|
+
elsif load_path.end_with?('/fonts')
|
243
|
+
output_dir = @app.fonts_dir
|
244
|
+
end
|
245
|
+
|
246
|
+
if output_dir
|
247
|
+
@app.sprockets.each_entry(load_path) do |path|
|
248
|
+
next unless path.file?
|
249
|
+
base_path = path.sub("#{load_path}/", '')
|
250
|
+
new_path = File.join(output_dir, base_path)
|
251
|
+
resources_list << ::Middleman::Sitemap::Resource.new(@app.sitemap, new_path.to_s, path.to_s)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
resources + resources_list
|
256
|
+
end
|
257
|
+
end
|
166
258
|
end
|
data/middleman-sprockets.gemspec
CHANGED
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
s.add_dependency("middleman-more", [">= 3.0.11"])
|
22
|
-
s.add_dependency("sprockets", ["~> 2.1"
|
22
|
+
s.add_dependency("sprockets", ["~> 2.1"])
|
23
23
|
s.add_dependency("sprockets-sass", ["~> 0.9.1"])
|
24
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-sprockets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: middleman-more
|
@@ -35,9 +35,6 @@ dependencies:
|
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '2.1'
|
38
|
-
- - <
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2.5'
|
41
38
|
type: :runtime
|
42
39
|
prerelease: false
|
43
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -46,9 +43,6 @@ dependencies:
|
|
46
43
|
- - ~>
|
47
44
|
- !ruby/object:Gem::Version
|
48
45
|
version: '2.1'
|
49
|
-
- - <
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: '2.5'
|
52
46
|
- !ruby/object:Gem::Dependency
|
53
47
|
name: sprockets-sass
|
54
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,6 +92,7 @@ files:
|
|
98
92
|
- fixtures/asset-hash-app/source/other.html.erb
|
99
93
|
- fixtures/asset-hash-app/source/partials.html.erb
|
100
94
|
- fixtures/asset-hash-app/source/stylesheets/_partial.sass
|
95
|
+
- fixtures/asset-hash-app/source/stylesheets/jquery-mobile.css.scss
|
101
96
|
- fixtures/asset-hash-app/source/stylesheets/site.css.scss
|
102
97
|
- fixtures/asset-hash-app/source/stylesheets/uses_partials.css.sass
|
103
98
|
- fixtures/asset-hash-app/source/subdir/index.html.erb
|
@@ -119,6 +114,8 @@ files:
|
|
119
114
|
- fixtures/glob-app/source/stylesheets/module2/_derp.sass
|
120
115
|
- fixtures/glob-app/source/stylesheets/shared/3rd-party/bootstrap.sass
|
121
116
|
- fixtures/glob-app/source/stylesheets/shared/shared.scss
|
117
|
+
- fixtures/jquery-mobile-app/config.rb
|
118
|
+
- fixtures/jquery-mobile-app/source/stylesheets/base.css.scss
|
122
119
|
- fixtures/preview-app/config.rb
|
123
120
|
- fixtures/preview-app/source/content.html.erb
|
124
121
|
- fixtures/preview-app/source/layout.erb
|
@@ -132,9 +129,6 @@ files:
|
|
132
129
|
- fixtures/sprockets-app-debug-assets/source/javascripts/dependency1.js
|
133
130
|
- fixtures/sprockets-app-debug-assets/source/javascripts/dependency2.js
|
134
131
|
- fixtures/sprockets-app-debug-assets/source/javascripts/main.js
|
135
|
-
- fixtures/sprockets-app/.sass-cache/be37f3d65d619a3996ff80c3e286084336419f31/bootstrap_include.css.scssc
|
136
|
-
- fixtures/sprockets-app/.sass-cache/be37f3d65d619a3996ff80c3e286084336419f31/sprockets_base1.css.scssc
|
137
|
-
- fixtures/sprockets-app/.sass-cache/be37f3d65d619a3996ff80c3e286084336419f31/sprockets_base2.css.scssc
|
138
132
|
- fixtures/sprockets-app/config.rb
|
139
133
|
- fixtures/sprockets-app/source/index.html.erb
|
140
134
|
- fixtures/sprockets-app/source/library/css/bootstrap_include.css.scss
|
@@ -161,9 +155,12 @@ files:
|
|
161
155
|
- fixtures/sprockets-app2/source/stylesheets/sprockets_base1.css.scss
|
162
156
|
- fixtures/sprockets-app2/source/stylesheets/sprockets_base2.css.scss
|
163
157
|
- fixtures/sprockets-app2/source/stylesheets/sprockets_sub.css.scss
|
158
|
+
- fixtures/sprockets-images-app/config.rb
|
159
|
+
- fixtures/sprockets-images-app/source/index.html.erb
|
160
|
+
- fixtures/sprockets-images-app/source/library/images/cat.jpg
|
161
|
+
- fixtures/sprockets-images-app/vendor/assets/images/cat-2.jpg
|
164
162
|
- lib/middleman-sprockets.rb
|
165
163
|
- lib/middleman-sprockets/extension.rb
|
166
|
-
- lib/middleman-sprockets/sass.rb
|
167
164
|
- lib/middleman-sprockets/version.rb
|
168
165
|
- lib/middleman_extension.rb
|
169
166
|
- middleman-sprockets.gemspec
|
@@ -181,7 +178,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
178
|
version: '0'
|
182
179
|
segments:
|
183
180
|
- 0
|
184
|
-
hash:
|
181
|
+
hash: -471944256885700963
|
185
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
183
|
none: false
|
187
184
|
requirements:
|
@@ -190,10 +187,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
187
|
version: '0'
|
191
188
|
segments:
|
192
189
|
- 0
|
193
|
-
hash:
|
190
|
+
hash: -471944256885700963
|
194
191
|
requirements: []
|
195
192
|
rubyforge_project: middleman-sprockets
|
196
|
-
rubygems_version: 1.8.
|
193
|
+
rubygems_version: 1.8.24
|
197
194
|
signing_key:
|
198
195
|
specification_version: 3
|
199
196
|
summary: Sprockets support for Middleman
|
@@ -218,6 +215,7 @@ test_files:
|
|
218
215
|
- fixtures/asset-hash-app/source/other.html.erb
|
219
216
|
- fixtures/asset-hash-app/source/partials.html.erb
|
220
217
|
- fixtures/asset-hash-app/source/stylesheets/_partial.sass
|
218
|
+
- fixtures/asset-hash-app/source/stylesheets/jquery-mobile.css.scss
|
221
219
|
- fixtures/asset-hash-app/source/stylesheets/site.css.scss
|
222
220
|
- fixtures/asset-hash-app/source/stylesheets/uses_partials.css.sass
|
223
221
|
- fixtures/asset-hash-app/source/subdir/index.html.erb
|
@@ -239,6 +237,8 @@ test_files:
|
|
239
237
|
- fixtures/glob-app/source/stylesheets/module2/_derp.sass
|
240
238
|
- fixtures/glob-app/source/stylesheets/shared/3rd-party/bootstrap.sass
|
241
239
|
- fixtures/glob-app/source/stylesheets/shared/shared.scss
|
240
|
+
- fixtures/jquery-mobile-app/config.rb
|
241
|
+
- fixtures/jquery-mobile-app/source/stylesheets/base.css.scss
|
242
242
|
- fixtures/preview-app/config.rb
|
243
243
|
- fixtures/preview-app/source/content.html.erb
|
244
244
|
- fixtures/preview-app/source/layout.erb
|
@@ -252,9 +252,6 @@ test_files:
|
|
252
252
|
- fixtures/sprockets-app-debug-assets/source/javascripts/dependency1.js
|
253
253
|
- fixtures/sprockets-app-debug-assets/source/javascripts/dependency2.js
|
254
254
|
- fixtures/sprockets-app-debug-assets/source/javascripts/main.js
|
255
|
-
- fixtures/sprockets-app/.sass-cache/be37f3d65d619a3996ff80c3e286084336419f31/bootstrap_include.css.scssc
|
256
|
-
- fixtures/sprockets-app/.sass-cache/be37f3d65d619a3996ff80c3e286084336419f31/sprockets_base1.css.scssc
|
257
|
-
- fixtures/sprockets-app/.sass-cache/be37f3d65d619a3996ff80c3e286084336419f31/sprockets_base2.css.scssc
|
258
255
|
- fixtures/sprockets-app/config.rb
|
259
256
|
- fixtures/sprockets-app/source/index.html.erb
|
260
257
|
- fixtures/sprockets-app/source/library/css/bootstrap_include.css.scss
|
@@ -281,4 +278,8 @@ test_files:
|
|
281
278
|
- fixtures/sprockets-app2/source/stylesheets/sprockets_base1.css.scss
|
282
279
|
- fixtures/sprockets-app2/source/stylesheets/sprockets_base2.css.scss
|
283
280
|
- fixtures/sprockets-app2/source/stylesheets/sprockets_sub.css.scss
|
281
|
+
- fixtures/sprockets-images-app/config.rb
|
282
|
+
- fixtures/sprockets-images-app/source/index.html.erb
|
283
|
+
- fixtures/sprockets-images-app/source/library/images/cat.jpg
|
284
|
+
- fixtures/sprockets-images-app/vendor/assets/images/cat-2.jpg
|
284
285
|
has_rdoc:
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require "sprockets-sass"
|
2
|
-
|
3
|
-
module Middleman
|
4
|
-
module Sprockets
|
5
|
-
|
6
|
-
# Sass renderer
|
7
|
-
module Sass
|
8
|
-
|
9
|
-
# Setup extension
|
10
|
-
class << self
|
11
|
-
|
12
|
-
# Once registered
|
13
|
-
def registered(app)
|
14
|
-
|
15
|
-
# Stick with Compass' asset functions
|
16
|
-
::Sprockets::Sass.add_sass_functions = false
|
17
|
-
|
18
|
-
# Tell Sprockets to use our custom Sass template
|
19
|
-
::Sprockets.register_engine ".sass", SassPlusCSSFilenameTemplate
|
20
|
-
|
21
|
-
# Tell Tilt to use it as well (for inline sass blocks)
|
22
|
-
::Tilt.register 'sass', SassPlusCSSFilenameTemplate
|
23
|
-
::Tilt.prefer(SassPlusCSSFilenameTemplate)
|
24
|
-
|
25
|
-
# Tell Sprockets to use our custom Scss template
|
26
|
-
::Sprockets.register_engine ".scss", ScssPlusCSSFilenameTemplate
|
27
|
-
|
28
|
-
# Tell Tilt to use it as well (for inline scss blocks)
|
29
|
-
::Tilt.register 'scss', ScssPlusCSSFilenameTemplate
|
30
|
-
::Tilt.prefer(ScssPlusCSSFilenameTemplate)
|
31
|
-
end
|
32
|
-
|
33
|
-
alias :included :registered
|
34
|
-
end
|
35
|
-
|
36
|
-
# A SassTemplate for Sprockets/Tilt which outputs debug messages
|
37
|
-
class SassPlusCSSFilenameTemplate < ::Sprockets::Sass::SassTemplate
|
38
|
-
self.default_mime_type = 'text/css'
|
39
|
-
|
40
|
-
# Add exception messaging
|
41
|
-
# @param [Class] context
|
42
|
-
# @param [Hash] locals
|
43
|
-
# @return [String]
|
44
|
-
def evaluate(context, locals, &block)
|
45
|
-
begin
|
46
|
-
super
|
47
|
-
rescue ::Sass::SyntaxError => e
|
48
|
-
::Sass::SyntaxError.exception_to_css(e, :full_exception => true)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
protected
|
53
|
-
def cache_store
|
54
|
-
nil
|
55
|
-
end
|
56
|
-
|
57
|
-
# Change Sass path, for url functions, to the build folder if we're building
|
58
|
-
# @return [Hash]
|
59
|
-
def sass_options
|
60
|
-
orig = super
|
61
|
-
|
62
|
-
if context && context.app
|
63
|
-
location_of_sass_file = File.expand_path(context.app.source, context.app.root)
|
64
|
-
css_dir = File.join(location_of_sass_file, context.app.css_dir)
|
65
|
-
css_filename = File.expand_path(file, css_dir)
|
66
|
-
orig.merge!(:css_filename => css_filename)
|
67
|
-
end
|
68
|
-
|
69
|
-
orig
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# SCSS version of the above template
|
74
|
-
class ScssPlusCSSFilenameTemplate < SassPlusCSSFilenameTemplate
|
75
|
-
self.default_mime_type = 'text/css'
|
76
|
-
|
77
|
-
# Define the expected syntax for the template
|
78
|
-
# @return [Symbol]
|
79
|
-
def syntax
|
80
|
-
:scss
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|