diff options
author | pazz <patricktotzke@gmail.com> | 2011-06-14 15:40:41 +0100 |
---|---|---|
committer | pazz <patricktotzke@gmail.com> | 2011-06-18 13:25:46 +0100 |
commit | e48523bcbbf6fd431bc3a7343ea32b65af8a4f29 (patch) | |
tree | 74c319c175c31b6db3c40f40a1c70b2bf818a291 /alot/widgets.py | |
parent | 316423a063f262d15a41c5a8d167f760eb411085 (diff) |
use mailcap info for text/html dumps
Diffstat (limited to 'alot/widgets.py')
-rw-r--r-- | alot/widgets.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/alot/widgets.py b/alot/widgets.py index b45a0825..c5ca43fd 100644 --- a/alot/widgets.py +++ b/alot/widgets.py @@ -18,6 +18,8 @@ Copyright (C) 2011 Patrick Totzke <patricktotzke@gmail.com> """ import email import urwid +import tempfile +import os from urwid import Text from urwid import Edit from urwid import Pile @@ -29,8 +31,10 @@ from urwid import SimpleListWalker from datetime import datetime from settings import config +from settings import get_mime_handler from helper import shorten from helper import pretty_datetime +from helper import cmd_output class ThreadlineWidget(AttrMap): @@ -354,9 +358,21 @@ class MessageBodyWidget(AttrMap): if ctype == 'text/plain': bodytxt += part.get_payload(None, True) elif ctype == 'text/html': - #TODO: call external render - bodytxt += part.get_payload(None, True) - + #get mime handler + handler = get_mime_handler(ctype, key='view', + interactive=False) + #open tempfile: + tmpfile = tempfile.NamedTemporaryFile(delete=False, + suffix='.html') + #write payload to tmpfile + tmpfile.write(part.get_payload(None, True)) + #create and call external command + cmd = handler % tmpfile.name + rendered = cmd_output(cmd) + #remove tempfile + tmpfile.close() + os.unlink(tmpfile.name) + bodytxt += rendered AttrMap.__init__(self, Text(bodytxt), 'message_body') def selectable(self): |