InlineAttachment 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +32 -1
- data/lib/inline_attachment.rb +5 -3
- metadata +2 -2
data/README
CHANGED
@@ -45,4 +45,35 @@ template, and display it like so:
|
|
45
45
|
As of version 0.2.0, Inline Attachment automatically embeds any images found within
|
46
46
|
your ActionMailer templates. There is no longer any extra code required when adding images
|
47
47
|
into your mail templates. Though, you must use rails image_tag helper when displaying
|
48
|
-
images within your mailer views.
|
48
|
+
images within your mailer views.
|
49
|
+
|
50
|
+
With version 0.3.0, you are now able to embed images into nested parts by specifying
|
51
|
+
a part container to place the attached images into. For example:
|
52
|
+
|
53
|
+
class Notifier < ActionMailer::Base
|
54
|
+
def images
|
55
|
+
recipients "test@test.com"
|
56
|
+
from "test@test.com"
|
57
|
+
subject "Test"
|
58
|
+
content_type "multipart/alternative"
|
59
|
+
|
60
|
+
part "text/plain" do |p|
|
61
|
+
p.body = render_message("images.text.plain.rhtml", {})
|
62
|
+
p.content_disposition = ""
|
63
|
+
p.transfer_encoding = "7bit"
|
64
|
+
p.charset = "ISO-8859-15"
|
65
|
+
end
|
66
|
+
|
67
|
+
part "multipart/related" do |p|
|
68
|
+
p.parts << ActionMailer::Part.new(
|
69
|
+
:content_type => "text/html", :body => render_message("images.text.html.rhtml", :part_container => p),
|
70
|
+
:disposition => "",
|
71
|
+
:charset => "ISO-8859-15",
|
72
|
+
:transfer_encoding => "7bit"
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
You can see that we passed in the variable :part_container => p into the body of the nested part.
|
79
|
+
This needs to be done so that the images are embedded into the part that they are used in.
|
data/lib/inline_attachment.rb
CHANGED
@@ -11,7 +11,7 @@ module ActionMailer
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
class Part
|
14
|
+
class Part
|
15
15
|
def to_mail(defaults)
|
16
16
|
part = TMail::Mail.new
|
17
17
|
|
@@ -68,15 +68,17 @@ module ActionView
|
|
68
68
|
module AssetTagHelper
|
69
69
|
def image_tag(source, options = {})
|
70
70
|
options.symbolize_keys!
|
71
|
+
|
72
|
+
@part_container ||= @controller
|
71
73
|
|
72
|
-
if @
|
74
|
+
if @part_container.is_a?(ActionMailer::Base) or @part_container.is_a?(ActionMailer::Part)
|
73
75
|
file_path = "#{RAILS_ROOT}/public#{image_path(source).split('?').first}"
|
74
76
|
basename = File.basename(file_path, '.*')
|
75
77
|
ext = basename.split('.').last
|
76
78
|
cid = Time.now.to_f.to_s + "#{basename}@inline_attachment"
|
77
79
|
file = File.open(file_path, 'rb')
|
78
80
|
|
79
|
-
@
|
81
|
+
@part_container.inline_attachment(:content_type => "image/#{ext}",
|
80
82
|
:body => file.read,
|
81
83
|
:filename => basename,
|
82
84
|
:cid => "<#{cid}>",
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: InlineAttachment
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-11-
|
6
|
+
version: 0.3.0
|
7
|
+
date: 2007-11-07 00:00:00 +11:00
|
8
8
|
summary: "A package created from a Rails patch (ticket #2179) that automatically embedded images found in your ActionMailer templates."
|
9
9
|
require_paths:
|
10
10
|
- lib
|