Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : KA Maps Engine8 * File : server/km-maps/src/pages.ts9 * Module : server10 * Repository : https://git.spboucher.ai/ka-maps-engine11 * Created : 2026-12-0112 * Last Modified : 2026-12-0113 *14 * Author : Simon-Pierre Boucher15 * Position : Professor of Finance16 * Institution : Université du Québec en Outaouais (UQO)17 * Organization : SP Boucher18 * Website : https://spboucher.ai19 * Git : https://git.spboucher.ai20 *21 * Preferred Contact: support@spboucher.ai22 * Development : dev@spboucher.ai23 * Support : support@spboucher.ai24 * Security/Admin : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142// Pages publiques : accueil, licences, feuille de style. HTML statique, sans script.43import { esc, markdownToHtml } from '../lib/markdown.ts';44import type { Snapshot } from '../lib/snapshot.ts';4546export const SITE_CSS = `47:root { --land:#f4f0e8; --paper:#fbfaf7; --ink:#2a2825; --soft:#5e584f; --faint:#8c857a; --line:#d9d2c6; --accent:#8c4a2f; --ok:#4d6b4a; --bad:#9a3324; }48* { box-sizing: border-box; }49html { background: var(--land); color: var(--ink); font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }50body { margin: 0; }51a { color: var(--accent); text-underline-offset: 3px; }52a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }53header.top { border-bottom: 1px solid var(--line); background: var(--paper); }54.wrap { max-width: 1040px; margin: 0 auto; padding: 0 28px; }55header.top .wrap { display: flex; align-items: baseline; justify-content: space-between; height: 64px; padding-top: 20px; }56.mark { font-weight: 650; letter-spacing: .14em; text-transform: uppercase; font-size: 14px; color: var(--ink); text-decoration: none; }57nav a { margin-left: 24px; font-size: 14px; color: var(--soft); text-decoration: none; }58nav a:hover { color: var(--ink); text-decoration: underline; }59h1 { font-size: 40px; line-height: 1.12; font-weight: 600; letter-spacing: -.015em; margin: 64px 0 16px; max-width: 18em; }60h2 { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--soft); font-weight: 650; margin: 56px 0 16px; padding-top: 16px; border-top: 1px solid var(--line); }61h3 { font-size: 18px; margin: 32px 0 8px; font-weight: 600; }62h4, h5, h6 { font-size: 15px; margin: 24px 0 6px; }63p.lead { font-size: 19px; color: var(--soft); max-width: 40em; margin: 0 0 32px; }64figure { margin: 40px 0 0; border: 1px solid var(--line); background: var(--paper); }65figure img { display: block; width: 100%; height: auto; }66figcaption { font-size: 13px; color: var(--faint); padding: 10px 14px; border-top: 1px solid var(--line); }67.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0; border: 1px solid var(--line); background: var(--paper); }68.cell { padding: 18px 20px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }69.cell b { display: block; font-size: 15px; font-weight: 600; }70.cell span { font-size: 13px; color: var(--soft); }71.cell code { display: block; margin-top: 8px; font-size: 12px; color: var(--faint); word-break: break-all; }72.state { display: inline-block; width: 9px; height: 9px; margin-right: 8px; background: var(--faint); }73.state.ok { background: var(--ok); } .state.bad { background: var(--bad); }74table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--paper); }75.table { overflow-x: auto; border: 1px solid var(--line); margin: 16px 0; }76th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }77th { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); font-weight: 650; }78tr:last-child td { border-bottom: 0; }79code, pre { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }80pre { background: var(--paper); border: 1px solid var(--line); padding: 14px 16px; overflow-x: auto; }81blockquote { margin: 16px 0; padding: 2px 18px; border-left: 3px solid var(--line); color: var(--soft); }82footer { margin: 72px 0 0; border-top: 1px solid var(--line); background: var(--paper); }83footer .wrap { padding: 22px 28px 28px; font-size: 13px; color: var(--faint); }84main { padding-bottom: 8px; }85@media (max-width: 640px) { h1 { font-size: 30px; margin-top: 40px; } nav a { margin-left: 14px; } }86`;8788function page(title: string, body: string): string {89 return `<!doctype html>90<html lang="fr-CA">91<head>92<meta charset="utf-8">93<meta name="viewport" content="width=device-width, initial-scale=1">94<title>${esc(title)}</title>95<meta name="description" content="KA Maps — moteur cartographique propriétaire : tuiles, thèmes, relief et recherche d'adresses pour le Québec.">96<link rel="stylesheet" href="/site.css">97</head>98<body>99<header class="top"><div class="wrap"><a class="mark" href="/">KA Maps</a><nav><a href="/#services">Services</a><a href="/#themes">Thèmes</a><a href="/licences">Sources et licences</a></nav></div></header>100<main class="wrap">101${body}102</main>103<footer><div class="wrap">KA Maps — moteur cartographique propriétaire. Données cartographiques : © les contributeurs d'OpenStreetMap, Gouvernement du Québec, Ressources naturelles Canada. <a href="/licences">Sources et licences</a>.</div></footer>104</body>105</html>`;106}107108export type ServiceState = { name: string; label: string; url: string; ok: boolean | null; ms: number | null; checkedAt: string | null };109110export function landingPage(s: Snapshot, services: ServiceState[], hero: boolean, sdk: string | null): string {111 const themeRows = [...s.themes.values()]112 .map((t) => {113 const last = t.versions[t.versions.length - 1];114 return last ? `<tr><td><strong>${esc(t.title)}</strong><br><code>${esc(t.id)}</code></td><td>${t.versions.length}</td><td>v${last.version} · ${esc(last.createdAt.slice(0, 10))}</td><td>${esc(last.minEngine)}</td><td><a href="/v1/themes/${esc(t.id)}/${last.version}.json">JSON</a></td></tr>` : '';115 })116 .join('');117 const svc = services118 .map((x) => `<div class="cell"><b><i class="state ${x.ok === null ? '' : x.ok ? 'ok' : 'bad'}"></i>${esc(x.label)}</b><span>${x.ok === null ? 'non vérifié' : x.ok ? `en service${x.ms !== null ? ` · ${Math.round(x.ms)} ms` : ''}` : 'hors service'}</span><code>${esc(x.url)}</code></div>`)119 .join('');120 const checked = services.find((x) => x.checkedAt)?.checkedAt;121 return page(122 'KA Maps — moteur cartographique propriétaire',123 `<h1>KA Maps — moteur cartographique propriétaire</h1>124<p class="lead">Un moteur de rendu écrit en Rust, ses propres tuiles vectorielles, son relief et sa recherche d'adresses. Il dessine les cartes de Lou-Ka, Immo-Ka, Vrai-Prix et Valo-Plex, sur le Web, iOS et Android.</p>125${hero ? `<figure><img src="/v1/static?center=-73.5674,45.5019&zoom=14.6&size=984x420&scale=2&theme=signature" width="984" height="420" alt="Centre-ville de Montréal rendu par le moteur KA Maps, thème signature"><figcaption>Centre-ville de Montréal, thème « signature ». Image produite par ce service (<code>/v1/static</code>) avec le moteur, sans bibliothèque cartographique tierce.</figcaption></figure>` : ''}126<h2 id="services">État des services</h2>127<div class="grid">${svc}</div>128<p><small>${checked ? `Vérifié à ${esc(checked.slice(11, 16))} UTC. ` : ''}Version des données : ${esc(s.dataVersion ?? 'inconnue')}. État lisible par programme : <a href="/status.json">/status.json</a>.</small></p>129<h2 id="themes">Thèmes publiés</h2>130<div class="table"><table><thead><tr><th>Thème</th><th>Versions</th><th>Dernière</th><th>Moteur minimal</th><th>Document</th></tr></thead><tbody>${themeRows || '<tr><td colspan="5">Aucun thème publié.</td></tr>'}</tbody></table></div>131<h2 id="api">Ce que sert ce domaine</h2>132<div class="table"><table><tbody>133<tr><td><code>GET /v1/manifest.json?app=&platform=&engine=&bucket=</code></td><td>Thèmes en service pour une application, version minimale du moteur, adresses des services, configuration, tranche de diffusion.</td></tr>134<tr><td><code>GET /v1/themes/{id}/{version}.json</code></td><td>Document de thème <code>kastyle/1</code>, immuable.</td></tr>135<tr><td><code>GET /v1/themes/{id}/current.json?app=</code></td><td>Thème en service pour l'application, marque appliquée.</td></tr>136<tr><td><code>GET /v1/static?center=&zoom=&size=</code></td><td>Image PNG d'une carte, rendue par le moteur.</td></tr>137<tr><td><code>GET /sdk/{version}/…</code></td><td>SDK Web (WebAssembly)${sdk ? ` — version ${esc(sdk)}` : ' — pas encore publié ici'}.</td></tr>138</tbody></table></div>139<p><small>Service en lecture seule. Aucun compte, aucun témoin, aucun journal par utilisateur : seuls des compteurs agrégés par application et par jour sont conservés.</small></p>`,140 );141}142143export function licencesPage(markdown: string | null, datasets: any[]): string {144 const table = datasets.length145 ? `<h2>Jeux de données intégrés</h2><div class="table"><table><thead><tr><th>Jeu</th><th>Fournisseur</th><th>Licence</th><th>Mention</th><th>Date</th></tr></thead><tbody>${datasets146 .map((d) => `<tr><td>${/^https?:\/\//.test(d.url ?? '') ? `<a href="${esc(d.url)}" rel="noopener">${esc(d.title)}</a>` : esc(d.title)}</td><td>${esc(d.provider)}</td><td>${/^https?:\/\//.test(d.licence_url ?? '') ? `<a href="${esc(d.licence_url)}" rel="noopener">${esc(d.licence)}</a>` : esc(d.licence)}</td><td>${esc(d.attribution)}</td><td>${d.source_date ? esc(new Date(d.source_date).toISOString().slice(0, 10)) : ''}</td></tr>`)147 .join('')}</tbody></table></div>`148 : '';149 const body = markdown150 ? markdownToHtml(markdown)151 : `<h1>Sources et licences</h1><p class="lead">Le document de référence des licences (<code>docs/DATA_LICENSING.md</code>) n'est pas encore publié sur ce serveur.</p><p>Mention affichée sur toutes les cartes : « © OpenStreetMap, Gouvernement du Québec, RNCan ». Les données OpenStreetMap sont sous licence <a href="https://www.openstreetmap.org/copyright" rel="noopener">ODbL 1.0</a>.</p>`;152 return page('KA Maps — sources et licences', `${body}\n${table}`);153}154