dynamic_assets 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,26 +1,26 @@
1
1
 
2
2
  module DynamicAssetsHelpers
3
3
 
4
- def stylesheet_asset_tag(group_key, http_attributes = {})
4
+ def stylesheet_asset_tag(group_key, options = {})
5
5
  DynamicAssets::Manager.asset_references_for_group_key(:stylesheets, group_key).map do |asset_ref|
6
6
 
7
7
  tag :link, {
8
8
  :type => "text/css",
9
9
  :rel => "stylesheet",
10
10
  :media => "screen",
11
- :href => asset_url(asset_ref)
12
- }.merge!(http_attributes)
11
+ :href => asset_url(asset_ref, options.delete(:token))
12
+ }.merge!(options)
13
13
 
14
14
  end.join.html_safe
15
15
  end
16
16
 
17
- def javascript_asset_tag(group_key, http_attributes = {})
17
+ def javascript_asset_tag(group_key, options = {})
18
18
  DynamicAssets::Manager.asset_references_for_group_key(:javascripts, group_key).map do |asset_ref|
19
19
 
20
20
  content_tag :script, "", {
21
21
  :type => "text/javascript",
22
- :src => asset_url(asset_ref)
23
- }.merge!(http_attributes)
22
+ :src => asset_url(asset_ref, options.delete(:token))
23
+ }.merge!(options)
24
24
 
25
25
  end.join.html_safe
26
26
  end
@@ -28,12 +28,12 @@ module DynamicAssetsHelpers
28
28
 
29
29
  protected
30
30
 
31
- def asset_path(asset_ref)
31
+ def asset_path(asset_ref, token = nil)
32
32
  path_args = []
33
33
  path_args << asset_ref.name
34
34
 
35
35
  signature = asset_ref.signature DynamicAssets::ViewContext.get(controller)
36
- path_args << { :signature => signature } if signature.present?
36
+ path_args << { :signature => signature, :token => token } if signature.present?
37
37
 
38
38
  case asset_ref
39
39
  when DynamicAssets::StylesheetReference then stylesheet_asset_path *path_args
@@ -42,8 +42,8 @@ protected
42
42
  end
43
43
  end
44
44
 
45
- def asset_url(asset_ref)
46
- path = asset_path asset_ref
45
+ def asset_url(asset_ref, token = nil)
46
+ path = asset_path asset_ref, token
47
47
  path = "/" + path unless path[0,1] == "/"
48
48
 
49
49
  host = compute_asset_host path
data/config/routes.rb CHANGED
@@ -1,14 +1,14 @@
1
1
 
2
2
  Rails.application.routes.draw do
3
3
 
4
- match '/assets/javascripts(/v/:signature)/:name.:format' => 'assets#show_javascript',
4
+ match '/assets(-:token)/javascripts(/v/:signature)/:name.:format' => 'assets#show_javascript',
5
5
  :as => :javascript_asset,
6
6
  :format => "js", # Important for action-caching non-HTML resources
7
7
  :constraints => {
8
8
  :name => /[^ ]+/ # By default, route segments can't have dots. We allow all but space.
9
9
  }
10
10
 
11
- match '/assets/stylesheets(/v/:signature)/:name.:format' => 'assets#show_stylesheet',
11
+ match '/assets(-:token)/stylesheets(/v/:signature)/:name.:format' => 'assets#show_stylesheet',
12
12
  :as => :stylesheet_asset,
13
13
  :format => "css", # Important for action-caching non-HTML resources
14
14
  :constraints => { # By default, segments can't have dots. We allow all but space.
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dynamic_assets
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.7.0
5
+ version: 0.7.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Robert Davis
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-06 00:00:00 -05:00
13
+ date: 2011-06-08 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -128,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- hash: -1939636484692022246
131
+ hash: 2926007834367923587
132
132
  segments:
133
133
  - 0
134
134
  version: "0"