-
Notifications
You must be signed in to change notification settings - Fork 21
/
template.pug
123 lines (123 loc) · 4.09 KB
/
template.pug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
doctype html
html
head
meta(charset="utf-8")
meta(http-equiv="x-ua-compatible", content="ie=edge")
if subject
title= subject
meta(name="viewport", content="width=device-width, initial-scale=1")
style(type='text/css').
iframe {
border: 0;
height: 100%;
width: 100%;
min-height: 800px;
max-width: 600px;
display: block;
}
.preview-email-tabs {
display: flex;
flex-wrap: wrap;
max-width: 600px;
border: 1px solid black;
background: #e2e2e2;
}
.preview-email-tabs input[type="radio"] {
display: none;
}
.preview-email-tabs label {
padding: 1rem;
background: #e2e2e2;
font-weight: bold;
cursor: pointer;
}
.preview-email-tabs .preview-email-tab {
width: 100%;
background: #fff;
order: 1;
display: none;
}
.preview-email-tabs input[type='radio']:checked + label + .preview-email-tab {
display: block;
}
.preview-email-tabs input[type="radio"]:checked + label {
background: #fff;
}
body
table
if base64
tr
td(colspan=2, style='text-align:right;'): button(type='button', onclick='downloadRawEmail()') Download Original
script.
function downloadRawEmail() {
var link = document.createElement('a');
link.href = "data:message/rfc822;base64,#{base64}";
link.download = "#{messageId ? messageId.replace('<', '').replace('>', '').split('@')[0] : Date.now()}.eml";
link.click();
}
each headerLine, i in headerLines
- const index = headerLine.line.indexOf(': ')
- const value = headerLine.line.slice(index + 2)
- const header = headers.get(headerLine.key)
tr
td
strong= headerLine.line.slice(0, index)
td
if header
case headerLine.key
when 'content-type'
//- TODO: header.params[key]
= header.value || header || value
when 'content-disposition'
when 'dkim-signature'
//- TODO: header.params[key]
= value
when 'subject'
when 'references'
when 'message-id'
when 'in-reply-to'
when 'priority'
when 'x-priority'
when 'x-msmail-priority'
when 'importance'
= header.value || header || value
when 'from'
when 'to'
when 'cc'
when 'bcc'
when 'sender'
when 'reply-to'
when 'delivered-to'
when 'return-path'
if header.html
!= header.html
else
= header.value || header || value
default
//- when 'date'
= header.value || header || value
else
= value
if attachments && attachments.length > 0
tr
td: strong Attachments
td
ul
each a in attachments
li
a(href=`data:${a.contentType};base64,${a.content.toString('base64')}`, download=a.filename, target='_blank')
if a.filename
code= a.filename
else
code= 'Unnamed file'
.preview-email-tabs
if html
input(type='radio', name='preview_email', checked)#tab-html
label(for='tab-html') HTML
.preview-email-tab
iframe(sandbox='allow-popups', referrerpolicy='no-referrer', seamless='seamless', srcdoc=`<base target='_top'>${html}`)#html
if text
input(type='radio', name='preview_email', checked=!html)#tab-text
label(for='tab-text') Plain text
.preview-email-tab
iframe(sandbox='allow-popups', referrerpolicy='no-referrer', seamless='seamless', srcdoc=`<pre>${text}</pre>`)#text