Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
5e519fb0
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,发现更多精彩内容 >>
提交
5e519fb0
编写于
5月 22, 2011
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3-1-stable'
Conflicts: actionpack/actionpack.gemspec activemodel/activemodel.gemspec
上级
ba3ea9c9
7ad24a7d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
61 addition
and
18 deletion
+61
-18
actionpack/actionpack.gemspec
actionpack/actionpack.gemspec
+2
-1
actionpack/lib/action_view/helpers/sprockets_helper.rb
actionpack/lib/action_view/helpers/sprockets_helper.rb
+47
-15
actionpack/test/fixtures/sprockets/app/javascripts/application.js
...ck/test/fixtures/sprockets/app/javascripts/application.js
+1
-0
actionpack/test/fixtures/sprockets/app/stylesheets/application.css
...k/test/fixtures/sprockets/app/stylesheets/application.css
+1
-0
actionpack/test/template/sprockets_helper_test.rb
actionpack/test/template/sprockets_helper_test.rb
+9
-2
activemodel/activemodel.gemspec
activemodel/activemodel.gemspec
+1
-0
未找到文件。
actionpack/actionpack.gemspec
浏览文件 @
5e519fb0
...
...
@@ -20,10 +20,11 @@
s
.
add_dependency
(
'activemodel'
,
version
)
s
.
add_dependency
(
'rack-cache'
,
'~> 1.0.1'
)
s
.
add_dependency
(
'builder'
,
'~> 3.0.0'
)
s
.
add_dependency
(
'i18n'
,
'~> 0.6'
)
s
.
add_dependency
(
'rack'
,
'~> 1.3.0.beta2'
)
s
.
add_dependency
(
'rack-test'
,
'~> 0.6.0'
)
s
.
add_dependency
(
'rack-mount'
,
'~> 0.8.1'
)
s
.
add_dependency
(
'sprockets'
,
'~> 2.0.0.beta.
5
'
)
s
.
add_dependency
(
'sprockets'
,
'~> 2.0.0.beta.
8
'
)
s
.
add_dependency
(
'tzinfo'
,
'~> 0.3.27'
)
s
.
add_dependency
(
'erubis'
,
'~> 2.7.0'
)
end
actionpack/lib/action_view/helpers/sprockets_helper.rb
浏览文件 @
5e519fb0
...
...
@@ -4,28 +4,53 @@
module
ActionView
module
Helpers
module
SprocketsHelper
def
asset_path
(
source
,
default_ext
=
nil
)
sprockets_asset_paths
.
compute_public_path
(
source
,
'assets'
,
default_ext
,
true
)
def
debug_assets?
params
[
:debug_assets
]
==
'1'
||
params
[
:debug_assets
]
==
'true'
end
def
asset_path
(
source
,
default_ext
=
nil
,
body
=
false
)
source
=
source
.
logical_path
if
source
.
respond_to?
(
:logical_path
)
path
=
sprockets_asset_paths
.
compute_public_path
(
source
,
'assets'
,
default_ext
,
true
)
body
?
"
#{
path
}
?body=1"
:
path
end
def
sprockets_javascript_include_tag
(
source
,
options
=
{})
options
=
{
'type'
=>
"text/javascript"
,
'src'
=>
asset_path
(
source
,
'js'
)
}.
merge
(
options
.
stringify_keys
)
debug
=
options
.
key?
(
:debug
)
?
options
.
delete
(
:debug
)
:
debug_assets?
body
=
options
.
key?
(
:body
)
?
options
.
delete
(
:body
)
:
false
content_tag
'script'
,
""
,
options
if
debug
&&
asset
=
sprockets_asset_paths
.
asset_for
(
source
,
'js'
)
asset
.
to_a
.
map
{
|
dep
|
sprockets_javascript_include_tag
(
dep
,
:debug
=>
false
,
:body
=>
true
)
}.
join
(
"
\n
"
).
html_safe
else
options
=
{
'type'
=>
"text/javascript"
,
'src'
=>
asset_path
(
source
,
'js'
,
body
)
}.
merge
(
options
.
stringify_keys
)
content_tag
'script'
,
""
,
options
end
end
def
sprockets_stylesheet_link_tag
(
source
,
options
=
{})
options
=
{
'rel'
=>
"stylesheet"
,
'type'
=>
"text/css"
,
'media'
=>
"screen"
,
'href'
=>
asset_path
(
source
,
'css'
)
}.
merge
(
options
.
stringify_keys
)
debug
=
options
.
key?
(
:debug
)
?
options
.
delete
(
:debug
)
:
debug_assets?
body
=
options
.
key?
(
:body
)
?
options
.
delete
(
:body
)
:
false
tag
'link'
,
options
if
debug
&&
asset
=
sprockets_asset_paths
.
asset_for
(
source
,
'css'
)
asset
.
to_a
.
map
{
|
dep
|
sprockets_stylesheet_link_tag
(
dep
,
:debug
=>
false
,
:body
=>
true
)
}.
join
(
"
\n
"
).
html_safe
else
options
=
{
'rel'
=>
"stylesheet"
,
'type'
=>
"text/css"
,
'media'
=>
"screen"
,
'href'
=>
asset_path
(
source
,
'css'
,
body
)
}.
merge
(
options
.
stringify_keys
)
tag
'link'
,
options
end
end
private
...
...
@@ -39,6 +64,13 @@ def sprockets_asset_paths
end
class
AssetPaths
<
ActionView
::
Helpers
::
AssetPaths
#:nodoc:
def
asset_for
(
source
,
ext
)
source
=
source
.
to_s
return
nil
if
is_uri?
(
source
)
source
=
rewrite_extension
(
source
,
nil
,
ext
)
assets
[
source
]
end
def
rewrite_asset_path
(
source
,
dir
)
if
source
[
0
]
==
?/
source
...
...
@@ -66,4 +98,4 @@ def performing_caching?
end
end
end
end
\ No newline at end of file
end
actionpack/test/fixtures/sprockets/app/javascripts/application.js
浏览文件 @
5e519fb0
//= require xmlhr
actionpack/test/fixtures/sprockets/app/stylesheets/application.css
浏览文件 @
5e519fb0
/*= require style */
actionpack/test/template/sprockets_helper_test.rb
浏览文件 @
5e519fb0
...
...
@@ -18,6 +18,7 @@ def setup
super
@controller
=
BasicController
.
new
@controller
.
stubs
(
:params
).
returns
({})
@request
=
Class
.
new
do
def
protocol
()
'http://'
end
...
...
@@ -90,10 +91,13 @@ def url_for(*args)
sprockets_javascript_include_tag
(
"xmlhr.js"
)
assert_equal
'<script src="http://www.example.com/xmlhr" type="text/javascript"></script>'
,
sprockets_javascript_include_tag
(
"http://www.example.com/xmlhr"
)
assert_equal
"<script src=
\"
/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js?body=1
\"
type=
\"
text/javascript
\"
></script>
\n
<script src=
\"
/assets/application-d41d8cd98f00b204e9800998ecf8427e.js?body=1
\"
type=
\"
text/javascript
\"
></script>"
,
sprockets_javascript_include_tag
(
:application
,
:debug
=>
true
)
end
test
"stylesheet path"
do
assert_equal
"/assets/application-
d41d8cd98f00b204e9800998ecf8427e
.css"
,
asset_path
(
:application
,
"css"
)
assert_equal
"/assets/application-
68b329da9893e34099c7d8ad5cb9c940
.css"
,
asset_path
(
:application
,
"css"
)
assert_equal
"/assets/style-d41d8cd98f00b204e9800998ecf8427e.css"
,
asset_path
(
"style"
,
"css"
)
assert_equal
"/assets/dir/style-d41d8cd98f00b204e9800998ecf8427e.css"
,
asset_path
(
"dir/style.css"
,
"css"
)
...
...
@@ -106,7 +110,7 @@ def url_for(*args)
end
test
"stylesheet link tag"
do
assert_equal
'<link href="/assets/application-
d41d8cd98f00b204e9800998ecf8427e
.css" media="screen" rel="stylesheet" type="text/css" />'
,
assert_equal
'<link href="/assets/application-
68b329da9893e34099c7d8ad5cb9c940
.css" media="screen" rel="stylesheet" type="text/css" />'
,
sprockets_stylesheet_link_tag
(
:application
)
assert_equal
'<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />'
,
...
...
@@ -120,5 +124,8 @@ def url_for(*args)
sprockets_stylesheet_link_tag
(
"style"
,
:media
=>
"all"
)
assert_equal
'<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="print" rel="stylesheet" type="text/css" />'
,
sprockets_stylesheet_link_tag
(
"style"
,
:media
=>
"print"
)
assert_equal
"<link href=
\"
/assets/style-d41d8cd98f00b204e9800998ecf8427e.css?body=1
\"
media=
\"
screen
\"
rel=
\"
stylesheet
\"
type=
\"
text/css
\"
/>
\n
<link href=
\"
/assets/application-68b329da9893e34099c7d8ad5cb9c940.css?body=1
\"
media=
\"
screen
\"
rel=
\"
stylesheet
\"
type=
\"
text/css
\"
/>"
,
sprockets_stylesheet_link_tag
(
:application
,
:debug
=>
true
)
end
end
activemodel/activemodel.gemspec
浏览文件 @
5e519fb0
...
...
@@ -18,5 +18,6 @@
s
.
add_dependency
(
'activesupport'
,
version
)
s
.
add_dependency
(
'builder'
,
'~> 3.0.0'
)
s
.
add_dependency
(
'i18n'
,
'~> 0.6'
)
s
.
add_dependency
(
'bcrypt-ruby'
,
'~> 2.1.4'
)
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录