b6c2598710
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 11s
CI / integration (pull_request) Successful in 26s
CI / ui (pull_request) Successful in 1m13s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Failing after 16m19s
Robokassa moderation requires the public offer to list every digital good with its price. Move /offer/ off the static landing container to the render sidecar: it splices the live catalog price list (§4.4) into the owner-edited ui/legal/offer_ru.md and renders it with the shared ui/src/lib/offer.ts — one renderer, no drift, always matching the current catalog with no redeploy. - backend: /api/v1/internal/offer/pricing (internal, off the edge allow-list) projects the active catalog into two markdown tables — chip packs priced per rail (roubles / VK votes / Telegram Stars) and chip-priced values — through payments.Money so no float reaches the page. Cached in memory: warmed at boot, marked stale on every catalog mutation, so a served render issues no query. - renderer: GET /offer/ fetches the tables and substitutes them at the <#pricing_template#> marker, then renders; offer_ru.md is baked into the image and marked is bundled from ui. GET /offer -> 301. Only /offer/ is edge-exposed. - caddy: route /offer/ to the sidecar; drop the now-dead landing /offer/ handlers and the vite emit-offer plugin. - offer: fill §4.3 (the chip-payment wording) and drop the in-page back link. - landing footer: a feedback link (the offer's Telegram contact) beside the offer link. - docs (ARCHITECTURE, FUNCTIONAL +_ru, renderer README), CI /offer/ probe, unit + integration + node tests.
90 lines
2.5 KiB
TypeScript
90 lines
2.5 KiB
TypeScript
import { marked } from 'marked';
|
|
|
|
/**
|
|
* renderOfferHtml renders the public-offer markdown source into a standalone,
|
|
* self-contained HTML document served at `/offer/`. It runs server-side in the
|
|
* render sidecar (`renderer/src/offer.mjs`), which reads the owner-edited
|
|
* `ui/legal/offer_ru.md`, splices the live catalog price list into it and calls
|
|
* this function — one renderer shared with the browser build, kept unit-tested
|
|
* here (`offer.test.ts`).
|
|
*
|
|
* The input `markdown` is trusted repository content plus the backend's own
|
|
* catalog projection, not user input, so the rendered HTML is deliberately not
|
|
* sanitised. The page carries its own minimal light/dark styling so it needs
|
|
* neither the app bundle nor `app.css`.
|
|
*/
|
|
export function renderOfferHtml(markdown: string): string {
|
|
const body = marked.parse(markdown, { async: false }) as string;
|
|
return `<!doctype html>
|
|
<html lang="ru">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Публичная оферта — Эрудит</title>
|
|
<link rel="canonical" href="https://erudit-game.ru/offer/" />
|
|
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#f3f4f6" />
|
|
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#0f1115" />
|
|
<style>
|
|
:root {
|
|
color-scheme: light dark;
|
|
--bg: #ffffff;
|
|
--text: #1a1c20;
|
|
--accent: #2563eb;
|
|
--rule: #e5e7eb;
|
|
}
|
|
@media (prefers-color-scheme: dark) {
|
|
:root {
|
|
--bg: #0f1115;
|
|
--text: #e7e9ee;
|
|
--accent: #6ea8fe;
|
|
--rule: #242832;
|
|
}
|
|
}
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
body {
|
|
margin: 0;
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
font: 16px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
}
|
|
main {
|
|
max-width: 760px;
|
|
margin: 0 auto;
|
|
padding: 24px 20px 64px;
|
|
}
|
|
a {
|
|
color: var(--accent);
|
|
}
|
|
h1 {
|
|
font-size: 1.6rem;
|
|
text-align: center;
|
|
}
|
|
h2 {
|
|
font-size: 1.2rem;
|
|
margin-top: 2em;
|
|
padding-top: 1em;
|
|
border-top: 1px solid var(--rule);
|
|
}
|
|
h3 {
|
|
font-size: 1.05rem;
|
|
margin-top: 1.5em;
|
|
}
|
|
ul {
|
|
padding-left: 1.25em;
|
|
}
|
|
li {
|
|
margin: 0.25em 0;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<main>
|
|
${body}
|
|
</main>
|
|
</body>
|
|
</html>
|
|
`;
|
|
}
|