summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/feed2imap/itemtomail.rb21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/feed2imap/itemtomail.rb b/lib/feed2imap/itemtomail.rb
index ffa6b22..0f97ac0 100644
--- a/lib/feed2imap/itemtomail.rb
+++ b/lib/feed2imap/itemtomail.rb
@@ -87,14 +87,8 @@ def item_to_mail(item, id, updated, from = 'Feed2Imap', inline_images = false, w
htmlpart.body = item.to_html
# inline images as attachments
+ imgs = []
if inline_images
- message.header.set('Content-Type', 'multipart/related', 'type'=> 'multipart/alternative')
- texthtml = RMail::Message::new
- texthtml.header.set('Content-Type', 'multipart/alternative')
- texthtml.add_part(textpart)
- texthtml.add_part(htmlpart)
- message.add_part(texthtml)
-
cids = []
htmlpart.body.gsub!(/(<img[^>]+)src="(\S+?\/([^\/]+?\.(png|gif|jpe?g)))"([^>]*>)/i) do |match|
# $2 contains url, $3 the image name, $4 the image extension
@@ -111,7 +105,7 @@ def item_to_mail(item, id, updated, from = 'Feed2Imap', inline_images = false, w
imgpart.header.set('Content-Disposition', 'attachment', 'filename' => $3)
imgpart.header.set('Content-Transfer-Encoding', 'base64')
imgpart.body = image
- message.add_part(imgpart)
+ imgs << imgpart
end
# now to specify what to replace with
newtag = "#{$1}src=\"cid:#{cid}\"#{$5}"
@@ -122,6 +116,17 @@ def item_to_mail(item, id, updated, from = 'Feed2Imap', inline_images = false, w
$& # don't modify on exception
end
end
+ end
+ if imgs.length > 0
+ message.header.set('Content-Type', 'multipart/related', 'type'=> 'multipart/alternative')
+ texthtml = RMail::Message::new
+ texthtml.header.set('Content-Type', 'multipart/alternative')
+ texthtml.add_part(textpart)
+ texthtml.add_part(htmlpart)
+ message.add_part(texthtml)
+ imgs.each do |i|
+ message.add_part(i)
+ end
else
message.header['Content-Type'] = 'multipart/alternative'
message.add_part(textpart)
0.14&id=bf86fab5906e1466984d072cc9a0309b38b55a43&follow=1'>One database instance is enough :)René 'Necoro' Neumann1-7/+18 2009-09-05Print database type at the bottom of exceptions. NOTE: This does not handle m...René 'Necoro' Neumann2-1/+6 2009-09-05Fix an error, where a category vanishes after refreshing, using the EixSQLDat...René 'Necoro' Neumann2-1/+19 2009-09-03And here is the debugging again :) ... using ctypesRené 'Necoro' Neumann1-1/+8 2009-09-03Screw debugging ... prefer the ctypes approach to get rid of yet another c-mo...René 'Necoro' Neumann3-27/+11 2009-09-03Use this wrapper instead of ctypes to set the textdomain and stuff for the gt...René 'Necoro' Neumann1-9/+5 2009-09-03Add small wrapper to C-gettextRené 'Necoro' Neumann2-1/+22 2009-08-31Update messages.potRené 'Necoro' Neumann1-42/+94 2009-08-31Removed the gtk- strings from translationsRené 'Necoro' Neumann7-3639/+3479 2009-08-31Removed the 'translatable' attribute from 'gtk-*' stringsRené 'Necoro' Neumann5-11/+11 2009-08-31Removed TODO. Renamed ChangeLog to TODORené 'Necoro' Neumann2-40/+0 2009-08-27Only import stuff if necessaryRené 'Necoro' Neumann1-8/+8 2009-08-25Release the threadQueue-Lock in syncv0.13René 'Necoro' Neumann1-0/+1 2009-08-25Updated portugese translationAlberto Federman Neto1-650/+687 2009-08-15Update spanish translationDaniel Halens1-245/+258 2009-08-15Use boolean flags instead of obscure C flags for ipc.MessageQueueRené 'Necoro' Neumann3-13/+15 2009-08-15TypoRené 'Necoro' Neumann1-1/+1 2009-08-15Enhanced the extensions.shRené 'Necoro' Neumann1-3/+8 2009-08-15Move eix-format to correct locationRené 'Necoro' Neumann1-0/+0