Redesign landing page, JSON caller response, shared email shell

- docs.htm: dark single-page redesign in plain CSS, live URL builder,
  all four parsers documented, Bootstrap CDN dependency dropped
- index.php: respond with pretty-printed JSON (success and 400 error);
  email "Parsed Variables" block uses JSON instead of print_r
- parsers/helpers.php: emailShell() provides one stylesheet, header and
  footer for every email template; five duplicated stylesheets removed
This commit is contained in:
Andy Dixon
2026-09-11 18:23:25 +01:00
parent f3f58dbf95
commit c1ec1adf85
7 changed files with 602 additions and 1503 deletions
+75
View File
@@ -89,3 +89,78 @@ function renderDataAsTable($data, $depth = 0) {
return $html;
}
/**
* Shared email chrome: one stylesheet, one header, one footer, for every template.
*
* @param string $title Header text (already HTML-safe)
* @param string $stamp Timestamp line (already HTML-safe)
* @param string $body Inner HTML made of .section / .metadata / .data-box blocks
* @param string $footer Footer sentence
* @return string Complete HTML document
*/
function emailShell($title, $stamp, $body, $footer = 'Automatically forwarded to your inbox.') {
$host = htmlspecialchars($_SERVER['HTTP_HOST'] ?? 'webhook', ENT_QUOTES, 'UTF-8');
$plainTitle = strip_tags($title);
return <<<HTML
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="color-scheme" content="light">
<title>$plainTitle</title>
<style>
body { margin:0; padding:0; background:#f3f1fb; color:#15151f; -webkit-font-smoothing:antialiased;
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif; font-size:15px; line-height:1.6; }
a { color:#7c3aed; }
.wrap { padding:28px 12px; }
.container { max-width:640px; margin:0 auto; background:#ffffff; border-radius:16px; overflow:hidden;
box-shadow:0 12px 40px rgba(40,20,90,.10); border:1px solid #e9e6f5; }
.stripe { height:6px; background:#8b5cf6; background-image:linear-gradient(90deg,#8b5cf6,#ec4899 55%,#f97316); }
.header { padding:28px 32px 20px; border-bottom:1px solid #eeecf6; }
.header h1 { margin:0 0 6px; font-size:22px; font-weight:800; letter-spacing:-.02em; line-height:1.25; color:#15151f; }
.timestamp { margin:0; font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:12px; color:#8b8ba3; letter-spacing:.06em; text-transform:uppercase; }
.section { padding:22px 32px 0; }
.section-title { font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:11px; font-weight:700; letter-spacing:.14em; text-transform:uppercase; color:#7c3aed; margin:0 0 10px; }
.subsection { margin:14px 0; }
.subsection-title { font-size:13px; font-weight:700; color:#15151f; margin:16px 0 8px; padding-left:10px; border-left:3px solid #ec4899; }
.metadata { display:table; width:100%; border:1px solid #e9e6f5; border-radius:10px; border-collapse:separate; overflow:hidden; }
.metadata-row { display:table-row; }
.metadata-label, .metadata-value { display:table-cell; padding:10px 14px; border-bottom:1px solid #f0eef8; vertical-align:top; }
.metadata-row:last-child .metadata-label, .metadata-row:last-child .metadata-value { border-bottom:0; }
.metadata-label { width:150px; font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:12px; color:#6b6b80; background:#faf9fe; white-space:nowrap; }
.metadata-value { font-size:14px; color:#15151f; word-break:break-word; }
.data-box { margin:0; padding:16px 18px; background:#0f0f17; color:#e6e6f0; border-radius:10px; font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
font-size:12.5px; line-height:1.65; white-space:pre-wrap; word-break:break-word; overflow-x:auto; }
.path-title { margin:18px 0 8px; padding:8px 12px; font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:12px; font-weight:700;
color:#db2777; background:#fdf2f8; border-left:3px solid #ec4899; border-radius:0 8px 8px 0; }
.array-item, .array-item-simple { margin:0 0 12px; padding:14px 16px; background:#faf9fe; border:1px solid #e9e6f5; border-radius:10px; }
.array-item-title { font-size:13px; font-weight:700; margin:0 0 10px; color:#15151f; }
.array-item .metadata { background:#fff; }
.message-box { margin:12px 0; padding:14px 16px; background:#faf9fe; border:1px solid #e9e6f5; border-radius:10px; font-size:15px; line-height:1.6; }
.error-box { margin:12px 0; padding:12px 14px; background:#fef2f2; border-left:3px solid #ef4444; border-radius:0 8px 8px 0; }
.footer { margin-top:28px; padding:18px 32px 24px; border-top:1px solid #eeecf6; text-align:center; color:#8b8ba3;
font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:11px; letter-spacing:.04em; }
.footer p { margin:0 0 4px; }
</style>
</head>
<body>
<div class="wrap">
<div class="container">
<div class="stripe"></div>
<div class="header">
<h1>$title</h1>
<p class="timestamp">$stamp</p>
</div>
$body
<div class="footer">
<p>$footer</p>
<p>⚡ $host</p>
</div>
</div>
</div>
</body>
</html>
HTML;
}