message.html: add tab to view raw email

This commit is contained in:
Drew DeVault 2020-10-23 15:32:59 -04:00
parent bd91b3eacf
commit 3db443c1df
2 changed files with 11 additions and 6 deletions

View file

@ -334,7 +334,11 @@ func handleGetPart(ctx *alps.Context, raw bool) error {
return fmt.Errorf("failed to parse part Content-Type: %v", err) return fmt.Errorf("failed to parse part Content-Type: %v", err)
} }
if len(partPath) == 0 { if len(partPath) == 0 {
mimeType = "message/rfc822" if ctx.QueryParam("plain") == "1" {
mimeType = "text/plain"
} else {
mimeType = "message/rfc822"
}
} }
if raw { if raw {

View file

@ -11,7 +11,7 @@
{{if .IsText}} {{if .IsText}}
href="?part={{.PathString}}" href="?part={{.PathString}}"
{{else}} {{else}}
href="/raw?part={{.PathString}}" href="{{$.Message.URL}}raw?part={{.PathString}}"
{{end}} {{end}}
> >
{{if eq $.Part.PathString .PathString}}<strong>{{end}} {{if eq $.Part.PathString .PathString}}<strong>{{end}}
@ -178,15 +178,15 @@
{{ $html := .Message.HTMLPart }} {{ $html := .Message.HTMLPart }}
{{ $text := .Message.TextPart }} {{ $text := .Message.TextPart }}
<div class="tabs"> <div class="tabs">
{{ if and $html $text }}
{{ if ne $html.PathString $text.PathString }}
{{/* https://github.com/golang/go/issues/31103 */}} {{/* https://github.com/golang/go/issues/31103 */}}
<a <a
href="?part={{.Message.TextPart.PathString}}" href="?part={{$text.PathString}}"
{{ if eq $text.PathString .Part.PathString }} {{ if eq $text.PathString .Part.PathString }}
class="active" class="active"
{{ end }} {{ end }}
>Plain text</a> >Plain text</a>
{{ if and $html $text }}
{{ if ne $html.PathString $text.PathString }}
<a <a
href="?part={{$html.PathString}}" href="?part={{$html.PathString}}"
{{ if eq $html.PathString .Part.PathString }} {{ if eq $html.PathString .Part.PathString }}
@ -195,12 +195,13 @@
>HTML</a> >HTML</a>
{{ end }} {{ end }}
{{ end }} {{ end }}
<a href="{{.Message.URL}}/raw?plain=1">Raw email</a>
</div> </div>
{{if .View}} {{if .View}}
{{.View}} {{.View}}
{{else}} {{else}}
<p>Can't preview this message part.</p> <p>Can't preview this message part.</p>
<a href="{{.Message.Uid}}/raw?part={{.Part.PathString}}">Download</a> <a href="{{.Message.URL}}/raw?part={{.Part.PathString}}">Download</a>
{{end}} {{end}}
</main> </main>
</div> </div>