feat(pages): a top bar section, section labels and serif headings

Landing pages gain a Top bar section (the company logo and an optional button,
kept at the top of the window, first section only), a short label above the
headings of five section types, and serif section headings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-04 12:28:09 +08:00
1 parent 2a69826e66
commit e4ad18a8a3
18 files changed
+428 -22

No files matched your search

@@ -12,7 +12,8 @@ import java.util.List;
* One landing-page block. Which fields apply depends on {@code type}:
* HERO (imageId, heading, text, button, optional eventUuid for a sign-up form beside the text, fullWidth, formHeading and formText, cards as title-only points), RICH_TEXT (html), IMAGE_TEXT (imageId, imagePosition, heading, html, button),
* FAQ (heading, items), FORM (heading, eventUuid), HTML (html), FEATURES (heading, text, cards), STEPS (heading, cards),
* TRUST (cards), CTA (heading, text, button), FOOTER (cards as title-and-text columns, text as the legal line). Any block may carry anchor and look.
* TRUST (cards), CTA (heading, text, button), FOOTER (cards as title-and-text columns, text as the legal line),
* TOPBAR (button only; the first block). Any block may carry anchor and look.
*/
@Getter
@Setter
@@ -42,4 +43,6 @@ public class CmsBlock {
private String formText;
/** add-landing-thanks-and-footer: text (200) under the thank-you after a sign-up; FORM, or HERO with an event. */
private String thanksText;
/** add-landing-page-polish: a short label (40) above the heading of FEATURES, STEPS, IMAGE_TEXT, FAQ and CTA. */
private String eyebrow;
}
@@ -17,7 +17,7 @@ import java.util.regex.Pattern;
* Co-Lite changes: images are uploaded ids of the page's company, FORM points at an event of that company,
* buttons may also use mailto: and tel:, and rich-text HTML holding scripts is refused (the public page sanitises as well).
* The HTML block (custom HTML) is exempt from the script check: it is served only inside a sandboxed frame.
* add-landing-thanks-and-footer adds FOOTER and the thank-you text. add-page-sections adds FEATURES, STEPS, TRUST and CTA, a look on any block, and makes the HERO image optional.
* add-landing-page-polish adds TOPBAR and section labels. add-landing-thanks-and-footer adds FOOTER and the thank-you text. add-page-sections adds FEATURES, STEPS, TRUST and CTA, a look on any block, and makes the HERO image optional.
* Throws 422 on the first violation, with the reason "path|MessageCode".
*/
public final class CmsBlockValidator {
@@ -28,6 +28,8 @@ public final class CmsBlockValidator {
private static final Set<String> LOOKS = Set.of("DEFAULT", "MUTED", "DARK", "ACCENT");
static final Set<String> ICONS = Set.of("wifi", "phone", "tv", "monitor", "lock", "shield-check", "cloud", "wrench", "headset", "users", "calendar", "star");
private static final Set<String> CARD_TYPES = Set.of("FEATURES", "STEPS", "TRUST", "HERO", "FOOTER");
/** add-landing-page-polish: blocks that may carry a short label above their heading. */
private static final Set<String> EYEBROW_TYPES = Set.of("FEATURES", "STEPS", "IMAGE_TEXT", "FAQ", "CTA");
private static final Pattern SCRIPT = Pattern.compile("(?i)<\\s*script|\\son[a-z]+\\s*=|javascript\\s*:");
private CmsBlockValidator() {
@@ -66,6 +68,12 @@ public final class CmsBlockValidator {
if (b.getThanksText() != null && !"FORM".equals(b.getType()) && !"HERO".equals(b.getType())) {
throw refuse(path + ".thanksText", "PagesUnusedField");
}
if (b.getEyebrow() != null) {
if (!EYEBROW_TYPES.contains(b.getType())) {
throw refuse(path + ".eyebrow", "PagesUnusedField");
}
max(b.getEyebrow(), path + ".eyebrow", 40);
}
switch (b.getType()) {
case "HERO" -> {
if (b.getImageId() != null) {
@@ -150,6 +158,24 @@ public final class CmsBlockValidator {
required(b.getButtonLabel(), path + ".buttonLabel");
button(b, path);
}
case "TOPBAR" -> {
// add-landing-page-polish: the company logo and an optional button, sticky, so only at the top.
if (i > 0) {
throw refuse(path + ".type", "PagesTopBarFirst");
}
unused(path, "heading", b.getHeading());
unused(path, "text", b.getText());
unused(path, "html", b.getHtml());
unused(path, "imageId", b.getImageId());
unused(path, "imagePosition", b.getImagePosition());
unused(path, "items", b.getItems());
unused(path, "eventUuid", b.getEventUuid());
unused(path, "fullWidth", b.getFullWidth());
unused(path, "formHeading", b.getFormHeading());
unused(path, "formText", b.getFormText());
unused(path, "look", b.getLook());
button(b, path);
}
default -> throw refuse(path + ".type", "PagesUnknownType");
}
}
@@ -159,6 +185,12 @@ public final class CmsBlockValidator {
return new ResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY, path + "|" + code);
}
private static void unused(String path, String field, Object value) {
if (value != null) {
throw refuse(path + "." + field, "PagesUnusedField");
}
}
static void required(String value, String path) {
if (value == null || value.isBlank()) {
throw refuse(path, "PagesRequired");