237 lines · 9.1 KB
// Self-contained HTML for a "View full email" page, served by src/worker.ts.
// Same no-external-assets constraint as the counter page.
//
// Laid out like a mail client's reading view: a top bar, the subject as the
// heading, then one message with a sender avatar row above its body.
//
// Everything interesting happens in the browser. The Worker serves this
// shell to anyone who asks for a valid id; the shell takes the key out of
// the URL fragment (which never reached the Worker), fetches the sealed
// body, and decrypts it locally. A server-side render was never an option:
// the Worker has no key.
export function renderWebviewPage(): string {
  return `<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="referrer" content="no-referrer">
<meta name="robots" content="noindex, nofollow">
<meta name="color-scheme" content="dark light">
<title>Cindermail</title>
<style>
  /* Dark by default, matching the rest of Cindermail. The light values only
     apply to a browser that asks for them. */
  :root {
    --page: #141210;
    --text: #f1e6dc;
    --muted: #a8917f;
    --code: #d9c8ba;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    --plain: #1f1b18;
  }
  @media (prefers-color-scheme: light) {
    :root {
      --page: #f3f4f6;
      --text: #111827;
      --muted: #6b7280;
      --code: #374151;
      --shadow: 0 1px 3px rgba(17, 24, 39, 0.08), 0 4px 14px rgba(17, 24, 39, 0.05);
      --plain: #ffffff;