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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
{{/*
  One message as a page of its own.

  /msg/{id} is a fragment: the sender's body, wrapped in a CSP and a <base>, and
  meant to be framed by a listing that already printed who wrote it and when.
  Opened by hand it is a body with no header block, no size, and — the reason
  this page exists — no mention of what came attached to it. A URL a reader can
  paste into a browser should answer the question the reader had.

  So the fragment stays a fragment and this page frames it, in the same sandbox
  the listings use. Everything mailweb says about the message is out here, in
  mailweb's own document: subject, correspondents, date, size, attachments, the
  reply editor. Nothing mailweb says is rendered inside a document the sender
  wrote — see the comment in attachments.html.
*/}}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>mailweb ({{account}}) — {{if .Msg.Subject}}{{.Msg.Subject}}{{else}}(no subject){{end}}</title>
<link rel="alternate" type="text/llm" href="/msg/{{.Msg.ID}}"
      title="Same information as a compact plain-text rendering for machine and LLM consumption: identical semantics and links, far fewer tokens. Request it with: Accept: text/llm">
<style>
  :root {
    color-scheme: light dark;
    --bg:           #f5f5f5;
    --bg-card:      #ffffff;
    --border:       #dddddd;
    --border-frame: #eeeeee;
    --text:         #111111;
    --text-meta:    #666666;
    --link:         #3781b8;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg:           #1a1a1a;
      --bg-card:      #242424;
      --border:       #3a3a3a;
      --border-frame: #333333;
      --text:         #e8e8e8;
      --text-meta:    #999999;
      --link:         #7ab3e0;
    }
  }
  body    { font-family: sans-serif; margin: 0; padding: 1rem;
            background: var(--bg); color: var(--text); }
  main    { background: var(--bg-card); border: 1px solid var(--border);
            border-radius: 4px; padding: 1rem; max-width: 60rem; }
  h1      { font-size: 1.15rem; margin: 0 0 0.6rem 0; }
  nav     { margin-bottom: 1rem; display: flex; gap: 1.5rem; }
  a       { color: var(--link); text-decoration: none; }
  a:hover { text-decoration: underline; }
  nav a   { font-size: 0.9rem; }
  dl.hdr  { margin: 0 0 0.8rem 0; font-size: 0.85rem;
            display: grid; grid-template-columns: auto 1fr;
            gap: 0.15rem 0.6rem; }
  dl.hdr dt { color: var(--text-meta); }
  dl.hdr dd { margin: 0; }
  iframe  { width: 100%; border: 1px solid var(--border-frame);
            border-radius: 2px; display: block; }
  .unsub-form { margin-top: 0.5rem; }
  button.unsub-btn {
    background: none; border: 1px solid var(--border); border-radius: 3px;
    color: var(--text-meta); font-size: 0.8rem; padding: 0.2rem 0.5rem;
    cursor: pointer;
  }
  button.unsub-btn:hover { color: var(--text); border-color: var(--text-meta); }
  /* The thread region is chrome, not content: it is mailweb's reading of
     headers somebody else wrote, so it is set apart from the message rather
     than beside it, and stated in smaller type than the mail itself. */
  .thread  { font-size: 0.85rem; margin: 0 0 0.8rem 0; padding: 0.5rem 0.7rem;
             border-left: 2px solid var(--border); color: var(--text-meta); }
  .thread-row  { margin: 0.15rem 0; }
  .thread-lbl  { display: inline-block; min-width: 6.5rem; }
  .thread-note { font-style: italic; }
{{template "nameStyle"}}
{{template "attachmentStyle"}}
{{template "editorStyle"}}
</style>
<script>
// Sizing a frame to its content means reading the frame's height. Safe only
// because the sandbox below withholds allow-scripts: nothing in the message can
// run, so allow-same-origin grants the outer page a reader and the message
// nothing. The two must never be granted together.
function resizeIframe(el) {
  try {
    var doc = el.contentDocument || el.contentWindow.document;
    el.style.height = doc.documentElement.scrollHeight + "px";
  } catch(e) {}
}
</script>
</head>
<body>
<nav>
  <a href="/">← messages</a>
  <a href="{{.LLMViewURL}}" title="Compact plain-text rendering of this page">text view →</a>
