Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: wmorgan-sup@masanjin.net (William Morgan)
Subject: [sup-talk] new in svn: mime-type hook
Date: Tue, 28 Aug 2007 21:15:23 -0700	[thread overview]
Message-ID: <1188360667-sup-3717@south> (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>


             reply	other threads:[~2007-08-29  4:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-29  4:15 William Morgan [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1188360667-sup-3717@south \
    --to=wmorgan-sup@masanjin.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox