Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
a22164a2
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,发现更多精彩内容 >>
提交
a22164a2
编写于
8月 18, 2016
作者:
S
schneems
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix formatting
上级
9b22681c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
26 deletion
+25
-26
actionview/lib/action_view/helpers/asset_tag_helper.rb
actionview/lib/action_view/helpers/asset_tag_helper.rb
+8
-8
actionview/lib/action_view/helpers/asset_url_helper.rb
actionview/lib/action_view/helpers/asset_url_helper.rb
+14
-15
railties/test/application/asset_debugging_test.rb
railties/test/application/asset_debugging_test.rb
+3
-3
未找到文件。
actionview/lib/action_view/helpers/asset_tag_helper.rb
浏览文件 @
a22164a2
...
@@ -186,17 +186,17 @@ def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {})
...
@@ -186,17 +186,17 @@ def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {})
# favicon_link_tag 'mb-icon.png', rel: 'apple-touch-icon', type: 'image/png'
# favicon_link_tag 'mb-icon.png', rel: 'apple-touch-icon', type: 'image/png'
# # => <link href="/assets/mb-icon.png" rel="apple-touch-icon" type="image/png" />
# # => <link href="/assets/mb-icon.png" rel="apple-touch-icon" type="image/png" />
def
favicon_link_tag
(
source
=
"favicon.ico"
,
options
=
{})
def
favicon_link_tag
(
source
=
"favicon.ico"
,
options
=
{})
tag
(
'link'
,
{
tag
(
"link"
,
{
rel:
"shortcut icon"
,
rel:
"shortcut icon"
,
type:
"image/x-icon"
,
type:
"image/x-icon"
,
href:
path_to_image
(
source
,
{
public_folder:
options
.
delete
(
:public_folder
)
}
)
href:
path_to_image
(
source
,
public_folder:
options
.
delete
(
:public_folder
)
)
}.
merge!
(
options
.
symbolize_keys
))
}.
merge!
(
options
.
symbolize_keys
))
end
end
# Returns a link tag for a favicon asset in the public
# Returns a link tag for a favicon asset in the public
# folder. This uses +favicon_link_tag+ and skips any asset
# folder. This uses +favicon_link_tag+ and skips any asset
# lookups by assuming any assets are in the `public` folder.
# lookups by assuming any assets are in the `public` folder.
def
public_favicon_link_tag
(
source
=
'favicon.ico'
,
options
=
{})
def
public_favicon_link_tag
(
source
=
"favicon.ico"
,
options
=
{})
favicon_link_tag
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
favicon_link_tag
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
...
@@ -234,7 +234,7 @@ def image_tag(source, options={})
...
@@ -234,7 +234,7 @@ def image_tag(source, options={})
options
=
options
.
symbolize_keys
options
=
options
.
symbolize_keys
check_for_image_tag_errors
(
options
)
check_for_image_tag_errors
(
options
)
src
=
options
[
:src
]
=
path_to_image
(
source
,
{
public_folder:
options
.
delete
(
:public_folder
)
}
)
src
=
options
[
:src
]
=
path_to_image
(
source
,
public_folder:
options
.
delete
(
:public_folder
)
)
unless
src
.
start_with?
(
"cid:"
)
||
src
.
start_with?
(
"data:"
)
||
src
.
blank?
unless
src
.
start_with?
(
"cid:"
)
||
src
.
start_with?
(
"data:"
)
||
src
.
blank?
options
[
:alt
]
=
options
.
fetch
(
:alt
)
{
image_alt
(
src
)
}
options
[
:alt
]
=
options
.
fetch
(
:alt
)
{
image_alt
(
src
)
}
...
@@ -315,7 +315,7 @@ def video_tag(*sources)
...
@@ -315,7 +315,7 @@ def video_tag(*sources)
public_poster_folder
=
options
.
delete
(
:public_poster_folder
)
public_poster_folder
=
options
.
delete
(
:public_poster_folder
)
sources
<<
options
sources
<<
options
multiple_sources_tag
(
"video"
,
sources
)
do
|
options
|
multiple_sources_tag
(
"video"
,
sources
)
do
|
options
|
options
[
:poster
]
=
path_to_image
(
options
[
:poster
],
{
public_folder:
public_poster_folder
}
)
if
options
[
:poster
]
options
[
:poster
]
=
path_to_image
(
options
[
:poster
],
public_folder:
public_poster_folder
)
if
options
[
:poster
]
options
[
:width
],
options
[
:height
]
=
extract_dimensions
(
options
.
delete
(
:size
))
if
options
[
:size
]
options
[
:width
],
options
[
:height
]
=
extract_dimensions
(
options
.
delete
(
:size
))
if
options
[
:size
]
end
end
end
end
...
@@ -325,7 +325,7 @@ def video_tag(*sources)
...
@@ -325,7 +325,7 @@ def video_tag(*sources)
# lookups by assuming any assets are in the `public` folder.
# lookups by assuming any assets are in the `public` folder.
def
public_video_tag
(
*
sources
)
def
public_video_tag
(
*
sources
)
options
=
sources
.
extract_options!
options
=
sources
.
extract_options!
video_tag
(
*
sources
,
{
public_folder:
true
,
public_poster_folder:
true
}.
merge!
(
options
))
video_tag
(
*
sources
,
{
public_folder:
true
,
public_poster_folder:
true
}.
merge!
(
options
))
end
end
# Returns an HTML audio tag for the +source+.
# Returns an HTML audio tag for the +source+.
...
@@ -361,10 +361,10 @@ def multiple_sources_tag(type, sources)
...
@@ -361,10 +361,10 @@ def multiple_sources_tag(type, sources)
if
sources
.
size
>
1
if
sources
.
size
>
1
content_tag
(
type
,
options
)
do
content_tag
(
type
,
options
)
do
safe_join
sources
.
map
{
|
source
|
tag
(
"source"
,
src:
send
(
"path_to_
#{
type
}
"
,
source
,
{
public_folder:
public_folder
}
))
}
safe_join
sources
.
map
{
|
source
|
tag
(
"source"
,
src:
send
(
"path_to_
#{
type
}
"
,
source
,
public_folder:
public_folder
))
}
end
end
else
else
options
[
:src
]
=
send
(
"path_to_
#{
type
}
"
,
sources
.
first
,
{
public_folder:
public_folder
}
)
options
[
:src
]
=
send
(
"path_to_
#{
type
}
"
,
sources
.
first
,
public_folder:
public_folder
)
content_tag
(
type
,
nil
,
options
)
content_tag
(
type
,
nil
,
options
)
end
end
end
end
...
...
actionview/lib/action_view/helpers/asset_url_helper.rb
浏览文件 @
a22164a2
...
@@ -167,12 +167,11 @@ def asset_path(source, options = {})
...
@@ -167,12 +167,11 @@ def asset_path(source, options = {})
end
end
alias_method
:path_to_asset
,
:asset_path
# aliased to avoid conflicts with an asset_path named route
alias_method
:path_to_asset
,
:asset_path
# aliased to avoid conflicts with an asset_path named route
# Computes the path to an asset in the public folder.
# Computes the path to an asset in the public folder.
# This uses +asset_path+ and skips any asset lookups by assuming the asset is in the
# This uses +asset_path+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_asset_path
(
source
,
options
=
{})
def
public_asset_path
(
source
,
options
=
{})
path_to_asset
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
path_to_asset
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_asset
,
:public_asset_path
# aliased to avoid conflicts with an public_asset_path named route
alias_method
:path_to_public_asset
,
:public_asset_path
# aliased to avoid conflicts with an public_asset_path named route
...
@@ -195,7 +194,7 @@ def asset_url(source, options = {})
...
@@ -195,7 +194,7 @@ def asset_url(source, options = {})
# This uses +asset_url+ and skips any asset lookups by assuming the asset is in the
# This uses +asset_url+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_asset_url
(
source
,
options
=
{})
def
public_asset_url
(
source
,
options
=
{})
url_to_asset
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
url_to_asset
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_asset
,
:public_asset_path
# aliased to avoid conflicts with a public_asset_path named route
alias_method
:path_to_public_asset
,
:public_asset_path
# aliased to avoid conflicts with a public_asset_path named route
...
@@ -289,7 +288,7 @@ def javascript_path(source, options = {})
...
@@ -289,7 +288,7 @@ def javascript_path(source, options = {})
# This uses +javascript_path+ and skips any asset lookups by assuming the asset is in the
# This uses +javascript_path+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_javascript_path
(
source
,
options
=
{})
def
public_javascript_path
(
source
,
options
=
{})
path_to_javascript
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
path_to_javascript
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_javascript
,
:public_javascript_path
# aliased to avoid conflicts with a public_javascript_path named route
alias_method
:path_to_public_javascript
,
:public_javascript_path
# aliased to avoid conflicts with a public_javascript_path named route
...
@@ -309,7 +308,7 @@ def javascript_url(source, options = {})
...
@@ -309,7 +308,7 @@ def javascript_url(source, options = {})
# This uses +javascript_url+ and skips any asset lookups by assuming the asset is in the
# This uses +javascript_url+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_javascript_url
(
source
,
options
=
{})
def
public_javascript_url
(
source
,
options
=
{})
url_to_javascript
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
url_to_javascript
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_javascript
,
:public_javascript_path
# aliased to avoid conflicts with a public_javascript_path named route
alias_method
:path_to_public_javascript
,
:public_javascript_path
# aliased to avoid conflicts with a public_javascript_path named route
...
@@ -332,7 +331,7 @@ def stylesheet_path(source, options = {})
...
@@ -332,7 +331,7 @@ def stylesheet_path(source, options = {})
# This uses +stylesheet_path+ and skips any asset lookups by assuming the asset is in the
# This uses +stylesheet_path+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_stylesheet_path
(
source
,
options
=
{})
def
public_stylesheet_path
(
source
,
options
=
{})
path_to_stylesheet
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
path_to_stylesheet
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_stylesheet
,
:public_stylesheet_path
# aliased to avoid conflicts with a public_stylesheet_path named route
alias_method
:path_to_public_stylesheet
,
:public_stylesheet_path
# aliased to avoid conflicts with a public_stylesheet_path named route
...
@@ -352,7 +351,7 @@ def stylesheet_url(source, options = {})
...
@@ -352,7 +351,7 @@ def stylesheet_url(source, options = {})
# This uses +stylesheet_url+ and skips any asset lookups by assuming the asset is in the
# This uses +stylesheet_url+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_stylesheet_url
(
source
,
options
=
{})
def
public_stylesheet_url
(
source
,
options
=
{})
url_to_stylesheet
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
url_to_stylesheet
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_stylesheet
,
:public_stylesheet_path
# aliased to avoid conflicts with a public_stylesheet_path named route
alias_method
:path_to_public_stylesheet
,
:public_stylesheet_path
# aliased to avoid conflicts with a public_stylesheet_path named route
...
@@ -378,7 +377,7 @@ def image_path(source, options = {})
...
@@ -378,7 +377,7 @@ def image_path(source, options = {})
# This uses +image_path+ and skips any asset lookups by assuming the asset is in the
# This uses +image_path+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_image_path
(
source
,
options
=
{})
def
public_image_path
(
source
,
options
=
{})
path_to_image
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
path_to_image
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_image
,
:public_image_path
# aliased to avoid conflicts with a public_image_path named route
alias_method
:path_to_public_image
,
:public_image_path
# aliased to avoid conflicts with a public_image_path named route
...
@@ -398,7 +397,7 @@ def image_url(source, options = {})
...
@@ -398,7 +397,7 @@ def image_url(source, options = {})
# This uses +image_url+ and skips any asset lookups by assuming the asset is in the
# This uses +image_url+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_image_url
(
source
,
options
=
{})
def
public_image_url
(
source
,
options
=
{})
url_to_image
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
url_to_image
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_image
,
:public_image_path
# aliased to avoid conflicts with a public_image_path named route
alias_method
:path_to_public_image
,
:public_image_path
# aliased to avoid conflicts with a public_image_path named route
...
@@ -420,7 +419,7 @@ def video_path(source, options = {})
...
@@ -420,7 +419,7 @@ def video_path(source, options = {})
# This uses +video_path+ and skips any asset lookups by assuming the asset is in the
# This uses +video_path+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_video_path
(
source
,
options
=
{})
def
public_video_path
(
source
,
options
=
{})
path_to_video
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
path_to_video
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_video
,
:public_video_path
# aliased to avoid conflicts with a public_video_path named route
alias_method
:path_to_public_video
,
:public_video_path
# aliased to avoid conflicts with a public_video_path named route
...
@@ -440,7 +439,7 @@ def video_url(source, options = {})
...
@@ -440,7 +439,7 @@ def video_url(source, options = {})
# This uses +video_url+ and skips any asset lookups by assuming the asset is in the
# This uses +video_url+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_video_url
(
source
,
options
=
{})
def
public_video_url
(
source
,
options
=
{})
url_to_video
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
url_to_video
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_video
,
:public_video_path
# aliased to avoid conflicts with a public_video_path named route
alias_method
:path_to_public_video
,
:public_video_path
# aliased to avoid conflicts with a public_video_path named route
...
@@ -462,7 +461,7 @@ def audio_path(source, options = {})
...
@@ -462,7 +461,7 @@ def audio_path(source, options = {})
# This uses +audio_path+ and skips any asset lookups by assuming the asset is in the
# This uses +audio_path+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_audio_path
(
source
,
options
=
{})
def
public_audio_path
(
source
,
options
=
{})
path_to_audio
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
path_to_audio
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_audio
,
:public_audio_path
# aliased to avoid conflicts with a public_audio_path named route
alias_method
:path_to_public_audio
,
:public_audio_path
# aliased to avoid conflicts with a public_audio_path named route
...
@@ -482,7 +481,7 @@ def audio_url(source, options = {})
...
@@ -482,7 +481,7 @@ def audio_url(source, options = {})
# This uses +audio_url+ and skips any asset lookups by assuming the asset is in the
# This uses +audio_url+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_audio_url
(
source
,
options
=
{})
def
public_audio_url
(
source
,
options
=
{})
url_to_audio
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
url_to_audio
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_audio
,
:public_audio_path
# aliased to avoid conflicts with a public_audio_path named route
alias_method
:path_to_public_audio
,
:public_audio_path
# aliased to avoid conflicts with a public_audio_path named route
...
@@ -503,7 +502,7 @@ def font_path(source, options = {})
...
@@ -503,7 +502,7 @@ def font_path(source, options = {})
# This uses +font_path+ and skips any asset lookups by assuming the asset is in the
# This uses +font_path+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_font_path
(
source
,
options
=
{})
def
public_font_path
(
source
,
options
=
{})
path_to_font
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
path_to_font
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_font
,
:public_font_path
# aliased to avoid conflicts with a public_font_path named route
alias_method
:path_to_public_font
,
:public_font_path
# aliased to avoid conflicts with a public_font_path named route
...
@@ -523,7 +522,7 @@ def font_url(source, options = {})
...
@@ -523,7 +522,7 @@ def font_url(source, options = {})
# This uses +font_url+ and skips any asset lookups by assuming the asset is in the
# This uses +font_url+ and skips any asset lookups by assuming the asset is in the
# `public` folder.
# `public` folder.
def
public_font_url
(
source
,
options
=
{})
def
public_font_url
(
source
,
options
=
{})
url_to_font
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
url_to_font
(
source
,
{
public_folder:
true
}.
merge!
(
options
))
end
end
alias_method
:path_to_public_font
,
:public_font_path
# aliased to avoid conflicts with a public_font_url named route
alias_method
:path_to_public_font
,
:public_font_path
# aliased to avoid conflicts with a public_font_url named route
end
end
...
...
railties/test/application/asset_debugging_test.rb
浏览文件 @
a22164a2
...
@@ -94,7 +94,7 @@ class ::PostsController < ActionController::Base ; end
...
@@ -94,7 +94,7 @@ class ::PostsController < ActionController::Base ; end
class
::
PostsController
<
ActionController
::
Base
;
end
class
::
PostsController
<
ActionController
::
Base
;
end
get
'/posts?debug_assets=true'
get
"/posts?debug_assets=true"
body
=
last_response
.
body
body
=
last_response
.
body
assert_match
(
tag_match
,
body
,
"Expected `
#{
view_method
}
` to produce a match to
#{
tag_match
}
, but did not:
#{
body
}
"
)
assert_match
(
tag_match
,
body
,
"Expected `
#{
view_method
}
` to produce a match to
#{
tag_match
}
, but did not:
#{
body
}
"
)
...
@@ -120,7 +120,7 @@ class ::PostsController < ActionController::Base ; end
...
@@ -120,7 +120,7 @@ class ::PostsController < ActionController::Base ; end
class
::
PostsController
<
ActionController
::
Base
;
end
class
::
PostsController
<
ActionController
::
Base
;
end
get
'/posts?debug_assets=true'
get
"/posts?debug_assets=true"
body
=
last_response
.
body
body
=
last_response
.
body
assert_match
(
tag_match
,
body
,
"Expected `
#{
view_method
}
` to produce a match to
#{
tag_match
}
, but did not:
#{
body
}
"
)
assert_match
(
tag_match
,
body
,
"Expected `
#{
view_method
}
` to produce a match to
#{
tag_match
}
, but did not:
#{
body
}
"
)
...
@@ -140,7 +140,7 @@ class ::PostsController < ActionController::Base ; end
...
@@ -140,7 +140,7 @@ class ::PostsController < ActionController::Base ; end
class
::
PostsController
<
ActionController
::
Base
;
end
class
::
PostsController
<
ActionController
::
Base
;
end
get
'/posts?debug_assets=true'
get
"/posts?debug_assets=true"
body
=
last_response
.
body
.
strip
body
=
last_response
.
body
.
strip
assert_match
(
tag_match
,
body
,
"Expected `
#{
view_method
}
` to produce a match to
#{
tag_match
}
, but did not:
#{
body
}
"
)
assert_match
(
tag_match
,
body
,
"Expected `
#{
view_method
}
` to produce a match to
#{
tag_match
}
, but did not:
#{
body
}
"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录