Files
hoelee-check/src/lib/html.mjs
T
hoelee 8925d10424 feat(check): seven checks, and the one picture worth having
Adds mail-transport (MTA-STS + policy file, TLS-RPT, BIMI) and hardening (compression,
CAA vs the issuing CA, cookie flags, version banners). Wiring them exposed a real gap:
net-guard pinned accept-encoding to identity, so the compression question could only ever
be answered 'not measured'. requestOnce now takes acceptEncoding, decompresses, and returns
both the wire size and the decoded size - hoelee.com measures 39.6 KB against 119.4 KB.

The hub gets a CSS trust-flow diagram instead of a picture: four boxes and three arrows
cost no request, stay sharp, and can be corrected without re-exporting anything. The
1200x630 social card is drawn in HTML and screenshotted, because a diffusion model renders
'technical' as soft glyph soup that turns to mud at WhatsApp thumbnail size.
2026-11-10 19:20:16 +08:00

114 lines
4.5 KiB
JavaScript

// Tiny HTML layer. No template engine: every string that reaches the page goes through esc(),
// and the only dynamic markup is built from arrays.
export const PREFIX = '/check';
export const ORIGIN = 'https://www.hoelee.com';
export function esc(value) {
return String(value ?? '')
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
export function abs(path) {
if (/^https?:\/\//.test(path)) return path;
return `${ORIGIN}${PREFIX}${path.startsWith('/') ? path : `/${path}`}`;
}
const NAV = [
['/spf-dkim-dmarc/', 'Email', 'spf-dkim-dmarc'],
['/ssl/', 'Certificate', 'ssl'],
['/headers/', 'Redirects & headers', 'headers'],
['/about/', 'How this works', 'about']
];
export function layout({ title, description, body, active = '', robots = 'index,follow', canonical, extraHead = '' }) {
const nav = NAV.map(([href, label, key]) => {
const current = key === active ? ' aria-current="page"' : '';
return `<a href="${esc(PREFIX + href)}"${current}>${esc(label)}</a>`;
}).join('');
return `<!doctype html>
<html lang="en-MY">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>${esc(title)}</title>
<meta name="description" content="${esc(description)}">
<meta name="robots" content="${esc(robots)}">
<link rel="canonical" href="${esc(canonical || abs('/'))}">
<link rel="stylesheet" href="${esc(PREFIX)}/assets/style.css">
<meta property="og:type" content="website">
<meta property="og:title" content="${esc(title)}">
<meta property="og:description" content="${esc(description)}">
<meta property="og:url" content="${esc(canonical || abs('/'))}">
<meta property="og:image" content="${esc(abs('/assets/og.png'))}">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Hoelee domain check: certificate, email records, WhatsApp card, www and registry in one pass">
<meta name="twitter:card" content="summary_large_image">
${extraHead}
</head>
<body>
<header class="site"><div class="wrap">
<a class="brand" href="${esc(PREFIX)}/">Hoelee Check <span>by Hoelee Enterprise</span></a>
<nav>${nav}</nav>
</div></header>
<main><div class="wrap">
${body}
</div></main>
<footer class="site"><div class="wrap">
<p>Built and hosted by <a href="https://www.hoelee.com/">Hoelee Enterprise</a>, Perak, Malaysia.
No trackers, no cookies, no account. Every check reads only what the public internet can already see.</p>
<p><a href="${esc(PREFIX)}/about/">What this service queries, and what it refuses to do</a></p>
</div></footer>
</body>
</html>
`;
}
export function badge(state, label) {
const cls = state === 'not-evaluated' ? 'neutral' : state;
return `<span class="badge ${esc(cls)}">${esc(label)}</span>`;
}
export function form({ action = '/', value = '', label = 'Domain name', button = 'Run the check' }) {
return `<form class="check" method="get" action="${esc(PREFIX + action)}">
<label class="sr" for="d" hidden>${esc(label)}</label>
<input id="d" name="d" type="text" inputmode="url" autocomplete="off" spellcheck="false"
placeholder="yourbusiness.com.my" value="${esc(value)}" required>
<button type="submit">${esc(button)}</button>
</form>`;
}
export function evidenceTable(rows) {
if (!rows || rows.length === 0) return '';
const body = rows
.map((r) => `<tr><th scope="row">${esc(r.label)}</th><td>${r.html ? r.html : `<span class="mono">${esc(r.value)}</span>`}${r.note ? `<div class="faint">${esc(r.note)}</div>` : ''}</td></tr>`)
.join('');
return `<table class="evidence">${body}</table>`;
}
export function findingList(findings) {
if (!findings || findings.length === 0) return '';
return `<ul class="findings">${findings
.map((f) => `<li class="${esc(f.level)}">${esc(f.message)}${f.fix ? `<span class="fix">${esc(f.fix)}</span>` : ''}</li>`)
.join('')}</ul>`;
}
export function whatsappPreview(preview, host) {
const image = preview && preview.image
? `<img src="${esc(preview.image)}" alt="" referrerpolicy="no-referrer" loading="lazy">`
: 'No preview image found';
return `<div class="wa">
<div class="wa-label">How your link looks in WhatsApp</div>
<div class="wa-img">${image}</div>
<div class="wa-title">${esc((preview && preview.title) || host)}</div>
<div class="wa-desc">${esc((preview && preview.description) || 'No description found — WhatsApp will show the bare link.')}</div>
<div class="wa-url">${esc(host.toUpperCase())}</div>
</div>`;
}