From 6c21ed9e3fa837c797a4de27ea3a59ff2404454f Mon Sep 17 00:00:00 2001 From: Lucas Nussbaum Date: Sun, 13 Jul 2008 17:33:13 +0200 Subject: added wrapping of text output --- ChangeLog | 2 ++ lib/feed2imap/config.rb | 11 +++++++++-- lib/feed2imap/feed2imap.rb | 4 ++-- lib/feed2imap/itemtomail.rb | 6 +++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 73c49a3..56079d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ Feed2Imap 0.9.3 (XX/02/2008) option). Based on a patch by Pavel Avgustinov, and with help from Arnt Gulbrandsen. * Dropped rubymail_patch.rb +* Added option to wrap text output. Thanks to Maxime Petazzoni for + the patch. Feed2Imap 0.9.2 (28/10/2007) ============================ diff --git a/lib/feed2imap/config.rb b/lib/feed2imap/config.rb index f6ef634..c0bf4ac 100644 --- a/lib/feed2imap/config.rb +++ b/lib/feed2imap/config.rb @@ -64,7 +64,13 @@ class F2IConfig s += "#{i}. #{f.name}\n" s += " URL: #{f.url}\n" s += " IMAP Account: #{f.imapaccount}\n" - s += " Folder: #{f.folder}\n\n" + s += " Folder: #{f.folder}\n" + + if not f.wrapto + s += " Not wrapped.\n" + end + + s += "\n" i += 1 end s @@ -73,7 +79,7 @@ end # A configured feed. simple data container. class ConfigFeed - attr_reader :name, :url, :imapaccount, :folder, :always_new, :execurl, :filter, :ignore_hash, :dumpdir, :include_images + attr_reader :name, :url, :imapaccount, :folder, :always_new, :execurl, :filter, :ignore_hash, :dumpdir, :wrapto, :include_images attr_accessor :body def initialize(f, imapaccount, folder, f2iconfig) @@ -88,6 +94,7 @@ class ConfigFeed @ignore_hash = f['ignore-hash'] || false @freq = @freq.to_i if @freq @dumpdir = f['dumpdir'] || nil + @wrapto = if f['wrapto'] == nil then 72 else f['wrapto'].to_i end @include_images = f2iconfig.include_images if f['include-images'] @include_images = (f['include-images'] != 'false') diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb index 63a00b8..ebae470 100644 --- a/lib/feed2imap/feed2imap.rb +++ b/lib/feed2imap/feed2imap.rb @@ -230,13 +230,13 @@ class Feed2Imap begin if !cacherebuild updateditems.each do |i| - email = item_to_mail(i, i.cacheditem.index, true, f.name, f.include_images) + email = item_to_mail(i, i.cacheditem.index, true, f.name, f.include_images, f.wrapto) f.imapaccount.updatemail(f.folder, email, i.cacheditem.index, i.date || Time::new) end # reverse is needed to upload older items first (fixes gna#8986) newitems.reverse.each do |i| - email = item_to_mail(i, i.cacheditem.index, false, f.name, f.include_images) + email = item_to_mail(i, i.cacheditem.index, false, f.name, f.include_images, f.wrapto) f.imapaccount.putmail(f.folder, email, i.date || Time::new) end end diff --git a/lib/feed2imap/itemtomail.rb b/lib/feed2imap/itemtomail.rb index 91e6c18..27fc362 100644 --- a/lib/feed2imap/itemtomail.rb +++ b/lib/feed2imap/itemtomail.rb @@ -47,7 +47,7 @@ class String end end -def item_to_mail(item, index, updated, from = 'Feed2Imap', inline_images = false) +def item_to_mail(item, index, updated, from = 'Feed2Imap', inline_images = false, wrapto = false) message = RMail::Message::new if item.creator and item.creator != '' if item.creator.include?('@') @@ -77,9 +77,9 @@ def item_to_mail(item, index, updated, from = 'Feed2Imap', inline_images = false end end textpart = RMail::Message::new - textpart.header['Content-Type'] = 'text/plain; charset=utf-8' + textpart.header['Content-Type'] = 'text/plain; charset=utf-8; format=flowed' textpart.header['Content-Transfer-Encoding'] = '8bit' - textpart.body = item.to_text + textpart.body = item.to_text(true, wrapto) htmlpart = RMail::Message::new htmlpart.header['Content-Type'] = 'text/html; charset=utf-8' htmlpart.header['Content-Transfer-Encoding'] = '8bit' -- cgit v1.2.3