</nav>
<main>
<h1>{{if .Msg.Subject}}{{.Msg.Subject}}{{else}}(no subject){{end}}</h1>
<dl class="hdr">
  <dt>From</dt><dd>{{template "name" .Msg.From}} &lt;{{.Msg.From.Address}}&gt;</dd>
  {{- with .Msg.To}}
  <dt>To</dt><dd>{{template "nameList" .}}</dd>
  {{- end}}
  {{- with .Msg.Cc}}
  <dt>Cc</dt><dd>{{template "nameList" .}}</dd>
  {{- end}}
  {{- with .Msg.Bcc}}
  <dt>Bcc</dt><dd>{{template "nameList" .}}</dd>
  {{- end}}
  {{- /* No visible header names the reader, yet it arrived. See
         "correspondents" in templates/name.html. */}}
  {{- with .Msg.DeliveredTo}}
  <dt>To</dt><dd title="No recipient header on this message names you; it reached this account as a blind copy. This address comes from the Delivered-To header added on delivery.">undisclosed recipients — delivered to {{.}}</dd>
  {{- end}}
  <dt>Date</dt><dd>{{.Msg.Date.Format "Mon, 02 Jan 2006 15:04"}}</dd>
  <dt>Mailbox</dt><dd>{{.Mailbox}}{{with .Msg.SizeHint}}{{.}}{{end}}</dd>
</dl>
{{/* Where this message sits in the exchange, reconstructed from In-Reply-To —
     a header the sender wrote and nobody verified. It is rendered above the
     body because "what is this answering" is a question a reader has before
     reading, and marked as mailweb's own reading rather than as part of the
     mail. A claimed parent that is not mirrored says so: a third of the
     messages here that name a parent name one this mirror does not hold, and
     rendering that as nothing would say the message began the thread. */}}
{{with .Thread}}
{{if .HasAny}}
<div class="thread">
  {{if .Parent}}
  <div class="thread-row"><span class="thread-lbl">In reply to</span>
    <a href="/msg/{{.Parent.ID}}/view">{{if .Parent.Subject}}{{.Parent.Subject}}{{else}}(no subject){{end}}</a>
    — {{if .Parent.Outgoing}}you wrote it{{else}}{{template "name" (index $.ThreadNames .Parent.ID)}}{{end}},
    {{.Parent.Date.Format "2006-01-02"}}
  </div>
  {{else if .ParentMissing}}
  <div class="thread-row thread-note"><span class="thread-lbl">In reply to</span>
    a message this mirror does not hold, which the sender named
    <code>{{.ParentID}}</code>. It may predate the two-year backfill window, sit
    in a mailbox that is not watched, or never have existed.
  </div>
  {{end}}
  {{range .Replies}}
  <div class="thread-row"><span class="thread-lbl">Reply</span>
    <a href="/msg/{{.ID}}/view">{{if .Subject}}{{.Subject}}{{else}}(no subject){{end}}</a>
    — {{if .Outgoing}}you wrote it{{else}}{{template "name" (index $.ThreadNames .ID)}}{{end}},
    {{.Date.Format "2006-01-02"}}
  </div>
  {{end}}
</div>
{{end}}
{{end}}
{{/* Above the body: for mail that carries a calendar, the event usually is the
     message and the text is the covering letter. */}}
{{template "calendars" .Att}}
{{/* The body, and only the body, inside the sandbox. */}}
<iframe src="/msg/{{.Msg.ID}}"
        sandbox="allow-same-origin allow-popups allow-popups-to-escape-sandbox"
        onload="resizeIframe(this)"></iframe>
{{template "attachments" .Att}}
{{/* Below the body and below the list of what is attached: a PDF is an
     enclosure to a covering note, so the note is read first and the row naming
     the file comes before the file itself. Only on this page — a listing would
     pay an uncached IMAP fetch per message, and 270 messages here carry one. */}}
{{template "pdfs" .Att}}
{{if .Msg.ListUnsubscribe}}
<form class="unsub-form" method="POST" action="/unsubscribe/{{.Msg.ID}}">
  <button class="unsub-btn" type="submit" title="Send unsubscribe email to {{.Msg.ListUnsubscribe}}">✉ unsubscribe</button>
</form>
{{else if .Msg.ListUnsubscribeURL}}
<form class="unsub-form" method="POST" action="/unsubscribe/{{.Msg.ID}}">
  <button class="unsub-btn" type="submit"
          onclick="window.open('{{.Msg.ListUnsubscribeURL}}', '_blank')"
          title="Open unsubscribe page: {{.Msg.ListUnsubscribeURL}}">✉ unsubscribe</button>
</form>
{{end}}
{{range .Drafts}}
<div data-draft-editor="{{.Token}}"></div>
{{else}}
{{template "replyButton" .Msg.ID}}
{{end}}
</main>
{{template "editorScript"}}
</body>
</html>