actionpack 3.1.0.rc1 → 3.1.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/lib/action_controller.rb +7 -6
- data/lib/action_controller/metal/http_authentication.rb +2 -2
- data/lib/action_controller/metal/instrumentation.rb +1 -1
- data/lib/action_controller/metal/params_wrapper.rb +3 -3
- data/lib/action_controller/metal/request_forgery_protection.rb +1 -1
- data/lib/action_controller/metal/streaming.rb +0 -1
- data/lib/action_controller/test_case.rb +1 -1
- data/lib/action_dispatch/middleware/cookies.rb +1 -1
- data/lib/action_dispatch/middleware/session/abstract_store.rb +1 -1
- data/lib/action_dispatch/testing/assertions.rb +6 -7
- data/lib/action_dispatch/testing/assertions/response.rb +0 -7
- data/lib/action_pack/version.rb +1 -1
- data/lib/action_view/buffers.rb +2 -2
- data/lib/action_view/helpers.rb +0 -2
- data/lib/action_view/helpers/asset_paths.rb +6 -1
- data/lib/action_view/helpers/asset_tag_helper.rb +3 -15
- data/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb +1 -10
- data/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb +3 -11
- data/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb +3 -11
- data/lib/action_view/helpers/form_helper.rb +2 -2
- data/lib/action_view/helpers/form_options_helper.rb +1 -1
- data/lib/action_view/helpers/number_helper.rb +1 -1
- data/lib/action_view/lookup_context.rb +1 -1
- data/lib/action_view/testing/resolvers.rb +1 -1
- data/lib/sprockets/helpers.rb +5 -0
- data/lib/sprockets/helpers/rails_helper.rb +107 -0
- data/lib/sprockets/railtie.rb +10 -22
- metadata +87 -11
- data/lib/action_view/helpers/sprockets_helper.rb +0 -69
data/lib/action_controller.rb
CHANGED
@@ -37,12 +37,13 @@ module ActionController
|
|
37
37
|
autoload :UrlFor
|
38
38
|
end
|
39
39
|
|
40
|
-
autoload :Integration,
|
41
|
-
autoload :IntegrationTest,
|
42
|
-
autoload :PerformanceTest,
|
43
|
-
autoload :UrlWriter,
|
44
|
-
autoload :Routing,
|
45
|
-
autoload :TestCase,
|
40
|
+
autoload :Integration, 'action_controller/deprecated/integration_test'
|
41
|
+
autoload :IntegrationTest, 'action_controller/deprecated/integration_test'
|
42
|
+
autoload :PerformanceTest, 'action_controller/deprecated/performance_test'
|
43
|
+
autoload :UrlWriter, 'action_controller/deprecated'
|
44
|
+
autoload :Routing, 'action_controller/deprecated'
|
45
|
+
autoload :TestCase, 'action_controller/test_case'
|
46
|
+
autoload :TemplateAssertions, 'action_controller/test_case'
|
46
47
|
|
47
48
|
eager_autoload do
|
48
49
|
autoload :RecordIdentifier
|
@@ -106,7 +106,7 @@ module ActionController
|
|
106
106
|
|
107
107
|
module ControllerMethods
|
108
108
|
extend ActiveSupport::Concern
|
109
|
-
|
109
|
+
|
110
110
|
module ClassMethods
|
111
111
|
def http_basic_authenticate_with(options = {})
|
112
112
|
before_filter(options.except(:name, :password, :realm)) do
|
@@ -116,7 +116,7 @@ module ActionController
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
def authenticate_or_request_with_http_basic(realm = "Application", &login_procedure)
|
121
121
|
authenticate_with_http_basic(&login_procedure) || request_http_basic_authentication(realm)
|
122
122
|
end
|
@@ -19,7 +19,7 @@ module ActionController
|
|
19
19
|
:controller => self.class.name,
|
20
20
|
:action => self.action_name,
|
21
21
|
:params => request.filtered_parameters,
|
22
|
-
:format => request.format.ref,
|
22
|
+
:format => request.format.try(:ref),
|
23
23
|
:method => request.method,
|
24
24
|
:path => (request.fullpath rescue "unknown")
|
25
25
|
}
|
@@ -64,7 +64,7 @@ module ActionController
|
|
64
64
|
# end
|
65
65
|
#
|
66
66
|
# will try to check if +Admin::User+ or +User+ model exists, and use it to
|
67
|
-
# determine the wrapper key respectively. If both
|
67
|
+
# determine the wrapper key respectively. If both models don't exist,
|
68
68
|
# it will then fallback to use +user+ as the key.
|
69
69
|
module ParamsWrapper
|
70
70
|
extend ActiveSupport::Concern
|
@@ -88,14 +88,14 @@ module ActionController
|
|
88
88
|
# # wraps parameters into +params[:person]+ hash
|
89
89
|
#
|
90
90
|
# wrap_parameters Person
|
91
|
-
# # wraps parameters by
|
91
|
+
# # wraps parameters by determining the wrapper key from Person class
|
92
92
|
# (+person+, in this case) and the list of attribute names
|
93
93
|
#
|
94
94
|
# wrap_parameters :include => [:username, :title]
|
95
95
|
# # wraps only +:username+ and +:title+ attributes from parameters.
|
96
96
|
#
|
97
97
|
# wrap_parameters false
|
98
|
-
# #
|
98
|
+
# # disables parameters wrapping for this controller altogether.
|
99
99
|
#
|
100
100
|
# ==== Options
|
101
101
|
# * <tt>:format</tt> - The list of formats in which the parameters wrapper
|
@@ -96,7 +96,7 @@ module ActionController #:nodoc:
|
|
96
96
|
|
97
97
|
# Sets the token value for the current session.
|
98
98
|
def form_authenticity_token
|
99
|
-
session[:_csrf_token] ||=
|
99
|
+
session[:_csrf_token] ||= SecureRandom.base64(32)
|
100
100
|
end
|
101
101
|
|
102
102
|
# The form's authenticity parameter. Override to provide your own.
|
@@ -130,7 +130,7 @@ module ActionController
|
|
130
130
|
super
|
131
131
|
|
132
132
|
self.session = TestSession.new
|
133
|
-
self.session_options = TestSession::DEFAULT_OPTIONS.merge(:id =>
|
133
|
+
self.session_options = TestSession::DEFAULT_OPTIONS.merge(:id => SecureRandom.hex(16))
|
134
134
|
end
|
135
135
|
|
136
136
|
class Result < ::Array #:nodoc:
|
@@ -305,7 +305,7 @@ module ActionDispatch
|
|
305
305
|
|
306
306
|
if secret.length < SECRET_MIN_LENGTH
|
307
307
|
raise ArgumentError, "Secret should be something secure, " +
|
308
|
-
"like \"#{
|
308
|
+
"like \"#{SecureRandom.hex(16)}\". The value you " +
|
309
309
|
"provided, \"#{secret}\", is shorter than the minimum length " +
|
310
310
|
"of #{SECRET_MIN_LENGTH} characters"
|
311
311
|
end
|
@@ -8,12 +8,11 @@ module ActionDispatch
|
|
8
8
|
|
9
9
|
extend ActiveSupport::Concern
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
include TagAssertions
|
17
|
-
end
|
11
|
+
include DomAssertions
|
12
|
+
include ResponseAssertions
|
13
|
+
include RoutingAssertions
|
14
|
+
include SelectorAssertions
|
15
|
+
include TagAssertions
|
18
16
|
end
|
19
17
|
end
|
18
|
+
|
@@ -6,13 +6,6 @@ module ActionDispatch
|
|
6
6
|
module ResponseAssertions
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
-
included do
|
10
|
-
# TODO: Need to pull in AV::Template monkey patches that track which
|
11
|
-
# templates are rendered. assert_template should probably be part
|
12
|
-
# of AV instead of AD.
|
13
|
-
require 'action_view/test_case'
|
14
|
-
end
|
15
|
-
|
16
9
|
# Asserts that the response is one of the following types:
|
17
10
|
#
|
18
11
|
# * <tt>:success</tt> - Status code was 200
|
data/lib/action_pack/version.rb
CHANGED
data/lib/action_view/buffers.rb
CHANGED
data/lib/action_view/helpers.rb
CHANGED
@@ -22,7 +22,6 @@ module ActionView #:nodoc:
|
|
22
22
|
autoload :RecordTagHelper
|
23
23
|
autoload :RenderingHelper
|
24
24
|
autoload :SanitizeHelper
|
25
|
-
autoload :SprocketsHelper
|
26
25
|
autoload :TagHelper
|
27
26
|
autoload :TextHelper
|
28
27
|
autoload :TranslationHelper
|
@@ -53,7 +52,6 @@ module ActionView #:nodoc:
|
|
53
52
|
include RecordTagHelper
|
54
53
|
include RenderingHelper
|
55
54
|
include SanitizeHelper
|
56
|
-
include SprocketsHelper
|
57
55
|
include TagHelper
|
58
56
|
include TextHelper
|
59
57
|
include TranslationHelper
|
@@ -44,7 +44,12 @@ module ActionView
|
|
44
44
|
raise NotImplementedError
|
45
45
|
end
|
46
46
|
|
47
|
+
def rewrite_relative_url_root(source, relative_url_root)
|
48
|
+
relative_url_root && !source.starts_with?("#{relative_url_root}/") ? "#{relative_url_root}#{source}" : source
|
49
|
+
end
|
50
|
+
|
47
51
|
def rewrite_host_and_protocol(source, has_request)
|
52
|
+
source = rewrite_relative_url_root(source, controller.config.relative_url_root) if has_request
|
48
53
|
host = compute_asset_host(source)
|
49
54
|
if has_request && host && !is_uri?(host)
|
50
55
|
host = "#{controller.request.protocol}#{host}"
|
@@ -75,4 +80,4 @@ module ActionView
|
|
75
80
|
end
|
76
81
|
|
77
82
|
end
|
78
|
-
end
|
83
|
+
end
|
@@ -274,11 +274,7 @@ module ActionView
|
|
274
274
|
# The alias +path_to_image+ is provided to avoid that. Rails uses the alias internally, and
|
275
275
|
# plugin authors are encouraged to do so.
|
276
276
|
def image_path(source)
|
277
|
-
|
278
|
-
asset_path(source)
|
279
|
-
else
|
280
|
-
asset_paths.compute_public_path(source, 'images')
|
281
|
-
end
|
277
|
+
asset_paths.compute_public_path(source, 'images')
|
282
278
|
end
|
283
279
|
alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route
|
284
280
|
|
@@ -293,11 +289,7 @@ module ActionView
|
|
293
289
|
# video_path("/trailers/hd.avi") # => /trailers/hd.avi
|
294
290
|
# video_path("http://www.example.com/vid/hd.avi") # => http://www.example.com/vid/hd.avi
|
295
291
|
def video_path(source)
|
296
|
-
|
297
|
-
asset_path(source)
|
298
|
-
else
|
299
|
-
asset_paths.compute_public_path(source, 'videos')
|
300
|
-
end
|
292
|
+
asset_paths.compute_public_path(source, 'videos')
|
301
293
|
end
|
302
294
|
alias_method :path_to_video, :video_path # aliased to avoid conflicts with a video_path named route
|
303
295
|
|
@@ -312,11 +304,7 @@ module ActionView
|
|
312
304
|
# audio_path("/sounds/horse.wav") # => /sounds/horse.wav
|
313
305
|
# audio_path("http://www.example.com/sounds/horse.wav") # => http://www.example.com/sounds/horse.wav
|
314
306
|
def audio_path(source)
|
315
|
-
|
316
|
-
asset_path(source)
|
317
|
-
else
|
318
|
-
asset_paths.compute_public_path(source, 'audios')
|
319
|
-
end
|
307
|
+
asset_paths.compute_public_path(source, 'audios')
|
320
308
|
end
|
321
309
|
alias_method :path_to_audio, :audio_path # aliased to avoid conflicts with an audio_path named route
|
322
310
|
|
@@ -85,17 +85,8 @@ module ActionView
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
88
|
-
|
89
|
-
def rewrite_relative_url_root(source, relative_url_root)
|
90
|
-
relative_url_root && !source.starts_with?("#{relative_url_root}/") ? "#{relative_url_root}#{source}" : source
|
91
|
-
end
|
92
|
-
|
93
|
-
def rewrite_host_and_protocol(source, has_request)
|
94
|
-
source = rewrite_relative_url_root(source, controller.config.relative_url_root) if has_request
|
95
|
-
super(source, has_request)
|
96
|
-
end
|
97
88
|
end
|
98
89
|
|
99
90
|
end
|
100
91
|
end
|
101
|
-
end
|
92
|
+
end
|
@@ -83,11 +83,7 @@ module ActionView
|
|
83
83
|
# javascript_path "http://www.example.com/js/xmlhr" # => http://www.example.com/js/xmlhr
|
84
84
|
# javascript_path "http://www.example.com/js/xmlhr.js" # => http://www.example.com/js/xmlhr.js
|
85
85
|
def javascript_path(source)
|
86
|
-
|
87
|
-
asset_path(source, 'js')
|
88
|
-
else
|
89
|
-
asset_paths.compute_public_path(source, 'javascripts', 'js')
|
90
|
-
end
|
86
|
+
asset_paths.compute_public_path(source, 'javascripts', 'js')
|
91
87
|
end
|
92
88
|
alias_method :path_to_javascript, :javascript_path # aliased to avoid conflicts with a javascript_path named route
|
93
89
|
|
@@ -187,12 +183,8 @@ module ActionView
|
|
187
183
|
#
|
188
184
|
# javascript_include_tag :all, :cache => true, :recursive => true
|
189
185
|
def javascript_include_tag(*sources)
|
190
|
-
|
191
|
-
|
192
|
-
else
|
193
|
-
@javascript_include ||= JavascriptIncludeTag.new(config, asset_paths)
|
194
|
-
@javascript_include.include_tag(*sources)
|
195
|
-
end
|
186
|
+
@javascript_include ||= JavascriptIncludeTag.new(config, asset_paths)
|
187
|
+
@javascript_include.include_tag(*sources)
|
196
188
|
end
|
197
189
|
end
|
198
190
|
end
|
@@ -60,11 +60,7 @@ module ActionView
|
|
60
60
|
# stylesheet_path "http://www.example.com/css/style" # => http://www.example.com/css/style
|
61
61
|
# stylesheet_path "http://www.example.com/css/style.css" # => http://www.example.com/css/style.css
|
62
62
|
def stylesheet_path(source)
|
63
|
-
|
64
|
-
asset_path(source, 'css')
|
65
|
-
else
|
66
|
-
asset_paths.compute_public_path(source, 'stylesheets', 'css')
|
67
|
-
end
|
63
|
+
asset_paths.compute_public_path(source, 'stylesheets', 'css')
|
68
64
|
end
|
69
65
|
alias_method :path_to_stylesheet, :stylesheet_path # aliased to avoid conflicts with a stylesheet_path named route
|
70
66
|
|
@@ -137,12 +133,8 @@ module ActionView
|
|
137
133
|
# stylesheet_link_tag :all, :concat => true
|
138
134
|
#
|
139
135
|
def stylesheet_link_tag(*sources)
|
140
|
-
|
141
|
-
|
142
|
-
else
|
143
|
-
@stylesheet_include ||= StylesheetIncludeTag.new(config, asset_paths)
|
144
|
-
@stylesheet_include.include_tag(*sources)
|
145
|
-
end
|
136
|
+
@stylesheet_include ||= StylesheetIncludeTag.new(config, asset_paths)
|
137
|
+
@stylesheet_include.include_tag(*sources)
|
146
138
|
end
|
147
139
|
|
148
140
|
end
|
@@ -202,13 +202,13 @@ module ActionView
|
|
202
202
|
#
|
203
203
|
# is equivalent to something like:
|
204
204
|
#
|
205
|
-
# <%= form_for @post, :as => :post, :url =>
|
205
|
+
# <%= form_for @post, :as => :post, :url => posts_path, :html => { :class => "new_post", :id => "new_post" } do |f| %>
|
206
206
|
# ...
|
207
207
|
# <% end %>
|
208
208
|
#
|
209
209
|
# You can also overwrite the individual conventions, like this:
|
210
210
|
#
|
211
|
-
# <%= form_for(@post, :url =>
|
211
|
+
# <%= form_for(@post, :url => super_posts_path) do |f| %>
|
212
212
|
# ...
|
213
213
|
# <% end %>
|
214
214
|
#
|
@@ -427,7 +427,7 @@ module ActionView
|
|
427
427
|
#
|
428
428
|
# Sample usage (Hash):
|
429
429
|
# grouped_options = {
|
430
|
-
# 'North America' => [['United States','US], 'Canada'],
|
430
|
+
# 'North America' => [['United States','US'], 'Canada'],
|
431
431
|
# 'Europe' => ['Denmark','Germany','France']
|
432
432
|
# }
|
433
433
|
# grouped_options_for_select(grouped_options)
|
@@ -342,7 +342,7 @@ module ActionView
|
|
342
342
|
options[:strip_insignificant_zeros] = true if not options.key?(:strip_insignificant_zeros)
|
343
343
|
|
344
344
|
storage_units_format = I18n.translate(:'number.human.storage_units.format', :locale => options[:locale], :raise => true)
|
345
|
-
|
345
|
+
|
346
346
|
base = options[:prefix] == :si ? 1000 : 1024
|
347
347
|
|
348
348
|
if number.to_i < base
|
@@ -34,7 +34,7 @@ module ActionView #:nodoc:
|
|
34
34
|
templates << Template.new(source, _path, handler,
|
35
35
|
:virtual_path => path.virtual, :format => format, :updated_at => updated_at)
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
templates.sort_by {|t| -t.identifier.match(/^#{query}$/).captures.reject(&:blank?).size }
|
39
39
|
end
|
40
40
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require "action_view/helpers/asset_paths"
|
2
|
+
require "action_view/helpers/asset_tag_helper"
|
3
|
+
|
4
|
+
module Sprockets
|
5
|
+
module Helpers
|
6
|
+
module RailsHelper
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
include ActionView::Helpers::AssetTagHelper
|
9
|
+
|
10
|
+
def asset_paths
|
11
|
+
@asset_paths ||= begin
|
12
|
+
config = self.config if respond_to?(:config)
|
13
|
+
controller = self.controller if respond_to?(:controller)
|
14
|
+
RailsHelper::AssetPaths.new(config, controller)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def javascript_include_tag(source, options = {})
|
19
|
+
debug = options.key?(:debug) ? options.delete(:debug) : debug_assets?
|
20
|
+
body = options.key?(:body) ? options.delete(:body) : false
|
21
|
+
|
22
|
+
if debug && asset = asset_paths.asset_for(source, 'js')
|
23
|
+
asset.to_a.map { |dep|
|
24
|
+
javascript_include_tag(dep, :debug => false, :body => true)
|
25
|
+
}.join("\n").html_safe
|
26
|
+
else
|
27
|
+
options = {
|
28
|
+
'type' => "text/javascript",
|
29
|
+
'src' => asset_path(source, 'js', body)
|
30
|
+
}.merge(options.stringify_keys)
|
31
|
+
|
32
|
+
content_tag 'script', "", options
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def stylesheet_link_tag(source, options = {})
|
37
|
+
debug = options.key?(:debug) ? options.delete(:debug) : debug_assets?
|
38
|
+
body = options.key?(:body) ? options.delete(:body) : false
|
39
|
+
|
40
|
+
if debug && asset = asset_paths.asset_for(source, 'css')
|
41
|
+
asset.to_a.map { |dep|
|
42
|
+
stylesheet_link_tag(dep, :debug => false, :body => true)
|
43
|
+
}.join("\n").html_safe
|
44
|
+
else
|
45
|
+
options = {
|
46
|
+
'rel' => "stylesheet",
|
47
|
+
'type' => "text/css",
|
48
|
+
'media' => "screen",
|
49
|
+
'href' => asset_path(source, 'css', body)
|
50
|
+
}.merge(options.stringify_keys)
|
51
|
+
|
52
|
+
tag 'link', options
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
def debug_assets?
|
58
|
+
params[:debug_assets] == '1' ||
|
59
|
+
params[:debug_assets] == 'true'
|
60
|
+
end
|
61
|
+
|
62
|
+
def asset_path(source, default_ext = nil, body = false)
|
63
|
+
source = source.logical_path if source.respond_to?(:logical_path)
|
64
|
+
path = asset_paths.compute_public_path(source, 'assets', default_ext, true)
|
65
|
+
body ? "#{path}?body=1" : path
|
66
|
+
end
|
67
|
+
|
68
|
+
class AssetPaths < ActionView::Helpers::AssetPaths #:nodoc:
|
69
|
+
def compute_public_path(source, dir, ext=nil, include_host=true)
|
70
|
+
super(source, 'assets', ext, include_host)
|
71
|
+
end
|
72
|
+
|
73
|
+
def asset_for(source, ext)
|
74
|
+
source = source.to_s
|
75
|
+
return nil if is_uri?(source)
|
76
|
+
source = rewrite_extension(source, nil, ext)
|
77
|
+
assets[source]
|
78
|
+
end
|
79
|
+
|
80
|
+
def rewrite_asset_path(source, dir)
|
81
|
+
if source[0] == ?/
|
82
|
+
source
|
83
|
+
else
|
84
|
+
assets.path(source, performing_caching?, dir)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def rewrite_extension(source, dir, ext)
|
89
|
+
if ext && File.extname(source).empty?
|
90
|
+
"#{source}.#{ext}"
|
91
|
+
else
|
92
|
+
source
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def assets
|
97
|
+
Rails.application.assets
|
98
|
+
end
|
99
|
+
|
100
|
+
# When included in Sprockets::Context, we need to ask the top-level config as the controller is not available
|
101
|
+
def performing_caching?
|
102
|
+
@config ? @config.perform_caching : Rails.application.config.action_controller.perform_caching
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/lib/sprockets/railtie.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Sprockets
|
2
|
-
|
2
|
+
autoload :Helpers, "sprockets/helpers"
|
3
|
+
|
4
|
+
class Railtie < ::Rails::Railtie
|
3
5
|
def self.using_coffee?
|
4
6
|
require 'coffee-script'
|
5
7
|
defined?(CoffeeScript)
|
@@ -7,15 +9,7 @@ module Sprockets
|
|
7
9
|
false
|
8
10
|
end
|
9
11
|
|
10
|
-
def self.using_scss?
|
11
|
-
require 'sass'
|
12
|
-
defined?(Sass)
|
13
|
-
rescue LoadError
|
14
|
-
false
|
15
|
-
end
|
16
|
-
|
17
12
|
config.app_generators.javascript_engine :coffee if using_coffee?
|
18
|
-
config.app_generators.stylesheet_engine :scss if using_scss?
|
19
13
|
|
20
14
|
# Configure ActionController to use sprockets.
|
21
15
|
initializer "sprockets.set_configs", :after => "action_controller.set_configs" do |app|
|
@@ -26,7 +20,8 @@ module Sprockets
|
|
26
20
|
|
27
21
|
# We need to configure this after initialization to ensure we collect
|
28
22
|
# paths from all engines. This hook is invoked exactly before routes
|
29
|
-
# are compiled
|
23
|
+
# are compiled, and so that other Railties have an opportunity to
|
24
|
+
# register compressors.
|
30
25
|
config.after_initialize do |app|
|
31
26
|
assets = app.config.assets
|
32
27
|
next unless assets.enabled
|
@@ -34,8 +29,10 @@ module Sprockets
|
|
34
29
|
app.assets = asset_environment(app)
|
35
30
|
|
36
31
|
ActiveSupport.on_load(:action_view) do
|
32
|
+
include ::Sprockets::Helpers::RailsHelper
|
33
|
+
|
37
34
|
app.assets.context_class.instance_eval do
|
38
|
-
include ::
|
35
|
+
include ::Sprockets::Helpers::RailsHelper
|
39
36
|
end
|
40
37
|
end
|
41
38
|
|
@@ -57,8 +54,8 @@ module Sprockets
|
|
57
54
|
env.static_root = File.join(app.root.join("public"), assets.prefix)
|
58
55
|
env.paths.concat assets.paths
|
59
56
|
env.logger = Rails.logger
|
60
|
-
env.js_compressor = expand_js_compressor(assets.js_compressor)
|
61
|
-
env.css_compressor = expand_css_compressor(assets.css_compressor)
|
57
|
+
env.js_compressor = expand_js_compressor(assets.js_compressor) if assets.compress
|
58
|
+
env.css_compressor = expand_css_compressor(assets.css_compressor) if assets.compress
|
62
59
|
env
|
63
60
|
end
|
64
61
|
|
@@ -80,15 +77,6 @@ module Sprockets
|
|
80
77
|
|
81
78
|
def expand_css_compressor(sym)
|
82
79
|
case sym
|
83
|
-
when :scss
|
84
|
-
require 'sass'
|
85
|
-
compressor = Object.new
|
86
|
-
def compressor.compress(source)
|
87
|
-
Sass::Engine.new(source,
|
88
|
-
:syntax => :scss, :style => :compressed
|
89
|
-
).render
|
90
|
-
end
|
91
|
-
compressor
|
92
80
|
when :yui
|
93
81
|
require 'yui/compressor'
|
94
82
|
YUI::CssCompressor.new
|
metadata
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15424097
|
4
5
|
prerelease: 6
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 3
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
- rc
|
11
|
+
- 2
|
12
|
+
version: 3.1.0.rc2
|
6
13
|
platform: ruby
|
7
14
|
authors:
|
8
15
|
- David Heinemeier Hansson
|
@@ -10,8 +17,7 @@ autorequire:
|
|
10
17
|
bindir: bin
|
11
18
|
cert_chain: []
|
12
19
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
20
|
+
date: 2011-06-07 00:00:00 Z
|
15
21
|
dependencies:
|
16
22
|
- !ruby/object:Gem::Dependency
|
17
23
|
name: activesupport
|
@@ -21,7 +27,14 @@ dependencies:
|
|
21
27
|
requirements:
|
22
28
|
- - "="
|
23
29
|
- !ruby/object:Gem::Version
|
24
|
-
|
30
|
+
hash: 15424097
|
31
|
+
segments:
|
32
|
+
- 3
|
33
|
+
- 1
|
34
|
+
- 0
|
35
|
+
- rc
|
36
|
+
- 2
|
37
|
+
version: 3.1.0.rc2
|
25
38
|
type: :runtime
|
26
39
|
version_requirements: *id001
|
27
40
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +45,14 @@ dependencies:
|
|
32
45
|
requirements:
|
33
46
|
- - "="
|
34
47
|
- !ruby/object:Gem::Version
|
35
|
-
|
48
|
+
hash: 15424097
|
49
|
+
segments:
|
50
|
+
- 3
|
51
|
+
- 1
|
52
|
+
- 0
|
53
|
+
- rc
|
54
|
+
- 2
|
55
|
+
version: 3.1.0.rc2
|
36
56
|
type: :runtime
|
37
57
|
version_requirements: *id002
|
38
58
|
- !ruby/object:Gem::Dependency
|
@@ -43,6 +63,11 @@ dependencies:
|
|
43
63
|
requirements:
|
44
64
|
- - ~>
|
45
65
|
- !ruby/object:Gem::Version
|
66
|
+
hash: 21
|
67
|
+
segments:
|
68
|
+
- 1
|
69
|
+
- 0
|
70
|
+
- 1
|
46
71
|
version: 1.0.1
|
47
72
|
type: :runtime
|
48
73
|
version_requirements: *id003
|
@@ -54,6 +79,11 @@ dependencies:
|
|
54
79
|
requirements:
|
55
80
|
- - ~>
|
56
81
|
- !ruby/object:Gem::Version
|
82
|
+
hash: 7
|
83
|
+
segments:
|
84
|
+
- 3
|
85
|
+
- 0
|
86
|
+
- 0
|
57
87
|
version: 3.0.0
|
58
88
|
type: :runtime
|
59
89
|
version_requirements: *id004
|
@@ -65,7 +95,11 @@ dependencies:
|
|
65
95
|
requirements:
|
66
96
|
- - ~>
|
67
97
|
- !ruby/object:Gem::Version
|
68
|
-
|
98
|
+
hash: 7
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
- 6
|
102
|
+
version: "0.6"
|
69
103
|
type: :runtime
|
70
104
|
version_requirements: *id005
|
71
105
|
- !ruby/object:Gem::Dependency
|
@@ -76,7 +110,12 @@ dependencies:
|
|
76
110
|
requirements:
|
77
111
|
- - ~>
|
78
112
|
- !ruby/object:Gem::Version
|
79
|
-
|
113
|
+
hash: 27
|
114
|
+
segments:
|
115
|
+
- 1
|
116
|
+
- 3
|
117
|
+
- 0
|
118
|
+
version: 1.3.0
|
80
119
|
type: :runtime
|
81
120
|
version_requirements: *id006
|
82
121
|
- !ruby/object:Gem::Dependency
|
@@ -87,6 +126,11 @@ dependencies:
|
|
87
126
|
requirements:
|
88
127
|
- - ~>
|
89
128
|
- !ruby/object:Gem::Version
|
129
|
+
hash: 7
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
- 6
|
133
|
+
- 0
|
90
134
|
version: 0.6.0
|
91
135
|
type: :runtime
|
92
136
|
version_requirements: *id007
|
@@ -98,6 +142,11 @@ dependencies:
|
|
98
142
|
requirements:
|
99
143
|
- - ~>
|
100
144
|
- !ruby/object:Gem::Version
|
145
|
+
hash: 61
|
146
|
+
segments:
|
147
|
+
- 0
|
148
|
+
- 8
|
149
|
+
- 1
|
101
150
|
version: 0.8.1
|
102
151
|
type: :runtime
|
103
152
|
version_requirements: *id008
|
@@ -109,7 +158,14 @@ dependencies:
|
|
109
158
|
requirements:
|
110
159
|
- - ~>
|
111
160
|
- !ruby/object:Gem::Version
|
112
|
-
|
161
|
+
hash: 62196471
|
162
|
+
segments:
|
163
|
+
- 2
|
164
|
+
- 0
|
165
|
+
- 0
|
166
|
+
- beta
|
167
|
+
- 10
|
168
|
+
version: 2.0.0.beta.10
|
113
169
|
type: :runtime
|
114
170
|
version_requirements: *id009
|
115
171
|
- !ruby/object:Gem::Dependency
|
@@ -120,6 +176,11 @@ dependencies:
|
|
120
176
|
requirements:
|
121
177
|
- - ~>
|
122
178
|
- !ruby/object:Gem::Version
|
179
|
+
hash: 37
|
180
|
+
segments:
|
181
|
+
- 0
|
182
|
+
- 3
|
183
|
+
- 27
|
123
184
|
version: 0.3.27
|
124
185
|
type: :runtime
|
125
186
|
version_requirements: *id010
|
@@ -131,6 +192,11 @@ dependencies:
|
|
131
192
|
requirements:
|
132
193
|
- - ~>
|
133
194
|
- !ruby/object:Gem::Version
|
195
|
+
hash: 19
|
196
|
+
segments:
|
197
|
+
- 2
|
198
|
+
- 7
|
199
|
+
- 0
|
134
200
|
version: 2.7.0
|
135
201
|
type: :runtime
|
136
202
|
version_requirements: *id011
|
@@ -296,7 +362,6 @@ files:
|
|
296
362
|
- lib/action_view/helpers/record_tag_helper.rb
|
297
363
|
- lib/action_view/helpers/rendering_helper.rb
|
298
364
|
- lib/action_view/helpers/sanitize_helper.rb
|
299
|
-
- lib/action_view/helpers/sprockets_helper.rb
|
300
365
|
- lib/action_view/helpers/tag_helper.rb
|
301
366
|
- lib/action_view/helpers/text_helper.rb
|
302
367
|
- lib/action_view/helpers/translation_helper.rb
|
@@ -323,8 +388,9 @@ files:
|
|
323
388
|
- lib/action_view/test_case.rb
|
324
389
|
- lib/action_view/testing/resolvers.rb
|
325
390
|
- lib/action_view.rb
|
391
|
+
- lib/sprockets/helpers/rails_helper.rb
|
392
|
+
- lib/sprockets/helpers.rb
|
326
393
|
- lib/sprockets/railtie.rb
|
327
|
-
has_rdoc: true
|
328
394
|
homepage: http://www.rubyonrails.org
|
329
395
|
licenses: []
|
330
396
|
|
@@ -338,17 +404,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
338
404
|
requirements:
|
339
405
|
- - ">="
|
340
406
|
- !ruby/object:Gem::Version
|
407
|
+
hash: 57
|
408
|
+
segments:
|
409
|
+
- 1
|
410
|
+
- 8
|
411
|
+
- 7
|
341
412
|
version: 1.8.7
|
342
413
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
343
414
|
none: false
|
344
415
|
requirements:
|
345
416
|
- - ">"
|
346
417
|
- !ruby/object:Gem::Version
|
418
|
+
hash: 25
|
419
|
+
segments:
|
420
|
+
- 1
|
421
|
+
- 3
|
422
|
+
- 1
|
347
423
|
version: 1.3.1
|
348
424
|
requirements:
|
349
425
|
- none
|
350
426
|
rubyforge_project:
|
351
|
-
rubygems_version: 1.
|
427
|
+
rubygems_version: 1.8.2
|
352
428
|
signing_key:
|
353
429
|
specification_version: 3
|
354
430
|
summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).
|
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'uri'
|
2
|
-
require 'action_view/helpers/asset_paths'
|
3
|
-
|
4
|
-
module ActionView
|
5
|
-
module Helpers
|
6
|
-
module SprocketsHelper
|
7
|
-
def asset_path(source, default_ext = nil)
|
8
|
-
sprockets_asset_paths.compute_public_path(source, 'assets', default_ext, true)
|
9
|
-
end
|
10
|
-
|
11
|
-
def sprockets_javascript_include_tag(source, options = {})
|
12
|
-
options = {
|
13
|
-
'type' => "text/javascript",
|
14
|
-
'src' => asset_path(source, 'js')
|
15
|
-
}.merge(options.stringify_keys)
|
16
|
-
|
17
|
-
content_tag 'script', "", options
|
18
|
-
end
|
19
|
-
|
20
|
-
def sprockets_stylesheet_link_tag(source, options = {})
|
21
|
-
options = {
|
22
|
-
'rel' => "stylesheet",
|
23
|
-
'type' => "text/css",
|
24
|
-
'media' => "screen",
|
25
|
-
'href' => asset_path(source, 'css')
|
26
|
-
}.merge(options.stringify_keys)
|
27
|
-
|
28
|
-
tag 'link', options
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def sprockets_asset_paths
|
34
|
-
@sprockets_asset_paths ||= begin
|
35
|
-
config = self.config if respond_to?(:config)
|
36
|
-
controller = self.controller if respond_to?(:controller)
|
37
|
-
SprocketsHelper::AssetPaths.new(config, controller)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class AssetPaths < ActionView::Helpers::AssetPaths #:nodoc:
|
42
|
-
def rewrite_asset_path(source, dir)
|
43
|
-
if source[0] == ?/
|
44
|
-
source
|
45
|
-
else
|
46
|
-
assets.path(source, performing_caching?, dir)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def rewrite_extension(source, dir, ext)
|
51
|
-
if ext && File.extname(source).empty?
|
52
|
-
"#{source}.#{ext}"
|
53
|
-
else
|
54
|
-
source
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def assets
|
59
|
-
Rails.application.assets
|
60
|
-
end
|
61
|
-
|
62
|
-
# When included in Sprockets::Context, we need to ask the top-level config as the controller is not available
|
63
|
-
def performing_caching?
|
64
|
-
@config ? @config.perform_caching : Rails.application.config.action_controller.perform_caching
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|