Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] new in svn: mime-type hook
@ 2007-08-29  4:15 William Morgan
  2007-08-31 19:02 ` jeff covey
  0 siblings, 1 reply; 5+ messages in thread
From: William Morgan @ 2007-08-29  4:15 UTC (permalink / raw)


There's a new hook for all your MIME decoding needs:

  mime-decode
  -----------
  File: ~/.sup/hooks/mime-decode.rb
  Executes when decoding a MIME attachment.
  Variables:
     content_type: the content-type of the message
         filename: the filename of the attachment as saved to disk (generated
                   on the fly, so don't call more than once)
    sibling_types: if this attachment is part of a multipart MIME attachment,
                   an array of content-types for all attachments. Otherwise,
                   the empty array.
  Return value:
    The decoded text of the attachment, or nil if not decoded.

Here's what I use for mime-decode.rb. It uses w3m to translate all HTML
attachments that don't have a text/html alternative:

  unless sibling_types.member? "text/plain"
    case content_type
    when "text/html"
      `/usr/bin/w3m -dump -T #{content_type} '#{filename}'`
    end
  end


-- 
William <wmorgan-sup at masanjin.net>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-09-02 11:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-29  4:15 [sup-talk] new in svn: mime-type hook William Morgan
2007-08-31 19:02 ` jeff covey
2007-08-31 19:36   ` Magnus Therning
2007-09-01  6:28   ` William Morgan
2007-09-02 11:31     ` jeff covey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox