Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
937f4191
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,发现更多精彩内容 >>
提交
937f4191
编写于
7月 29, 2010
作者:
P
Piotr Sarnacki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Engine's assets are now served with ActionDispatch::Static
上级
401cd979
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
6 deletion
+46
-6
railties/lib/rails/application.rb
railties/lib/rails/application.rb
+17
-1
railties/lib/rails/engine.rb
railties/lib/rails/engine.rb
+4
-5
railties/test/railties/engine_test.rb
railties/test/railties/engine_test.rb
+25
-0
未找到文件。
railties/lib/rails/application.rb
浏览文件 @
937f4191
...
...
@@ -145,9 +145,25 @@ def config
protected
def
static_paths
@static_paths
||=
begin
static_paths
=
ActiveSupport
::
OrderedHash
.
new
static_paths
[
"/"
]
=
paths
.
public
.
to_a
.
first
railties
.
all
do
|
railtie
|
if
railtie
.
config
.
respond_to?
(
:asset_path
)
&&
railtie
.
config
.
asset_path
public_path
=
railtie
.
config
.
paths
.
public
.
to_a
.
first
static_paths
[
railtie
.
config
.
asset_path
%
""
]
=
public_path
if
File
.
exists?
(
public_path
)
end
end
static_paths
end
end
def
default_middleware_stack
ActionDispatch
::
MiddlewareStack
.
new
.
tap
do
|
middleware
|
middleware
.
use
::
ActionDispatch
::
Static
,
paths
.
public
.
to_a
.
first
if
config
.
serve_static_assets
middleware
.
use
::
ActionDispatch
::
Static
,
static_paths
if
config
.
serve_static_assets
middleware
.
use
::
Rack
::
Lock
if
!
config
.
allow_concurrency
middleware
.
use
::
Rack
::
Runtime
middleware
.
use
::
Rails
::
Rack
::
Logger
...
...
railties/lib/rails/engine.rb
浏览文件 @
937f4191
...
...
@@ -256,11 +256,7 @@ def initializers
end
def
config
@config
||=
begin
config
=
Engine
::
Configuration
.
new
(
find_root_with_flag
(
"lib"
))
config
.
asset_path
=
"/
#{
engine_name
}
%s"
if
File
.
exists?
(
config
.
paths
.
public
.
to_a
.
first
)
config
end
@config
||=
Engine
::
Configuration
.
new
(
find_root_with_flag
(
"lib"
))
end
# Add configured load paths to ruby load paths and remove duplicates.
...
...
@@ -335,6 +331,9 @@ def config
require
environment
if
environment
end
initializer
:default_asset_path
do
config
.
asset_path
=
"/
#{
engine_name
}
%s"
unless
config
.
asset_path
end
protected
def
find_root_with_flag
(
flag
,
default
=
nil
)
root_path
=
self
.
class
.
called_from
...
...
railties/test/railties/engine_test.rb
浏览文件 @
937f4191
...
...
@@ -273,5 +273,30 @@ def index
"<link href=
\"
/omg/bukkits/stylesheets/foo.css
\"
media=
\"
screen
\"
rel=
\"
stylesheet
\"
type=
\"
text/css
\"
/>"
assert_equal
expected
,
stripped_body
end
test
"engine's files are served via ActionDispatch::Static"
do
add_to_config
"config.serve_static_assets = true"
@plugin
.
write
"lib/bukkits.rb"
,
<<-
RUBY
class Bukkits
class Engine < ::Rails::Engine
engine_name :bukkits
end
end
RUBY
@plugin
.
write
"public/bukkits.html"
,
"/bukkits/bukkits.html"
app_file
"public/app.html"
,
"/app.html"
boot_rails
env
=
Rack
::
MockRequest
.
env_for
(
"/app.html"
)
response
=
Rails
.
application
.
call
(
env
)
assert_equal
response
[
2
].
path
,
File
.
join
(
app_path
,
"public/app.html"
)
env
=
Rack
::
MockRequest
.
env_for
(
"/bukkits/bukkits.html"
)
response
=
Rails
.
application
.
call
(
env
)
assert_equal
response
[
2
].
path
,
File
.
join
(
@plugin
.
path
,
"public/bukkits.html"
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录