Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
e484d4ae
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e484d4ae
编写于
3月 11, 2010
作者:
D
Denis Odorcic
提交者:
José Valim
3月 12, 2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Made asset_tag_helper use config.perform_caching instead of ActionController::Base.perform_caching
Signed-off-by:
N
José Valim
<
jose.valim@gmail.com
>
上级
b8f7ba29
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
32 addition
and
32 deletion
+32
-32
actionpack/lib/action_view/helpers/asset_tag_helper.rb
actionpack/lib/action_view/helpers/asset_tag_helper.rb
+14
-14
actionpack/test/template/asset_tag_helper_test.rb
actionpack/test/template/asset_tag_helper_test.rb
+18
-18
未找到文件。
actionpack/lib/action_view/helpers/asset_tag_helper.rb
浏览文件 @
e484d4ae
...
...
@@ -242,12 +242,12 @@ def javascript_path(source)
# == Caching multiple javascripts into one
#
# You can also cache multiple javascripts into one file, which requires less HTTP connections to download and can better be
# compressed by gzip (leading to faster transfers). Caching will only happen if
ActionController::Base
.perform_caching
# compressed by gzip (leading to faster transfers). Caching will only happen if
config
.perform_caching
# is set to <tt>true</tt> (which is the case by default for the Rails production environment, but not for the development
# environment).
#
# ==== Examples
# javascript_include_tag :all, :cache => true # when
ActionController::Base
.perform_caching is false =>
# javascript_include_tag :all, :cache => true # when
config
.perform_caching is false =>
# <script type="text/javascript" src="/javascripts/prototype.js"></script>
# <script type="text/javascript" src="/javascripts/effects.js"></script>
# ...
...
...
@@ -255,15 +255,15 @@ def javascript_path(source)
# <script type="text/javascript" src="/javascripts/shop.js"></script>
# <script type="text/javascript" src="/javascripts/checkout.js"></script>
#
# javascript_include_tag :all, :cache => true # when
ActionController::Base
.perform_caching is true =>
# javascript_include_tag :all, :cache => true # when
config
.perform_caching is true =>
# <script type="text/javascript" src="/javascripts/all.js"></script>
#
# javascript_include_tag "prototype", "cart", "checkout", :cache => "shop" # when
ActionController::Base
.perform_caching is false =>
# javascript_include_tag "prototype", "cart", "checkout", :cache => "shop" # when
config
.perform_caching is false =>
# <script type="text/javascript" src="/javascripts/prototype.js"></script>
# <script type="text/javascript" src="/javascripts/cart.js"></script>
# <script type="text/javascript" src="/javascripts/checkout.js"></script>
#
# javascript_include_tag "prototype", "cart", "checkout", :cache => "shop" # when
ActionController::Base
.perform_caching is true =>
# javascript_include_tag "prototype", "cart", "checkout", :cache => "shop" # when
config
.perform_caching is true =>
# <script type="text/javascript" src="/javascripts/shop.js"></script>
#
# The <tt>:recursive</tt> option is also available for caching:
...
...
@@ -275,11 +275,11 @@ def javascript_include_tag(*sources)
cache
=
concat
||
options
.
delete
(
"cache"
)
recursive
=
options
.
delete
(
"recursive"
)
if
concat
||
(
ActionController
::
Base
.
perform_caching
&&
cache
)
if
concat
||
(
config
.
perform_caching
&&
cache
)
joined_javascript_name
=
(
cache
==
true
?
"all"
:
cache
)
+
".js"
joined_javascript_path
=
File
.
join
(
joined_javascript_name
[
/^
#{
File
::
SEPARATOR
}
/
]
?
config
.
assets_dir
:
config
.
javascripts_dir
,
joined_javascript_name
)
unless
ActionController
::
Base
.
perform_caching
&&
File
.
exists?
(
joined_javascript_path
)
unless
config
.
perform_caching
&&
File
.
exists?
(
joined_javascript_path
)
write_asset_file_contents
(
joined_javascript_path
,
compute_javascript_paths
(
sources
,
recursive
))
end
javascript_src_tag
(
joined_javascript_name
,
options
)
...
...
@@ -390,25 +390,25 @@ def stylesheet_path(source)
# == Caching multiple stylesheets into one
#
# You can also cache multiple stylesheets into one file, which requires less HTTP connections and can better be
# compressed by gzip (leading to faster transfers). Caching will only happen if
ActionController::Base
.perform_caching
# compressed by gzip (leading to faster transfers). Caching will only happen if
config
.perform_caching
# is set to true (which is the case by default for the Rails production environment, but not for the development
# environment). Examples:
#
# ==== Examples
# stylesheet_link_tag :all, :cache => true # when
ActionController::Base
.perform_caching is false =>
# stylesheet_link_tag :all, :cache => true # when
config
.perform_caching is false =>
# <link href="/stylesheets/style1.css" media="screen" rel="stylesheet" type="text/css" />
# <link href="/stylesheets/styleB.css" media="screen" rel="stylesheet" type="text/css" />
# <link href="/stylesheets/styleX2.css" media="screen" rel="stylesheet" type="text/css" />
#
# stylesheet_link_tag :all, :cache => true # when
ActionController::Base
.perform_caching is true =>
# stylesheet_link_tag :all, :cache => true # when
config
.perform_caching is true =>
# <link href="/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />
#
# stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when
ActionController::Base
.perform_caching is false =>
# stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when
config
.perform_caching is false =>
# <link href="/stylesheets/shop.css" media="screen" rel="stylesheet" type="text/css" />
# <link href="/stylesheets/cart.css" media="screen" rel="stylesheet" type="text/css" />
# <link href="/stylesheets/checkout.css" media="screen" rel="stylesheet" type="text/css" />
#
# stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when
ActionController::Base
.perform_caching is true =>
# stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when
config
.perform_caching is true =>
# <link href="/stylesheets/payment.css" media="screen" rel="stylesheet" type="text/css" />
#
# The <tt>:recursive</tt> option is also available for caching:
...
...
@@ -426,11 +426,11 @@ def stylesheet_link_tag(*sources)
cache
=
concat
||
options
.
delete
(
"cache"
)
recursive
=
options
.
delete
(
"recursive"
)
if
concat
||
(
ActionController
::
Base
.
perform_caching
&&
cache
)
if
concat
||
(
config
.
perform_caching
&&
cache
)
joined_stylesheet_name
=
(
cache
==
true
?
"all"
:
cache
)
+
".css"
joined_stylesheet_path
=
File
.
join
(
joined_stylesheet_name
[
/^
#{
File
::
SEPARATOR
}
/
]
?
config
.
assets_dir
:
config
.
stylesheets_dir
,
joined_stylesheet_name
)
unless
ActionController
::
Base
.
perform_caching
&&
File
.
exists?
(
joined_stylesheet_path
)
unless
config
.
perform_caching
&&
File
.
exists?
(
joined_stylesheet_path
)
write_asset_file_contents
(
joined_stylesheet_path
,
compute_stylesheet_paths
(
sources
,
recursive
))
end
stylesheet_tag
(
joined_stylesheet_name
,
options
)
...
...
actionpack/test/template/asset_tag_helper_test.rb
浏览文件 @
e484d4ae
...
...
@@ -50,7 +50,7 @@ def host_with_port() 'localhost' end
end
def
teardown
ActionController
::
Base
.
perform_caching
=
false
config
.
perform_caching
=
false
ENV
.
delete
(
'RAILS_ASSET_ID'
)
end
...
...
@@ -422,7 +422,7 @@ def test_caching_image_path_with_caching_and_proc_asset_host_using_request
def
test_caching_javascript_include_tag_when_caching_on
ENV
[
"RAILS_ASSET_ID"
]
=
""
@controller
.
config
.
asset_host
=
'http://a0.example.com'
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
assert_dom_equal
(
%(<script src="http://a0.example.com/javascripts/all.js" type="text/javascript"></script>)
,
...
...
@@ -454,7 +454,7 @@ def test_caching_javascript_include_tag_when_caching_on
def
test_caching_javascript_include_tag_when_caching_on_with_proc_asset_host
ENV
[
'RAILS_ASSET_ID'
]
=
''
@controller
.
config
.
asset_host
=
Proc
.
new
{
|
source
|
"http://a
#{
source
.
length
}
.example.com"
}
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
assert_equal
'/javascripts/scripts.js'
.
length
,
23
assert_dom_equal
(
...
...
@@ -477,7 +477,7 @@ def test_caching_javascript_include_tag_when_caching_on_with_2_argument_proc_ass
"
#{
request
.
protocol
}
assets
#{
source
.
length
}
.example.com"
end
}
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
assert_equal
'/javascripts/vanilla.js'
.
length
,
23
assert_dom_equal
(
...
...
@@ -517,7 +517,7 @@ def call(source, request)
end
end
.
new
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
assert_equal
'/javascripts/vanilla.js'
.
length
,
23
assert_dom_equal
(
...
...
@@ -548,7 +548,7 @@ def ssl?() true end
def
test_caching_javascript_include_tag_when_caching_on_and_using_subdirectory
ENV
[
"RAILS_ASSET_ID"
]
=
""
@controller
.
config
.
asset_host
=
'http://a%d.example.com'
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
hash
=
'/javascripts/cache/money.js'
.
hash
%
4
assert_dom_equal
(
...
...
@@ -564,7 +564,7 @@ def test_caching_javascript_include_tag_when_caching_on_and_using_subdirectory
def
test_caching_javascript_include_tag_with_all_and_recursive_puts_defaults_at_the_start_of_the_file
ENV
[
"RAILS_ASSET_ID"
]
=
""
@controller
.
config
.
asset_host
=
'http://a0.example.com'
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
assert_dom_equal
(
%(<script src="http://a0.example.com/javascripts/combined.js" type="text/javascript"></script>)
,
...
...
@@ -585,7 +585,7 @@ def test_caching_javascript_include_tag_with_all_and_recursive_puts_defaults_at_
def
test_caching_javascript_include_tag_with_all_puts_defaults_at_the_start_of_the_file
ENV
[
"RAILS_ASSET_ID"
]
=
""
@controller
.
config
.
asset_host
=
'http://a0.example.com'
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
assert_dom_equal
(
%(<script src="http://a0.example.com/javascripts/combined.js" type="text/javascript"></script>)
,
...
...
@@ -606,7 +606,7 @@ def test_caching_javascript_include_tag_with_all_puts_defaults_at_the_start_of_t
def
test_caching_javascript_include_tag_with_relative_url_root
ENV
[
"RAILS_ASSET_ID"
]
=
""
@controller
.
config
.
relative_url_root
=
"/collaboration/hieraki"
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
assert_dom_equal
(
%(<script src="/collaboration/hieraki/javascripts/all.js" type="text/javascript"></script>)
,
...
...
@@ -629,7 +629,7 @@ def test_caching_javascript_include_tag_with_relative_url_root
def
test_caching_javascript_include_tag_when_caching_off
ENV
[
"RAILS_ASSET_ID"
]
=
""
ActionController
::
Base
.
perform_caching
=
false
config
.
perform_caching
=
false
assert_dom_equal
(
%(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>)
,
...
...
@@ -658,7 +658,7 @@ def test_caching_javascript_include_tag_when_caching_off
def
test_caching_javascript_include_tag_when_caching_on_and_missing_javascript_file
ENV
[
"RAILS_ASSET_ID"
]
=
""
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
assert_raise
(
Errno
::
ENOENT
)
{
javascript_include_tag
(
'bank'
,
'robber'
,
'missing_security_guard'
,
:cache
=>
true
)
...
...
@@ -675,7 +675,7 @@ def test_caching_javascript_include_tag_when_caching_on_and_missing_javascript_f
def
test_caching_javascript_include_tag_when_caching_off_and_missing_javascript_file
ENV
[
"RAILS_ASSET_ID"
]
=
""
ActionController
::
Base
.
perform_caching
=
false
config
.
perform_caching
=
false
assert_raise
(
Errno
::
ENOENT
)
{
javascript_include_tag
(
'bank'
,
'robber'
,
'missing_security_guard'
,
:cache
=>
true
)
...
...
@@ -693,7 +693,7 @@ def test_caching_javascript_include_tag_when_caching_off_and_missing_javascript_
def
test_caching_stylesheet_link_tag_when_caching_on
ENV
[
"RAILS_ASSET_ID"
]
=
""
@controller
.
config
.
asset_host
=
'http://a0.example.com'
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
assert_dom_equal
(
%(<link href="http://a0.example.com/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />)
,
...
...
@@ -760,7 +760,7 @@ def test_concat_stylesheet_link_tag_when_caching_off
def
test_caching_stylesheet_link_tag_when_caching_on_and_missing_css_file
ENV
[
"RAILS_ASSET_ID"
]
=
""
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
assert_raise
(
Errno
::
ENOENT
)
{
stylesheet_link_tag
(
'bank'
,
'robber'
,
'missing_security_guard'
,
:cache
=>
true
)
...
...
@@ -781,7 +781,7 @@ def test_caching_stylesheet_link_tag_when_caching_on_and_missing_css_file
def
test_caching_stylesheet_link_tag_when_caching_off_and_missing_css_file
ENV
[
"RAILS_ASSET_ID"
]
=
""
ActionController
::
Base
.
perform_caching
=
false
config
.
perform_caching
=
false
assert_raise
(
Errno
::
ENOENT
)
{
stylesheet_link_tag
(
'bank'
,
'robber'
,
'missing_security_guard'
,
:cache
=>
true
)
...
...
@@ -803,7 +803,7 @@ def test_caching_stylesheet_link_tag_when_caching_off_and_missing_css_file
def
test_caching_stylesheet_link_tag_when_caching_on_with_proc_asset_host
ENV
[
"RAILS_ASSET_ID"
]
=
""
@controller
.
config
.
asset_host
=
Proc
.
new
{
|
source
|
"http://a
#{
source
.
length
}
.example.com"
}
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
assert_equal
'/stylesheets/styles.css'
.
length
,
23
assert_dom_equal
(
...
...
@@ -820,7 +820,7 @@ def test_caching_stylesheet_link_tag_when_caching_on_with_proc_asset_host
def
test_caching_stylesheet_link_tag_with_relative_url_root
ENV
[
"RAILS_ASSET_ID"
]
=
""
@controller
.
config
.
relative_url_root
=
"/collaboration/hieraki"
ActionController
::
Base
.
perform_caching
=
true
config
.
perform_caching
=
true
assert_dom_equal
(
%(<link href="/collaboration/hieraki/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />)
,
...
...
@@ -845,7 +845,7 @@ def test_caching_stylesheet_link_tag_with_relative_url_root
def
test_caching_stylesheet_include_tag_when_caching_off
ENV
[
"RAILS_ASSET_ID"
]
=
""
ActionController
::
Base
.
perform_caching
=
false
config
.
perform_caching
=
false
assert_dom_equal
(
%(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />)
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录