lib/sup/message-chunks.rb in sup-0.6 vs lib/sup/message-chunks.rb in sup-0.7
- old
+ new
@@ -39,10 +39,12 @@
end
module Redwood
module Chunk
+ WRAP_LEN = 80 # wrap messages and text attachments at this width
+
class Attachment
HookManager.register "mime-decode", <<EOS
Executes when decoding a MIME attachment.
Variables:
content_type: the content-type of the message
@@ -93,10 +95,11 @@
end
@lines = nil
if text
@lines = text.gsub("\r\n", "\n").gsub(/\t/, " ").gsub(/\r/, "").split("\n")
+ @lines = lines.map {|l| l.chomp.wrap WRAP_LEN}.flatten
@quotable = true
end
end
def color; :none end
@@ -114,11 +117,11 @@
def inlineable?; false end
def expandable?; !viewable? end
def initial_state; :open end
def viewable?; @lines.nil? end
def view_default! path
- cmd = "/usr/bin/run-mailcap --action=view '#{@content_type}:#{path}' > /dev/null 2> /dev/null"
+ cmd = "/usr/bin/run-mailcap --action=view '#{@content_type}:#{path}' 2>/dev/null"
Redwood::log "running: #{cmd.inspect}"
system cmd
$? == 0
end
@@ -141,11 +144,10 @@
@lines || @raw_content
end
end
class Text
- WRAP_LEN = 80 # wrap at this width
attr_reader :lines
def initialize lines
@lines = lines.map { |l| l.chomp.wrap WRAP_LEN }.flatten # wrap
@@ -204,10 +206,10 @@
end
def inlineable?; false end
def quotable?; false end
def expandable?; true end
- def initial_state; :open end
+ def initial_state; :closed end
def viewable?; false end
def patina_color; :generic_notice_patina_color end
def patina_text; "Begin enclosed message from #{from} (#{@lines.length} lines)" end