Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
c039bcdb
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,发现更多精彩内容 >>
提交
c039bcdb
编写于
12月 28, 2009
作者:
M
Mikel Lindsaar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Moved sort_parts into Mail, updated mail requirement to 1.4.2
上级
971f4ff8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
40 deletion
+22
-40
Gemfile
Gemfile
+1
-1
actionmailer/CHANGELOG
actionmailer/CHANGELOG
+4
-0
actionmailer/lib/action_mailer.rb
actionmailer/lib/action_mailer.rb
+2
-1
actionmailer/lib/action_mailer/base.rb
actionmailer/lib/action_mailer/base.rb
+10
-31
actionmailer/test/mail_service_test.rb
actionmailer/test/mail_service_test.rb
+5
-7
未找到文件。
Gemfile
浏览文件 @
c039bcdb
...
...
@@ -10,7 +10,7 @@ end
gem
"
i18n
"
,
">= 0.3.0"
# AM
gem
"
mail
"
,
">= 1.4.
1
"
gem
"
mail
"
,
">= 1.4.
2
"
# AR
gem
"
arel
"
,
"0.2.pre"
,
:git
=>
"git://github.com/rails/arel.git"
...
...
actionmailer/CHANGELOG
浏览文件 @
c039bcdb
*Mail Integration
* ActionMailer::Base :default_implicit_parts_order now is in the sequence of the order you want, no
reversing of ordering takes place. The default order now is text/plain, then text/enriched, then
text/html and then any other part that is not one of these three.
* Mail does not have "quoted_body", "quoted_subject" etc. All of these are accessed via body.encoded,
subject.encoded etc
...
...
actionmailer/lib/action_mailer.rb
浏览文件 @
c039bcdb
...
...
@@ -24,6 +24,7 @@
actionpack_path
=
File
.
expand_path
(
'../../../actionpack/lib'
,
__FILE__
)
$:
.
unshift
(
actionpack_path
)
if
File
.
directory?
(
actionpack_path
)
&&
!
$:
.
include?
(
actionpack_path
)
require
'action_controller'
require
'action_view'
...
...
@@ -46,4 +47,4 @@ module Text
autoload
:Format
,
'action_mailer/vendor/text_format'
end
require
'mail'
\ No newline at end of file
require
'mail'
actionmailer/lib/action_mailer/base.rb
浏览文件 @
c039bcdb
...
...
@@ -282,7 +282,13 @@ class Base < AbstractController::Base
@@default_mime_version
=
"1.0"
cattr_accessor
:default_mime_version
@@default_implicit_parts_order
=
[
"text/html"
,
"text/enriched"
,
"text/plain"
]
# This specifies the order that the parts of a multipart email will be. Usually you put
# text/plain at the top so someone without a MIME capable email reader can read the plain
# text of your email first.
#
# Any content type that is not listed here will be inserted in the order you add them to
# the email after the content types you list here.
@@default_implicit_parts_order
=
[
"text/plain"
,
"text/enriched"
,
"text/html"
]
cattr_accessor
:default_implicit_parts_order
@@protected_instance_variables
=
%w(@parts @mail)
...
...
@@ -534,7 +540,6 @@ def create_parts #:nodoc:
if
@parts
.
size
>
1
@content_type
=
"multipart/alternative"
if
@content_type
!~
/^multipart/
@parts
=
sort_parts
(
@parts
,
@implicit_parts_order
)
end
# If this is a multipart e-mail add the mime_version if it is not
...
...
@@ -554,35 +559,6 @@ def create_inline_part(body, mime_type=nil) #:nodoc:
)
end
def
sort_parts
(
parts
,
order
=
[])
#:nodoc:
order
=
order
.
collect
{
|
s
|
s
.
downcase
}
parts
=
parts
.
sort
do
|
a
,
b
|
a_ct
=
a
.
content_type
.
string
.
downcase
b_ct
=
b
.
content_type
.
string
.
downcase
a_in
=
order
.
include?
a_ct
b_in
=
order
.
include?
b_ct
s
=
case
when
a_in
&&
b_in
order
.
index
(
a_ct
)
<=>
order
.
index
(
b_ct
)
when
a_in
-
1
when
b_in
1
else
a_ct
<=>
b_ct
end
# reverse the ordering because parts that come last are displayed
# first in mail clients
(
s
*
-
1
)
end
parts
end
def
create_mail
#:nodoc:
m
=
Mail
.
new
...
...
@@ -606,9 +582,12 @@ def create_mail #:nodoc:
m
.
content_type
([
main_type
,
sub_type
,
ctype_attrs
])
m
.
body
=
@parts
.
first
.
body
.
encoded
else
@parts
.
each
do
|
p
|
m
.
add_part
(
p
)
end
m
.
body
.
set_sort_order
(
@implicit_parts_order
)
m
.
body
.
sort_parts!
if
real_content_type
=~
/multipart/
ctype_attrs
.
delete
"charset"
...
...
actionmailer/test/mail_service_test.rb
浏览文件 @
c039bcdb
...
...
@@ -930,7 +930,6 @@ def test_explicitly_multipart_messages
mail
=
TestMailer
.
create_explicitly_multipart_example
(
@recipient
)
assert_equal
3
,
mail
.
parts
.
length
assert_equal
'multipart/mixed'
,
mail
.
content_type
.
string
assert_equal
"text/plain"
,
mail
.
parts
[
0
].
content_type
.
string
assert_equal
"text/html"
,
mail
.
parts
[
1
].
content_type
.
string
...
...
@@ -938,7 +937,6 @@ def test_explicitly_multipart_messages
assert_equal
"image/jpeg"
,
mail
.
parts
[
2
].
content_type
.
string
assert_equal
"attachment"
,
mail
.
parts
[
2
].
content_disposition
.
disposition_type
assert_equal
"foo.jpg"
,
mail
.
parts
[
2
].
content_disposition
.
filename
assert_equal
"foo.jpg"
,
mail
.
parts
[
2
].
content_type
.
filename
assert_nil
mail
.
parts
[
2
].
charset
...
...
@@ -963,11 +961,11 @@ def test_implicitly_multipart_messages
assert_equal
3
,
mail
.
parts
.
length
assert_equal
"1.0"
,
mail
.
mime_version
.
to_s
assert_equal
"multipart/alternative"
,
mail
.
content_type
.
string
assert_equal
"
application/x-yaml
"
,
mail
.
parts
[
0
].
content_type
.
string
assert_equal
"
text/plain
"
,
mail
.
parts
[
0
].
content_type
.
string
assert_equal
"utf-8"
,
mail
.
parts
[
0
].
charset
assert_equal
"text/
plain
"
,
mail
.
parts
[
1
].
content_type
.
string
assert_equal
"text/
html
"
,
mail
.
parts
[
1
].
content_type
.
string
assert_equal
"utf-8"
,
mail
.
parts
[
1
].
charset
assert_equal
"
text/ht
ml"
,
mail
.
parts
[
2
].
content_type
.
string
assert_equal
"
application/x-ya
ml"
,
mail
.
parts
[
2
].
content_type
.
string
assert_equal
"utf-8"
,
mail
.
parts
[
2
].
charset
end
...
...
@@ -976,9 +974,9 @@ def test_implicitly_multipart_messages_with_custom_order
mail
=
TestMailer
.
create_implicitly_multipart_example
(
@recipient
,
nil
,
[
"application/x-yaml"
,
"text/plain"
])
assert_equal
3
,
mail
.
parts
.
length
assert_equal
"
text/ht
ml"
,
mail
.
parts
[
0
].
content_type
.
string
assert_equal
"
application/x-ya
ml"
,
mail
.
parts
[
0
].
content_type
.
string
assert_equal
"text/plain"
,
mail
.
parts
[
1
].
content_type
.
string
assert_equal
"
application/x-ya
ml"
,
mail
.
parts
[
2
].
content_type
.
string
assert_equal
"
text/ht
ml"
,
mail
.
parts
[
2
].
content_type
.
string
end
def
test_implicitly_multipart_messages_with_charset
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录