middleman-more 3.0.0.beta.1 → 3.0.0.beta.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.
- data/Rakefile +1 -0
- data/features/asset_hash.feature +84 -0
- data/features/cache_buster.feature +5 -4
- data/features/coffee-script.feature +2 -2
- data/features/compass-sprites.feature +6 -0
- data/features/gzip.feature +21 -0
- data/features/{ignore_already_minified.features → ignore_already_minified.feature} +0 -0
- data/features/minify_css.feature +50 -2
- data/features/minify_javascript.feature +89 -6
- data/features/relative_assets.feature +47 -6
- data/features/sass_partials.feature +5 -1
- data/features/sprockets_gems.feature +7 -2
- data/fixtures/asset-hash-app/config.rb +8 -0
- data/fixtures/asset-hash-app/source/images/100px.gif +0 -0
- data/fixtures/asset-hash-app/source/images/100px.jpg +0 -0
- data/fixtures/asset-hash-app/source/images/100px.png +0 -0
- data/fixtures/asset-hash-app/source/index.html.erb +308 -0
- data/fixtures/asset-hash-app/source/javascripts/application.js +8 -0
- data/fixtures/asset-hash-app/source/layout.erb +18 -0
- data/fixtures/asset-hash-app/source/other.html.erb +2 -0
- data/fixtures/asset-hash-app/source/partials.html.erb +1 -0
- data/fixtures/asset-hash-app/source/stylesheets/_partial.sass +2 -0
- data/fixtures/asset-hash-app/source/stylesheets/site.css.scss +4 -0
- data/fixtures/asset-hash-app/source/stylesheets/uses_partials.css.sass +4 -0
- data/fixtures/asset-hash-app/source/subdir/index.html.erb +308 -0
- data/fixtures/asset-hash-host-app/config.rb +6 -0
- data/fixtures/asset-hash-host-app/source/images/100px.gif +0 -0
- data/fixtures/asset-hash-host-app/source/images/100px.jpg +0 -0
- data/fixtures/asset-hash-host-app/source/images/100px.png +0 -0
- data/fixtures/asset-hash-host-app/source/index.html.erb +6 -0
- data/fixtures/asset-hash-host-app/source/layout.erb +17 -0
- data/fixtures/asset-hash-host-app/source/other.html.erb +2 -0
- data/fixtures/asset-hash-host-app/source/stylesheets/site.css.scss +4 -0
- data/fixtures/asset-hash-host-app/source/subdir/index.html.erb +6 -0
- data/fixtures/cache-buster-app/source/cache-buster.html.erb +2 -1
- data/fixtures/compass-sprites-app/config.rb +0 -0
- data/fixtures/compass-sprites-app/source/images/icon/arrow_down.png +0 -0
- data/fixtures/compass-sprites-app/source/images/icon/arrow_left.png +0 -0
- data/fixtures/compass-sprites-app/source/images/icon/arrow_right.png +0 -0
- data/fixtures/compass-sprites-app/source/images/icon/arrow_up.png +0 -0
- data/fixtures/compass-sprites-app/source/stylesheets/site.css.scss +3 -0
- data/fixtures/gzip-app/config.rb +1 -0
- data/fixtures/gzip-app/source/index.html +0 -0
- data/fixtures/gzip-app/source/javascripts/test.js +1 -0
- data/fixtures/gzip-app/source/stylesheets/test.css +1 -0
- data/fixtures/minify-css-app/source/inline-css.html.haml +5 -0
- data/fixtures/minify-css-app/source/more-css/site.css +3 -0
- data/fixtures/minify-css-app/source/stylesheets/site.css.sass +5 -1
- data/fixtures/minify-js-app/config.rb +1 -1
- data/fixtures/minify-js-app/source/inline-js.html.haml +22 -1
- data/fixtures/minify-js-app/source/more-js/other.js +8 -0
- data/fixtures/passthrough-app/config.rb +4 -4
- data/fixtures/passthrough-app/source/inline-css.html.haml +5 -4
- data/fixtures/passthrough-app/source/inline-js.html.haml +22 -1
- data/fixtures/relative-assets-app/config.rb +1 -0
- data/fixtures/relative-assets-app/source/relative_image.html.erb +8 -1
- data/fixtures/sprockets-app/source/library/js/vendored_include.js +1 -0
- data/fixtures/sprockets-app/vendor/assets/javascripts/vendored_js.js +1 -0
- data/lib/middleman-more.rb +23 -9
- data/lib/middleman-more/core_extensions/compass.rb +22 -38
- data/lib/middleman-more/core_extensions/sprockets.rb +41 -123
- data/lib/middleman-more/extensions/asset_hash.rb +132 -0
- data/lib/middleman-more/extensions/cache_buster.rb +5 -6
- data/lib/middleman-more/extensions/gzip.rb +57 -0
- data/lib/middleman-more/extensions/minify_css.rb +73 -7
- data/lib/middleman-more/extensions/minify_css/rainpress.rb +168 -0
- data/lib/middleman-more/extensions/minify_javascript.rb +45 -21
- data/lib/middleman-more/extensions/relative_assets.rb +2 -1
- data/lib/middleman-more/renderers/haml.rb +4 -0
- data/lib/middleman-more/renderers/liquid.rb +6 -1
- data/lib/middleman-more/renderers/markdown.rb +10 -1
- data/lib/middleman-more/renderers/sass.rb +12 -6
- data/lib/middleman-more/renderers/slim.rb +5 -0
- data/middleman-more.gemspec +9 -9
- metadata +192 -178
- data/lib/middleman-more/extensions/minify_css/cssmin.rb +0 -55
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
|
|
6
|
+
<%= stylesheet_link_tag "site" %>
|
|
7
|
+
<%= yield_content :head %>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body class="<%= page_classes %>">
|
|
11
|
+
|
|
12
|
+
<div id="main" role="main">
|
|
13
|
+
<%= yield %>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
activate :gzip
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function test_function() {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
test_selector {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require "coffee-filter"
|
|
1
|
+
require "coffee-filter"
|
|
@@ -4,4 +4,25 @@
|
|
|
4
4
|
should();
|
|
5
5
|
all.be();
|
|
6
6
|
on = { one: line };
|
|
7
|
-
})();
|
|
7
|
+
})();
|
|
8
|
+
|
|
9
|
+
%script
|
|
10
|
+
:plain
|
|
11
|
+
;(function() {
|
|
12
|
+
this;
|
|
13
|
+
should();
|
|
14
|
+
too();
|
|
15
|
+
})();
|
|
16
|
+
|
|
17
|
+
%script(type="text/javascript")
|
|
18
|
+
:plain
|
|
19
|
+
//<!--
|
|
20
|
+
;(function() {
|
|
21
|
+
one;
|
|
22
|
+
line();
|
|
23
|
+
here();
|
|
24
|
+
})();
|
|
25
|
+
//-->
|
|
26
|
+
|
|
27
|
+
%script(type="text/html")
|
|
28
|
+
I'm a jQuery {{template}}.
|
|
@@ -4,14 +4,14 @@ module ::PassThrough
|
|
|
4
4
|
end
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
set :js_compressor, ::PassThrough
|
|
8
|
-
set :css_compressor, ::PassThrough
|
|
9
|
-
|
|
10
7
|
activate :minify_javascript
|
|
11
8
|
activate :minify_css
|
|
12
9
|
|
|
10
|
+
set :js_compressor, ::PassThrough
|
|
11
|
+
set :css_compressor, ::PassThrough
|
|
12
|
+
|
|
13
13
|
with_layout false do
|
|
14
14
|
page "/inline-css.html"
|
|
15
15
|
page "/inline-js.html"
|
|
16
16
|
page "/inline-coffeescript.html"
|
|
17
|
-
end
|
|
17
|
+
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
%style(type="text/css")
|
|
2
|
+
:sass
|
|
3
|
+
body
|
|
4
|
+
test: style
|
|
5
|
+
good: deal
|
|
@@ -4,4 +4,25 @@
|
|
|
4
4
|
should();
|
|
5
5
|
all.be();
|
|
6
6
|
on = { one: line };
|
|
7
|
-
})();
|
|
7
|
+
})();
|
|
8
|
+
|
|
9
|
+
%script
|
|
10
|
+
:plain
|
|
11
|
+
;(function() {
|
|
12
|
+
this;
|
|
13
|
+
should();
|
|
14
|
+
too();
|
|
15
|
+
})();
|
|
16
|
+
|
|
17
|
+
%script(type="text/javascript")
|
|
18
|
+
:plain
|
|
19
|
+
//<!--
|
|
20
|
+
;(function() {
|
|
21
|
+
one;
|
|
22
|
+
line();
|
|
23
|
+
here();
|
|
24
|
+
})();
|
|
25
|
+
//-->
|
|
26
|
+
|
|
27
|
+
%script(type="text/html")
|
|
28
|
+
I'm a jQuery {{template}}.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# activate :relative_assets
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//= require "vendored_js"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var vendored_js_included = true;
|
data/lib/middleman-more.rb
CHANGED
|
@@ -16,6 +16,7 @@ module Middleman
|
|
|
16
16
|
autoload :Slim, "middleman-more/renderers/slim"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
# Core (automatic) extensions
|
|
19
20
|
module CoreExtensions
|
|
20
21
|
# Compass framework for Sass
|
|
21
22
|
autoload :Compass, "middleman-more/core_extensions/compass"
|
|
@@ -23,7 +24,8 @@ module Middleman
|
|
|
23
24
|
# Sprockets 2
|
|
24
25
|
autoload :Sprockets, "middleman-more/core_extensions/sprockets"
|
|
25
26
|
end
|
|
26
|
-
|
|
27
|
+
|
|
28
|
+
# User-activatable extensions
|
|
27
29
|
module Extensions
|
|
28
30
|
# RelativeAssets allow any asset path in dynamic templates to be either
|
|
29
31
|
# relative to the root of the project or use an absolute URL.
|
|
@@ -33,25 +35,33 @@ module Middleman
|
|
|
33
35
|
# browser caches failing to update to your new content.
|
|
34
36
|
autoload :CacheBuster, "middleman-more/extensions/cache_buster"
|
|
35
37
|
|
|
38
|
+
# AssetHash appends a hash of the file contents to the assets filename
|
|
39
|
+
# to avoid browser caches failing to update to your new content.
|
|
40
|
+
autoload :AssetHash, "middleman-more/extensions/asset_hash"
|
|
41
|
+
|
|
36
42
|
# MinifyCss uses the YUI compressor to shrink CSS files
|
|
37
43
|
autoload :MinifyCss, "middleman-more/extensions/minify_css"
|
|
38
44
|
|
|
39
45
|
# MinifyJavascript uses the YUI compressor to shrink JS files
|
|
40
46
|
autoload :MinifyJavascript, "middleman-more/extensions/minify_javascript"
|
|
47
|
+
|
|
48
|
+
# GZIP assets and pages during build
|
|
49
|
+
autoload :Gzip, "middleman-more/extensions/gzip"
|
|
41
50
|
end
|
|
42
51
|
|
|
52
|
+
# Setup renderers
|
|
43
53
|
require "coffee_script"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
Application.register Middleman::Renderers::Haml
|
|
55
|
+
Application.register Middleman::Renderers::Sass
|
|
56
|
+
Application.register Middleman::Renderers::Markdown
|
|
57
|
+
Application.register Middleman::Renderers::Liquid
|
|
58
|
+
Application.register Middleman::Renderers::Slim
|
|
49
59
|
|
|
50
60
|
# Compass framework
|
|
51
|
-
|
|
61
|
+
Application.register Middleman::CoreExtensions::Compass
|
|
52
62
|
|
|
53
63
|
# Sprockets asset handling
|
|
54
|
-
|
|
64
|
+
Application.register Middleman::CoreExtensions::Sprockets
|
|
55
65
|
|
|
56
66
|
# Register the optional extensions
|
|
57
67
|
Extensions.register(:cache_buster) {
|
|
@@ -62,4 +72,8 @@ module Middleman
|
|
|
62
72
|
::Middleman::Extensions::MinifyJavascript }
|
|
63
73
|
Extensions.register(:relative_assets) {
|
|
64
74
|
::Middleman::Extensions::RelativeAssets }
|
|
65
|
-
|
|
75
|
+
Extensions.register(:gzip) {
|
|
76
|
+
::Middleman::Extensions::Gzip }
|
|
77
|
+
Extensions.register(:asset_hash) {
|
|
78
|
+
::Middleman::Extensions::AssetHash }
|
|
79
|
+
end
|
|
@@ -16,40 +16,27 @@ module Middleman::CoreExtensions::Compass
|
|
|
16
16
|
|
|
17
17
|
app.after_configuration do
|
|
18
18
|
::Compass.configuration do |config|
|
|
19
|
-
config.project_path =
|
|
19
|
+
config.project_path = source_dir
|
|
20
20
|
config.environment = :development
|
|
21
21
|
config.cache_path = File.join(root, ".sass-cache")
|
|
22
|
-
config.sass_dir =
|
|
23
|
-
config.css_dir =
|
|
24
|
-
config.javascripts_dir =
|
|
25
|
-
config.fonts_dir =
|
|
26
|
-
config.images_dir =
|
|
22
|
+
config.sass_dir = css_dir
|
|
23
|
+
config.css_dir = css_dir
|
|
24
|
+
config.javascripts_dir = js_dir
|
|
25
|
+
config.fonts_dir = fonts_dir
|
|
26
|
+
config.images_dir = images_dir
|
|
27
|
+
config.http_path = http_prefix
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
else
|
|
37
|
-
File.join(http_prefix, css_dir)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
config.http_javascripts_path = if respond_to? :http_js_path
|
|
41
|
-
http_js_path
|
|
42
|
-
else
|
|
43
|
-
File.join(http_prefix, js_dir)
|
|
44
|
-
end
|
|
29
|
+
# Correctly support HTTP paths with generated sprites
|
|
30
|
+
# if config.respond_to? :http_generated_images_path
|
|
31
|
+
# config.http_generated_images_path = if app.respond_to? :http_generated_images_path
|
|
32
|
+
# app.http_generated_images_path
|
|
33
|
+
# else
|
|
34
|
+
# File.join(app.http_prefix || "/", app.images_dir)
|
|
35
|
+
# end
|
|
36
|
+
# end
|
|
45
37
|
|
|
46
|
-
config.http_fonts_path = if respond_to? :http_fonts_path
|
|
47
|
-
http_fonts_path
|
|
48
|
-
else
|
|
49
|
-
File.join(http_prefix, fonts_dir)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
38
|
config.asset_cache_buster :none
|
|
39
|
+
config.relative_assets = false
|
|
53
40
|
config.output_style = :nested
|
|
54
41
|
|
|
55
42
|
if respond_to?(:asset_host) && asset_host.is_a?(Proc)
|
|
@@ -57,15 +44,12 @@ module Middleman::CoreExtensions::Compass
|
|
|
57
44
|
end
|
|
58
45
|
end
|
|
59
46
|
|
|
60
|
-
#
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
config.fonts_dir = File.join(build_dir, fonts_dir)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
47
|
+
# if build?
|
|
48
|
+
# ::Compass.configuration do |config|
|
|
49
|
+
# config.environment = :production
|
|
50
|
+
# config.project_path = File.join(root, build_dir)
|
|
51
|
+
# end
|
|
52
|
+
# end
|
|
69
53
|
|
|
70
54
|
run_hook :compass_config, ::Compass.configuration
|
|
71
55
|
run_hook :after_compass_config
|
|
@@ -3,92 +3,57 @@ require "sprockets"
|
|
|
3
3
|
|
|
4
4
|
# Sprockets extension
|
|
5
5
|
module Middleman::CoreExtensions::Sprockets
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
# Setup extension
|
|
8
8
|
class << self
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
# Once registered
|
|
11
11
|
def registered(app)
|
|
12
|
-
#
|
|
13
|
-
app.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# Cut off every extension after .js (which sprockets eats up)
|
|
17
|
-
app.build_reroute do |destination, request_path|
|
|
18
|
-
if !request_path.match(/\.js\./i)
|
|
19
|
-
false
|
|
20
|
-
else
|
|
21
|
-
[
|
|
22
|
-
destination.gsub(/\.js(\..*)$/, ".js"),
|
|
23
|
-
request_path.gsub(/\.js(\..*)$/, ".js")
|
|
24
|
-
]
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
12
|
+
# Add class methods to context
|
|
13
|
+
app.send :include, InstanceMethods
|
|
14
|
+
|
|
28
15
|
# Once Middleman is setup
|
|
29
16
|
app.ready do
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
gems_with_js = ::Middleman.rubygems_latest_specs.select do |spec|
|
|
36
|
-
::Middleman.spec_has_file?(spec, vendor_dir)
|
|
37
|
-
end.each do |spec|
|
|
38
|
-
js_env.append_path File.join(spec.full_gem_path, vendor_dir)
|
|
39
|
-
end
|
|
17
|
+
# Add any gems with (vendor|app|.)/assets/javascripts to paths
|
|
18
|
+
# also add similar directories from project root (like in rails)
|
|
19
|
+
root_paths = [%w{ app }, %w{ assets }, %w{ vendor }, %w{ app assets }, %w{ vendor assets }, %w{ lib }, %w{ lib assets }]
|
|
20
|
+
try_paths = root_paths.map {|rp| File.join(rp, 'javascripts') } +
|
|
21
|
+
root_paths.map {|rp| File.join(rp, 'stylesheets') }
|
|
40
22
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
end.each do |spec|
|
|
46
|
-
js_env.append_path File.join(spec.full_gem_path, app_dir)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Intercept requests to /javascripts and pass to sprockets
|
|
50
|
-
map "/#{js_dir}" do
|
|
51
|
-
run js_env
|
|
23
|
+
([root] + ::Middleman.rubygems_latest_specs.map(&:full_gem_path)).each do |root_path|
|
|
24
|
+
try_paths.map {|p| File.join(root_path, p) }.
|
|
25
|
+
select {|p| File.directory?(p) }.
|
|
26
|
+
each {|path| sprockets.append_path(path) }
|
|
52
27
|
end
|
|
53
28
|
|
|
54
29
|
# Setup Sprockets Sass options
|
|
55
30
|
sass.each { |k, v| ::Sprockets::Sass.options[k] = v }
|
|
56
|
-
|
|
57
|
-
#
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
vendor_dir = File.join("vendor", "assets", "stylesheets")
|
|
62
|
-
gems_with_css = ::Middleman.rubygems_latest_specs.select do |spec|
|
|
63
|
-
::Middleman.spec_has_file?(spec, vendor_dir)
|
|
64
|
-
end.each do |spec|
|
|
65
|
-
css_env.append_path File.join(spec.full_gem_path, vendor_dir)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# Add any gems with app/assets/stylesheets to paths
|
|
69
|
-
app_dir = File.join("app", "assets", "stylesheets")
|
|
70
|
-
gems_with_css = ::Middleman.rubygems_latest_specs.select do |spec|
|
|
71
|
-
::Middleman.spec_has_file?(spec, app_dir)
|
|
72
|
-
end.each do |spec|
|
|
73
|
-
css_env.append_path File.join(spec.full_gem_path, app_dir)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# Intercept requests to /stylesheets and pass to sprockets
|
|
77
|
-
map("/#{css_dir}") do
|
|
78
|
-
run css_env
|
|
79
|
-
end
|
|
31
|
+
|
|
32
|
+
# Intercept requests to /javascripts and /stylesheets and pass to sprockets
|
|
33
|
+
our_sprockets = sprockets
|
|
34
|
+
map("/#{js_dir}") { run our_sprockets }
|
|
35
|
+
map("/#{css_dir}") { run our_sprockets }
|
|
80
36
|
end
|
|
81
37
|
end
|
|
82
38
|
alias :included :registered
|
|
83
39
|
end
|
|
84
40
|
|
|
41
|
+
module InstanceMethods
|
|
42
|
+
# @return [Middleman::CoreExtensions::Sprockets::MiddlemanSprocketsEnvironment]
|
|
43
|
+
def sprockets
|
|
44
|
+
@sprockets ||= MiddlemanSprocketsEnvironment.new(self)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
85
48
|
# Generic Middleman Sprockets env
|
|
86
|
-
class
|
|
49
|
+
class MiddlemanSprocketsEnvironment < ::Sprockets::Environment
|
|
87
50
|
# Setup
|
|
88
51
|
def initialize(app)
|
|
89
52
|
@app = app
|
|
90
53
|
super app.source_dir
|
|
91
|
-
|
|
54
|
+
|
|
55
|
+
digest = Digest::SHA1
|
|
56
|
+
|
|
92
57
|
# Make the app context available to Sprockets
|
|
93
58
|
context_class.send(:define_method, :app) { app }
|
|
94
59
|
context_class.class_eval do
|
|
@@ -100,76 +65,29 @@ module Middleman::CoreExtensions::Sprockets
|
|
|
100
65
|
end
|
|
101
66
|
end
|
|
102
67
|
end
|
|
68
|
+
|
|
69
|
+
# Remove compressors, we handle these with middleware
|
|
70
|
+
unregister_bundle_processor 'application/javascript', :js_compressor
|
|
71
|
+
unregister_bundle_processor 'text/css', :css_compressor
|
|
72
|
+
|
|
73
|
+
# configure search paths
|
|
74
|
+
append_path app.js_dir
|
|
75
|
+
append_path app.css_dir
|
|
103
76
|
end
|
|
104
|
-
|
|
77
|
+
|
|
105
78
|
# During development, don't use the asset cache
|
|
106
79
|
def find_asset(path, options = {})
|
|
107
80
|
expire_index! if @app.development?
|
|
108
81
|
super
|
|
109
82
|
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
# Javascript specific environment
|
|
113
|
-
class JavascriptEnvironment < MiddlemanEnvironment
|
|
114
|
-
|
|
115
|
-
# Init
|
|
116
|
-
def initialize(app)
|
|
117
|
-
super
|
|
118
|
-
|
|
119
|
-
expire_index!
|
|
120
83
|
|
|
121
|
-
# Remove old compressor
|
|
122
|
-
unregister_bundle_processor 'application/javascript', :js_compressor
|
|
123
|
-
|
|
124
|
-
# Register compressor from config
|
|
125
|
-
register_bundle_processor 'application/javascript', :js_compressor do |context, data|
|
|
126
|
-
if context.pathname.to_s =~ /\.min\./
|
|
127
|
-
data
|
|
128
|
-
else
|
|
129
|
-
app.js_compressor.compress(data)
|
|
130
|
-
end
|
|
131
|
-
end if app.js_compressor
|
|
132
|
-
|
|
133
|
-
# configure search paths
|
|
134
|
-
append_path app.js_dir
|
|
135
|
-
end
|
|
136
|
-
|
|
137
84
|
# Clear cache on error
|
|
138
85
|
def javascript_exception_response(exception)
|
|
139
86
|
expire_index!
|
|
140
87
|
super(exception)
|
|
141
88
|
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
# CSS specific environment
|
|
145
|
-
class StylesheetEnvironment < MiddlemanEnvironment
|
|
146
|
-
|
|
147
|
-
# Init
|
|
148
|
-
def initialize(app)
|
|
149
|
-
super
|
|
150
|
-
|
|
151
|
-
expire_index!
|
|
152
89
|
|
|
153
|
-
# Remove old compressor
|
|
154
|
-
unregister_bundle_processor 'text/css', :css_compressor
|
|
155
|
-
|
|
156
|
-
# Register compressor from config
|
|
157
|
-
register_bundle_processor 'text/css', :css_compressor do |context, data|
|
|
158
|
-
if context.pathname.to_s =~ /\.min\./
|
|
159
|
-
data
|
|
160
|
-
else
|
|
161
|
-
app.css_compressor.compress(data)
|
|
162
|
-
end
|
|
163
|
-
end if app.css_compressor
|
|
164
|
-
|
|
165
|
-
# configure search paths
|
|
166
|
-
append_path app.css_dir
|
|
167
|
-
end
|
|
168
|
-
|
|
169
90
|
# Clear cache on error
|
|
170
|
-
|
|
171
|
-
expire_index!
|
|
172
|
-
super(exception)
|
|
173
|
-
end
|
|
91
|
+
alias :css_exception_response :javascript_exception_response
|
|
174
92
|
end
|
|
175
|
-
end
|
|
93
|
+
end
|