Handle multipart/alternative and application/x-unknown-content-type-scpfile
Strange combination, but the first message with multipart/alternative also contained a .scp file and not as an attachment. The template for multipart/alternative allows switching between the alternatives.
This commit is contained in:
parent
090fd79c79
commit
77d2b87b1e
20
mbox2web
20
mbox2web
|
@ -211,6 +211,26 @@ def render_body(msg):
|
||||||
}
|
}
|
||||||
bodyhtml = bodytmpl.render(context)
|
bodyhtml = bodytmpl.render(context)
|
||||||
|
|
||||||
|
elif content_type == "multipart/alternative":
|
||||||
|
partshtml = []
|
||||||
|
partstypes = []
|
||||||
|
for part in msg.get_payload():
|
||||||
|
partstypes.append(part.get_content_type())
|
||||||
|
partshtml.append(render_body(part))
|
||||||
|
bodytmpl = jenv.get_template("body_multipart_alternative.html")
|
||||||
|
context = {
|
||||||
|
"types": partstypes,
|
||||||
|
"parts": partshtml,
|
||||||
|
}
|
||||||
|
bodyhtml = bodytmpl.render(context)
|
||||||
|
|
||||||
|
elif content_type == "application/x-unknown-content-type-scpfile":
|
||||||
|
bodytmpl = jenv.get_template("body_application_x-unknown-content-type-scpfile.html")
|
||||||
|
context = {
|
||||||
|
"body": msg.get_payload(decode=True).decode(msg.get_charset() or "iso-8859-1")
|
||||||
|
}
|
||||||
|
bodyhtml = bodytmpl.render(context)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Content-type " + content_type + " not implemented yet")
|
raise RuntimeError("Content-type " + content_type + " not implemented yet")
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<div class="partouter">
|
||||||
|
<div class="partheader">
|
||||||
|
application/x-unknown-content-type-scpfile
|
||||||
|
</div>
|
||||||
|
<div class="partinner">
|
||||||
|
<pre>
|
||||||
|
{{body}}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,24 @@
|
||||||
|
<div class="partouter">
|
||||||
|
<div class="partheader">
|
||||||
|
multipart/alternative
|
||||||
|
</div>
|
||||||
|
<div class="partinner">
|
||||||
|
{% for type in types %}
|
||||||
|
<input id="sp{{prefix}}_{{loop.index}}" type="radio" name="g{{prefix}}">
|
||||||
|
<label for="sp{{prefix}}_{{loop.index}}">{{type}}</label>
|
||||||
|
<style>
|
||||||
|
#p{{prefix}}_{{loop.index}} {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
input#sp{{prefix}}_{{loop.index}}:checked ~ #p{{prefix}}_{{loop.index}} {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endfor %}
|
||||||
|
{% for part in parts %}
|
||||||
|
<div id="p{{prefix}}_{{loop.index}}">
|
||||||
|
{{part}}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
Loading…
Reference in New Issue