diff options
author | Drew DeVault <sir@cmpwn.com> | 2020-10-23 15:15:46 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-10-23 15:15:46 -0400 |
commit | 64b16f4a5039bee9a97d3c69db0b49c5a9217908 (patch) | |
tree | 5b3968c915da53f19d4f398c2c30a2bae3154b6e | |
parent | f97f38d4a9550bb15d39cfc05a3011e969927d22 (diff) | |
download | alps-64b16f4a5039bee9a97d3c69db0b49c5a9217908.tar.gz alps-64b16f4a5039bee9a97d3c69db0b49c5a9217908.zip |
message.html: add tabs to select html/plaintext
-rw-r--r-- | plugins/base/imap.go | 23 | ||||
-rw-r--r-- | themes/alps/assets/style.css | 41 | ||||
-rw-r--r-- | themes/alps/message.html | 22 |
3 files changed, 81 insertions, 5 deletions
diff --git a/plugins/base/imap.go b/plugins/base/imap.go index 3492e7e..07b69c7 100644 --- a/plugins/base/imap.go +++ b/plugins/base/imap.go @@ -210,6 +210,29 @@ func (msg *IMAPMessage) TextPart() *IMAPPartNode { return best } +func (msg *IMAPMessage) HTMLPart() *IMAPPartNode { + if msg.BodyStructure == nil { + return nil + } + + var best *IMAPPartNode + msg.BodyStructure.Walk(func(path []int, part *imap.BodyStructure) bool { + if !strings.EqualFold(part.MIMEType, "text") { + return true + } + if part.Disposition != "" && !strings.EqualFold(part.Disposition, "inline") { + return true + } + + if part.MIMESubType == "html" { + best = newIMAPPartNode(msg, path, part) + } + return true + }) + + return best +} + func (msg *IMAPMessage) Attachments() []IMAPPartNode { if msg.BodyStructure == nil { return nil diff --git a/themes/alps/assets/style.css b/themes/alps/assets/style.css index 507342f..b0345e0 100644 --- a/themes/alps/assets/style.css +++ b/themes/alps/assets/style.css @@ -181,7 +181,9 @@ main.create-update form textarea { flex: 1 auto; resize: none; margin-top: 1rem; main.create-update h1 { margin: 0; } main table { border-collapse: collapse; width: 100%; border: 1px solid #eee; } -main table td { white-space: nowrap; padding: 0.3rem; color: #757373; +main table td { + white-space: nowrap; + padding: 0.3rem; overflow: hidden; text-overflow: ellipsis; max-width: 200px; @@ -206,15 +208,48 @@ main.message .remote-content td { color: black; } +main.message .tabs { + margin: 0.3rem 0 0 0; + padding: 0; + border-bottom: 1px solid #eee; + overflow: visible; +} + +main.message .tabs a { + padding: 0.2rem 0.5rem; + margin: 0; + display: inline-block; + height: calc(100% + 1px); + margin-bottom: -1px; + border-style: solid; + border-color: transparent; + border-width: 1px; + text-decoration: none; + color: #555; +} + +main.message .tabs a.active { + background-color: white; + border-color: #eee #eee white #eee; + color: black; +} + +main.message .tabs a:hover { + background-color: white; + color: black; +} + main.message pre, main.message iframe, main.contact .details, main.event pre { flex: 1 auto; padding: 1rem; - margin: 0.3rem 0 0 0; + margin: 0; background-color: white; - border: 1px solid #eee; + border-style: solid; + border-color: #eee; + border-width: 0 1px 1px 1px; max-width: 100%; } diff --git a/themes/alps/message.html b/themes/alps/message.html index 713d3bc..c92d5ac 100644 --- a/themes/alps/message.html +++ b/themes/alps/message.html @@ -9,9 +9,9 @@ <a class="nav-link" {{if .IsText}} - href="{{$.Message.URL}}?part={{.PathString}}" + href="?part={{.PathString}}" {{else}} - href="{{$.Message.URL}}/raw?part={{.PathString}}" + href="/raw?part={{.PathString}}" {{end}} > {{if eq $.Part.PathString .PathString}}<strong>{{end}} @@ -175,6 +175,24 @@ {{end}} {{end}} + {{ $html := .Message.HTMLPart }} + {{ $text := .Message.TextPart }} + <div class="tabs"> + {{ if and $html (ne $html.PathString $text.PathString) }} + <a + href="?part={{.Message.TextPart.PathString}}" + {{ if eq $text.PathString .Part.PathString }} + class="active" + {{ end }} + >Plain text</a> + <a + href="?part={{$html.PathString}}" + {{ if eq $html.PathString .Part.PathString }} + class="active" + {{ end }} + >HTML</a> + {{ end }} + </div> {{if .View}} {{.View}} {{else}} |