summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLucas Nussbaum <lucas@lucas-nussbaum.net>2008-07-13 17:33:13 +0200
committerLucas Nussbaum <lucas@lucas-nussbaum.net>2008-07-13 17:33:13 +0200
commit6c21ed9e3fa837c797a4de27ea3a59ff2404454f (patch)
treebe64700c868a209ea9e66739119eca16b3cf6300 /lib
parent681282e34aa028f1a365ef0e95c05a185d4caed3 (diff)
downloadfeed2imap-6c21ed9e3fa837c797a4de27ea3a59ff2404454f.tar.gz
feed2imap-6c21ed9e3fa837c797a4de27ea3a59ff2404454f.tar.bz2
feed2imap-6c21ed9e3fa837c797a4de27ea3a59ff2404454f.zip
added wrapping of text output
Diffstat (limited to '')
-rw-r--r--lib/feed2imap/config.rb11
-rw-r--r--lib/feed2imap/feed2imap.rb4
-rw-r--r--lib/feed2imap/itemtomail.rb6
3 files changed, 14 insertions, 7 deletions
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'