Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
42cbd710
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,发现更多精彩内容 >>
提交
42cbd710
编写于
9月 09, 2008
作者:
M
Matthew M. Boedicker
提交者:
Pratik Naik
10月 13, 2008
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for xml processing instructions in atom_feed_helper [#926 state:resolved]
Signed-off-by:
N
Pratik Naik
<
pratiknaik@gmail.com
>
上级
b47c76b1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
61 addition
and
0 deletion
+61
-0
actionpack/lib/action_view/helpers/atom_feed_helper.rb
actionpack/lib/action_view/helpers/atom_feed_helper.rb
+10
-0
actionpack/test/template/atom_feed_helper_test.rb
actionpack/test/template/atom_feed_helper_test.rb
+51
-0
未找到文件。
actionpack/lib/action_view/helpers/atom_feed_helper.rb
浏览文件 @
42cbd710
...
...
@@ -51,6 +51,7 @@ module AtomFeedHelper
# * <tt>:schema_date</tt>: The date at which the tag scheme for the feed was first used. A good default is the year you
# created the feed. See http://feedvalidator.org/docs/error/InvalidTAG.html for more information. If not specified,
# 2005 is used (as an "I don't care" value).
# * <tt>:instruct</tt>: Hash of XML processing instructions in the form {target => {attribute => value, }} or {target => [{attribute => value, }, ]}
#
# Other namespaces can be added to the root element:
#
...
...
@@ -85,6 +86,15 @@ def atom_feed(options = {}, &block)
xml
=
options
[
:xml
]
||
eval
(
"xml"
,
block
.
binding
)
xml
.
instruct!
if
options
[
:instruct
]
options
[
:instruct
].
each
do
|
target
,
attrs
|
if
attrs
.
respond_to?
(
:keys
)
xml
.
instruct!
(
target
,
attrs
)
elsif
attrs
.
respond_to?
(
:each
)
attrs
.
each
{
|
attr_group
|
xml
.
instruct!
(
target
,
attr_group
)
}
end
end
end
feed_opts
=
{
"xml:lang"
=>
options
[
:language
]
||
"en-US"
,
"xmlns"
=>
'http://www.w3.org/2005/Atom'
}
feed_opts
.
merge!
(
options
).
reject!
{
|
k
,
v
|
!
k
.
to_s
.
match
(
/^xml/
)}
...
...
actionpack/test/template/atom_feed_helper_test.rb
浏览文件 @
42cbd710
...
...
@@ -85,6 +85,42 @@ class ScrollsController < ActionController::Base
entry.content(scroll.body, :type => 'html')
entry.tag!('app:edited', Time.now)
entry.author do |author|
author.name("DHH")
end
end
end
end
EOT
FEEDS
[
"feed_with_xml_processing_instructions"
]
=
<<-
EOT
atom_feed(:schema_date => '2008',
:instruct => {'xml-stylesheet' => { :href=> 't.css', :type => 'text/css' }}) do |feed|
feed.title("My great blog!")
feed.updated((@scrolls.first.created_at))
for scroll in @scrolls
feed.entry(scroll) do |entry|
entry.title(scroll.title)
entry.content(scroll.body, :type => 'html')
entry.author do |author|
author.name("DHH")
end
end
end
end
EOT
FEEDS
[
"feed_with_xml_processing_instructions_duplicate_targets"
]
=
<<-
EOT
atom_feed(:schema_date => '2008',
:instruct => {'target1' => [{ :a => '1', :b => '2' }, { :c => '3', :d => '4' }]}) do |feed|
feed.title("My great blog!")
feed.updated((@scrolls.first.created_at))
for scroll in @scrolls
feed.entry(scroll) do |entry|
entry.title(scroll.title)
entry.content(scroll.body, :type => 'html')
entry.author do |author|
author.name("DHH")
end
...
...
@@ -194,6 +230,21 @@ def test_feed_should_allow_overriding_ids
end
end
def
test_feed_xml_processing_instructions
with_restful_routing
(
:scrolls
)
do
get
:index
,
:id
=>
'feed_with_xml_processing_instructions'
assert_match
%r{<
\?
xml-stylesheet type="text/css" href="t.css"
\?
>}
,
@response
.
body
end
end
def
test_feed_xml_processing_instructions_duplicate_targets
with_restful_routing
(
:scrolls
)
do
get
:index
,
:id
=>
'feed_with_xml_processing_instructions_duplicate_targets'
assert_match
%r{<
\?
target1 (a="1" b="2"|b="2" a="1")
\?
>}
,
@response
.
body
assert_match
%r{<
\?
target1 (c="3" d="4"|d="4" c="3")
\?
>}
,
@response
.
body
end
end
private
def
with_restful_routing
(
resources
)
with_routing
do
|
set
|
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录