X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fmessage-chunks.rb;h=40e098f2914e8c606d69c95a62234a53c12b9f10;hb=38b3d2167248fd42b7057edf3036215937fe2ed4;hp=ba8b84641f294d3820896ddb53f06dd2169c76b9;hpb=575b990f67492b7c2f255cb54a2838eb548f8b48;p=sup diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb index ba8b846..40e098f 100644 --- a/lib/sup/message-chunks.rb +++ b/lib/sup/message-chunks.rb @@ -41,9 +41,14 @@ end module Redwood module Chunk + WRAP_LEN = 80 # wrap messages and text attachments at this width + class Attachment HookManager.register "mime-decode", < content_type, :filename => lambda { write_to_disk }, @@ -95,6 +109,7 @@ EOS @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 @@ -105,7 +120,7 @@ EOS if expandable? "Attachment: #{filename} (#{lines.length} lines)" else - "Attachment: #{filename} (#{content_type})" + "Attachment: #{filename} (#{content_type}; #{@raw_content.size.to_human_size})" end end @@ -116,9 +131,9 @@ EOS 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" - Redwood::log "running: #{cmd.inspect}" - system cmd + cmd = "/usr/bin/run-mailcap --action=view '#{@content_type}:#{path}'" + debug "running: #{cmd.inspect}" + BufferManager.shell_out(cmd) $? == 0 end @@ -143,7 +158,6 @@ EOS end class Text - WRAP_LEN = 80 # wrap at this width attr_reader :lines def initialize lines @@ -206,7 +220,7 @@ EOS 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 @@ -226,8 +240,8 @@ EOS def patina_color case status - when :valid: :cryptosig_valid_color - when :invalid: :cryptosig_invalid_color + when :valid then :cryptosig_valid_color + when :invalid then :cryptosig_invalid_color else :cryptosig_unknown_color end end