Compare commits

..
Author SHA1 Message Date
ngqileandClaude Opus 5.5 405dab55dd fix(pages): fit the top bar, hero and trust strip on one desktop screen
A trust strip band uses less padding, the full-width hero less padding, and the
landing-page form tighter gaps with the consent in small text. Controls keep
their 44 px height. On the INS page at 1920x1080 the trust strip now ends at
937 px instead of 1077 px.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 12:44:55 +08:00
ngqile b6f5fb441e Merge pull request 'docs: archive add-landing-page-polish' (#81) from archive-landing-page-polish into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 04:28:36 +00:00
ngqileandClaude Opus 5.5 cc2d1c794e docs: archive add-landing-page-polish
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 12:28:28 +08:00
ngqile c21a31e10f Merge pull request 'feat(pages): a top bar section, section labels and serif headings' (#80) from add-landing-page-polish into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 04:28:21 +00:00
ngqileandClaude Opus 5.5 e4ad18a8a3 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
2026-12-04 12:28:09 +08:00
ngqile 2a69826e66 Merge pull request 'docs: archive add-landing-thanks-and-footer' (#79) from archive-landing-thanks-and-footer into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 03:45:57 +00:00
ngqileandClaude Opus 5.5 92412cb300 docs: archive add-landing-thanks-and-footer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 11:45:49 +08:00
ngqile 35e9b796f7 Merge pull request 'feat(pages): a footer section with contact links, and a thank-you text on landing forms' (#78) from add-landing-thanks-and-footer into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 03:45:38 +00:00
ngqileandClaude Opus 5.5 3446f261be feat(pages): a footer section with contact links, and a thank-you text on landing forms
Landing pages gain a Footer section (1 to 4 columns of title and text, a legal
line under a divider) whose phone numbers, emails and web addresses show as
links. The Form block and a hero with a form may carry a thank-you text shown
after sign-up, with the same links. Full-width heroes get a lighter shade.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 11:45:25 +08:00
ngqile 5a1aa447d5 Merge pull request 'docs: archive add-compact-landing-form' (#77) from archive-compact-landing-form into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 02:47:28 +00:00
ngqileandClaude Opus 5.5 2697a591aa docs: archive add-compact-landing-form
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 10:47:20 +08:00
ngqile 23840e8fbf Merge pull request 'feat(pages): a short sign-up form on landing pages, and coloured sections join' (#76) from add-compact-landing-form into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 02:47:12 +00:00
ngqileandClaude Opus 5.5 ba6ab7554d feat(pages): a short sign-up form on landing pages, and coloured sections join
Landing-page forms drop job title, ask for one service in a dropdown and fold the
privacy notice behind one line above the consent box. QR, invitation and customer
forms keep the full form. Sections with a colour look join with no gap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 10:47:02 +08:00
ngqile a7129b417e Merge pull request 'docs: archive add-html-image-upload' (#75) from archive-html-image-upload into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 02:10:43 +00:00
ngqileandClaude Opus 5.5 a83752c34e docs: archive add-html-image-upload
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 10:10:35 +08:00
ngqile bba99993cb Merge pull request 'feat(pages): upload an image from a Custom HTML block and copy its link' (#74) from add-html-image-upload into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 02:10:26 +00:00
ngqileandClaude Opus 5.5 1136046fc2 feat(pages): upload an image from a Custom HTML block and copy its link
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 10:10:15 +08:00
ngqile 44eace2bcb Merge pull request 'docs: archive add-hero-full-width' (#73) from archive-hero-full-width into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 01:47:05 +00:00
ngqileandClaude Opus 5.5 dc5cfd1c54 docs: archive add-hero-full-width
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 09:46:57 +08:00
ngqile fae25c11a6 Merge pull request 'feat(pages): a hero can run full width with points and a form card heading' (#72) from add-hero-full-width into main
CI / build-and-publish (push) Failing after 0s
2026-12-04 01:46:44 +00:00
ngqileandClaude Opus 5.5 b55b8d2d86 feat(pages): a hero can run full width with points and a form card heading
A full-width hero spans the window with a larger serif headline and a lighter
left-to-right shade. It may list up to 6 points and give its form card a heading
and text. Full-width neighbours join with no gap. Custom HTML frames now shrink
to 20 px and re-report their height when the page asks, so a short top bar no
longer leaves a blank band.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 09:46:32 +08:00
ngqile dbb58e6e94 Merge pull request 'fix(pages): a short Custom HTML block shrinks to its content height' (#71) from fix-frame-content-height into main
CI / build-and-publish (push) Failing after 0s
2026-12-03 12:07:10 +00:00
ngqileandClaude Opus 5.5 3d89eb3118 fix(pages): a short Custom HTML block shrinks to its content height
scrollHeight inside the frame never drops below the frame's own 600 px start height,
so a top bar left a large blank gap. The frame script now reports the content box height.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 20:06:57 +08:00
ngqile e70051f912 Merge pull request 'docs: archive add-hero-signup-form' (#70) from archive-hero-signup-form into main
CI / build-and-publish (push) Failing after 0s
2026-12-03 11:46:05 +00:00
ngqileandClaude Opus 5.5 0073b41333 docs: archive add-hero-signup-form
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 19:45:55 +08:00
ngqile d4a2646786 Merge pull request 'feat(pages): a hero section can carry the sign-up form beside its text' (#69) from add-hero-signup-form into main
CI / build-and-publish (push) Failing after 0s
2026-12-03 11:45:48 +00:00
ngqileandClaude Opus 5.5 48896d1958 fix(pages): top-align the hero text beside a long form and clear the editor's image button
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 19:45:34 +08:00
ngqileandClaude Opus 5.5 417af36227 feat(pages): a hero section can carry the sign-up form beside its text
A HERO block may name an event. services-counter checks it belongs to the
page's company; mobile-api serves and accepts the form for it like a FORM
block; the portal shows the form in a card beside the hero text (below it on
phones), with the hero's own event picker, "No form" by default.

OpenSpec change: add-hero-signup-form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 19:36:16 +08:00
ngqile 55ae666f01 Merge pull request 'docs: archive add-k8s-deployment' (#68) from archive-k8s-deployment into main
CI / build-and-publish (push) Failing after 0s
2026-12-03 11:07:44 +00:00
ngqileandClaude Opus 5.5 ff39d3f452 docs: archive add-k8s-deployment (task 6.2, the server-side dry run on the real cluster, stays open for the first apply)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 19:07:36 +08:00
ngqile c17d2f4bf3 Merge pull request 'feat(deploy): Kubernetes manifests, secret and release scripts, manifest check' (#67) from add-k8s-deployment into main
CI / build-and-publish (push) Failing after 0s
2026-12-03 11:07:21 +00:00
ngqileandClaude Opus 5.5 12babb9b88 fix(deploy): create the namespace before the first secrets; prove probe settings; keep the start order as fallback
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 19:07:05 +08:00
ngqileandClaude Opus 5.5 c7bc7a8dcb feat(deploy): Kubernetes manifests, secret and release scripts, and a manifest check
deploy/k8s holds a Kustomize base (a Deployment and Service for each of the ten
images, with the probes, settings and mounts from docs/deployment.md) and a prod
overlay that pins every image to one commit SHA and routes only the admin portal
and mobile-api's exact WhatsApp webhook path through Traefik with TLS.

Secrets never enter git: deploy/k8s/secrets.example holds placeholders, the filled
copy in deploy/k8s/secrets is ignored, and deploy/create-secrets.sh loads it
without printing a value. deploy/set-release.sh pins or rolls back the release.

deploy/check.sh (also a CI step) renders the overlay in one pinned container,
validates it with kubeconform and refuses public routes to internal services,
latest or untagged images, Secret data or literal secret env values, mixed SHAs
and a second or rolling service-counter; --release also refuses unfilled cluster
facts. --self-test proves each rule fires on its fixture.

OpenSpec change: add-k8s-deployment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 19:03:28 +08:00
ngqile a0da31f0da Merge pull request 'fix(pages): keep the section toolbar inside the section' (#66) from fix-section-toolbar-clip into main
CI / build-and-publish (push) Failing after 0s
2026-12-03 09:48:15 +00:00
ngqileandClaude Opus 5.5 e3d7b7ec4c fix(pages): keep the section toolbar inside the section so the canvas edge never clips it
The toolbar hung 20 px above the selected section, so it was cut off for the
first section and for any section scrolled to the top of the canvas. It now
sits inside the section's top-right corner, and the hero's image button moves
to the top-left so the two never overlap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 17:48:04 +08:00
ngqile be74080492 Merge pull request 'docs: archive add-page-visual-editor' (#65) from archive-page-visual-editor into main
CI / build-and-publish (push) Failing after 0s
2026-12-03 08:19:49 +00:00
ngqileandClaude Opus 5.5 c346f43f0e docs: archive add-page-visual-editor
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 16:19:40 +08:00
ngqile 7cd2972a70 Merge pull request 'feat(pages): on-page visual editor for landing pages' (#64) from add-page-visual-editor into main
CI / build-and-publish (push) Failing after 0s
2026-12-03 08:19:05 +00:00
ngqileandClaude Opus 5.5 d42e60d104 docs: add-page-visual-editor spec covers reveal, empty-field cues and Ctrl+Z focus
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 16:18:40 +08:00
ngqileandClaude Opus 5.5 7f43869444 docs: tick add-page-visual-editor live check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 16:13:10 +08:00
ngqileandClaude Opus 5.5 5c216551fa fix(pages): bring an added, copied or moved section into view on the canvas
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 16:12:59 +08:00
ngqileandClaude Opus 5.5 68159086a9 fix(pages): empty rich text on the canvas gets room and a faded cue
A new Text section was a thin line under its Add section button, with nothing
to click or read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 16:12:59 +08:00
ngqileandClaude Opus 5.5 cd3c2e1987 fix(pages): Ctrl+Z undoes when focus fell out of the editor
A toolbar button removed with its section drops focus on the canvas body, and
a button that just went disabled drops it on the page body; neither reached the
editor's key handler. Listen on both documents as a fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 15:57:53 +08:00
ngqileandClaude Opus 5.5 d977467182 docs: the on-page editor in the deployment guide
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 15:31:16 +08:00
ngqileandClaude Opus 5.5 5f2ddf90ba feat(pages): on-page editor with canvas, side panel, section tools, undo and refusals
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 15:31:03 +08:00
ngqileandClaude Opus 5.5 d31661fd3e feat(pages): selection, section actions, undo and refusal mapping in the page draft
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 15:23:38 +08:00
ngqileandClaude Opus 5.5 af1bab4afa feat(pages): edit rich text in place on the canvas; say why a link is refused
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 15:20:16 +08:00
ngqileandClaude Opus 5.5 54ceb7b631 feat(pages): page canvas and in-place editing of landing page text
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 15:15:32 +08:00
ngqileandClaude Opus 5.5 537ac65dc0 docs: tick add-page-visual-editor 1.4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 15:03:49 +08:00
ngqileandClaude Opus 5.5 ede3da1cbe feat(pages): ask before an in-app link leaves unsaved page edits
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 15:01:16 +08:00
ngqileandClaude Opus 5.5 6b3498d123 test(pages): cover the canvas frame; record its unsandboxed frame in the proposal
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 15:01:16 +08:00
ngqileandClaude Opus 5.5 7e916b77b9 refactor(pages): move the page editor's state and actions into usePageDraft
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 14:46:05 +08:00
ngqileandClaude Opus 5.5 b768b66f6f test(security): allow-list the editor canvas frame by its constant blank document
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 14:46:05 +08:00
ngqileandClaude Opus 5.5 5f4f3bc1ee feat(pages): canvas frame spike passes; Custom HTML frames listen on their own window
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 14:36:17 +08:00
ngqileandClaude Opus 5.5 55d9535ef2 docs: OpenSpec change add-page-visual-editor
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 12:20:48 +08:00
ngqile a0691188ca Merge pull request 'docs: archive add-page-drafts-and-templates' (#63) from archive-page-drafts-and-templates into main
CI / build-and-publish (push) Failing after 0s
2026-12-03 04:09:05 +00:00
142 changed files with 7307 additions and 595 deletions

No files matched your search

+7
View File
@@ -47,6 +47,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Check the Kubernetes manifests
# Proves each manifest rule still fires, then checks the prod overlay (openspec spec cluster-deployment).
# Cluster-fact placeholders are allowed here; deploy/check.sh --release refuses them before a real apply.
run: |
sh deploy/check.sh --self-test
sh deploy/check.sh
- name: Build and test the services
run: |
mvn -T 1C -B -Dmaven.repo.local=/root/.m2/repository-co-lite verify \
+3
View File
@@ -20,3 +20,6 @@ solvway-admin-portal/.impeccable/
# Build output
target/
# Filled-in Kubernetes secrets (templates: deploy/k8s/secrets.example)
deploy/k8s/secrets/
@@ -0,0 +1,35 @@
# expect: replicas must be 1
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: admin-portal}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: admin-portal}}
template:
metadata: {labels: {app: admin-portal}}
spec:
containers:
- name: admin-portal
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: service-counter}
spec:
replicas: 2
strategy: {type: Recreate}
selector: {matchLabels: {app: service-counter}}
template:
metadata: {labels: {app: service-counter}}
spec:
containers:
- name: service-counter
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
@@ -0,0 +1,18 @@
# expect: strategy must be Recreate
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: service-counter}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: service-counter}}
template:
metadata: {labels: {app: service-counter}}
spec:
containers:
- name: service-counter
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
+18
View File
@@ -0,0 +1,18 @@
# expect: not 'latest'
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: admin-portal}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: admin-portal}}
template:
metadata: {labels: {app: admin-portal}}
spec:
containers:
- name: admin-portal
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:latest
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
@@ -0,0 +1,90 @@
# expect: env JWT_SECRET holds a literal value
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: admin-portal}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: admin-portal}}
template:
metadata: {labels: {app: admin-portal}}
spec:
containers:
- name: admin-portal
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: mobile-api}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: mobile-api}}
template:
metadata: {labels: {app: mobile-api}}
spec:
containers:
- name: mobile-api
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: service-counter}
spec:
replicas: 1
strategy: {type: Recreate}
selector: {matchLabels: {app: service-counter}}
template:
metadata: {labels: {app: service-counter}}
spec:
containers:
- name: service-counter
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: admin-portal}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`)
kind: Rule
services: [{name: admin-portal, port: 3000}]
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: whatsapp-webhook}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
kind: Rule
services: [{name: mobile-api, port: 80}]
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: service-log}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: service-log}}
template:
metadata: {labels: {app: service-log}}
spec:
containers:
- name: service-log
image: gitea.containerverse.dev/solvway/co-lite-service-log:abc1234
env:
- {name: JWT_SECRET, value: x}
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
+89
View File
@@ -0,0 +1,89 @@
# expect: different tags
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: admin-portal}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: admin-portal}}
template:
metadata: {labels: {app: admin-portal}}
spec:
containers:
- name: admin-portal
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: mobile-api}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: mobile-api}}
template:
metadata: {labels: {app: mobile-api}}
spec:
containers:
- name: mobile-api
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: service-counter}
spec:
replicas: 1
strategy: {type: Recreate}
selector: {matchLabels: {app: service-counter}}
template:
metadata: {labels: {app: service-counter}}
spec:
containers:
- name: service-counter
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: admin-portal}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`)
kind: Rule
services: [{name: admin-portal, port: 3000}]
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: whatsapp-webhook}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
kind: Rule
services: [{name: mobile-api, port: 80}]
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: service-log}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: service-log}}
template:
metadata: {labels: {app: service-log}}
spec:
containers:
- name: service-log
image: gitea.containerverse.dev/solvway/co-lite-service-log:def5678
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
+77
View File
@@ -0,0 +1,77 @@
# expect: Service type NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: admin-portal}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: admin-portal}}
template:
metadata: {labels: {app: admin-portal}}
spec:
containers:
- name: admin-portal
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: mobile-api}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: mobile-api}}
template:
metadata: {labels: {app: mobile-api}}
spec:
containers:
- name: mobile-api
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: service-counter}
spec:
replicas: 1
strategy: {type: Recreate}
selector: {matchLabels: {app: service-counter}}
template:
metadata: {labels: {app: service-counter}}
spec:
containers:
- name: service-counter
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: admin-portal}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`)
kind: Rule
services: [{name: admin-portal, port: 3000}]
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: whatsapp-webhook}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
kind: Rule
services: [{name: mobile-api, port: 80}]
---
apiVersion: v1
kind: Service
metadata: {name: api-gateway}
spec: {type: NodePort, ports: [{port: 80}]}
+18
View File
@@ -0,0 +1,18 @@
# expect: not 'no tag'
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: admin-portal}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: admin-portal}}
template:
metadata: {labels: {app: admin-portal}}
spec:
containers:
- name: admin-portal
image: gitea.containerverse.dev/solvway/co-lite-admin-portal
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
@@ -0,0 +1,78 @@
# expect: still a placeholder: <mysql host>
# flags: --release
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: admin-portal}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: admin-portal}}
template:
metadata: {labels: {app: admin-portal}}
spec:
containers:
- name: admin-portal
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: mobile-api}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: mobile-api}}
template:
metadata: {labels: {app: mobile-api}}
spec:
containers:
- name: mobile-api
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: service-counter}
spec:
replicas: 1
strategy: {type: Recreate}
selector: {matchLabels: {app: service-counter}}
template:
metadata: {labels: {app: service-counter}}
spec:
containers:
- name: service-counter
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: admin-portal}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`)
kind: Rule
services: [{name: admin-portal, port: 3000}]
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: whatsapp-webhook}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
kind: Rule
services: [{name: mobile-api, port: 80}]
---
apiVersion: v1
kind: ConfigMap
metadata: {name: co-lite-settings}
data: {MYSQLHOST: <mysql host>}
@@ -0,0 +1,82 @@
# expect: reaches 'api-gateway'
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: admin-portal}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: admin-portal}}
template:
metadata: {labels: {app: admin-portal}}
spec:
containers:
- name: admin-portal
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: mobile-api}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: mobile-api}}
template:
metadata: {labels: {app: mobile-api}}
spec:
containers:
- name: mobile-api
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: service-counter}
spec:
replicas: 1
strategy: {type: Recreate}
selector: {matchLabels: {app: service-counter}}
template:
metadata: {labels: {app: service-counter}}
spec:
containers:
- name: service-counter
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: admin-portal}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`)
kind: Rule
services: [{name: admin-portal, port: 3000}]
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: whatsapp-webhook}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
kind: Rule
services: [{name: mobile-api, port: 80}]
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: gw}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`)
kind: Rule
services: [{name: api-gateway, port: 80}]
@@ -0,0 +1,82 @@
# expect: reaches 'mobile-api'
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: admin-portal}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: admin-portal}}
template:
metadata: {labels: {app: admin-portal}}
spec:
containers:
- name: admin-portal
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: mobile-api}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: mobile-api}}
template:
metadata: {labels: {app: mobile-api}}
spec:
containers:
- name: mobile-api
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: service-counter}
spec:
replicas: 1
strategy: {type: Recreate}
selector: {matchLabels: {app: service-counter}}
template:
metadata: {labels: {app: service-counter}}
spec:
containers:
- name: service-counter
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: admin-portal}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`)
kind: Rule
services: [{name: admin-portal, port: 3000}]
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: whatsapp-webhook}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
kind: Rule
services: [{name: mobile-api, port: 80}]
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: api}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`) && PathPrefix(`/api/public/whatsapp/webhook`)
kind: Rule
services: [{name: mobile-api, port: 80}]
+77
View File
@@ -0,0 +1,77 @@
# expect: Secret with data
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: admin-portal}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: admin-portal}}
template:
metadata: {labels: {app: admin-portal}}
spec:
containers:
- name: admin-portal
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: mobile-api}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: mobile-api}}
template:
metadata: {labels: {app: mobile-api}}
spec:
containers:
- name: mobile-api
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: service-counter}
spec:
replicas: 1
strategy: {type: Recreate}
selector: {matchLabels: {app: service-counter}}
template:
metadata: {labels: {app: service-counter}}
spec:
containers:
- name: service-counter
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: admin-portal}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`)
kind: Rule
services: [{name: admin-portal, port: 3000}]
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: whatsapp-webhook}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
kind: Rule
services: [{name: mobile-api, port: 80}]
---
apiVersion: v1
kind: Secret
metadata: {name: co-lite-shared}
data: {JWT_TOKEN: eA==}
+72
View File
@@ -0,0 +1,72 @@
# expect: pass
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: admin-portal}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: admin-portal}}
template:
metadata: {labels: {app: admin-portal}}
spec:
containers:
- name: admin-portal
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: mobile-api}
spec:
replicas: 1
strategy: {type: RollingUpdate}
selector: {matchLabels: {app: mobile-api}}
template:
metadata: {labels: {app: mobile-api}}
spec:
containers:
- name: mobile-api
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: service-counter}
spec:
replicas: 1
strategy: {type: Recreate}
selector: {matchLabels: {app: service-counter}}
template:
metadata: {labels: {app: service-counter}}
spec:
containers:
- name: service-counter
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: admin-portal}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`)
kind: Rule
services: [{name: admin-portal, port: 3000}]
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata: {name: whatsapp-webhook}
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
kind: Rule
services: [{name: mobile-api, port: 80}]
+47
View File
@@ -0,0 +1,47 @@
#!/bin/sh
# Checks the production manifests (openspec spec cluster-deployment): renders deploy/k8s/overlays/prod, validates it
# against the Kubernetes schemas, then applies check_rules.py (public routes, pinned images, no secret data,
# one service-counter, all ten services present). Needs only Docker. The deploy folder goes to the container through stdin, so this also works
# against a remote Docker daemon (CI's DOCKER_HOST).
# deploy/check.sh check the prod overlay
# deploy/check.sh --self-test prove every rule fires on its fixture in deploy/check-fixtures
# deploy/check.sh --release also refuse any <…> placeholder; run it before every real apply
# deploy/check.sh --render print the rendered prod manifests
set -eu
IMAGE=alpine/k8s:1.33.4@sha256:b0523f0a244ddc4c8e055aa335c040d3d78b3ead5528f4544395f7f9f69c7b68
# Traefik's IngressRoute schema comes from the CRDs catalog; Kubernetes' own from kubeconform's default location.
CRDS='https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json'
cd "$(dirname "$0")/.."
in_container() {
tar -cf - deploy | docker run --rm -i "$IMAGE" sh -c "set -e; mkdir -p /w && tar -xf - -C /w && cd /w && $1"
}
case "${1:-}" in
--render)
in_container 'kubectl kustomize deploy/k8s/overlays/prod'
;;
--self-test)
in_container '
fail=0
for f in deploy/check-fixtures/*.yaml; do
expect=$(sed -n "1s/^# expect: //p" "$f")
flags=$(sed -n "2s/^# flags: //p" "$f")
if out=$(python3 -I deploy/check_rules.py $flags < "$f"); then got=pass; else got=$out; fi
case "$got" in
*"$expect"*) echo "ok $f" ;;
*) echo "FAIL $f: expected \"$expect\", got: $got"; fail=1 ;;
esac
done
exit $fail'
;;
""|--release)
in_container "
kubectl kustomize deploy/k8s/overlays/prod > /tmp/prod.yaml
kubeconform -strict -summary -schema-location default -schema-location '$CRDS' /tmp/prod.yaml
python3 -I deploy/check_rules.py --full ${1:-} < /tmp/prod.yaml && echo 'prod manifests: rules passed'"
;;
*)
echo "usage: $0 [--release|--self-test|--render]" >&2; exit 2
;;
esac
+127
View File
@@ -0,0 +1,127 @@
"""Production manifest rules (openspec spec cluster-deployment). Reads rendered multi-document YAML on stdin,
prints one line per violation and exits 1 if there is any. Runs inside the pinned alpine/k8s image (deploy/check.sh)."""
import re
import sys
import yaml
WEBHOOK = "/api/public/whatsapp/webhook"
PUBLIC = {"admin-portal"}
SECRETISH = re.compile(r"(SECRET|TOKEN|PASSWORD|PWD|KEY|KEYS)$")
WORKLOADS = {"Deployment", "StatefulSet", "DaemonSet", "Job", "CronJob"}
# The ten images of docs/deployment.md section 1; their Service names are fixed in the gateway's and mobile-api's config.
SYSTEM = {"admin-portal", "mobile-api", "api-gateway", "service-auth", "service-system", "service-counter",
"service-member", "service-log", "service-email", "service-whatsapp"}
def name(doc):
return f"{doc.get('kind')}/{(doc.get('metadata') or {}).get('name')}"
def pod_spec(doc):
spec = doc.get("spec") or {}
if doc.get("kind") == "CronJob":
spec = ((spec.get("jobTemplate") or {}).get("spec") or {})
return ((spec.get("template") or {}).get("spec") or {})
def check_route(doc, out):
for route in (doc.get("spec") or {}).get("routes") or []:
match = route.get("match", "")
for svc in route.get("services") or []:
target = svc.get("name")
if target in PUBLIC:
continue
exact = f"Path(`{WEBHOOK}`)" in match and "PathPrefix" not in match and "||" not in match
if target == "mobile-api" and exact:
continue
out.append(f"{name(doc)}: route '{match}' reaches '{target}'; only admin-portal and mobile-api's exact {WEBHOOK} may be public")
def check_images(doc, out):
spec = pod_spec(doc)
for c in (spec.get("containers") or []) + (spec.get("initContainers") or []):
image = c.get("image", "")
if "@sha256:" in image:
continue
last = image.rsplit("/", 1)[-1]
tag = last.split(":", 1)[1] if ":" in last else ""
if tag in ("", "latest"):
out.append(f"{name(doc)}: image '{image}' must be pinned to a commit SHA, not '{tag or 'no tag'}'")
elif "co-lite-" in last and not re.fullmatch(r"[0-9a-f]{7,40}", tag):
out.append(f"{name(doc)}: image '{image}' tag must be a commit SHA")
def check_env(doc, out):
spec = pod_spec(doc)
for c in (spec.get("containers") or []) + (spec.get("initContainers") or []):
for env in c.get("env") or []:
if SECRETISH.search(env.get("name", "")) and "value" in env:
out.append(f"{name(doc)}: env {env['name']} holds a literal value; take it from a Secret")
def complete(docs):
out = []
for kind in ("Deployment", "Service"):
have = {(d.get("metadata") or {}).get("name") for d in docs if d.get("kind") == kind}
out += [f"{kind}/{n}: missing from the manifests" for n in sorted(SYSTEM - have)]
return out
def placeholders(docs):
"""Before a real apply every <…> cluster fact must be filled in (deploy/check.sh --release)."""
out = []
def walk(doc, value, path):
if isinstance(value, dict):
for k, v in value.items():
walk(doc, v, f"{path}.{k}")
elif isinstance(value, list):
for i, v in enumerate(value):
walk(doc, v, f"{path}[{i}]")
elif isinstance(value, str) and re.search(r"<[^<>]+>", value):
out.append(f"{name(doc)}: {path.lstrip('.')} is still a placeholder: {value}")
for doc in docs:
walk(doc, doc, "")
return out
def rules(docs):
out = []
shas = {}
for doc in docs:
kind = doc.get("kind")
if kind == "Secret" and (doc.get("data") or doc.get("stringData")):
out.append(f"{name(doc)}: Secret with data in the manifests; create it with deploy/create-secrets.sh")
if kind in ("Ingress", "IngressRouteTCP", "IngressRouteUDP"):
out.append(f"{name(doc)}: {kind} is not allowed; public routes are Traefik IngressRoutes")
if kind == "Service" and (doc.get("spec") or {}).get("type", "ClusterIP") != "ClusterIP":
out.append(f"{name(doc)}: Service type {doc['spec']['type']} exposes it outside the cluster")
if kind == "IngressRoute":
check_route(doc, out)
if kind in WORKLOADS:
check_images(doc, out)
check_env(doc, out)
for c in pod_spec(doc).get("containers") or []:
last = c.get("image", "").rsplit("/", 1)[-1]
if last.startswith("co-lite-") and ":" in last:
shas.setdefault(last.split(":", 1)[1].split("@")[0], []).append(name(doc))
if kind == "Deployment" and doc["metadata"]["name"] == "service-counter":
spec = doc.get("spec") or {}
if spec.get("replicas", 1) != 1:
out.append(f"{name(doc)}: replicas must be 1 (the daily follow-up summary would be sent once per replica)")
if (spec.get("strategy") or {}).get("type") != "Recreate":
out.append(f"{name(doc)}: strategy must be Recreate so a rollout never runs two copies")
if len(shas) > 1:
out.append(f"images: co-lite images use different tags {sorted(shas)}; one release is one commit SHA")
return out
if __name__ == "__main__":
docs = [d for d in yaml.safe_load_all(sys.stdin) if d]
found = rules(docs) + (complete(docs) if "--full" in sys.argv else []) \
+ (placeholders(docs) if "--release" in sys.argv else [])
for line in found:
print(line)
sys.exit(1 if found else 0)
+74
View File
@@ -0,0 +1,74 @@
#!/bin/sh
# Creates or updates Co-Lite's Kubernetes Secrets from the filled-in copy of deploy/k8s/secrets.example
# (openspec spec cluster-deployment: secrets never enter the repository). Never prints a value.
# deploy/create-secrets.sh [--dry-run] [folder] folder defaults to deploy/k8s/secrets
# --dry-run checks the folder and lists the Secrets and key names without kubectl.
# NAMESPACE (default co-lite) picks the namespace.
set -eu
cd "$(dirname "$0")/.."
dry=
[ "${1:-}" = "--dry-run" ] && { dry=1; shift; }
src=${1:-deploy/k8s/secrets}
tpl=deploy/k8s/secrets.example
ns=${NAMESPACE:-co-lite}
optional="co-lite-whatsapp.env"
fail() { echo "create-secrets: $*" >&2; exit 1; }
[ -d "$src" ] || fail "no folder $src; copy $tpl there and fill it in"
keys() { sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' "$1"; }
value_of() { sed -n "s/^$2=//p" "$1" | head -n 1; }
# Check everything before creating anything, so a half-filled folder changes nothing.
for t in "$tpl"/*.env "$tpl"/*/; do
base=$(basename "$t")
f="$src/$base"
if [ ! -e "$f" ]; then
case " $optional " in *" $base "*) continue ;; esac
fail "missing $f"
fi
if [ -d "$t" ]; then
for k in "$t"*; do
kf="$f/$(basename "$k")"
[ -s "$kf" ] || fail "missing or empty $kf"
! grep -q '<[^<>]*>' "$kf" || fail "$kf still holds a <…> placeholder"
done
else
for k in $(keys "$t"); do
v=$(value_of "$f" "$k")
[ -n "$v" ] || fail "$f: $k is missing or empty"
case "$v" in *"<"*">"*) fail "$f: $k is still a placeholder" ;; esac
done
fi
done
apply() { # name, then kubectl create arguments
name=$1; shift
kubectl create secret "$@" "$name" -n "$ns" --dry-run=client -o yaml | kubectl apply -f - >/dev/null
echo "applied Secret $name"
}
if [ -z "$dry" ]; then
# The first run comes before the first apply, which is what would otherwise create the namespace.
kubectl create namespace "$ns" --dry-run=client -o yaml | kubectl apply -f - >/dev/null
fi
for f in "$src"/*.env "$src"/*/; do
[ -e "$f" ] || continue
name=$(basename "$f" .env); name=${name%/}
[ -e "$tpl/$(basename "$f")" ] || fail "$f has no template in $tpl"
if [ "$name" = co-lite-registry ]; then
echo "Secret $name (image pull secret for gitea.containerverse.dev)"
[ -n "$dry" ] && continue
tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT
auth=$(printf '%s:%s' "$(value_of "$f" REGISTRY_USER)" "$(value_of "$f" REGISTRY_PASSWORD)" | base64 | tr -d '\n')
(umask 077; printf '{"auths":{"gitea.containerverse.dev":{"auth":"%s"}}}' "$auth" > "$tmp/config.json")
apply "$name" generic --type=kubernetes.io/dockerconfigjson --from-file=.dockerconfigjson="$tmp/config.json"
elif [ -d "$f" ]; then
echo "Secret $name: $(ls "$f" | tr '\n' ' ')"
[ -n "$dry" ] && continue
apply "$name" generic --from-file="$f"
else
echo "Secret $name: $(keys "$f" | tr '\n' ' ')"
[ -n "$dry" ] && continue
apply "$name" generic --from-env-file="$f"
fi
done
+41
View File
@@ -0,0 +1,41 @@
# The only Service routed to as a whole (overlays/prod/routes.yaml). No health endpoint: GET /login answers 200 without a session.
apiVersion: apps/v1
kind: Deployment
metadata:
name: admin-portal
spec:
replicas: 1
selector:
matchLabels: {app: admin-portal}
template:
metadata:
labels: {app: admin-portal}
spec:
imagePullSecrets:
- {name: co-lite-registry}
containers:
- name: admin-portal
image: gitea.containerverse.dev/solvway/co-lite-admin-portal
ports:
- {name: http, containerPort: 3000}
envFrom:
- {configMapRef: {name: co-lite-portal}}
- {secretRef: {name: co-lite-admin-portal}}
livenessProbe:
tcpSocket: {port: http}
periodSeconds: 20
readinessProbe:
httpGet: {path: /login, port: http}
periodSeconds: 10
resources:
requests: {cpu: 100m, memory: 256Mi}
limits: {memory: 512Mi}
---
apiVersion: v1
kind: Service
metadata:
name: admin-portal
spec:
selector: {app: admin-portal}
ports:
- {name: http, port: 3000, targetPort: http}
+51
View File
@@ -0,0 +1,51 @@
# Routes to http://service-* on port 80; needs only JWT_TOKEN and the mounted appkeys.json (docs/deployment.md 6, 7).
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-gateway
spec:
replicas: 1
selector:
matchLabels: {app: api-gateway}
template:
metadata:
labels: {app: api-gateway}
spec:
imagePullSecrets:
- {name: co-lite-registry}
containers:
- name: api-gateway
image: gitea.containerverse.dev/solvway/co-lite-api-gateway
ports:
- {name: http, containerPort: 80}
env:
- name: JWT_TOKEN
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
- name: JAVA_OPTS
valueFrom: {configMapKeyRef: {name: co-lite-settings, key: JAVA_OPTS}}
startupProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 20
readinessProbe:
httpGet: {path: /actuator/health/readiness, port: http}
periodSeconds: 10
resources:
requests: {cpu: 100m, memory: 512Mi}
limits: {memory: 1Gi}
volumeMounts:
- {name: appkeys, mountPath: /deployments/appkeys, readOnly: true}
volumes:
- {name: appkeys, secret: {secretName: co-lite-gateway-appkeys}}
---
apiVersion: v1
kind: Service
metadata:
name: api-gateway
spec:
selector: {app: api-gateway}
ports:
- {name: http, port: 80, targetPort: http}
+18
View File
@@ -0,0 +1,18 @@
# Co-Lite on Kubernetes: one Deployment and one Service per image (docs/deployment.md section 1).
# Settings and Secrets are referenced by name only; the prod overlay generates the settings and
# deploy/create-secrets.sh creates the Secrets. Images carry no tag here: the overlay pins one commit SHA.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
labels:
- pairs: {app.kubernetes.io/part-of: co-lite}
resources:
- admin-portal.yaml
- api-gateway.yaml
- mobile-api.yaml
- service-auth.yaml
- service-counter.yaml
- service-email.yaml
- service-log.yaml
- service-member.yaml
- service-system.yaml
- service-whatsapp.yaml
+53
View File
@@ -0,0 +1,53 @@
# Internal; only its WhatsApp webhook path is public (overlays/prod/routes.yaml).
apiVersion: apps/v1
kind: Deployment
metadata:
name: mobile-api
spec:
replicas: 1
selector:
matchLabels: {app: mobile-api}
template:
metadata:
labels: {app: mobile-api}
spec:
imagePullSecrets:
- {name: co-lite-registry}
containers:
- name: mobile-api
image: gitea.containerverse.dev/solvway/co-lite-mobile-api
ports:
- {name: http, containerPort: 80}
envFrom:
- {configMapRef: {name: co-lite-settings}}
- {secretRef: {name: co-lite-shared}}
- {configMapRef: {name: co-lite-gcp}}
- {secretRef: {name: co-lite-mobile-api}}
- {configMapRef: {name: co-lite-whatsapp}}
- {secretRef: {name: co-lite-whatsapp, optional: true}}
startupProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 20
readinessProbe:
httpGet: {path: /actuator/health/readiness, port: http}
periodSeconds: 10
resources:
requests: {cpu: 100m, memory: 512Mi}
limits: {memory: 1Gi}
volumeMounts:
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
volumes:
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
---
apiVersion: v1
kind: Service
metadata:
name: mobile-api
spec:
selector: {app: mobile-api}
ports:
- {name: http, port: 80, targetPort: http}
+50
View File
@@ -0,0 +1,50 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: service-auth
spec:
replicas: 1
selector:
matchLabels: {app: service-auth}
template:
metadata:
labels: {app: service-auth}
spec:
imagePullSecrets:
- {name: co-lite-registry}
containers:
- name: service-auth
image: gitea.containerverse.dev/solvway/co-lite-service-auth
ports:
- {name: http, containerPort: 80}
envFrom:
- {configMapRef: {name: co-lite-settings}}
- {secretRef: {name: co-lite-shared}}
- {configMapRef: {name: co-lite-gcp}}
- {secretRef: {name: co-lite-service-auth}}
startupProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 20
readinessProbe:
httpGet: {path: /actuator/health/readiness, port: http}
periodSeconds: 10
resources:
requests: {cpu: 100m, memory: 512Mi}
limits: {memory: 1Gi}
volumeMounts:
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
volumes:
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
---
apiVersion: v1
kind: Service
metadata:
name: service-auth
spec:
selector: {app: service-auth}
ports:
- {name: http, port: 80, targetPort: http}
+51
View File
@@ -0,0 +1,51 @@
# Exactly one replica, replaced not rolled: it sends the daily follow-up summary (deploy/check_rules.py).
apiVersion: apps/v1
kind: Deployment
metadata:
name: service-counter
spec:
replicas: 1
strategy: {type: Recreate}
selector:
matchLabels: {app: service-counter}
template:
metadata:
labels: {app: service-counter}
spec:
imagePullSecrets:
- {name: co-lite-registry}
containers:
- name: service-counter
image: gitea.containerverse.dev/solvway/co-lite-service-counter
ports:
- {name: http, containerPort: 80}
envFrom:
- {configMapRef: {name: co-lite-settings}}
- {secretRef: {name: co-lite-shared}}
- {configMapRef: {name: co-lite-gcp}}
startupProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 20
readinessProbe:
httpGet: {path: /actuator/health/readiness, port: http}
periodSeconds: 10
resources:
requests: {cpu: 100m, memory: 768Mi}
limits: {memory: 1Gi}
volumeMounts:
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
volumes:
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
---
apiVersion: v1
kind: Service
metadata:
name: service-counter
spec:
selector: {app: service-counter}
ports:
- {name: http, port: 80, targetPort: http}
+49
View File
@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: service-email
spec:
replicas: 1
selector:
matchLabels: {app: service-email}
template:
metadata:
labels: {app: service-email}
spec:
imagePullSecrets:
- {name: co-lite-registry}
containers:
- name: service-email
image: gitea.containerverse.dev/solvway/co-lite-service-email
ports:
- {name: http, containerPort: 80}
envFrom:
- {configMapRef: {name: co-lite-settings}}
- {secretRef: {name: co-lite-shared}}
- {configMapRef: {name: co-lite-gcp}}
startupProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 20
readinessProbe:
httpGet: {path: /actuator/health/readiness, port: http}
periodSeconds: 10
resources:
requests: {cpu: 100m, memory: 512Mi}
limits: {memory: 1Gi}
volumeMounts:
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
volumes:
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
---
apiVersion: v1
kind: Service
metadata:
name: service-email
spec:
selector: {app: service-email}
ports:
- {name: http, port: 80, targetPort: http}
+49
View File
@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: service-log
spec:
replicas: 1
selector:
matchLabels: {app: service-log}
template:
metadata:
labels: {app: service-log}
spec:
imagePullSecrets:
- {name: co-lite-registry}
containers:
- name: service-log
image: gitea.containerverse.dev/solvway/co-lite-service-log
ports:
- {name: http, containerPort: 80}
envFrom:
- {configMapRef: {name: co-lite-settings}}
- {secretRef: {name: co-lite-shared}}
- {configMapRef: {name: co-lite-gcp}}
startupProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 20
readinessProbe:
httpGet: {path: /actuator/health/readiness, port: http}
periodSeconds: 10
resources:
requests: {cpu: 100m, memory: 512Mi}
limits: {memory: 1Gi}
volumeMounts:
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
volumes:
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
---
apiVersion: v1
kind: Service
metadata:
name: service-log
spec:
selector: {app: service-log}
ports:
- {name: http, port: 80, targetPort: http}
+49
View File
@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: service-member
spec:
replicas: 1
selector:
matchLabels: {app: service-member}
template:
metadata:
labels: {app: service-member}
spec:
imagePullSecrets:
- {name: co-lite-registry}
containers:
- name: service-member
image: gitea.containerverse.dev/solvway/co-lite-service-member
ports:
- {name: http, containerPort: 80}
envFrom:
- {configMapRef: {name: co-lite-settings}}
- {secretRef: {name: co-lite-shared}}
- {configMapRef: {name: co-lite-gcp}}
startupProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 20
readinessProbe:
httpGet: {path: /actuator/health/readiness, port: http}
periodSeconds: 10
resources:
requests: {cpu: 100m, memory: 512Mi}
limits: {memory: 1Gi}
volumeMounts:
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
volumes:
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
---
apiVersion: v1
kind: Service
metadata:
name: service-member
spec:
selector: {app: service-member}
ports:
- {name: http, port: 80, targetPort: http}
+49
View File
@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: service-system
spec:
replicas: 1
selector:
matchLabels: {app: service-system}
template:
metadata:
labels: {app: service-system}
spec:
imagePullSecrets:
- {name: co-lite-registry}
containers:
- name: service-system
image: gitea.containerverse.dev/solvway/co-lite-service-system
ports:
- {name: http, containerPort: 80}
envFrom:
- {configMapRef: {name: co-lite-settings}}
- {secretRef: {name: co-lite-shared}}
- {configMapRef: {name: co-lite-gcp}}
startupProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 20
readinessProbe:
httpGet: {path: /actuator/health/readiness, port: http}
periodSeconds: 10
resources:
requests: {cpu: 100m, memory: 512Mi}
limits: {memory: 1Gi}
volumeMounts:
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
volumes:
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
---
apiVersion: v1
kind: Service
metadata:
name: service-system
spec:
selector: {app: service-system}
ports:
- {name: http, port: 80, targetPort: http}
+47
View File
@@ -0,0 +1,47 @@
# No Pub/Sub, Redis or key.json; reads the WhatsApp settings at startup.
apiVersion: apps/v1
kind: Deployment
metadata:
name: service-whatsapp
spec:
replicas: 1
selector:
matchLabels: {app: service-whatsapp}
template:
metadata:
labels: {app: service-whatsapp}
spec:
imagePullSecrets:
- {name: co-lite-registry}
containers:
- name: service-whatsapp
image: gitea.containerverse.dev/solvway/co-lite-service-whatsapp
ports:
- {name: http, containerPort: 80}
envFrom:
- {configMapRef: {name: co-lite-settings}}
- {secretRef: {name: co-lite-shared}}
- {configMapRef: {name: co-lite-whatsapp}}
- {secretRef: {name: co-lite-whatsapp, optional: true}}
startupProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet: {path: /actuator/health/liveness, port: http}
periodSeconds: 20
readinessProbe:
httpGet: {path: /actuator/health/readiness, port: http}
periodSeconds: 10
resources:
requests: {cpu: 100m, memory: 512Mi}
limits: {memory: 1Gi}
---
apiVersion: v1
kind: Service
metadata:
name: service-whatsapp
spec:
selector: {app: service-whatsapp}
ports:
- {name: http, port: 80, targetPort: http}
+3
View File
@@ -0,0 +1,3 @@
# Pub/Sub (docs/deployment.md section 5). The key itself is the co-lite-gcp-key Secret, mounted at /var/secrets/gcp.
GCP_PROJECT=<google cloud project id>
GCP_CREDENTIAL_FILE=file:/var/secrets/gcp/key.json
@@ -0,0 +1,43 @@
# Production: the team's cluster. Apply with `kubectl apply -k deploy/k8s/overlays/prod` after
# deploy/create-secrets.sh and deploy/check.sh --release (docs/deployment.md section 2).
# Every <…> value is a cluster fact still to be filled in; deploy/check.sh --release refuses them.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: co-lite
resources:
- namespace.yaml
- ../../base
- routes.yaml
# Plain settings (docs/deployment.md section 6). Secrets are not here: deploy/create-secrets.sh makes them.
# A changed value gets a new ConfigMap name, so the pods that read it restart on the next apply.
configMapGenerator:
- name: co-lite-settings
envs: [settings.env]
- name: co-lite-gcp
envs: [gcp.env]
- name: co-lite-whatsapp
envs: [whatsapp.env]
- name: co-lite-portal
envs: [portal.env]
# One release is one commit SHA on main; change it with deploy/set-release.sh <sha>, roll back the same way.
images:
- name: gitea.containerverse.dev/solvway/co-lite-admin-portal
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
- name: gitea.containerverse.dev/solvway/co-lite-api-gateway
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
- name: gitea.containerverse.dev/solvway/co-lite-mobile-api
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
- name: gitea.containerverse.dev/solvway/co-lite-service-auth
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
- name: gitea.containerverse.dev/solvway/co-lite-service-counter
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
- name: gitea.containerverse.dev/solvway/co-lite-service-email
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
- name: gitea.containerverse.dev/solvway/co-lite-service-log
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
- name: gitea.containerverse.dev/solvway/co-lite-service-member
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
- name: gitea.containerverse.dev/solvway/co-lite-service-system
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
- name: gitea.containerverse.dev/solvway/co-lite-service-whatsapp
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
+4
View File
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: co-lite
+1
View File
@@ -0,0 +1 @@
MOBILE_API_BASE_URL=http://mobile-api
+31
View File
@@ -0,0 +1,31 @@
# The only public entry points (openspec spec cluster-deployment; deploy/check_rules.py enforces them):
# the admin portal, and exactly mobile-api's WhatsApp webhook path. Never route api-gateway or a service-*.
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: admin-portal
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.containerverse.dev`)
kind: Rule
services:
- name: admin-portal
port: 3000
tls:
certResolver: <traefik cert resolver>
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: whatsapp-webhook
spec:
entryPoints: [websecure]
routes:
- match: Host(`co-lite.containerverse.dev`) && Path(`/api/public/whatsapp/webhook`)
kind: Rule
services:
- name: mobile-api
port: 80
tls:
certResolver: <traefik cert resolver>
+9
View File
@@ -0,0 +1,9 @@
# Read by every Java service except api-gateway (which takes only JAVA_OPTS from here).
MYSQLHOST=<mysql host from the DBA>
MYSQLPORT=3306
REDISHOST=<host of the existing Redis>
APIGATEWAYURL=http://api-gateway
ADMIN_PORTAL_BASE_URL=https://co-lite.containerverse.dev
JAVA_OPTS=-Xmx384m
# mobile-api does not switch its liveness and readiness endpoints on by itself.
MANAGEMENT_HEALTH_PROBES_ENABLED=true
+7
View File
@@ -0,0 +1,7 @@
# WhatsApp stays off until WHATSAPP_COMPANIES is set (docs/deployment.md sections 6 and 11).
# To switch it on, uncomment and fill in; the tokens and app secrets go in the co-lite-whatsapp Secret.
# WHATSAPP_COMPANIES=INS,CV
# WHATSAPP_INS_PHONE_NUMBER_ID=
# WHATSAPP_INS_WABA_ID=
# WHATSAPP_CV_PHONE_NUMBER_ID=
# WHATSAPP_CV_WABA_ID=
+11
View File
@@ -0,0 +1,11 @@
# Secret templates
Placeholders only. Copy this folder to `deploy/k8s/secrets/` (git ignores it), fill in every `<…>`, then run
`deploy/create-secrets.sh`. Never commit the filled-in copy.
- `<name>.env` becomes the Secret `<name>`, one key per line.
- `<name>/` becomes the Secret `<name>`, one key per file (the file name is the key).
- `co-lite-registry.env` becomes the image pull secret for `gitea.containerverse.dev`.
- `co-lite-whatsapp.env` is optional: leave it out of `secrets/` while WhatsApp is off.
Make each random value separately, for example with `openssl rand -base64 48`. What each value is: `docs/deployment.md` sections 6 and 7.
@@ -0,0 +1,2 @@
MOBILE_API_KEY=<the portal key from AUTH_API_KEYS, without :APP>
SESSION_SECRET=<random, at least 32 characters>
@@ -0,0 +1,10 @@
[
{
"key": "<the APIKEY value given to mobile-api>",
"name": "Co-Lite mobile-api",
"desc": "mobile-api calls to the gateway",
"type": "BO",
"allowList": ["/"],
"ipList": ["<pod CIDR of the cluster>"]
}
]
@@ -0,0 +1 @@
<the Pub/Sub service-account JSON key file, docs/deployment.md section 5>
@@ -0,0 +1,4 @@
# APIKEY: the key in appkeys.json. AUTH_API_KEYS: <key>:APP entries, comma-separated; one is the portal's MOBILE_API_KEY.
APIKEY=<random, the same as the key in co-lite-gateway-appkeys/appkeys.json>
AUTH_API_KEYS=<portal key>:APP
JWT_SECRET=<the same value as JWT_TOKEN>
@@ -0,0 +1,3 @@
# A read-only package token for gitea.containerverse.dev, so the cluster can pull the images.
REGISTRY_USER=<gitea user>
REGISTRY_PASSWORD=<read-only package token>
@@ -0,0 +1,2 @@
AES_SECRET_KEY=<random, exactly 32 characters>
USER_AUTH_API_SECRET=<random, at least 32 characters>
@@ -0,0 +1,4 @@
# Every Java service. JWT_TOKEN: HS512 key, at least 32 characters; mobile-api's JWT_SECRET must be the same value.
JWT_TOKEN=<random, at least 32 characters>
MYSQLUSER=<database user from the DBA>
MYSQLPWD=<its password>
@@ -0,0 +1,6 @@
# Optional while WhatsApp is off. One ACCESS_TOKEN and APP_SECRET per company code in WHATSAPP_COMPANIES.
WHATSAPP_VERIFY_TOKEN=<random, at least 32 characters>
WHATSAPP_INS_ACCESS_TOKEN=<permanent system user token>
WHATSAPP_INS_APP_SECRET=<meta app secret>
WHATSAPP_CV_ACCESS_TOKEN=<permanent system user token>
WHATSAPP_CV_APP_SECRET=<meta app secret>
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
# Pins every Co-Lite image in the prod overlay to one commit SHA of main (openspec spec cluster-deployment).
# Roll back by running it with the previous SHA and applying again.
# deploy/set-release.sh <40-character commit sha>
set -eu
cd "$(dirname "$0")/.."
sha=${1:-}
printf '%s' "$sha" | grep -Eq '^[0-9a-f]{40}$' || { echo "usage: $0 <40-character commit sha of main>" >&2; exit 2; }
k=deploy/k8s/overlays/prod/kustomization.yaml
sed -i -E "s/^( newTag: )\"[0-9a-f]+\"$/\1\"$sha\"/" "$k"
n=$(grep -c "^ newTag: \"$sha\"$" "$k")
[ "$n" -eq 10 ] || { echo "set-release: expected 10 images at $sha, found $n" >&2; exit 1; }
echo "prod overlay now pins all 10 images to $sha"
+84 -79
View File
@@ -1,6 +1,6 @@
# Co-Lite Deployment Handover
This is for whoever deploys Co-Lite to the Kubernetes cluster. CI builds and publishes the images. The deployer writes the manifests and rolls them out. The database package goes to the DBA.
This is for whoever deploys Co-Lite to the Kubernetes cluster. CI builds and publishes the images. The manifests are in `deploy/k8s/` (Kustomize: a `base` and a `prod` overlay); the deployer fills in the cluster facts and Secrets and applies them. The database package goes to the DBA.
Spec: `openspec/specs/release-packaging/spec.md`. Local stack for comparison: `local/README.md`.
@@ -26,7 +26,7 @@ The Service names matter:
- mobile-api and the portal find the gateway and mobile-api through `APIGATEWAYURL` and `MOBILE_API_BASE_URL`.
**Health probes:**
- **Java services:** liveness `GET /actuator/health/liveness`, readiness `GET /actuator/health/readiness`. Spring Boot turns these on by itself on Kubernetes. `GET /actuator/health` also works everywhere.
- **Java services:** liveness `GET /actuator/health/liveness`, readiness `GET /actuator/health/readiness`. mobile-api does not switch these on by itself (measured: 404 without the setting), so the prod settings set `MANAGEMENT_HEALTH_PROBES_ENABLED=true` for every Java pod. Use the liveness path for the startup probe too: `GET /actuator/health` is 503 on service-email while no mail server is set.
- **Admin portal:** it has no health endpoint. Use a TCP probe on port 3000, or `GET /login`, which returns 200 without a session.
**The Java images run as root and listen on port 80** (the base image sets no user). A cluster that enforces `runAsNonRoot` or the restricted Pod Security level must allow them.
@@ -35,17 +35,60 @@ The Service names matter:
## 2. Order of setup
Everything below runs from the repository root, on `main`, with `kubectl` pointed at the cluster. The checks need only Docker.
1. The DBA prepares MySQL (section 3).
2. Create the Pub/Sub topics and the service-account key (section 5).
3. Create the Secrets and mounted files (sections 6 and 7).
4. Deploy, in this order:
3. **Fill in the cluster facts.** Replace every `<…>` in `deploy/k8s/overlays/prod/`:
- `settings.env`: `MYSQLHOST` (from the DBA) and `REDISHOST` (the existing Redis);
- `gcp.env`: `GCP_PROJECT`;
- `routes.yaml`: the Traefik cert resolver, in both routes.
The namespace is `co-lite` (`kustomization.yaml` and `namespace.yaml`). Commit these files: they hold no secrets.
4. **Create the Secrets.** Copy `deploy/k8s/secrets.example/` to `deploy/k8s/secrets/`. Git ignores that folder, so never commit it. Fill in every `<…>` (sections 6 and 7 say what each value is). Then:
```sh
deploy/create-secrets.sh --dry-run # checks every key is filled in; prints names, never values
deploy/create-secrets.sh # creates or updates the Secrets in the co-lite namespace
```
The script creates the `co-lite` namespace if it is missing. Leave `co-lite-whatsapp.env` out until WhatsApp is connected (step 9).
5. **Pick the release.** Choose a commit on `main` whose CI run pushed the images, and pin it:
```sh
deploy/set-release.sh <40-character commit sha>
deploy/check.sh --release # refuses any <…> left, a public route to an internal service, latest, or a second service-counter
```
6. **Apply:**
```sh
kubectl apply -k deploy/k8s/overlays/prod
kubectl -n co-lite rollout status deploy --timeout=10m
```
All ten Deployments start together; each Java pod gets up to 5 minutes to start. Starting them together has not been tried on the cluster yet. If a pod keeps restarting, apply in the old order instead and wait for each step to be ready:
1. `service-system`, `service-auth`, `service-counter`, `service-member`, `service-log`, `service-email`, `service-whatsapp`;
2. `api-gateway`;
3. `mobile-api`;
4. `admin-portal`.
5. Add the Traefik routes (section 8).
6. Connect WhatsApp in Meta (section 11). This can wait: until it is done, the inbox says "WhatsApp is not configured".
7. Sign in as the first admin at `https://co-lite.containerverse.dev` and set the real password. Then create the staff users under Users. The admin types each user's first password and passes it on in person. Each user must choose their own password at first sign-in. No email is needed.
Use `kubectl -n co-lite rollout restart deploy/<name>` once the services it calls are ready.
7. Commit the overlay with the new SHA, so `main` records what runs.
8. Check the Custom HTML frame header (section 8).
9. Connect WhatsApp in Meta (section 11) whenever you are ready. Until then the inbox says "WhatsApp is not configured". To switch it on: fill in `whatsapp.env` in the overlay and `co-lite-whatsapp.env` in `secrets/`, then run `create-secrets.sh` and apply again.
10. Sign in as the first admin at `https://co-lite.containerverse.dev` and set the real password. Then create the staff users under Users. The admin types each user's first password and passes it on in person. Each user must choose their own password at first sign-in. No email is needed.
**Rollback.** Run `deploy/set-release.sh <the previous sha>`, then `deploy/check.sh --release`, then apply again and wait for the rollout. The SHA history of `deploy/k8s/overlays/prod/kustomization.yaml` on `main` lists the releases. Database changes only go forward: roll back only to a SHA that works with the schema now in place. Each change's SQL in section 3 says whether older code still runs on it.
**Changing a setting.** Edit the `.env` file in the overlay and apply again. The settings ConfigMaps get a new name for each new content, so the pods that read them restart by themselves. **Changing a secret:** edit `deploy/k8s/secrets/`, run `create-secrets.sh`, then `kubectl -n co-lite rollout restart deploy/<name>` for the pods that read it. mobile-api needs no restart for the WhatsApp secrets (section 6).
**Left unset on purpose.** These settings keep their built-in defaults:
- the email provider keys (section 10);
- `SMSS360_EMAIL` and `CUSTOMER_PORTAL_BASE_URL`, which still point at Tastefully (section 10);
- `JUMIO_TOKEN` and `JUMIO_SECRET`;
- `XXL_JOB_TOKEN`.
**Cluster facts still to confirm before the first apply:**
- the Traefik cert resolver name;
- the Redis host and the MySQL host;
- the Pub/Sub project;
- whether the pull secret can be `co-lite-registry`, or the cluster already has one;
- whether the separate public-pages hostname (section 8) is wanted at go-live (it would be a third route in `routes.yaml`).
## 3. Database (for the DBA)
@@ -309,6 +352,8 @@ Generate each random value separately, for example with `openssl rand -base64 48
## 8. Traefik
The routes below are in `deploy/k8s/overlays/prod/routes.yaml`; `deploy/check.sh` fails if a route reaches anything else.
Route `co-lite.containerverse.dev` to the `admin-portal` Service on port 3000, with TLS. Only the admin portal is public: the browser talks to the portal, and the portal talks to `mobile-api` inside the cluster. Do not expose `mobile-api`, `api-gateway` or the services.
**WhatsApp webhook.** Meta must reach exactly one mobile-api path from the internet. Add a second route on the same host, for the path `/api/public/whatsapp/webhook` only (Traefik rule `Host(\`co-lite.containerverse.dev\`) && Path(\`/api/public/whatsapp/webhook\`)`), to the `mobile-api` Service on port 80. Expose no other mobile-api path. Every call on it is checked: a GET needs the verify token, and a POST needs Meta's signature under one of the configured app secrets (mobile-api checks it, and `service-whatsapp` checks it again).
@@ -323,76 +368,20 @@ QR registration pages (`/r/<code>`) are served by the admin portal on the same h
## 9. Secret templates
There is no template yet for `service-email` (its keys wait for the email provider) or `service-system` (its Jumio keys stay unset). Kubernetes Secrets hold base64 values. Encode each one with `printf '%s' 'value' | base64 -w0`. These are templates: replace every `<…>` and never commit the filled-in files.
The templates are in `deploy/k8s/secrets.example/`, one file per Secret, with placeholders only:
```yaml
apiVersion: v1
kind: Secret
metadata:
name: co-lite-shared
type: Opaque
data:
JWT_TOKEN: <base64>
MYSQLUSER: <base64>
MYSQLPWD: <base64>
---
apiVersion: v1
kind: Secret
metadata:
name: co-lite-service-auth
type: Opaque
data:
AES_SECRET_KEY: <base64>
USER_AUTH_API_SECRET: <base64>
---
apiVersion: v1
kind: Secret
metadata:
name: co-lite-mobile-api
type: Opaque
data:
APIKEY: <base64>
AUTH_API_KEYS: <base64>
JWT_SECRET: <base64, same value as JWT_TOKEN>
---
apiVersion: v1
kind: Secret
metadata:
name: co-lite-admin-portal
type: Opaque
data:
MOBILE_API_KEY: <base64>
SESSION_SECRET: <base64>
---
apiVersion: v1
kind: Secret
metadata:
name: co-lite-whatsapp
type: Opaque
data:
# mounted into both mobile-api and service-whatsapp; one ACCESS_TOKEN and APP_SECRET pair per company code
WHATSAPP_INS_ACCESS_TOKEN: <base64>
WHATSAPP_INS_APP_SECRET: <base64>
WHATSAPP_CV_ACCESS_TOKEN: <base64>
WHATSAPP_CV_APP_SECRET: <base64>
WHATSAPP_VERIFY_TOKEN: <base64>
---
apiVersion: v1
kind: Secret
metadata:
name: co-lite-gateway-appkeys
type: Opaque
data:
appkeys.json: <base64 of the whole appkeys.json file>
---
apiVersion: v1
kind: Secret
metadata:
name: co-lite-gcp-key
type: Opaque
data:
key.json: <base64 of the service-account JSON key>
```
| Template | Secret | Read by |
|---|---|---|
| `co-lite-shared.env` | `co-lite-shared`: `JWT_TOKEN`, `MYSQLUSER`, `MYSQLPWD` | every Java service (api-gateway only `JWT_TOKEN`) |
| `co-lite-service-auth.env` | `co-lite-service-auth` | service-auth |
| `co-lite-mobile-api.env` | `co-lite-mobile-api` | mobile-api |
| `co-lite-admin-portal.env` | `co-lite-admin-portal` | admin-portal |
| `co-lite-whatsapp.env` | `co-lite-whatsapp` (optional) | mobile-api and service-whatsapp |
| `co-lite-registry.env` | `co-lite-registry`, the image pull secret | every pod |
| `co-lite-gateway-appkeys/appkeys.json` | `co-lite-gateway-appkeys` | api-gateway (section 7) |
| `co-lite-gcp-key/key.json` | `co-lite-gcp-key` | every Java service except api-gateway and service-whatsapp |
`deploy/create-secrets.sh` turns the filled-in copy into Secrets (section 2, step 4). It refuses to change anything while any key is missing, empty or still a placeholder. There is still no template for `service-email` (its keys wait for the email provider) or `service-system` (its Jumio keys stay unset).
## 10. Known gaps at go-live
@@ -409,7 +398,7 @@ data:
- **Reference data from Tastefully.** It still holds some Tastefully business text (message templates with a phone number, bank account and form links; a public image bucket URL; Tastefully usernames in audit columns). Review it before go-live.
- **Other Tastefully defaults.** The sender addresses in `service-email` and the `CUSTOMER_PORTAL_BASE_URL` fallback point at Tastefully. Override them as described in section 6.
- **Leaked SMS key.** An SMS360 API key from Tastefully was in `service-email`'s config and is in git history. It has been removed from the config, but it must be rotated with SMS360 before go-live, by whoever owns that Tastefully account.
- **Deploy by SHA, not `latest`.** CI pushes the images one by one, so if a push fails halfway, `latest` can differ between images.
- **Deploy by SHA, not `latest`.** CI pushes the images one by one, so if a push fails halfway, `latest` can differ between images. `deploy/check.sh` refuses `latest`.
- **Chinese labels.** Staff switch the back office to 简体中文 with the language switcher, including on the sign-in page. The Chinese is a first pass, not checked by a native speaker. Grant `BO_MESSAGES` to the reviewer's role: under **Translations**, the **Missing Chinese** filter lists labels with no Chinese or with English copied in, and a saved change shows on the next page load. The list also holds about 3,400 labels inherited from Tastefully that Co-Lite never shows; the **Co-Lite labels only** box, ticked by default, hides them, and unticking it lists every label. Export and Import move all labels through a JSON file for review offline; import matches labels by code and never adds or removes languages. Grant `BO_LOCALES` only to whoever decides which languages staff can pick: English cannot be switched off. Only the back office is translated; visitor pages and emails keep their own wording.
- **Gateway paths for labels.** The gateway used to let every `/message/` path through without a user token. It now lets through only the label reads (`/message/catalogVersion`, `/message/getAllMessages/<area>`, `/message/getMessageJsonByAreaAndLocale/<area>/<locale>`, `/message/getMessageJsonForMobile/...`, the code lookups) and `GET /locale/findAllEnabled`. Saving, searching and the language writes need the user token mobile-api forwards. The gateway also gains a `/locale/**` route to services-system.
- **WhatsApp roles.** Staff need `BO_WHATSAPP` to see the inbox and their own chats. A WhatsApp admin needs both `BO_WHATSAPP` and `BO_WHATSAPP_ADMIN`: the menu entry and the page need the first, and the second adds every chat of the company, owner changes and template sync. A chat's owner is set automatically to the salesperson of the newest lead with that mobile number; an admin can set an owner by hand, which sticks until "Automatic" is chosen again. A user who is disabled or loses `BO_WHATSAPP` loses their chats to Unassigned.
@@ -422,7 +411,7 @@ data:
- A send that Meta accepts without a message id is stored as failed. A send that never gets an answer stays "Sending"; nothing sweeps it.
- Media is streamed with `;charset=UTF-8` added to its content type; browsers ignore it.
- Meta's media download address is not checked to be a Meta host before the access token is sent with it.
- **WhatsApp webhook and outages.** If `service-whatsapp` is down or answers with an error, the webhook answers 503 and Meta sends the event again, for up to 7 days; a message is never stored twice. The same happens right after `service-whatsapp` starts while `service-system` is unreachable. Keep `service-system` up before `service-whatsapp` (section 2).
- **WhatsApp webhook and outages.** If `service-whatsapp` is down or answers with an error, the webhook answers 503 and Meta sends the event again, for up to 7 days; a message is never stored twice. The same happens right after `service-whatsapp` starts while `service-system` is unreachable. So on the first apply, check that `service-system` is ready before Meta starts sending (section 2, step 6).
- **Client addresses for rate limits.** mobile-api takes a caller's address for its rate limits from the first entry of `X-Forwarded-For` when the header is present (`HttpReqRespUtils` in core-libs). On the webhook route, a caller can set that header itself and so pick its own limit bucket. The webhook still rejects anything Meta did not sign, so this only weakens the flood limit (6000 calls per 10 minutes per address). Check that Traefik replaces an `X-Forwarded-For` sent by an untrusted caller instead of passing it on (`forwardedHeaders.insecure` off, `trustedIPs` limited to real proxies).
- **Landing pages.**
@@ -465,10 +454,26 @@ Marketing builds public pages under **Events → Pages**. Each page has blocks (
- **Jump to the form.** To make a button jump to the sign-up form, give the form block a link name, for example `signup`, and link the button to `#signup`. Links inside a Custom HTML block work the same way: on the INS page, change the HTML's `#consult` links to `#signup`. A `#name` link inside the HTML that matches an `id` in that same HTML (such as `#top`) scrolls to that spot instead.
5. **Drafts of published pages.** Once a page is published, Save keeps the changes as a draft: visitors still see the published version, and the editor shows **Publish changes** and **Discard changes**. Preview shows the draft. The pages list marks such pages "Unpublished changes". Publish changes checks the page again (an ended event, for example, is refused at its field). Switching the status back to Draft and saving takes the page offline and drops the separate draft. Two people saving the same page overwrite each other's draft, last save wins.
6. **Templates and Duplicate.** New page offers a blank page, **Event sign-up** and **Service showcase**. A template fills the editor with sections and placeholder text; staff replace the text and choose the form's event before saving. **Duplicate** (on the list and in the editor) opens a copy titled "… (copy)" with slug "…-copy" as a new draft; nothing is stored until Save.
7. **Check.** Publish a page, open its address signed out, sign up through its form with `?utm_source=test` on the address, and check that the event lead shows source **Web page**, the page address and the campaign. Delete that test lead afterwards.
7. **The on-page editor.** On a screen 1024 px or wider, the editor shows the page itself on a canvas, as visitors see it, with **Desktop** (a 1280 px screen scaled to fit) and **Phone** (390 px). Staff click a heading, text, button label, card or FAQ entry and type; rich text gets a small toolbar; clicking an image opens the file picker. Clicking a section selects it: its settings (look, link name, button link, event) show in the side panel, and its toolbar moves, duplicates, deletes or drags it. **Add section** sits under each section. Undo and redo (Ctrl+Z, Ctrl+Shift+Z) go back up to 50 steps and survive Save. A refused save selects the section and shows the message at its field in the panel. Narrower windows keep the form editor; resizing switches between them without losing unsaved edits. Leaving with unsaved edits, by a menu link too, asks first.
8. **Custom HTML on the canvas.** The canvas shows a Custom HTML block as last saved, marked **Save to update** while its HTML has unsaved edits; it shows the new HTML after Save. Preview always shows the saved version.
9. **Check.** Publish a page, open its address signed out, sign up through its form with `?utm_source=test` on the address, and check that the event lead shows source **Web page**, the page address and the campaign. Delete that test lead afterwards.
A form stops taking sign-ups when its event is disabled, its end date has passed (Malaysia time), or the company has no privacy notice; the page then says sign-up is closed and still shows its other blocks. Sign-ups share the QR pages' rate limits.
**Release add-page-drafts-and-templates (SQL, in its OpenSpec change folder):** run `sql/01-page-draft.sql` (adds `cms_page.draft`) before the new services-counter starts, then deploy services-counter, mobile-api and the portal, then run `sql/02-draft-template-labels.sql`. Rollback: previous images, then `sql/99-rollback.sql`, which drops every unpublished draft, so publish or note them first.
**Release add-page-visual-editor (SQL, in its OpenSpec change folder):** portal only. Deploy the portal, then run `sql/01-visual-editor-labels.sql`. Rollback: the previous portal image, then `sql/99-rollback.sql` (labels only). No data changes.
**Release add-hero-signup-form (SQL, in its OpenSpec change folder):** deploy services-counter, mobile-api and the portal (any order), then run `sql/01-hero-form-labels.sql` (labels only). A hero section can now carry the sign-up form for an event, beside its text. Rollback: the previous images. A hero saved with an event keeps it in its JSON. The old code ignores it and shows the hero without a form, so add a Sign-up form section to those pages if you roll back.
**Release add-hero-full-width (SQL, in its OpenSpec change folder):** deploy services-counter, then the portal, then run `sql/01-hero-full-width-labels.sql` (labels only). Deploy services-counter first, because the portal's editor saves the new hero fields. A hero can now run full width, carry bullet points, and give its form card a heading. Custom HTML frames now shrink to fit short content and no longer leave a gap next to a full-width hero. Rollback: the previous images. Saved heroes keep the new fields in their JSON; the old code ignores them and shows the boxed hero. The old services-counter refuses to save a hero that has points or a form heading, so remove them before saving such a page.
**Release add-html-image-upload (SQL, in its OpenSpec change folder):** deploy the portal, then run `sql/01-html-image-labels.sql` (labels only). A Custom HTML block's panel can now upload an image and show its link to copy. Rollback: the previous portal image.
**Release add-compact-landing-form (SQL, in its OpenSpec change folder):** deploy the portal, then run `sql/01-compact-form-labels.sql` (labels only). Landing-page sign-up forms drop job title, ask for one service in a dropdown, and fold the privacy notice behind one line. Coloured sections now join with no gap. QR, invitation and customer forms are unchanged. Before go-live, the PDPA owner should confirm the folded notice. Rollback: the previous portal image.
**Release add-landing-thanks-and-footer (SQL, in its OpenSpec change folder):** deploy services-counter and the portal together, then run `sql/01-thanks-footer-labels.sql` (labels only). Landing pages gain a Footer section (1 to 4 columns, a legal line, contact links) and a thank-you text on the Form block and on a hero with a form. Full-width heroes get a lighter shade. Deploy the counter first: an older counter refuses pages that use the new fields. Rollback: the previous images; pages saved with a Footer or thank-you text then fail to save until the release is back.
**Release add-landing-page-polish (SQL, in its OpenSpec change folder):** deploy services-counter first, then the portal, then run `sql/01-polish-labels.sql` (labels only). Landing pages gain a Top bar section (the company logo and an optional button, kept at the top of the window, first section only) and an optional small label above the headings of Feature cards, Steps, Image with text, FAQ and Call to action. Section headings on every landing page, CV included, now use the serif typeface. Rollback: the previous images; pages saved with a top bar or labels then fail to save until the release is back.
**New portal dependencies:** `@tiptap/react`, `@tiptap/pm`, `@tiptap/starter-kit` and `@tiptap/extension-text-align` (the editor, loaded only on the editor screens), and `sanitize-html` (cleans page text on the server before it reaches a visitor). The image build installs them from `package-lock.json`; nothing to do by hand.
+72
View File
@@ -1117,6 +1117,12 @@ INSERT INTO message (code, content, area) SELECT 'RegCompany', JSON_OBJECT('en_U
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '公司') WHERE LOWER(code) = LOWER('RegCompany') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegJobTitle', JSON_OBJECT('en_US', 'Job title', 'zh_CN', '职位'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegJobTitle') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '职位') WHERE LOWER(code) = LOWER('RegJobTitle') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegServiceInterest', JSON_OBJECT('en_US', 'Service interested in (optional)', 'zh_CN', '感兴趣的服务(可选)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegServiceInterest') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '感兴趣的服务(可选)') WHERE LOWER(code) = LOWER('RegServiceInterest') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegChooseService', JSON_OBJECT('en_US', 'Choose a service', 'zh_CN', '选择服务'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegChooseService') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '选择服务') WHERE LOWER(code) = LOWER('RegChooseService') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegNoticeSummary', JSON_OBJECT('en_US', 'How we use your details (English / Bahasa Malaysia)', 'zh_CN', '我们如何使用您的资料(English / Bahasa Malaysia)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegNoticeSummary') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '我们如何使用您的资料(English / Bahasa Malaysia)') WHERE LOWER(code) = LOWER('RegNoticeSummary') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegInterests', JSON_OBJECT('en_US', 'Interests (optional)', 'zh_CN', '兴趣(可选)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegInterests') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '兴趣(可选)') WHERE LOWER(code) = LOWER('RegInterests') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegNoticeEn', JSON_OBJECT('en_US', 'English', 'zh_CN', '英文'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegNoticeEn') AND area = 'A');
@@ -1491,6 +1497,36 @@ INSERT INTO message (code, content, area) SELECT 'PagesDiscardTitle', JSON_OBJEC
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '放弃未发布的修改?') WHERE LOWER(code) = LOWER('PagesDiscardTitle') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesDiscardMessage', JSON_OBJECT('en_US', 'Your unpublished changes to "{title}" will be lost. Visitors keep seeing the published version.', 'zh_CN', '“{title}”未发布的修改将会丢失。访客仍看到已发布的版本。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesDiscardMessage') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '“{title}”未发布的修改将会丢失。访客仍看到已发布的版本。') WHERE LOWER(code) = LOWER('PagesDiscardMessage') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesLeaveTitle', JSON_OBJECT('en_US', 'Leave without saving?', 'zh_CN', '不保存就离开?'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesLeaveTitle') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '不保存就离开?') WHERE LOWER(code) = LOWER('PagesLeaveTitle') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesLeaveMessage', JSON_OBJECT('en_US', 'Your changes to this page are not saved. Leave and lose them?', 'zh_CN', '此页面的修改尚未保存。离开将丢失这些修改,确定离开吗?'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesLeaveMessage') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '此页面的修改尚未保存。离开将丢失这些修改,确定离开吗?') WHERE LOWER(code) = LOWER('PagesLeaveMessage') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesLeave', JSON_OBJECT('en_US', 'Leave', 'zh_CN', '离开'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesLeave') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '离开') WHERE LOWER(code) = LOWER('PagesLeave') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesSaveToUpdate', JSON_OBJECT('en_US', 'Save to update', 'zh_CN', '保存后更新'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesSaveToUpdate') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '保存后更新') WHERE LOWER(code) = LOWER('PagesSaveToUpdate') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesAddSection', JSON_OBJECT('en_US', 'Add section', 'zh_CN', '添加区块'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddSection') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加区块') WHERE LOWER(code) = LOWER('PagesAddSection') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesDragSection', JSON_OBJECT('en_US', 'Drag to move', 'zh_CN', '拖动以移动'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesDragSection') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '拖动以移动') WHERE LOWER(code) = LOWER('PagesDragSection') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesDuplicateSection', JSON_OBJECT('en_US', 'Duplicate section', 'zh_CN', '复制区块'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesDuplicateSection') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '复制区块') WHERE LOWER(code) = LOWER('PagesDuplicateSection') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesPageSettings', JSON_OBJECT('en_US', 'Page settings', 'zh_CN', '页面设置'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesPageSettings') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '页面设置') WHERE LOWER(code) = LOWER('PagesPageSettings') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesCanvas', JSON_OBJECT('en_US', 'Page canvas', 'zh_CN', '页面画布'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesCanvas') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '页面画布') WHERE LOWER(code) = LOWER('PagesCanvas') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesCanvasView', JSON_OBJECT('en_US', 'Canvas view', 'zh_CN', '画布视图'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesCanvasView') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '画布视图') WHERE LOWER(code) = LOWER('PagesCanvasView') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesDesktop', JSON_OBJECT('en_US', 'Desktop', 'zh_CN', '桌面'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesDesktop') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '桌面') WHERE LOWER(code) = LOWER('PagesDesktop') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesPhone', JSON_OBJECT('en_US', 'Phone', 'zh_CN', '手机'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesPhone') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '手机') WHERE LOWER(code) = LOWER('PagesPhone') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesUndo', JSON_OBJECT('en_US', 'Undo', 'zh_CN', '撤销'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUndo') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '撤销') WHERE LOWER(code) = LOWER('PagesUndo') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesRedo', JSON_OBJECT('en_US', 'Redo', 'zh_CN', '重做'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesRedo') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '重做') WHERE LOWER(code) = LOWER('PagesRedo') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesUntitled', JSON_OBJECT('en_US', 'Untitled page', 'zh_CN', '未命名页面'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUntitled') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '未命名页面') WHERE LOWER(code) = LOWER('PagesUntitled') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesChangesPublished', JSON_OBJECT('en_US', 'Changes published.', 'zh_CN', '修改已发布。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesChangesPublished') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '修改已发布。') WHERE LOWER(code) = LOWER('PagesChangesPublished') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesChangesDiscarded', JSON_OBJECT('en_US', 'Changes discarded.', 'zh_CN', '修改已放弃。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesChangesDiscarded') AND area = 'A');
@@ -1683,6 +1719,40 @@ INSERT INTO message (code, content, area) SELECT 'PagesFormClosed', JSON_OBJECT(
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '报名已截止。') WHERE LOWER(code) = LOWER('PagesFormClosed') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFormPreview', JSON_OBJECT('en_US', 'The sign-up form shows here on the published page.', 'zh_CN', '发布后的网页会在此显示报名表。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormPreview') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '发布后的网页会在此显示报名表。') WHERE LOWER(code) = LOWER('PagesFormPreview') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesHeroForm', JSON_OBJECT('en_US', 'Sign-up form', 'zh_CN', '报名表单'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesHeroForm') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '报名表单') WHERE LOWER(code) = LOWER('PagesHeroForm') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesNoForm', JSON_OBJECT('en_US', 'No form', 'zh_CN', '不显示表单'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesNoForm') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '不显示表单') WHERE LOWER(code) = LOWER('PagesNoForm') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFullWidth', JSON_OBJECT('en_US', 'Full width', 'zh_CN', '全宽'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFullWidth') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '全宽') WHERE LOWER(code) = LOWER('PagesFullWidth') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesPointN', JSON_OBJECT('en_US', 'Point {number}', 'zh_CN', '要点 {number}'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesPointN') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '要点 {number}') WHERE LOWER(code) = LOWER('PagesPointN') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesAddPoint', JSON_OBJECT('en_US', 'Add point', 'zh_CN', '添加要点'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddPoint') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加要点') WHERE LOWER(code) = LOWER('PagesAddPoint') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFormHeading', JSON_OBJECT('en_US', 'Form heading', 'zh_CN', '表单标题'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单标题') WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFormText', JSON_OBJECT('en_US', 'Form text', 'zh_CN', '表单说明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单说明') WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesThanksText', JSON_OBJECT('en_US', 'Thank-you text', 'zh_CN', '感谢语'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesThanksText') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '感谢语') WHERE LOWER(code) = LOWER('PagesThanksText') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesBlockFooter', JSON_OBJECT('en_US', 'Footer', 'zh_CN', '页脚'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesBlockFooter') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '页脚') WHERE LOWER(code) = LOWER('PagesBlockFooter') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesColumnN', JSON_OBJECT('en_US', 'Column {number}', 'zh_CN', '第 {number} 栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesColumnN') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '第 {number} 栏') WHERE LOWER(code) = LOWER('PagesColumnN') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesAddColumn', JSON_OBJECT('en_US', 'Add column', 'zh_CN', '添加栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddColumn') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加栏') WHERE LOWER(code) = LOWER('PagesAddColumn') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFooterLegal', JSON_OBJECT('en_US', 'Legal line', 'zh_CN', '版权声明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFooterLegal') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '版权声明') WHERE LOWER(code) = LOWER('PagesFooterLegal') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesBlockTopBar', JSON_OBJECT('en_US', 'Top bar', 'zh_CN', '顶栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesBlockTopBar') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '顶栏') WHERE LOWER(code) = LOWER('PagesBlockTopBar') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesEyebrow', JSON_OBJECT('en_US', 'Label', 'zh_CN', '小标签'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesEyebrow') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '小标签') WHERE LOWER(code) = LOWER('PagesEyebrow') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesTopBarFirst', JSON_OBJECT('en_US', 'The top bar must be the first section.', 'zh_CN', '顶栏必须是第一个区块。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesTopBarFirst') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '顶栏必须是第一个区块。') WHERE LOWER(code) = LOWER('PagesTopBarFirst') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesUploadImage', JSON_OBJECT('en_US', 'Upload image', 'zh_CN', '上传图片'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '上传图片') WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesUploadImageHint', JSON_OBJECT('en_US', 'PNG, JPEG or WebP up to 2 MB. Paste the link into your HTML, for example in an img tag''s src.', 'zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。') WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesToolbar', JSON_OBJECT('en_US', 'Formatting', 'zh_CN', '格式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesToolbar') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '格式') WHERE LOWER(code) = LOWER('PagesToolbar') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesTextStyle', JSON_OBJECT('en_US', 'Text style', 'zh_CN', '文字样式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesTextStyle') AND area = 'A');
@@ -1717,6 +1787,8 @@ INSERT INTO message (code, content, area) SELECT 'PagesLink', JSON_OBJECT('en_US
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '链接') WHERE LOWER(code) = LOWER('PagesLink') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesLinkPrompt', JSON_OBJECT('en_US', 'Link address (https://, mailto:, tel:, / or #name)', 'zh_CN', '链接地址(https://、mailto:、tel:、/ 或 #名称)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesLinkPrompt') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '链接地址(https://、mailto:、tel:、/ 或 #名称)') WHERE LOWER(code) = LOWER('PagesLinkPrompt') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesLinkRefused', JSON_OBJECT('en_US', 'That link is not allowed. Use https://, mailto:, tel:, a path starting with / or #name.', 'zh_CN', '不允许此链接。请使用 https://、mailto:、tel:、以 / 开头的路径或 #名称。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesLinkRefused') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '不允许此链接。请使用 https://、mailto:、tel:、以 / 开头的路径或 #名称。') WHERE LOWER(code) = LOWER('PagesLinkRefused') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesClearFormatting', JSON_OBJECT('en_US', 'Clear formatting', 'zh_CN', '清除格式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesClearFormatting') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '清除格式') WHERE LOWER(code) = LOWER('PagesClearFormatting') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesTooManyBlocks', JSON_OBJECT('en_US', 'A page can have at most 30 blocks.', 'zh_CN', '每个网页最多 30 个区块。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesTooManyBlocks') AND area = 'A');
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-04
@@ -0,0 +1,22 @@
# Design
## Context
Measured at 1920×1080 on the INS page: top bar 69 px, hero 886 px (set by the form card), trust strip about 122 px, 1077 px in all. The hero grid has `pt-16 pb-12`. Bands get `py-12`. The compact form uses `space-y-4`, and its consent box holds two lines of normal-size text (English and Malay).
## Approaches
1. **Trim spacing (chosen).** Trust band padding, hero padding and the compact form's gaps. It is about 150 px in all, with no field taken away and no setting added.
2. **Side-by-side fields** (Mobile and Email on one row on wide screens). That saves about 80 px more, but the fields get narrower, and the hint and errors under Mobile get harder to lay out. It is kept in reserve.
3. **A form-size setting for staff.** This adds UI for something the page should simply get right.
## Decisions
- The trust band padding is `py-5` only for TRUST. Other bands keep `py-12`.
- The full-width hero grid is `pt-8 pb-8`. The editor's image button still fits in the corner, because it is positioned on the section, not in the padding.
- In the compact form: `space-y-3` between fields, the consent box text is `text-sm`, and the form card's gap is `space-y-3`. The 44 px control heights stay, for touch targets.
- The check is a Playwright measurement at 1920×1080: the bottom of the trust strip at or below 950 px from the top. There is no unit test for pixel heights (jsdom has no layout). Render tests pin the classes instead.
## Risks
- **A tighter consent box is still the consent.** Its text, its checkbox and its required state do not change; only the font size does. `text-sm` (14 px) stays readable.
@@ -0,0 +1,33 @@
# Proposal
## Why
On the INS Hotel technology page (`/p/INS/hotel-technology`), the top bar, the full-width hero with its sign-up form, and the trust strip together are 1077 px tall. A visitor on a 1080p or 1440p desktop sees the trust strip cut off at the bottom of the first screen. The owner wants the hero and the trust strip to fit on one desktop screen. Staff have no way to change the form's size, and the form sets the hero's height.
## What Changes
- **Thinner trust strip.** A trust strip shown as a coloured band uses less padding above and below (about 20 px instead of 48 px), close to INS's 22 px.
- **Less padding in the full-width hero.** It is about 32 px top and bottom, instead of 64 px top and 48 px bottom.
- **Tighter compact form.** The landing-page form (the compact form) has smaller gaps between fields, and the consent box uses small text. The fields, the dropdown and the button keep their 44 px height, so they stay easy to tap.
- **Result.** The INS page's top bar, hero and trust strip fit within 950 px, which shows them in full on a 1920×1080 desktop browser.
Not changing:
- QR, invitation and customer forms.
- Heroes that are not full width, and other band looks.
- Phones, where the hero stacks the form below the text.
- Small laptops (768 px tall). There the form alone is taller than the screen, as on INS's own page.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`: adds "First Screen Fits The Hero And Trust Strip".
## Impact
- Portal only: `CmsBlocks.tsx` (trust band padding, full-width hero padding, form card gap) and `RegistrationForm.tsx` (compact spacing and consent text).
- No server, API or data change. No new labels.
@@ -0,0 +1,16 @@
## ADDED Requirements
### Requirement: First Screen Fits The Hero And Trust Strip
A page with a top bar, a full-width hero with its sign-up form, and a trust strip SHALL show all three in full within the first 950 px of a desktop browser window. To fit, the trust strip band SHALL use less padding than other bands, and the landing-page form SHALL keep its fields, dropdown and button at least 44 px tall.
#### Scenario: INS page on a 1080p desktop
- **GIVEN** page `/p/INS/hotel-technology` with a top bar, a full-width hero with a form, and a trust strip
- **WHEN** a visitor opens it in a 1920×1080 browser window
- **THEN** the bottom of the trust strip is within 950 px of the top of the page
#### Scenario: Form controls stay easy to tap
- **WHEN** a visitor opens a landing page with a sign-up form
- **THEN** each text field, the service dropdown and the Register button are at least 44 px tall
@@ -0,0 +1,26 @@
# Tasks
## 1. Portal
- [x] 1.1 `CmsBlocks.tsx`:
- a TRUST band uses `py-5`; other bands keep `py-12`;
- the full-width hero grid uses `pt-8 pb-8`;
- the hero form card uses `space-y-3`.
`RegistrationForm.tsx`, compact only: `space-y-3` between fields, and `text-sm` in the consent box.
Verify: render tests fail first, then pass; vitest exit 0, tsc and lint clean.
## 2. Verification
- [x] 2.1 Use Playwright on port 3001 to measure `/p/INS/hotel-technology` at 1920×1080: the trust strip's bottom is at most 950 px, and the controls are at least 44 px tall. Take screenshots at 1920×1080, 1280×900 and 390 px.
- [x] 2.2 Run `openspec validate add-hero-fits-screen --strict`.
## Notes (2026-12-04)
- **Red first:** the new render tests failed on the trust band padding, the hero padding, the card gap, the compact form gap and the consent text size.
- **Changed existing tests:** none.
- **Measured** on `/p/INS/hotel-technology` at 1920×1080 with Playwright:
- before: hero 886 px, trust strip bottom 1077 px;
- with `pt-10 pb-10`: 953 px, still over the 950 px target, so the hero padding became `pt-8 pb-8`;
- final: hero 802 px, trust strip bottom 937 px. Every text field, the dropdown and the Register button are 44 px.
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-03
@@ -0,0 +1,43 @@
# Proposal
## Why
Event pages convert best when the sign-up form is visible as soon as the page opens. INS's standalone landing page (`~/Projects/ins-landing-page`) puts the form in a card beside the hero text. In Co-Lite the form is always its own section, so on a page built from Custom HTML it lands below the hero, and the hero tells visitors to "scroll down to the form". Custom HTML cannot hold the real form: it runs in a sealed frame that cannot send leads into Co-Lite.
## What Changes
- A HERO block gains an optional event (`eventUuid`). When it is set, the hero shows Co-Lite's sign-up form for that event in a card beside the heading, text and button on wide screens, and below them on phones.
- The hero form behaves exactly like the FORM block:
- the same fields, interests and privacy notice;
- the same submit rules and limits;
- the same lead source, UTM values and closing rules.
- The server checks a hero's event like a FORM block's: it must be an event of the page's company.
- In the editor, the Hero's settings gain the same event picker as the Sign-up form, with "No form" as the default. The canvas shows the form card in place.
- Switching company in the editor clears a hero's event, as it already clears a FORM block's.
Not changing:
- The FORM block stays as it is.
- A page may have a hero form and a FORM block together, and each registers for its own event.
- The form card has no heading of its own; the hero's heading and text introduce it.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`: hero blocks may carry the sign-up form, and the event-reference rule covers them.
## Impact
- **services-counter:** `CmsBlockValidator`, which now checks a HERO's optional `eventUuid`.
- **mobile-api:** `PublicPageService`, which attaches form info to, and accepts submits for, any block with an event (FORM or a HERO that has one).
- **admin-portal:**
- the `HERO` rendering in `CmsBlocks.tsx`;
- the Hero fields in `BlockFields.tsx`;
- the company-switch reset in `usePageDraft.ts`;
- two labels, in English and Chinese.
- **No schema change:** blocks are JSON.
- **No new dependency.**
@@ -0,0 +1,48 @@
## ADDED Requirements
### Requirement: Hero With A Sign-Up Form
A HERO block MAY name an event. When it does, the hero SHALL show Co-Lite's sign-up form for that event in a card beside its heading, text and button on wide screens, and below them on narrow screens. The hero's form SHALL follow every rule of the FORM block (see "The Form Block Registers For An Event" and "The Form Block Closes With Its Event"). A HERO block without an event SHALL show no form.
#### Scenario: Sign up from the hero
- **GIVEN** page `/p/INS/hotel-technology` has a HERO block whose event is `INS website enquiries`
- **WHEN** a new visitor submits the form in the hero from a URL with `utm_source=facebook`
- **THEN** a new lead and an event lead with source Web page, no salesperson and UTM source `facebook` are created
#### Scenario: Hero form closes with its event
- **GIVEN** the HERO block's event ended yesterday
- **WHEN** a visitor opens the page
- **THEN** the hero still shows its heading and text, and its form area says sign-up is closed
#### Scenario: Hero without an event
- **WHEN** a visitor opens a page whose HERO block names no event
- **THEN** the hero shows no form
- **AND** a submit addressed to that block is refused as not found
#### Scenario: Pick the hero's event in the editor
- **GIVEN** staff editing a page with a HERO block
- **WHEN** they pick `INS website enquiries` under the hero's sign-up form setting
- **THEN** the canvas shows the form card beside the hero text
- **AND** choosing "No form" removes it
## MODIFIED Requirements
### Requirement: Block References Stay Inside The Company
A block's image SHALL be an image of the page's company, and the event of a FORM block or of a HERO block that names one SHALL be an event of the page's company. Otherwise the save SHALL be refused on that field.
#### Scenario: Another company's event
- **GIVEN** event `CV Roadshow` belongs to CV
- **WHEN** INS staff save a FORM block pointing at `CV Roadshow`
- **THEN** the save is refused on that block's event field
#### Scenario: Another company's event in a hero
- **GIVEN** event `CV Roadshow` belongs to CV
- **WHEN** INS staff save a HERO block whose event is `CV Roadshow`
- **THEN** the save is refused on that block's event field
@@ -0,0 +1,7 @@
-- The labels added by add-hero-signup-form, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
SET NAMES utf8mb4;
USE `service-system`;
INSERT INTO message (code, content, area) SELECT 'PagesHeroForm', JSON_OBJECT('en_US', 'Sign-up form', 'zh_CN', '报名表单'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesHeroForm') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '报名表单') WHERE LOWER(code) = LOWER('PagesHeroForm') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesNoForm', JSON_OBJECT('en_US', 'No form', 'zh_CN', '不显示表单'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesNoForm') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '不显示表单') WHERE LOWER(code) = LOWER('PagesNoForm') AND area = 'A';
@@ -0,0 +1,39 @@
# Tasks
## 1. Server
- [x] 1.1 services-counter `CmsBlockValidator`: a HERO's optional `eventUuid` must be an event of the page's company, refused at `blocks[n].eventUuid` with `PagesBadEvent`. Verify: new validator tests (own event saves, other company's event refused, no event saves) fail first, then pass; `mvn -T 1C -pl solvway-services-counter verify`.
- [x] 1.2 mobile-api `PublicPageService`: `page()` attaches `form`/`closed` to every block with an event that is FORM or HERO; `submit()` accepts a HERO with an event and refuses a HERO without one as not found. Verify: new service tests fail first, then pass; `mvn -T 1C -pl solvway-mobile-api verify`.
## 2. Portal
- [x] 2.1 `CmsBlocks.tsx` HERO: with `form` or `closed`, two columns from `md` (text left, form card right; stacked on phones), image and shade kept; the card is `LandingForm` with the hero's block index. Verify: render tests for with/without event, closed, and the edit canvas; vitest exit 0.
- [x] 2.2 `BlockFields.tsx`: the Hero gets the event picker ("No form" default, same hint and unavailable-event option as FORM; `eventUuid` shown inline); `usePageDraft` clears a HERO's event on company switch like a FORM's; labels `PagesHeroForm` and `PagesNoForm` in `defaultMessages.ts`, `zh_CN.seed.json` and an SQL label file in this change folder. Verify: editor tests fail first, then pass; tsc and lint clean.
## 3. Verification
- [x] 3.1 Rebuild services-counter and mobile-api locally; Playwright on port 3001: give a page's hero an event, see the card beside the text at 1280 px and below it at 390 px, submit as a visitor on the published page and see the lead under Event leads with source Web page; pick another company's event is impossible in the picker, and an ended event shows "closed". Use a disposable test page and the existing "LP Enquiries" test event; delete the test page after.
- [x] 3.2 Full portal vitest (exit 0), tsc, lint, both Maven modules, `openspec validate add-hero-signup-form --strict`.
## Notes (2026-12-03)
- **Red first:** each new test failed before its code existed. The validator test failed on the foreign event; the service tests found no form on the hero; the render tests, the editor picker test and the company-switch test failed too.
- **Existing editor test:** one query was scoped to the FORM block's picker, because "Website enquiries" is now an option in two pickers. Its assertions are unchanged.
- **Live check** (port 3001, rebuilt counter and mobile-api), on the throwaway page "Live check hero form":
- the hero picker defaults to "No form";
- the canvas shows the card beside the text;
- published at 1280 px, the form sits beside the text, and at 390 px below it;
- the visitor "Hero Check Visitor" registered from the hero and appears under INS website enquiries with "Web page: /p/INS/live-check-hero-form";
- the page was deleted afterwards. The test lead stays in the local database.
- **Fixes from the live check:**
- the hero text is top-aligned, because a long form left it below the fold;
- the top padding is larger, so the editor's image button clears the heading;
- the shade is a gradient, because the design-token test refuses flat `bg-black/*`.
- **Not checked live:**
- the closed state, which the picker cannot reach because it offers no ended events (covered by the service and render tests);
- the other-company refusal, which the picker cannot reach either (covered by the validator test).
- **Results:** Maven verify passed for services-counter and mobile-api; vitest 1985 passed (exit 0); tsc clean; lint 0 errors.
## Workflow follow-up
- PR to `main` and merge; archive on its own branch with its own PR.
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-03
@@ -0,0 +1,124 @@
# Design
## Context
- **Images:** CI publishes ten images to `gitea.containerverse.dev/solvway/`, each tagged with the commit SHA and with `latest`.
- **What `docs/deployment.md` already fixes:**
- the Service names and ports;
- the probes;
- every environment variable, and whether it is secret or plain;
- the two mounted files (`appkeys.json` for the gateway, the Pub/Sub `key.json` for the other Java images);
- the setup order;
- the Traefik routes (portal on `co-lite.containerverse.dev`, plus the webhook path).
- **Outside the cluster manifests:**
- MySQL, prepared by the DBA;
- Redis ("use the existing Redis");
- Google Pub/Sub.
- **Tools:** the repository has no Kubernetes files, and this machine has Docker but no kubectl.
## Goals / Non-Goals
**Goals:**
- One `kubectl apply -k deploy/k8s/overlays/prod` deploys the whole system once the Secrets exist.
- A check that fails on the mistakes that would hurt in production:
- a public route to an internal service;
- an image on `latest`;
- secret data in git;
- two service-counter replicas.
**Non-Goals:**
- Helm charts, GitOps tooling (Argo CD or Flux), or automatic deploys from CI. A person applies each release.
- Running MySQL, Redis or a Pub/Sub emulator in the cluster.
- A local Kubernetes preview. The owner previews the system with the docker-compose stack.
- Autoscaling, resource tuning beyond sensible requests, and NetworkPolicies. These can follow once the cluster's policy is known.
## Decisions
### 1. Kustomize, with a base and a `prod` overlay
- **Choice:** plain YAML under `deploy/k8s/base/`, plus `deploy/k8s/overlays/prod/` for the image SHA, the plain settings, the namespace and the routes.
- **Why:**
- Kustomize is built into kubectl, so the deployer installs nothing.
- The YAML reads like the handover doc.
- **Rejected:**
- Helm: templating for one environment adds code, and Helm would need installing.
- Raw YAML without overlays: the SHA would then be edited in ten files.
### 2. The image SHA is set in one place
- **How:** the overlay's `images:` list sets `newTag` for all ten images. A small `deploy/set-release.sh <sha>` rewrites those ten lines.
- **Rollback:** run `set-release.sh <previous sha>` and apply again. Every release is a commit on `main`, so the SHA in git history is the record of what ran.
### 3. Secrets are created by a script from git-ignored files, not stored as manifests
- **Templates:** `deploy/k8s/secrets.example/` holds one `.env` template per Secret (from `docs/deployment.md` section 9), plus an `appkeys.json` template.
- **Filling them in:** the deployer copies the folder to `deploy/k8s/secrets/`, which git ignores, and fills it in.
- **Creating them:** `deploy/create-secrets.sh` runs `kubectl create secret generic --from-env-file / --from-file ... --dry-run=client -o yaml | kubectl apply -f -`. It never prints a value.
- **Rejected:**
- Sealed Secrets or SOPS: new tooling and keys to manage, for a two-developer team. They can come later.
- A Kustomize `secretGenerator`: it would put the values into the rendered output, which the check must stay able to forbid.
### 4. Traefik IngressRoute for the public routes
- **What:** the `prod` overlay holds two IngressRoutes on `co-lite.containerverse.dev`:
- `/` to `admin-portal:3000`;
- `Path(/api/public/whatsapp/webhook)` to `mobile-api:80`.
- **Why:** the handover doc already states the routes as Traefik rules, and the cluster runs Traefik.
- **TLS:** a `tls:` block whose cert resolver (or cert-manager secret) name is a single field in the overlay (see Open Questions).
- **Rejected:** a standard Ingress with Traefik annotations. Exact-path matching is less clear there, and nothing else in the cluster needs portability.
### 5. The check runs from one pinned container
- **What:** `deploy/check.sh` sends the `deploy/` folder through stdin into `alpine/k8s:1.33.4`, pinned by digest. That one image has kubectl and kustomize, kubeconform, and python3 with PyYAML.
- **Why stdin:** it also works against CI's remote Docker daemon, where bind mounts would not reach the files.
- **Steps:**
1. Kustomize renders the overlay.
2. kubeconform validates the result. The Traefik schemas come from the CRDs catalog.
3. `check_rules.py` applies the rules.
- **Modes:**
- `--self-test` runs every rule against its fixture in `deploy/check-fixtures/`.
- `--release` also refuses any `<…>` placeholder. CI runs the plain check, because the cluster facts are still placeholders in git; the deployer runs `--release` before applying.
- **Rejected:** separate kubectl, kubeconform and Python images. That is three pulls and three pins for the same result.
### 6. Pod settings
- **Common to all pods:**
- one replica each;
- `TZ` left to the image;
- `GCP_CREDENTIAL_FILE` and the `key.json` mount on every Java pod except `api-gateway` and `service-whatsapp`;
- `imagePullSecrets` set to one named pull secret.
- **service-counter:** `strategy: Recreate`, so a rollout never runs two copies at once and the daily summary is never sent twice.
- **Probes:** the startup probe uses `/actuator/health/liveness` and allows up to 5 minutes. The overall `/actuator/health` is 503 on service-email while no mail server is configured.
- mobile-api does not turn its probe groups on by itself, so the settings set `MANAGEMENT_HEALTH_PROBES_ENABLED=true` for every Java pod.
- Both facts were measured on the local containers.
- **WhatsApp Secret:** referenced with `optional: true`, so mobile-api and service-whatsapp start while WhatsApp is off.
- **Image tags:** quoted in the overlay. A SHA made only of digits, or shaped like `1e45…`, would otherwise be read as a number.
- **Requests:** modest (`100m` CPU and `512Mi` for the Java pods; `256Mi` for the portal), with no CPU limit. `JAVA_OPTS=-Xmx384m` keeps the heap inside the memory limit.
- **Security context:** the Java images run as root (documented). The manifests do not set `runAsNonRoot`. If the cluster enforces it, that is a finding for the image, not a manifest workaround.
## Risks / Trade-offs
- **[A wrong cluster fact breaks the first apply]** (CRD version, pull-secret name, TLS method). Mitigation: those facts are single overlay fields, listed under Open Questions, and the first apply is done together with the owner.
- **[Secrets created by hand drift from the templates]** Mitigation: `create-secrets.sh` refuses to run if any key in a template is missing from the filled file.
- **[No automatic deploy means releases lag `main`]** This is accepted for go-live. Every release is a deliberate act with a recorded SHA.
- **[The check uses an image pulled from Docker Hub]** Mitigation: it is pinned by version and digest.
- **[kubeconform fetches the Traefik schema from GitHub]** Without network access the check fails rather than skipping. CI already needs the network to pull images.
## Migration Plan
1. The DBA prepares MySQL, and the Pub/Sub topics and key are created (handover sections 3 and 5).
2. Fill in `deploy/k8s/secrets/` and run `deploy/create-secrets.sh`. Create the registry pull secret.
3. Run `deploy/set-release.sh <sha>` and `deploy/check.sh`, then `kubectl apply -k deploy/k8s/overlays/prod`.
4. Wait for every Deployment to roll out (`kubectl rollout status`), then sign in as the first admin.
5. **Rollback:** run `set-release.sh <previous sha>`, apply again, and wait for the rollout. Database changes are forward-only. A release that ran new SQL rolls back only to a SHA that works with that schema; the SQL files say which ones are safe.
## Open Questions
These are single overlay fields. They are needed before the first real apply, not to build or check the manifests.
- **Namespace:** the default is `co-lite`.
- **TLS:** the Traefik cert resolver name (for example `letsencrypt`), or a cert-manager ClusterIssuer.
- **Pull secret:** its name for `gitea.containerverse.dev`, if the cluster already has one.
- **Redis:** the address of "the existing Redis".
- **Public-pages hostname:** the separate one for `/r`, `/i`, `/c` and `/p` (handover section 8), if it should exist at go-live.
- **Access:** who has kubectl access to the cluster for the first apply.
@@ -0,0 +1,46 @@
# Proposal
## Why
Phase 1 ends with Co-Lite running on the team's Kubernetes cluster before go-live on 15 January 2027. CI already publishes the images, and `docs/deployment.md` describes the environment the images need. Nobody has written the Kubernetes manifests yet, so every deploy would be typed by hand from a long document. That invites mistakes in the things that matter most: which paths are public, where secrets come from, and which image version runs.
## What Changes
- Add a `deploy/k8s/` folder with Kustomize manifests for the whole system:
- a Deployment and a Service for each of the ten images in `docs/deployment.md` section 1, with the names, ports, health probes and settings it lists;
- a `prod` overlay that pins every image to one commit SHA, sets the plain settings, and routes the public host through Traefik with TLS.
- Expose only two things to the internet: the admin portal, and mobile-api's WhatsApp webhook path. Nothing else gets a route.
- Keep every secret out of git. The manifests only refer to Secrets and mounted files by name. Add a checked-in template and a script that creates them from local files the deployer fills in and never commits.
- Add a check script, run locally and in CI, that renders the manifests and fails if:
- a route reaches anything other than the portal or the webhook path;
- an image uses `latest`;
- a Secret value appears in the rendered output;
- service-counter has more than one replica.
- Update `docs/deployment.md` so the deploy steps use the manifests (`kubectl apply -k`) instead of describing them in prose. Add the rollback steps.
Out of scope:
- MySQL and Redis: the DBA's MySQL and the existing Redis stay outside the cluster manifests.
- The Pub/Sub project and key.
- Choosing an email provider.
- Connecting WhatsApp in Meta.
## Capabilities
### New Capabilities
- `cluster-deployment`: how Co-Lite is described and rolled out on Kubernetes. It covers what is exposed publicly, how secrets are supplied, how image versions are pinned, and how a release is rolled back.
### Modified Capabilities
None. `release-packaging` (how images are built and published) does not change.
## Impact
- **New:** `deploy/k8s/` (base and `prod` overlay), `deploy/k8s/secrets.example/`, `deploy/check.sh`.
- **Changed:** `docs/deployment.md` and `.gitea/workflows/ci.yml` (one manifest-check step).
- **No application code changes.**
- **No new dependencies in the repo.** The check runs `kubectl kustomize` and kubeconform from pinned container images, so the machine needs only Docker.
- **The real cluster needs:**
- Traefik, with its IngressRoute CRD;
- a pull secret for `gitea.containerverse.dev`;
- the DNS record for `co-lite.containerverse.dev`.
@@ -0,0 +1,88 @@
# Spec Delta
## Purpose
Describe how Co-Lite is rolled out to Kubernetes from manifests in the repository, so that public exposure, secrets, image versions and rollback are fixed in reviewed files rather than typed by hand.
## ADDED Requirements
### Requirement: One manifest set deploys the whole system
The repository SHALL hold Kubernetes manifests that create a Deployment and a Service for each published image. The Service names and ports MUST be the ones the gateway, mobile-api and the portal already expect (`docs/deployment.md` section 1). Each Java service MUST have liveness and readiness probes on its actuator health endpoints. The admin portal MUST have a probe that needs no session.
#### Scenario: Apply brings every service up
- **GIVEN** a cluster where the Secrets, the mounted files, the database and the image pull secret already exist
- **WHEN** the deployer applies the `prod` overlay
- **THEN** a Deployment and a Service exist for all ten images under the expected names and ports
- **AND** every pod becomes ready
#### Scenario: Unhealthy pod gets no traffic
- **GIVEN** a Java service whose readiness endpoint reports down
- **WHEN** Kubernetes checks the pod
- **THEN** the pod is not ready and its Service sends it no requests
### Requirement: Only the portal and the WhatsApp webhook are public
The manifests SHALL route the public host, over TLS, to the admin-portal Service. They SHALL route exactly the path `/api/public/whatsapp/webhook` to the mobile-api Service. No other Service may be reachable from outside the cluster. The repository's manifest check MUST fail when a route targets any other Service or path.
#### Scenario: Gateway is not reachable from the internet
- **WHEN** the rendered `prod` manifests are checked
- **THEN** no route targets `api-gateway` or any `service-*`
- **AND** the only route to `mobile-api` matches exactly `/api/public/whatsapp/webhook`
#### Scenario: A new route is caught
- **GIVEN** a manifest change that adds a route to `api-gateway`
- **WHEN** the manifest check runs
- **THEN** it fails and names the route
### Requirement: Secrets never enter the repository
The manifests SHALL refer to Secrets and mounted files only by name. The repository MUST NOT hold any real secret value. Secret templates hold placeholders only. The script that creates the Secrets MUST read the values from files that git ignores.
#### Scenario: Rendered manifests hold no secret data
- **WHEN** the `prod` overlay is rendered
- **THEN** it contains no `Secret` object with data
- **AND** the manifest check fails if one appears
#### Scenario: Filled-in secret files cannot be committed
- **GIVEN** a deployer who fills in the secret files under the secrets folder
- **WHEN** they run `git status`
- **THEN** those files are ignored
### Requirement: Releases are pinned by commit and can be rolled back
The `prod` overlay SHALL pin every image to one commit SHA, never `latest`. Rolling back MUST be done by setting the previous SHA and applying again. The deployment docs MUST describe both steps. Before a real apply, a release check MUST refuse any cluster fact still left as a placeholder.
#### Scenario: latest is refused
- **GIVEN** a `prod` overlay where an image tag is `latest` or missing
- **WHEN** the manifest check runs
- **THEN** it fails and names the image
#### Scenario: Unfilled cluster fact refused before apply
- **GIVEN** a `prod` overlay that still holds a `<…>` placeholder, such as the MySQL host
- **WHEN** the deployer runs the release check
- **THEN** it fails and names each placeholder
#### Scenario: Roll back to the previous release
- **GIVEN** a release at SHA B that misbehaves, with SHA A deployed before it
- **WHEN** the deployer sets the overlay to SHA A and applies it
- **THEN** every Deployment rolls back to the SHA A images
### Requirement: Single-run jobs stay single
service-counter SHALL run as exactly one replica. It sends the daily follow-up summary, and two replicas would send it twice. The manifest check MUST fail when service-counter has more than one replica.
#### Scenario: Counter scaled by mistake
- **GIVEN** a manifest change that sets service-counter to two replicas
- **WHEN** the manifest check runs
- **THEN** it fails
@@ -0,0 +1,84 @@
# Tasks
## 1. Manifest check first (red)
- [x] 1.1 Add `deploy/check.sh` and its rule script.
- The script renders `deploy/k8s/overlays/prod` with pinned kubectl and kubeconform images, then applies the four rules:
- public routes reach only the portal and the exact webhook path;
- no image on `latest` or without a tag;
- no Secret data in the output;
- service-counter has exactly one replica.
- Add rule fixtures under `deploy/check-fixtures/`: one passing set and one failing set per rule.
- Verify: `deploy/check.sh --self-test` fails each bad fixture with a message naming the offending object, and passes the good one.
- Running it against the still-missing overlay fails.
- Done: 12 fixtures (one per rule, plus `bad-placeholder.yaml` for `--release`). The first red run passed on an empty render, so the container now stops on the first error, and `--full` requires all ten Deployments and Services.
## 2. Base manifests
- [x] 2.1 Add `deploy/k8s/base/`: a Deployment and a Service for each of the ten images, with the names, ports, probes, environment (secret refs and plain values) and mounts from `docs/deployment.md` sections 1, 6 and 7.
- service-counter: one replica, `strategy: Recreate`.
- Verify: `kubectl kustomize deploy/k8s/base`, run in the check container, renders the ten Deployments and ten Services. kubeconform passes.
- Done: 20 resources, all valid. The probe paths were checked against the running local containers. Two fixes came out of that:
- mobile-api answered 404 on liveness and readiness, so `MANAGEMENT_HEALTH_PROBES_ENABLED=true` is now in the settings;
- service-email's overall health is 503 without a mail server, so the startup probe uses the liveness path.
- [x] 2.2 Cross-check the base against `local/docker-compose.yml`: every variable a service reads locally is either set or deliberately left unset in the base.
- Verify: a scripted diff of the variable names per service shows no unexplained gaps. Record the deliberate ones in `docs/deployment.md`.
- Done: every `${…}` in each `application.yml` is supplied. Deliberately unset: the email keys, `SMSS360_EMAIL`, `CUSTOMER_PORTAL_BASE_URL`, Jumio, and `XXL_JOB_TOKEN` (listed in section 2).
- The WhatsApp Secret reference is `optional: true`, so mobile-api starts while WhatsApp is off.
## 3. Prod overlay, release pinning and routes
- [x] 3.1 Add `deploy/k8s/overlays/prod/`. It sets:
- the namespace;
- the `images:` list with one SHA for all ten images;
- the plain settings (`ADMIN_PORTAL_BASE_URL`, `REDISHOST`, `MYSQLHOST`, `GCP_PROJECT` and the rest);
- the pull secret;
- two Traefik IngressRoutes with TLS.
Verify: `deploy/check.sh` passes on the overlay (task 1 goes green).
- [x] 3.2 Add `deploy/set-release.sh <sha>`, which rewrites the overlay's ten tags.
- Verify: run it with a test SHA, then confirm that `check.sh` passes and `git diff` shows exactly ten tag lines changed. Running it with `latest` or a non-hex value is refused.
- Done: ten lines change. Running it with `latest` or a short SHA is refused.
- An all-digit SHA broke the render (YAML read it as a number), so the tags are now quoted. `2222…` and `1e45…` both render and pass.
## 4. Secrets
- [x] 4.1 Add `deploy/k8s/secrets.example/`: one `.env` template per Secret, plus an `appkeys.json` and a `key.json` placeholder, all with placeholders only.
- Add `deploy/k8s/secrets/` to `.gitignore`.
- Verify: a filled-in file under `deploy/k8s/secrets/` is listed by `git check-ignore`.
- [x] 4.2 Add `deploy/create-secrets.sh`. It creates or updates each Secret through `kubectl create ... --dry-run=client -o yaml | kubectl apply -f -`. It refuses if a template key is missing or still holds a placeholder, and it never prints a value.
- Verify: run it with `--dry-run` against a filled test folder; it prints only the Secret names and the key names.
- Verify: a missing key is refused, and the refusal names the key.
- Done: the dry run lists seven Secrets with their key names only. A missing `MYSQLPWD` is refused, and so is a placeholder `MYSQLPWD`.
- The real path ran in the check container, with `kubectl apply` stubbed:
- the `co-lite` namespace is created first, because the first run comes before any apply;
- seven Secrets carry the right keys and decode to the filled values;
- the registry Secret is a dockerconfigjson for `gitea.containerverse.dev`;
- no value appears on stdout.
- mobile-api's probes were proven on a throwaway container. Without `MANAGEMENT_HEALTH_PROBES_ENABLED` its liveness and readiness paths are missing; with it, all three return 200.
## 5. CI and docs
- [x] 5.1 Add a `deploy/check.sh` step to `.gitea/workflows/ci.yml`, before the image push.
- Verify: the workflow file parses, and the step runs locally with the same command.
- [x] 5.2 Rewrite the deploy steps in `docs/deployment.md` (sections 2 and 9) around the manifests:
- create the Secrets, set the release, run the check, apply, wait for the rollout;
- roll back;
- list the open cluster facts from `design.md`.
Verify: following the doc's commands in order against the check container renders and passes.
## 6. Verification
- [x] 6.1 Run the full check: `deploy/check.sh` and its self-test, the repository's existing build and tests (unchanged), and `openspec validate add-k8s-deployment --strict`.
- Done: the check and the self-test pass, and `openspec validate --strict` passes.
- Maven and vitest were not re-run: no module source or build file changed. Only `deploy/`, `docs/`, `.gitignore` and the CI file changed.
- [ ] 6.2 Run a server-side dry run against the real cluster: `kubectl apply -k deploy/k8s/overlays/prod --dry-run=server`, by the owner or with the owner's cluster access. Record the result here.
- This needs the open cluster facts filled in and access to the cluster. If access is not available before archive, leave the task unticked with a note, as was done for the WhatsApp e2e.
- Open (2026-12-03): there is no cluster access from this machine, and the cluster facts are not yet given. Owed by the owner with the first real apply.
## Workflow follow-up
- Branch from `origin/main`, then open a PR to `main` and merge it.
- Archive the change on its own branch, with its own PR.
- The first real apply happens with the owner, after the database package and Secrets are in place.
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-03
@@ -0,0 +1,109 @@
# Design: add-page-visual-editor
## Context
- **Design doc:** `docs/superpowers/specs/2026-12-03-page-builder-design.md`, change 3. Changes 1 and 2 are live: section types and looks, draft and live content, templates, and Duplicate.
- **Today's editor** is `app/components/pages/PageEditor.tsx`, about 415 lines. It holds all page state and actions:
- load, the draft, `show`, images uploaded on save;
- save, publish changes, discard and delete;
- mapping refusals to fields.
- **Block fields** are edited by `BlockFields.tsx`.
- **Rendering.** The public page and the preview render with `LandingPage` and `Block` in `CmsBlocks.tsx`. Custom HTML renders through `HtmlFrame`, a sealed frame loaded from a frame address that skips the nonce policy.
- **Page policy.** The baseline CSP sets no `style-src`. Scripts need the per-request nonce.
## Goals / Non-Goals
**Goals**
- Edit the page on the page, with Desktop and Phone views.
- Text editing in place, section actions and undo.
- Change 2's draft controls and entries kept.
- The form editor kept below 1024 px.
**Non-Goals**
- Free placement or per-element styling.
- Version history.
- Editing on phones.
- Live rendering of unsaved Custom HTML.
- Any server or API change.
## Decisions
### 1. The canvas is a blank same-origin frame that the editor renders into
The editor mounts `<iframe>` with no `src` (about:blank, same origin), then renders the page into its body with `createPortal`.
**Styles and theme.**
- The `<link rel=stylesheet>` and `<style>` elements in the editor's `<head>` are cloned into the frame. A MutationObserver keeps them in step when `next dev` swaps them.
- `<html>`'s `class`, `data-theme` and `style` are copied, which carries the Inter font variable, the dark class and the variables.
**Why the frame.** It has its own viewport, so `sm:`, `md:` and `lg:` respond to the canvas width, as on a visitor's device. React context (messages, auth) and events work through the portal, and there is a single copy of the draft.
**Rejected: a canvas address that exchanges the draft by `postMessage`,** as the design doc sketched. It needs a sync protocol both ways, origin checks and a second copy of the draft, which makes undo and in-place editing harder.
**Security.** The canvas frame has no `sandbox`, unlike every other frame in the portal. It must be same-origin for the portal, and a sandbox without `allow-scripts` would also stop the scripts of the Custom HTML frames nested in it. It holds no data HTML: its only document is a constant blank page (`srcDoc`, no `src`), and everything in it is React-rendered as on the preview page. The portal's markup sweep test allow-lists exactly that file, constant and shape.
**Fallback.** Task 1 is a spike with pass criteria. If it fails (Tiptap inside the frame, focus, drag events, or production CSS), use a canvas route `/pages/canvas` that reads the draft and posts edits back. Only the canvas wiring changes.
### 2. Desktop is 1280 px, scaled
- **Desktop** renders the frame 1280 px wide and scales it with a CSS transform to the width left beside the panel. The frame is one screen tall and scrolls inside, like a device. A frame grown to its content risks a feedback loop with the page's `min-h-svh`, and a fixed screen keeps `svh` honest.
- **Phone** is 390 px at 1:1.
- Outlines, toolbars and "Add section" buttons are drawn inside the frame document, so they scale with the page.
### 3. Edit-mode hooks in `LandingPage`
- An optional `edit` prop on `LandingPage` provides an `EditContext`. Without it, rendering is unchanged, and the public page and preview never pass it.
- **Plain text fields.** In edit mode, `Block` renders text fields through `<EditableText field=… max=…>`: a `contentEditable="plaintext-only"` element. It reports input on each keystroke and is never re-rendered from props while it has focus, so the caret stays.
- **Rich text** (RICH_TEXT and IMAGE_TEXT html) renders through the existing `RichTextEditor`. A `bare` option adds a floating toolbar and drops the boxed look. It uses the same `isSafeLink` rule.
- **Images.** An image spot is a button that opens a file input in the editor document. The chosen file previews from a data URL, as today.
- **`Section`** gains `data-index`, an outline when hovered or selected, and the toolbar. Gaps get "+ Add section".
- **Clicks.** Clicks on links, buttons and the form are prevented in edit mode. The FORM block already renders its preview note.
### 4. `HtmlFrame` listens on its own window
- It adds its message listener to `ref.current.ownerDocument.defaultView`. Inside the canvas, the sealed frame's parent is the canvas window, so the height and anchor messages arrive there.
- The canvas passes `frameBase` = the preview frame address (saved draft). Changing a block's HTML sets "Save to update" on that block until the next save. After Save, the frame reloads with a cache-busting `?v=<save count>`.
### 5. Shared state: `usePageDraft`
`PageEditor`'s state and actions move, unchanged, into `usePageDraft(pageId, fromId, initialBlocks)`. Both editors use it. This is a refactor guarded by the existing editor tests. The visual editor adds:
- **`selected` index** (or none).
- **History.** Arrays of `{ draft, rows }` snapshots, up to 50.
- A text field pushes one snapshot when it gains focus and changes.
- A structural action pushes one before it applies.
- Undo and redo replace the state and blur the focused editable first, so a focused field is re-rendered from the restored value.
- Ctrl+Z inside a rich-text field is Tiptap's own undo while that field has focus. Page undo applies after blur.
- **Refusal mapping.** A refused field `blocks[i].…` sets `selected = i` and scrolls the section into view in the frame. The panel then shows `BlockFields` errors as today.
### 6. Layout
```
┌ ← Pages Title [status] [Desktop|Phone] ↶ ↷ [Duplicate][Preview][View page][Delete] [Save] ┐
├ unpublished-changes banner (Publish changes / Discard changes), as in change 2 ──────────────────┤
├──────────────────── canvas ───────────────────────────────────┬──── panel (360 px) ────────────┤
```
- **Panel.** It shows `BlockFields` for the selected block, which already covers every field, the look and the link name. With nothing selected it shows the page settings card and the status card from today's form.
- **Which editor.** `matchMedia("(min-width: 1024px)")` chooses the editor. Resizing across the line switches editors with the state kept, since both use the same hook.
### 7. Leave guard for in-app links
A capture-phase click listener on `document`, active while there are unsaved changes, catches same-origin `<a href>` clicks that would leave the page. It shows the existing `ConfirmDialog`; Leave then calls `router.push`. This replaces the gap noted in `PageEditor` (`ponytail:` comment). Browser back is not guarded; this is named in the comment.
### 8. Drag and drop
Drag and drop uses native HTML5 events on the section handle inside the frame, with a drop line between sections. Keyboard users use up and down. jsdom cannot run native drag-and-drop, so the reorder function is unit-tested and the drag itself is checked live.
## Risks / Trade-offs
- **Tiptap or focus inside a portal frame.** ProseMirror reads `ownerDocument` in most places, but this is unverified for selection handling in a frame. The spike covers it, and the fallback is in Decision 1.
- **Style cloning in production.** A production build serves hashed CSS links, which clone fine. The spike checks a `next build` once, not only `next dev`.
- **Two editors share one hook.** Each keeps its own tests. The form editor stays the narrow-window path, and the fallback if the canvas misbehaves.
- **Saved-only Custom HTML on the canvas.** Accepted: staff paste HTML rarely. The marker says what they see.
## Migration Plan
- Portal-only deploy, then run `sql/01-visual-editor-labels.sql`.
- Rollback: the previous portal image, then `sql/99-rollback.sql` (labels).
- No data change.
@@ -0,0 +1,51 @@
# Proposal: add-page-visual-editor
## Why
INS and CV marketing staff build a page for every event and are not technical. Today they fill in a form of blocks and check a separate preview of the last saved version. The owner asked for a Wix-like editor: staff click the page itself to change it and see the result as they work. This is change 3 of the page builder (`docs/superpowers/specs/2026-12-03-page-builder-design.md`). Changes 1 (sections) and 2 (drafts, templates, Duplicate) are live.
## What Changes
- **On-page editor** at 1024 px and wider. The page renders in a canvas inside the editor, at the desktop width scaled to fit, or at phone width (390 px). It uses the same `LandingPage` rendering as visitors see. A side panel shows the selected section's settings, or the page settings when no section is selected.
- **Edit in place.**
- Headings, short texts, button labels, card titles and texts, and FAQ questions and answers are edited as plain text on the canvas, with the server's length limits.
- Rich text (Text, and Image with text) is edited in place with a small toolbar.
- Clicking an image spot opens the file picker.
- **Section actions.** Select, a toolbar (drag handle, up, down, duplicate, delete), and "+ Add section" between sections and at the end.
- **Undo and redo** for the page, up to 50 steps, with Ctrl+Z, Ctrl+Shift+Z and buttons.
- **Change 2 carried over.** The editor's top bar keeps Save, Preview, View page, Duplicate, Delete, the unpublished-changes banner with Publish changes and Discard changes, and the status. Templates and Duplicate open in the new editor.
- **Refusals on the canvas.** A refused field's section is selected and outlined, and the panel shows the message at the field.
- **Unsaved changes.** In-app links now ask before leaving with unsaved changes, in both editors. Today only reload and close ask.
- **Below 1024 px** the current form editor stays, with Preview.
### Departures from the approved design doc
These are builder calls, recorded in `design.md`:
1. **Canvas wiring.** The editor renders the page into a blank same-origin frame itself, instead of loading a canvas address that exchanges the draft by `postMessage`. There is one copy of the draft and no message protocol. A spike task proves it first, with a canvas route as the named fallback.
2. **Desktop view** renders at 1280 px and is scaled down to fit beside the panel, so the page's own breakpoints match a desktop visitor's. "Full width" would show the tablet layout on a laptop.
3. **Custom HTML** on the canvas shows the last saved version, with a "Save to update" mark once its HTML is edited. It reloads after Save. Unsaved pasted HTML cannot run sealed with today's frame routes and script policy.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`:
- The Page Editor, Saving And Deleting In The Editor, The Custom HTML Block In The Editor, and New Sections In The Editor change.
- The on-page editor requirements are added: canvas, editing in place, section actions, undo, and refusals on the canvas.
## Impact
- **Portal only:**
- New: `app/components/pages/visual/*` (canvas, panel, top bar, history).
- `PageEditor` state moves into a shared hook used by both editors.
- `CmsBlocks` gains edit-mode hooks, which the public page does not use.
- `HtmlFrame` listens on the window of the document it is in.
- A leave guard for in-app links.
- **Security:** the editor canvas is the portal's only frame without a `sandbox`. It must be same-origin for the editor to render into it, and a sandbox would also stop scripts in the Custom HTML frames nested inside. It loads only a constant blank document with no `src`, so no stored HTML ever runs as the portal. The markup sweep test allow-lists exactly that file and shape (design Decision 1).
- **No server, API, database or SQL changes.** New labels only, with a label SQL file.
- **No new dependencies.** Tiptap is already installed; dragging uses native drag-and-drop.
@@ -0,0 +1,133 @@
## MODIFIED Requirements
### Requirement: The Page Editor
At 1024 px and wider the editor SHALL be the on-page editor. Below 1024 px it SHALL be the form editor. Both SHALL offer the title, a slug filled from the title until edited, a meta description with a 160-character counter, the status, adding, moving and removing blocks, and images uploaded only on save. A FORM block SHALL pick from the company's enabled events that have not ended.
#### Scenario: Slug follows the title until edited
- **GIVEN** a new page
- **WHEN** staff type the title "Hotel Technology"
- **THEN** the slug becomes `hotel-technology`
#### Scenario: Narrow window keeps the form
- **WHEN** staff open a page in a window 900 px wide
- **THEN** the form editor shows, with Preview
### Requirement: Saving And Deleting In The Editor
Server field errors SHALL show at their fields, keeping all entered values. After a save the editor SHALL offer a link to view the page. Deleting a page SHALL ask first. With unsaved edits, reloading, closing and following an in-app link SHALL ask first.
#### Scenario: Server error at its field
- **WHEN** staff save a HERO button link `javascript:alert(1)`
- **THEN** the error shows at that button link and every entered value stays
#### Scenario: Leaving by an in-app link
- **GIVEN** staff changed a heading and did not save
- **WHEN** they click Pages in the menu
- **THEN** the editor asks before leaving, and Cancel keeps them on the page with the change
### Requirement: The Custom HTML Block In The Editor
The editor SHALL offer adding a Custom HTML block, edited in a monospace text box with a 200000-character counter and a note that forms inside it do not send. On the canvas the block SHALL show its last saved version as a sealed frame, marked "Save to update" while its HTML has unsaved edits. The editor SHALL offer a "hide page header" switch.
#### Scenario: Adding a Custom HTML block
- **WHEN** staff add a Custom HTML block and paste HTML into it
- **THEN** the block shows the pasted HTML, the character count and the note about forms
#### Scenario: Unsaved HTML on the canvas
- **GIVEN** a saved page with a Custom HTML block
- **WHEN** staff change its HTML in the panel
- **THEN** the canvas marks the block "Save to update"
- **AND** after Save the canvas shows the new HTML
#### Scenario: Hiding the header
- **WHEN** staff turn on "hide page header" and save
- **THEN** reading the page returns "hide header" on
### Requirement: New Sections In The Editor
Both editors SHALL offer adding FEATURES, STEPS, TRUST and CTA blocks, editing their fields, adding, removing and reordering cards, and choosing any block's look. Refusals SHALL show at the field they name, including card fields.
#### Scenario: A refused card title shows at its field
- **GIVEN** staff editing a page with a FEATURES block
- **WHEN** the save is refused on field `blocks[0].cards[1].title`
- **THEN** the message shows at the second card's title field
## ADDED Requirements
### Requirement: The Page Canvas
The on-page editor SHALL show the page on a canvas, rendered as visitors see it, with a Desktop view (1280 px wide, scaled to fit) and a Phone view (390 px wide). Changes SHALL show on the canvas as they are made, before saving. Links and buttons on the canvas SHALL NOT navigate, and the sign-up form SHALL show its preview note.
#### Scenario: Phone view uses the phone layout
- **GIVEN** a page with a FEATURES block of three cards
- **WHEN** staff switch to Phone
- **THEN** the cards stack in one column on the canvas
#### Scenario: A change shows before saving
- **WHEN** staff change a FEATURES card title in the side panel
- **THEN** the canvas shows the new title at once
### Requirement: Edit Text On The Page
Clicking a heading, short text, button label, card title or text, or FAQ question or answer on the canvas SHALL edit it in place as plain text, with the server's length limit shown when close. Rich text SHALL be edited in place with bold, italic, link, lists and alignment, and links SHALL follow the page link rule. An empty field SHALL show a faded cue naming it, and empty rich text SHALL keep room to click into. Clicking an image spot SHALL open the file picker.
#### Scenario: Edit a heading in place
- **WHEN** staff click the hero heading on the canvas and type "Hotel week"
- **THEN** the canvas and the side panel show "Hotel week"
#### Scenario: An unsafe link is refused in rich text
- **WHEN** staff add the link `javascript:alert(1)` in a Text block on the canvas
- **THEN** the link is not added and the toolbar says why
### Requirement: Section Selection And Actions
Clicking a section on the canvas SHALL select it, outline it and show its settings in the side panel. With none selected, the panel SHALL show the page settings. A selected section SHALL offer drag, up, down, duplicate and delete. "Add section" between sections and at the end SHALL offer every block type. Up and down SHALL work from the keyboard. A section that is added, duplicated or moved SHALL be brought into view on the canvas.
#### Scenario: Duplicate a section
- **WHEN** staff select the second section and press Duplicate
- **THEN** a copy appears as the third section and is selected
#### Scenario: Add a section between two
- **WHEN** staff press Add section between the first and second sections and choose Steps
- **THEN** a Steps section appears second and is selected
#### Scenario: Add a section from the side panel
- **GIVEN** the canvas shows the top of a long page
- **WHEN** staff press Add Text in the side panel
- **THEN** the canvas scrolls to the new Text section at the end, which shows a faded "Content" cue to type into
### Requirement: Undo And Redo
The on-page editor SHALL undo and redo page changes, up to 50 steps, by buttons and by Ctrl+Z and Ctrl+Shift+Z. The keys SHALL work wherever focus is in the editor, including after the focused control is removed or disabled, except inside a field outside the editor. Typing in one field SHALL be one step. Saving SHALL NOT clear the history.
#### Scenario: Undo a delete
- **GIVEN** staff deleted the FAQ section
- **WHEN** they press Ctrl+Z
- **THEN** the FAQ section is back in its place with its content
### Requirement: Refusals On The Canvas
When a save or publish is refused on a block field, the editor SHALL select that block, outline it, scroll it into view and show the message at the field in the side panel. A refusal on a page field SHALL show in the page settings.
#### Scenario: A form without an event
- **GIVEN** a page from the Event sign-up template
- **WHEN** staff save without choosing the form's event
- **THEN** the form section is selected and outlined and the panel shows the message at the Event field
@@ -0,0 +1,35 @@
-- The labels added by add-page-visual-editor, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
SET NAMES utf8mb4;
USE `service-system`;
INSERT INTO message (code, content, area) SELECT 'PagesLeaveTitle', JSON_OBJECT('en_US', 'Leave without saving?', 'zh_CN', '不保存就离开?'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesLeaveTitle') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '不保存就离开?') WHERE LOWER(code) = LOWER('PagesLeaveTitle') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesLeaveMessage', JSON_OBJECT('en_US', 'Your changes to this page are not saved. Leave and lose them?', 'zh_CN', '此页面的修改尚未保存。离开将丢失这些修改,确定离开吗?'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesLeaveMessage') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '此页面的修改尚未保存。离开将丢失这些修改,确定离开吗?') WHERE LOWER(code) = LOWER('PagesLeaveMessage') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesLeave', JSON_OBJECT('en_US', 'Leave', 'zh_CN', '离开'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesLeave') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '离开') WHERE LOWER(code) = LOWER('PagesLeave') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesSaveToUpdate', JSON_OBJECT('en_US', 'Save to update', 'zh_CN', '保存后更新'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesSaveToUpdate') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '保存后更新') WHERE LOWER(code) = LOWER('PagesSaveToUpdate') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesLinkRefused', JSON_OBJECT('en_US', 'That link is not allowed. Use https://, mailto:, tel:, a path starting with / or #name.', 'zh_CN', '不允许此链接。请使用 https://、mailto:、tel:、以 / 开头的路径或 #名称。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesLinkRefused') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '不允许此链接。请使用 https://、mailto:、tel:、以 / 开头的路径或 #名称。') WHERE LOWER(code) = LOWER('PagesLinkRefused') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesAddSection', JSON_OBJECT('en_US', 'Add section', 'zh_CN', '添加区块'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddSection') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加区块') WHERE LOWER(code) = LOWER('PagesAddSection') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesDragSection', JSON_OBJECT('en_US', 'Drag to move', 'zh_CN', '拖动以移动'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesDragSection') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '拖动以移动') WHERE LOWER(code) = LOWER('PagesDragSection') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesDuplicateSection', JSON_OBJECT('en_US', 'Duplicate section', 'zh_CN', '复制区块'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesDuplicateSection') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '复制区块') WHERE LOWER(code) = LOWER('PagesDuplicateSection') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesPageSettings', JSON_OBJECT('en_US', 'Page settings', 'zh_CN', '页面设置'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesPageSettings') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '页面设置') WHERE LOWER(code) = LOWER('PagesPageSettings') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesCanvas', JSON_OBJECT('en_US', 'Page canvas', 'zh_CN', '页面画布'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesCanvas') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '页面画布') WHERE LOWER(code) = LOWER('PagesCanvas') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesCanvasView', JSON_OBJECT('en_US', 'Canvas view', 'zh_CN', '画布视图'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesCanvasView') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '画布视图') WHERE LOWER(code) = LOWER('PagesCanvasView') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesDesktop', JSON_OBJECT('en_US', 'Desktop', 'zh_CN', '桌面'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesDesktop') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '桌面') WHERE LOWER(code) = LOWER('PagesDesktop') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesPhone', JSON_OBJECT('en_US', 'Phone', 'zh_CN', '手机'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesPhone') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '手机') WHERE LOWER(code) = LOWER('PagesPhone') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesUndo', JSON_OBJECT('en_US', 'Undo', 'zh_CN', '撤销'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUndo') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '撤销') WHERE LOWER(code) = LOWER('PagesUndo') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesRedo', JSON_OBJECT('en_US', 'Redo', 'zh_CN', '重做'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesRedo') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '重做') WHERE LOWER(code) = LOWER('PagesRedo') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesUntitled', JSON_OBJECT('en_US', 'Untitled page', 'zh_CN', '未命名页面'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUntitled') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '未命名页面') WHERE LOWER(code) = LOWER('PagesUntitled') AND area = 'A';
@@ -0,0 +1,3 @@
-- Co-Lite change add-page-visual-editor: rollback. Deploy the previous portal image first; this only removes its labels.
USE `service-system`;
DELETE FROM message WHERE code IN ('PagesLeaveTitle', 'PagesLeaveMessage', 'PagesLeave', 'PagesSaveToUpdate', 'PagesLinkRefused', 'PagesAddSection', 'PagesDragSection', 'PagesDuplicateSection', 'PagesPageSettings', 'PagesCanvas', 'PagesCanvasView', 'PagesDesktop', 'PagesPhone', 'PagesUndo', 'PagesRedo', 'PagesUntitled') AND area = 'A';
@@ -0,0 +1,58 @@
# Tasks: add-page-visual-editor
Design: `design.md`. Every task is TDD. Work is serial in the main session, with a self-review per task.
- Verify (portal): `cd solvway-admin-portal && npx vitest run; echo VITEST=$? && npx tsc --noEmit && npm run lint`
## 1. Foundations
- [x] 1.1 **Spike, kept only if it passes:** render `LandingPage` into a blank frame by portal, with copied styles and theme. It passes when all of these work, in `next dev` and in one `next build` + `next start`:
- Tailwind breakpoints follow the frame width (390 vs 1280).
- Fonts and dark mode look right.
- A Tiptap editor inside the frame types, selects and applies bold.
- A `contentEditable` field keeps its caret while typing.
- Native drag events fire.
- A Custom HTML frame inside it reports its height.
On failure, stop and switch to the canvas-route fallback (design Decision 1), noting why.
Passed 2026-12-03 in `next dev` and `next build` + `next start`: 390 px stacks the cards and 1280 px shows three columns; Inter and dark mode follow the editor live; Tiptap typed and applied bold; a plain field kept its caret; dragstart and drop fired inside the scaled frame; a Custom HTML frame grew to 4419 px after 1.2. The frame scrolls inside rather than growing (design Decision 2).
- [x] 1.2 `HtmlFrame` listens on its own document's window (test: a frame inside another document still resizes).
- [x] 1.3 Move `PageEditor` state and actions into `usePageDraft`, with no behaviour change. All existing `PageEditor*.test.tsx` stay green and unchanged.
- [x] 1.4 Leave guard for in-app links in the form editor (test: an in-app link click with unsaved edits asks; Cancel stays, Leave navigates).
## 2. Canvas
- [x] 2.1 `PageCanvas`: the frame, the Desktop view (1280 px scaled) and the Phone view (390 px), live updates from the draft, and links and buttons inert.
- [x] 2.2 Edit-mode hooks in `CmsBlocks`: `EditContext`, `EditableText` for every plain text field with its server limit, image spots, `Section` outline and `data-index`. Public rendering stays unchanged: the existing `CmsBlocks*.test.tsx` stay green.
- [x] 2.3 Rich text in place: `RichTextEditor` bare mode with a floating toolbar (test: an unsafe link is refused with a message).
- [x] 2.4 Custom HTML on the canvas: the saved-draft frame, the "Save to update" mark, and a reload after save.
## 3. Editor
- [x] 3.1 `VisualEditor` layout:
- The top bar: title, status, Desktop and Phone, undo and redo, Duplicate, Preview, View page, Delete, Save.
- The change 2 banner with Publish changes and Discard changes.
- The side panel: `BlockFields` for the selected block, or the page settings.
- The editor is chosen by width, 1024 px and up.
- [x] 3.2 Selection and section actions: select, toolbar (up, down, duplicate, delete), "Add section" between sections and at the end, native drag reorder (reorder function unit-tested), and the keyboard path.
- [x] 3.3 Undo and redo: history of 50, one step per field edit and per action, Ctrl+Z and Ctrl+Shift+Z, kept across saves.
- [x] 3.4 Refusals on the canvas: select, outline, scroll into view, message at the panel field; page-field refusals in the page settings.
- [x] 3.5 Templates (`?template=`) and Duplicate (`?from=`) open in the visual editor.
- [x] 3.6 Labels in `defaultMessages.ts` and `zh_CN.seed.json`, `npm run i18n:sql`, `sql/01-visual-editor-labels.sql`, `sql/99-rollback.sql`.
## 4. Release
- [x] 4.1 `docs/deployment.md` §12: the on-page editor for staff, the narrow-window form, and Custom HTML showing after Save.
- [x] 4.2 Live check with Playwright (snapshot, find and screenshots only; no `eval`), on disposable pages, at 1280 px and at 900 px for the form, with Desktop and Phone views:
- Create from a template, edit headings and a card in place, change a look in the panel, and add, duplicate, move and delete sections.
- Undo and redo.
- Save without an event: the form is outlined with the message at Event.
- Choose the event and save. Publish changes.
- Rich text with a safe link and a refused unsafe one.
- A Custom HTML block: the "Save to update" mark, then the new HTML after save.
- Leaving by a menu link with unsaved changes.
- Done 2026-12-03, re-run on fresh code after a full reload: Fast Refresh had not applied edits on this page. Also checked: one undo step per Ctrl+Z from three places, drag to reorder, Look, and Duplicate and Move up revealing their section. Found and fixed on the way:
- Ctrl+Z did nothing right after a toolbar delete: focus fell to the canvas body.
- Ctrl+Z also did nothing once Redo went disabled: focus fell to the page body.
- A new empty Text section was a thin line under its Add section button.
- A section added from the panel stayed out of view.
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-04
@@ -0,0 +1,44 @@
# Proposal
## Why
The INS sign-up form on the standalone landing page is short: full name, email, phone, company, a single "service" dropdown and the button. Co-Lite's landing-page form is roughly three times as long. Most of that comes from three things: the full English and Malay privacy notice shown in the form, five interest checkboxes, and a job-title field that INS does not ask for. On the rebuilt Hotel technology page, the form card is taller than two screens.
The coloured sections at the end of the page have a second problem: they are separated by pale gaps. The dark call to action and the dark footer therefore read as two footers.
The owner chose the following on 2026-12-04: a collapsed privacy notice, one interest as a dropdown, and no job title on landing pages.
## What Changes
- **Landing-page forms are compact.** This covers the FORM block and a hero's form; QR, invitation and customer sign-up forms are unchanged.
- The interests are a single optional dropdown ("Service interested in"), so a submission carries at most one interest.
- There is no job-title field.
- The privacy notice is folded behind one line, "How we use your details (English / Bahasa Malaysia)", just above the consent box. It opens to the full bilingual notice.
- The consent box itself and its wording do not change.
- **Coloured sections join.** A block with a non-default look (light grey, dark or company colour) counts as full width, like Custom HTML and the full-width hero. Two such blocks next to each other join with no gap.
Not changing:
- The server: it already accepts a submission without a job title and with zero or one interest.
- The QR, invitation and customer forms.
- The notice text, which consent still covers.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`:
- modifies "Full-Width Blocks Join Without Gaps";
- adds "Compact Landing-Page Form".
## Impact
- Portal:
- `RegistrationForm.tsx` gains a `compact` option;
- `LandingForm.tsx` passes it;
- `CmsBlocks.tsx` extends `bleeds()` to banded looks;
- new labels.
- The compliance owner should confirm that a folded notice next to the consent box meets PDPA. The owner was told this when they chose it.
@@ -0,0 +1,45 @@
## ADDED Requirements
### Requirement: Compact Landing-Page Form
A landing page's sign-up form, in a FORM block or a hero, SHALL show name, mobile, email and company, the event's interests as one optional dropdown, the privacy notice folded behind a single line that opens it in full, and the consent box. It SHALL NOT show a job-title field. QR, invitation and customer sign-up forms SHALL keep their full layout.
#### Scenario: Short form on the page
- **GIVEN** a page whose hero has an event with five interests
- **WHEN** a visitor opens the page
- **THEN** the form shows name, mobile, email, company, a "Service interested in" dropdown and the consent box, with no job title and no interest checkboxes
- **AND** the privacy notice is folded behind "How we use your details"
#### Scenario: Pick one service
- **WHEN** the visitor chooses "Cloud IP PABX" in the dropdown and submits
- **THEN** the submission carries that one interest
#### Scenario: Read the notice
- **WHEN** the visitor opens "How we use your details"
- **THEN** the full English and Malay notice shows above the consent box
#### Scenario: QR form unchanged
- **WHEN** a visitor opens an event's QR sign-up form
- **THEN** it shows job title, the interest checkboxes and the full notice as before
## MODIFIED Requirements
### Requirement: Full-Width Blocks Join Without Gaps
A full-width HERO, a Custom HTML block, and a block with a non-default look SHALL join with no gap when two of them are next to each other. Other blocks SHALL keep their usual spacing.
#### Scenario: Top bar runs straight into the hero
- **GIVEN** a Custom HTML top bar followed by a full-width HERO
- **WHEN** a visitor opens the page
- **THEN** the hero starts directly under the top bar, with no gap
#### Scenario: Dark call to action runs into a dark footer
- **GIVEN** a CTA block with the Dark look followed by a text block with the Dark look
- **WHEN** a visitor opens the page
- **THEN** the two bands join with no gap between them
@@ -0,0 +1,9 @@
-- The labels added by add-compact-landing-form, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
SET NAMES utf8mb4;
USE `service-system`;
INSERT INTO message (code, content, area) SELECT 'RegServiceInterest', JSON_OBJECT('en_US', 'Service interested in (optional)', 'zh_CN', '感兴趣的服务(可选)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegServiceInterest') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '感兴趣的服务(可选)') WHERE LOWER(code) = LOWER('RegServiceInterest') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegChooseService', JSON_OBJECT('en_US', 'Choose a service', 'zh_CN', '选择服务'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegChooseService') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '选择服务') WHERE LOWER(code) = LOWER('RegChooseService') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'RegNoticeSummary', JSON_OBJECT('en_US', 'How we use your details (English / Bahasa Malaysia)', 'zh_CN', '我们如何使用您的资料(English / Bahasa Malaysia)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegNoticeSummary') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '我们如何使用您的资料(English / Bahasa Malaysia)') WHERE LOWER(code) = LOWER('RegNoticeSummary') AND area = 'A';
@@ -0,0 +1,39 @@
# Tasks
## 1. Portal
- [x] 1.1 `RegistrationForm` `compact` option, passed by `LandingForm`:
- no job title;
- interests in one optional `<select>` ("Service interested in", first option "Choose a service"), which sets `interestIds` to `[]` or `[id]`;
- the notice inside a `<details>` with the summary "How we use your details (English / Bahasa Malaysia)", just above the consent box.
Verify: tests for the landing form (fields, one interest posted, the notice folded and openable) and for the QR form (unchanged) fail first, then pass.
- [x] 1.2 `CmsBlocks.tsx` `bleeds()`: a block with a non-default look counts too. Verify: a render test (a dark CTA followed by a dark text block has no gap) fails first, then passes.
- [x] 1.3 Add the labels (`RegServiceInterest`, `RegChooseService`, `RegNoticeSummary`) to `defaultMessages.ts`, `zh_CN.seed.json` and `sql/01-compact-form-labels.sql`, and regenerate the local seed.
## 2. Verification
- [x] 2.1 Use Playwright on port 3001 for `/p/INS/hotel-technology-native` at 1280 px and 390 px:
- check the short form;
- check that the notice opens;
- check that the closing bands join;
- check that an event's QR form (opened from Events) still shows the full form.
- [x] 2.2 Run the full vitest (exit 0), tsc, lint and `openspec validate --strict`. Add a release note.
## Notes (2026-12-04)
- **Red first:**
- the compact-form tests (fields, one service posted, the notice folded) and the band-join test failed first;
- the full-form test passed from the start, as the baseline it guards.
- **Live check** on `/p/INS/hotel-technology-native` (port 3001):
- the hero form shows name, mobile, email, company and "Service interested in", with no job title;
- the notice opens from "How we use your details";
- the hero runs into the trust strip;
- the dark call to action and the dark footer join into one ending.
- **Fix from the live check:** joined bands had lost their colour. `Section` treated every joining block as a full-width hero. Now only a full-width hero skips the page width, and the band test also checks the colour.
- **Not checked live:** the QR form staying full. The `RegistrationForm` test covers it (job title, checkboxes, notice open).
- **Results:** vitest 2002 passed (exit 0); tsc clean; lint 0 errors (the 4 warnings were already there).
## Workflow follow-up
- Open a PR to `main` and merge it. Archive the change on its own branch, with its own PR.
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-04
@@ -0,0 +1,25 @@
# Design
## Context
The HERO block renders inside `Section`, which wraps every non-HTML block in the page width (`max-w-5xl px-4`). The page's block list is `space-y-10`. Custom HTML blocks already render outside `Section`, so they run full width. The hero-with-form layout comes from add-hero-signup-form.
## Approaches
1. **A `fullWidth` option on HERO (chosen).** Explicit and opt-in, so existing heroes and templates do not change. It costs one boolean and one switch in the editor.
2. **Make every hero with a form full width.** This needs no new field, but it silently changes existing pages and ties two unrelated choices together.
3. **Build the hero in Custom HTML.** This cannot work: a sealed frame cannot hold the real sign-up form (see add-hero-signup-form).
## Decisions
- **Points reuse `cards`.** They use title-only cards, as the trust strip does. The DTO does not change, and the editor reuses the trust strip's item list (`PagesItemN`, `PagesAddItem`). On a HERO the validator allows 0 to 6 cards. FEATURES, STEPS and TRUST keep their 2 to 6 rule.
- **Joins.** A block counts as "bleed" when it is HTML, or when it is a full-width HERO. When a block and the block before it are both bleed, the block gets no top margin. Two Custom HTML blocks next to each other therefore join as well. That changes current pages, but only toward what Custom HTML sections expect: built sections are designed to stack.
- **A full-width hero is not wrapped in `Section`.** It renders outside the page width, in the same way as `HtmlSpot`. Its inner content uses a wider container (`max-w-6xl px-4`).
- **Font.** The headline uses Tailwind's `font-serif`, the system serif. No web font is added, so there is no new dependency and no third-party request.
- **Shade.** The full-width shade is a left-to-right gradient, from `black/75` through `black/45` to `black/10`. It stays black-based, because the design-token test refuses raw colours, and the white text sits on the dark side. On phones the layout stacks and the form card is solid, so contrast holds.
- **Form heading and text.** These are plain text fields edited with `Text` in place, in the same way as the hero heading. They are refused on a hero without an event, so they cannot hide in saved data.
## Risks
- **Contrast with a light photo on the right.** The text sits on the left, over the darkest part of the shade, and the right side holds the solid form card. This is acceptable.
- **Editor controls on the edge.** On the full-width canvas, the image button and the toolbar sit at the window's edge. They are already positioned inside the section by the PR #66 fix.
@@ -0,0 +1,59 @@
# Proposal
## Why
The INS Hotel technology page is being rebuilt in Co-Lite to match INS's standalone landing page (`~/Projects/ins-landing-page`). Since add-hero-signup-form, the form sits beside the hero text, but the hero still looks unlike the original in five ways:
- it is a rounded box inside the page width, with grey space around it, where the original runs edge to edge directly under the top bar;
- its shade is near-black over the whole photo, where the original fades from dark on the left to a clear photo on the right;
- its headline is small and pinned to the top, where the original's is large, serif and vertically centred;
- it has no bullet points under the text;
- the form card has no title or subtitle ("Get a free consultation" / "Tell us about your property…").
Marketing staff cannot fix any of these from the editor.
## What Changes
- A HERO block gains a **Full width** option (`fullWidth`). A full-width hero:
- spans the whole window, with square corners and no page margin;
- is taller, with a larger serif headline, vertically centred;
- uses a lighter shade that runs from dark on the left to almost clear on the right.
- Full-width heroes and Custom HTML blocks that sit next to each other join with no gap, so a Custom HTML top bar runs straight into the hero.
- Custom HTML frames (found in the live check):
- they may shrink to 20 px instead of 100 px, so a 68 px top bar leaves no blank band;
- the page asks each frame for its height once it listens and when the frame loads, because the frame's first report could arrive before the page was ready, leaving it at 600 px.
- A HERO block may carry up to 6 **points**, short title-only lines (`cards`, 80 characters each) shown as a bullet list under its text. The editor reuses the trust strip's item list.
- A HERO with an event may carry a **form heading** (`formHeading`, 80 characters) and **form text** (`formText`, 200 characters), shown at the top of the form card. Both can be typed in place on the canvas.
- The server validates the new fields:
- `fullWidth` is a boolean;
- the hero takes 0 to 6 points, each a non-empty title of at most 80 characters, with no icon or text;
- the form heading and form text are refused on a hero without an event.
- New editor labels in English and Chinese, with an SQL label file for real environments.
Not changing:
- The heroes that exist today. Without the option they look as they do now.
- The sign-up form's fields, the privacy notice and the consent box. They are shared with QR sign-up, and the notice and consent are required by the data-protection rules.
- Field labels and the interests checkboxes.
- The submit button colour, which follows the company's accent colour. For INS's gold button, set INS's accent colour in Companies; that is a setting, not code.
- The red wave decoration at the bottom of the INS hero, which is left out.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`: adds "Full-Width Hero", "Hero Points" and "Hero Form Heading".
## Impact
- services-counter: `CmsBlock` gains `fullWidth`, `formHeading` and `formText`. `CmsBlockValidator` lets a HERO carry `cards` as points and checks the new fields.
- mobile-api: none. Public blocks pass through as maps.
- Portal:
- `CmsBlocks.tsx` renders the hero layout and the joins between full-width blocks;
- `BlockFields.tsx` gets the Full width switch, the points list and the form heading and text;
- `cmsPages.ts` gets the types;
- new labels in `defaultMessages.ts` and `zh_CN.seed.json`.
- Data: no schema change, because the blocks are JSON. The new labels need a SQL label file in this change folder for real environments.
@@ -0,0 +1,86 @@
## ADDED Requirements
### Requirement: Full-Width Hero
A HERO block MAY be marked full width. A full-width hero SHALL span the whole window with square corners, show its heading larger and centred top to bottom in the hero's opening height (not beside a long form), and use a shade that is darker on the text side than on the far side. A hero that is not marked full width SHALL look as it did before. The server SHALL refuse a `fullWidth` value that is not true or false.
#### Scenario: Hero runs edge to edge under a Custom HTML top bar
- **GIVEN** page `/p/INS/hotel-technology` with a Custom HTML top bar followed by a full-width HERO with an image and an event
- **WHEN** a visitor opens the page in a 1280 px window
- **THEN** the hero spans the full window width
- **AND** the form card sits beside the heading
#### Scenario: Existing hero unchanged
- **WHEN** a visitor opens a page whose HERO block is not marked full width
- **THEN** the hero sits inside the page width with rounded corners, as before
#### Scenario: Turn on full width in the editor
- **GIVEN** staff editing a page with a HERO block
- **WHEN** they switch on "Full width" in the hero's settings
- **THEN** the canvas shows the hero across the full width
### Requirement: Full-Width Blocks Join Without Gaps
A full-width HERO and a Custom HTML block next to each other SHALL join with no gap between them, and so SHALL two Custom HTML blocks next to each other. Other blocks SHALL keep their usual spacing.
#### Scenario: Top bar runs straight into the hero
- **GIVEN** a Custom HTML top bar followed by a full-width HERO
- **WHEN** a visitor opens the page
- **THEN** the hero starts directly under the top bar, with no gap
### Requirement: Hero Points
A HERO block MAY carry up to 6 points, each a non-empty title of at most 80 characters, with no icon and no text. The hero SHALL show its points as a bulleted list under its text. The server SHALL refuse more than 6 points, an empty or over-long point, and a point with an icon or text, naming the field.
#### Scenario: Points under the hero text
- **GIVEN** a HERO block with points "One accountable partner instead of five vendors" and "Local support team in Malaysia"
- **WHEN** a visitor opens the page
- **THEN** both points show as a bulleted list under the hero text
#### Scenario: Too many points refused
- **WHEN** staff save a HERO block with 7 points
- **THEN** the save is refused at `blocks[n].cards`
### Requirement: Hero Form Heading
A HERO block with an event MAY carry a form heading of at most 80 characters and a form text of at most 200 characters. The hero SHALL show them at the top of its form card, above the form. The server SHALL refuse either on a hero without an event. On the canvas, staff SHALL be able to type both in place.
#### Scenario: Card shows its heading
- **GIVEN** a HERO block with an event, form heading "Get a free consultation" and form text "Tell us about your property. It takes under a minute."
- **WHEN** a visitor opens the page
- **THEN** the form card starts with that heading and text, followed by the form
#### Scenario: Form heading without a form refused
- **WHEN** staff save a HERO block with a form heading and no event
- **THEN** the save is refused at `blocks[n].formHeading`
## MODIFIED Requirements
### Requirement: Custom HTML Frame Height
The frame SHALL grow or shrink to fit its content, between 20 and 20000 pixels, using height reports sent by that frame only. Before the first report it SHALL be 600 pixels tall. The frame SHALL report the height of its content, not of its own window, and SHALL report again whenever the page asks, which the page SHALL do once it listens and when the frame loads.
#### Scenario: A tall paste grows the frame
- **GIVEN** a published HTML block whose content is 3000 pixels tall
- **WHEN** a visitor opens the page
- **THEN** the frame is 3000 pixels tall and shows no inner scroll bar
#### Scenario: A short top bar shrinks the frame
- **GIVEN** a published HTML block holding only a 68 pixel top bar
- **WHEN** a visitor opens the page, even if the frame loaded before the page was ready
- **THEN** the frame is 68 pixels tall, with no blank space below the bar
#### Scenario: Another frame cannot resize it
- **WHEN** a different window posts a height report to the page
- **THEN** the frame's height does not change
@@ -0,0 +1,13 @@
-- The labels added by add-hero-full-width, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
SET NAMES utf8mb4;
USE `service-system`;
INSERT INTO message (code, content, area) SELECT 'PagesFullWidth', JSON_OBJECT('en_US', 'Full width', 'zh_CN', '全宽'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFullWidth') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '全宽') WHERE LOWER(code) = LOWER('PagesFullWidth') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesPointN', JSON_OBJECT('en_US', 'Point {number}', 'zh_CN', '要点 {number}'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesPointN') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '要点 {number}') WHERE LOWER(code) = LOWER('PagesPointN') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesAddPoint', JSON_OBJECT('en_US', 'Add point', 'zh_CN', '添加要点'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddPoint') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加要点') WHERE LOWER(code) = LOWER('PagesAddPoint') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFormHeading', JSON_OBJECT('en_US', 'Form heading', 'zh_CN', '表单标题'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单标题') WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFormText', JSON_OBJECT('en_US', 'Form text', 'zh_CN', '表单说明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单说明') WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A';
@@ -0,0 +1,69 @@
# Tasks
## 1. Server
- [x] 1.1 services-counter `CmsBlock`: add `fullWidth` (Boolean), `formHeading` and `formText`. `CmsBlockValidator` HERO rules:
- allow `cards` on a HERO, 0 to 6 of them, each with a title that is required and at most 80 characters, and no icon or text;
- `formHeading` at most 80 characters and `formText` at most 200;
- refuse `formHeading` or `formText` without `eventUuid` (`PagesUnusedField`).
Verify: new validator tests fail first, then pass; `mvn -T 1C -pl solvway-services-counter verify`.
## 2. Portal
- [x] 2.1 `cmsPages.ts` types. In `CmsBlocks.tsx`:
- the HERO shows its points as a bulleted list;
- the form card shows `formHeading` and `formText`, editable in place;
- a full-width HERO renders outside the page width, with a larger serif heading, vertical centring and the lighter left-to-right shade;
- adjacent bleed blocks (HTML, or a full-width HERO) get no gap between them.
Verify: render tests fail first, then pass; vitest exit 0.
- [x] 2.2 `BlockFields.tsx`:
- the Hero gets a "Full width" switch, the points list (reusing the trust strip's item list), and the form heading and text fields, shown only when an event is picked;
- `INLINE.HERO` includes `formHeading`, `formText` and the points;
- add the labels to `defaultMessages.ts`, `zh_CN.seed.json` and `sql/01-hero-full-width-labels.sql`, and regenerate `local/seed/04-zh-cn-messages.sql`.
Verify: editor tests fail first, then pass; tsc and lint clean.
## 3. Verification
- [x] 3.1 Rebuild services-counter. Use Playwright on port 3001 to edit `/p/INS/hotel-technology` through the editor:
- turn on Full width;
- add the three INS points;
- set the form heading and text;
- publish the page.
Then check the published page at 1280 px and 390 px against the INS page, and check a save with 7 points shows the refusal on the canvas.
- [x] 3.2 Run the full portal vitest (exit 0), tsc, lint, Maven verify for services-counter, and `openspec validate add-hero-full-width --strict`.
- [x] 3.3 Add a release note to `docs/deployment.md` (label SQL).
## Notes (2026-12-04)
- **Red first:**
- the validator tests failed on points and the form heading;
- the render tests failed on full width, points, the card heading and the joins;
- the editor and company-switch tests failed;
- the frame floor, ask and answer tests failed.
- **Changed existing tests:**
- `CmsBlocks.html.test.tsx` "starts a header-less page flush at the top" now checks that the first block row has no top margin. It used to check for a `space-y` class, which is no longer how spacing works. It still asserts that the hidden title is outside the spacing.
- `frameHtml.test.ts` clamp test: the floor is now 20 px, per the modified "Custom HTML Frame Height" requirement. It also checks that 68 stays 68.
- **Live check** (port 3001, rebuilt counter), on `/p/INS/hotel-technology` through the editor:
- Full width switched on;
- three points and the form heading and text typed on the canvas;
- saved and published.
- **Published result at 1280 px:**
- the hero runs flush under the top bar and into the rest of the page;
- the serif headline is centred in the first screen;
- the points show in the accent colour, and the card has its heading.
- **Published result at 390 px:** the layout stacks, with the card below the text.
- **Fixes from the live check:**
- the text is centred in the opening height, not beside the long form;
- the frame floor is 20 px;
- the page asks frames for their height (both added to the spec).
- **Not reachable in the UI, covered by the validator tests:**
- 7 points, because Add point stops at 6;
- a form heading without a form, because No form clears it.
## Workflow follow-up
- Open a PR to `main` and merge it. Archive the change on its own branch, with its own PR.
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-04
@@ -0,0 +1,44 @@
# Proposal
## Why
Custom HTML blocks hold whole designed sections, such as the INS Hotel technology page. Their images must be served from somewhere. Today the only way to get an image link is to upload it as a hero image and read its id back, or to ask a developer. Marketing staff need to upload an image from the Custom HTML block itself and get a link they can paste into their HTML.
## What Changes
- The Custom HTML block's panel gains an **Upload image** file picker. Choosing a file uploads it at once, for the page's company, with the same checks as every page image:
- PNG, JPEG or WebP;
- at most 2 MB;
- the type is checked by the file's content.
- Each upload made while the panel is open shows:
- a small preview;
- its link (`/api/public/page-images/<id>`) in a read-only box;
- a **Copy link** button.
- A refused upload shows its reason under the picker.
- A new page with no company chosen yet asks for one first.
- The link is relative, so it works on the published page and inside the sealed frame. The INS top bar's logo already loads this way.
Not changing:
- The server. The existing `POST /api/pages/images` upload and the public image address are used as they are.
- Saving. The upload does not touch the page's HTML; staff paste the link where they want it.
- Unused images. They stay stored, as an unused hero upload would. Clean-up is left for later.
- The list of uploads, which is not saved. It shows this session's uploads only.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`: adds "Image Upload For Custom HTML".
## Impact
- Portal:
- `BlockFields.tsx`, the HTML block panel;
- the editor passes the page's company to the panel (or the panel reads it from the draft hook);
- `uploadPageImage` already exists.
- New labels in `defaultMessages.ts` and `zh_CN.seed.json`, a regenerated local seed, and a SQL label file in this change folder.
- No server or schema change.
@@ -0,0 +1,23 @@
## ADDED Requirements
### Requirement: Image Upload For Custom HTML
A Custom HTML block's panel in the editor SHALL offer an image upload for the page's company, under the same checks as other page images. On success it SHALL show the image's preview and its public link with a copy button; on refusal it SHALL show the reason. The upload SHALL NOT change the block's HTML.
#### Scenario: Upload an image for the HTML
- **GIVEN** staff editing an INS page with a Custom HTML block
- **WHEN** they choose `lobby.webp` under "Upload image" in that block's panel
- **THEN** the image is stored for INS and the panel shows its preview and the link `/api/public/page-images/<id>`
- **AND** "Copy link" copies that link, and the block's HTML is unchanged
#### Scenario: Refused upload
- **WHEN** staff choose a 3 MB JPEG under "Upload image"
- **THEN** the panel shows that the image is too large, and no link appears
#### Scenario: New page without a company
- **GIVEN** a super admin's new page with no company chosen
- **WHEN** they choose a file under "Upload image"
- **THEN** nothing is uploaded and the panel asks them to choose a company
@@ -0,0 +1,7 @@
-- The labels added by add-html-image-upload, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
SET NAMES utf8mb4;
USE `service-system`;
INSERT INTO message (code, content, area) SELECT 'PagesUploadImage', JSON_OBJECT('en_US', 'Upload image', 'zh_CN', '上传图片'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '上传图片') WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesUploadImageHint', JSON_OBJECT('en_US', 'PNG, JPEG or WebP up to 2 MB. Paste the link into your HTML, for example in an img tag''s src.', 'zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。') WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A';
@@ -0,0 +1,34 @@
# Tasks
## 1. Portal
- [x] 1.1 HTML block panel: an "Upload image" file picker (`image/png,image/jpeg,image/webp`) uploads at once through `uploadPageImage(companyId, base64)`.
- Each success adds a row: preview, a read-only link `/api/public/page-images/<id>`, and a "Copy link" button that uses the clipboard.
- A refusal shows the translated server reason under the picker.
- With no company, the panel shows "Choose a company." and does not upload.
- The block's HTML is never changed.
Verify: editor tests (success row and copy, refusal, no company, HTML unchanged) fail first, then pass; vitest exit 0; tsc; lint.
- [x] 1.2 Add the labels (`PagesUploadImage`, `PagesUploadImageHint`; the copy button reuses the page-address copy button) to `defaultMessages.ts`, `zh_CN.seed.json` and `sql/01-html-image-labels.sql`, and regenerate `local/seed/04-zh-cn-messages.sql`.
## 2. Verification
- [x] 2.1 Use Playwright on port 3001, signing in through the form and opening Hotel technology from Pages.
- In a Custom HTML block, upload an image, copy the link, and check that the panel shows the preview and the link.
- Upload a file that is not an image and see the refusal.
- Do not change the published page.
- [x] 2.2 Run the full portal vitest (exit 0), tsc, lint, and `openspec validate add-html-image-upload --strict`. Add a release note to `docs/deployment.md` (label SQL).
## Notes (2026-12-04)
- **Red first:** the success, refusal and no-company editor tests all failed, because there was no "Upload image" picker yet. They pass now.
- **Live check** (port 3001): signed in through the form, then opened Hotel technology from Pages.
- In block 3 (Custom HTML), uploaded `hero-bg.webp`. The panel showed the preview and `/api/public/page-images/7` with a copy button.
- A text file named `.png` was refused with "Use a PNG, JPEG or WebP image."
- The page was not saved or published.
- **Fix from the live check:** the link was shown twice (a read-only box and the copy button's text). It now shows once, beside its copy button, which reuses the page-address copy button with a `relative` option.
- **Results:** vitest 1997 passed (exit 0); tsc clean; lint 0 errors (the 4 warnings were already there).
## Workflow follow-up
- Open a PR to `main` and merge it. Archive the change on its own branch, with its own PR.
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-04
@@ -0,0 +1,24 @@
# Design
## Context
The company header and the page title are drawn by `LandingPage`, and "hide page header" (`hideHeader`) removes both. Page settings are database columns threaded through services-counter, mobile-api and the portal. Blocks are JSON validated by `CmsBlockValidator`, so a new block or block field needs no schema change.
## Approaches
1. **A Top bar block, used with "hide page header" (chosen).** It is JSON only: no migration, and no changes to the page records in three services. The INS page already uses "hide page header" with a Custom HTML top bar, so this is a native swap for the same layout.
2. **New page settings** ("hide title", header button label and link, heading font). This is the natural model, but it means four new columns and changes to every page DTO, the draft record, the admin and public APIs, and the settings panel. That is about ten times the work for the same result.
3. **Keep the top bar in Custom HTML.** This is what the original page does; the native page exists to avoid it.
## Decisions
- **The top bar is the first block only.** The server refuses it anywhere else (`PagesTopBarFirst`), because a sticky bar in the middle of a page would cover the content as the visitor scrolls past it. The bar is `sticky top-0` with a card background and a bottom border. It runs full width (it counts as bleed), so it joins a full-width hero below it with no gap.
- **Top bar fields.** Only `buttonLabel` and `buttonUrl` (the pair rule, at most 40 characters, a safe link) plus the usual `anchor`. A heading, text, image, cards or look are refused (`PagesUnusedField`). The logo comes from the company's branding, as the default header's does.
- **The label (`eyebrow`).** At most 40 characters, allowed on FEATURES, STEPS, IMAGE_TEXT, FAQ and CTA, and refused on other types. It renders as a `p` above the h2, not as part of the heading, so screen readers read the heading on its own. It can be edited in place on the canvas.
- **Label colour.** On the DARK band it uses `text-primary`, the accent colour. On light backgrounds the accent can be too pale (INS gold on white is about 2:1), so it uses the accent mixed with the foreground colour, `color-mix(in srgb, var(--primary) 60%, var(--foreground))`. On the ACCENT band it uses the band's own text colour.
- **Serif headings.** Section h2s get `font-serif`, Tailwind's system serif, as the full-width hero does. No web font is added. This changes every landing page, CV's included. It is a small change, and it matches the hero.
## Risks
- **CV pages change font.** CV's section headings become serif. If CV wants sans-serif, a later change can make the font a company setting.
- **Sticky bar and same-page links.** A `#name` jump lands with the heading under the bar. `scroll-margin-top` on the named blocks keeps them clear when a top bar exists.
@@ -0,0 +1,42 @@
# Proposal
## Why
The native INS page (`/p/INS/hotel-technology-native`) now matches INS's standalone page in content, but it still looks different at the top and in its section headings:
- INS has a white top bar with the logo on the left and a "Get My Free Consultation" button on the right. The bar stays at the top while the visitor scrolls. Our page has two choices: show the company header and the page title, which INS does not have, or hide both, which also hides the logo.
- INS puts a small gold uppercase label above each section heading ("Services", "How we work", "Why Infinity", "FAQ"). We have no such label.
- INS's section headings are serif. Ours are sans-serif, except for the full-width hero.
## What Changes
- **Top bar block** (`TOPBAR`). It shows the company logo on the left (the company name when there is no logo) and an optional button on the right (`buttonLabel` and `buttonUrl`, with the same link rules as other buttons). It stays at the top of the window while the page scrolls. It may only be the first block. Together with "hide page header", it gives INS's layout: the logo and button stay, and the title and the default header go.
- **Section labels** (`eyebrow`, at most 40 characters). Feature cards, Steps, Image with text, FAQ and Call to action may carry a short label. It shows above the heading in small uppercase letters in the accent colour, darkened on light backgrounds so it stays readable.
- **Serif section headings.** Section headings (h2) on landing pages use the same serif as the full-width hero.
- New editor labels in English and Chinese, with an SQL label file.
Not changing:
- The page settings and the database. "Hide page header" already exists, and the new fields live in the block JSON.
- Card and step layout, and the bullet style in rich text.
- The default company header on pages without a top bar.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`: adds "Top Bar Block", "Section Labels" and "Serif Section Headings".
## Impact
- services-counter: `CmsBlock` gains `eyebrow`. `CmsBlockValidator` validates TOPBAR and `eyebrow`.
- mobile-api: none. Public blocks pass through as maps.
- Portal:
- `cmsPages.ts`: the TOPBAR type, its label and empty block, and `eyebrow`;
- `CmsBlocks.tsx`: renders the top bar, the labels and the serif headings;
- `BlockFields.tsx`: the top bar's button and the label field;
- labels in `defaultMessages.ts` and `zh_CN.seed.json`.
- Data: no schema change. The new labels need a SQL label file in this change folder.
@@ -0,0 +1,42 @@
## ADDED Requirements
### Requirement: Top Bar Block
A page's first block MAY be a top bar. The top bar SHALL show the company logo, or the company name when there is no logo, and an optional button, and SHALL stay at the top of the window while the page scrolls. The server SHALL refuse a top bar that is not the first block, or one that carries fields other than its button and link name.
#### Scenario: Logo and button without the page title
- **GIVEN** page `/p/INS/hotel-technology-native` with "hide page header" on, a top bar with the button "Get My Free Consultation" linking to `#consult`, and a full-width hero
- **WHEN** a visitor opens the page and scrolls down
- **THEN** the INS logo and the button stay at the top of the window
- **AND** no page title heading shows, and the hero starts directly under the bar
#### Scenario: Top bar further down is refused
- **WHEN** staff save a page whose top bar is the second block
- **THEN** the save is refused with the reason naming that block
### Requirement: Section Labels
Feature cards, Steps, Image with text, FAQ and Call to action blocks MAY carry a label of at most 40 characters. The page SHALL show the label above the block's heading, in small uppercase letters in the accent colour. The server SHALL refuse a longer label, or a label on any other block type.
#### Scenario: Label above a heading
- **GIVEN** a Feature cards block with the label "Services" and the heading "Everything your guests touch, handled by one team"
- **WHEN** a visitor opens the page
- **THEN** "Services" shows in small uppercase letters directly above the heading
#### Scenario: Type a label in the editor
- **GIVEN** staff editing a Steps block
- **WHEN** they type "How we work" in its label field and save
- **THEN** the page keeps the label
### Requirement: Serif Section Headings
Section headings on landing pages SHALL use the serif typeface that the full-width hero uses.
#### Scenario: Feature heading in serif
- **WHEN** a visitor opens a page with a Feature cards block
- **THEN** its heading uses the serif typeface
@@ -0,0 +1,9 @@
-- The labels added by add-landing-page-polish, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
SET NAMES utf8mb4;
USE `service-system`;
INSERT INTO message (code, content, area) SELECT 'PagesBlockTopBar', JSON_OBJECT('en_US', 'Top bar', 'zh_CN', '顶栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesBlockTopBar') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '顶栏') WHERE LOWER(code) = LOWER('PagesBlockTopBar') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesEyebrow', JSON_OBJECT('en_US', 'Label', 'zh_CN', '小标签'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesEyebrow') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '小标签') WHERE LOWER(code) = LOWER('PagesEyebrow') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesTopBarFirst', JSON_OBJECT('en_US', 'The top bar must be the first section.', 'zh_CN', '顶栏必须是第一个区块。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesTopBarFirst') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '顶栏必须是第一个区块。') WHERE LOWER(code) = LOWER('PagesTopBarFirst') AND area = 'A';
@@ -0,0 +1,55 @@
# Tasks
## 1. Server
- [x] 1.1 services-counter `CmsBlock`: add `eyebrow`. `CmsBlockValidator`:
- TOPBAR is allowed only at index 0 (`PagesTopBarFirst`); it takes the button pair and `anchor` only, and any other field is refused (`PagesUnusedField`);
- `eyebrow` at most 40 characters on FEATURES, STEPS, IMAGE_TEXT, FAQ and CTA, and refused elsewhere (`PagesUnusedField`).
Verify: new validator tests fail first, then pass; `mvn -T 1C -pl solvway-services-counter verify`.
## 2. Portal
- [x] 2.1 `CmsBlocks.tsx`:
- renders TOPBAR (logo or name, optional button, sticky, full width, joins a full-width hero);
- renders the label above section headings, in the accent colour, darkened on light backgrounds;
- renders section h2s in serif;
- named blocks keep clear of a sticky bar when jumped to.
Verify: render tests fail first, then pass; vitest exit 0.
- [x] 2.2 Editor:
- `cmsPages.ts`: TOPBAR type, label and empty block; `eyebrow`;
- `BlockFields.tsx`: the top bar's button fields, and the label field on the five types; the label is editable in place on the canvas;
- labels in `defaultMessages.ts`, `zh_CN.seed.json` and `sql/01-polish-labels.sql`; regenerate `local/seed/04-zh-cn-messages.sql`.
Verify: editor tests fail first, then pass; tsc and lint clean.
## 3. Verification
- [x] 3.1 Rebuild services-counter. Use Playwright on port 3001 to edit `/p/INS/hotel-technology-native` through the editor:
- turn on "hide page header";
- add a top bar first, with "Get My Free Consultation" linking to `#consult`;
- add the labels "Services", "How we work", "Why Infinity" and "FAQ";
- publish.
Check the published page at 1280 px and 390 px against the INS page, including the bar staying put on scroll.
- [x] 3.2 Run the full portal vitest (exit 0), tsc, lint, Maven verify for services-counter, and `openspec validate add-landing-page-polish --strict`.
- [x] 3.3 Add a release note to `docs/deployment.md` (label SQL).
## Notes (2026-12-04)
- **Red first:**
- the validator tests failed on the top bar and the labels;
- the render tests failed on the top bar, the scroll margin, the labels and the serif headings;
- the editor test failed on the label field and the top bar.
- **Changed existing tests:** none. One of my own new render tests changed before going green: the sticky class sits on the top bar's row, not on the header. A sticky element only sticks inside its parent, and the header's parent is just as tall as the header.
- **Live check** (port 3001, rebuilt counter), on `/p/INS/hotel-technology-native` through the editor:
- "hide page header" was already on;
- added a Top bar section, moved it first, and set "Get My Free Consultation" linking to `#consult`;
- typed the labels "Services", "How we work", "Why Infinity" and "FAQ" on the canvas;
- saved and published.
- **Published result:**
- at 1280 px the logo and button sit in a white bar above the full-width hero, with no title, and the bar stays at the top while scrolling;
- the labels show in darkened gold uppercase above serif headings;
- at 390 px the bar keeps the logo and button, and the hero stacks.
- **Not reachable in the UI, covered by the validator tests:** a top bar that is not first is refused (the server rule; the editor's Move up and Move down allow it, and the refusal shows on the canvas).
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-04
@@ -0,0 +1,30 @@
# Design
## Context
Landing blocks are JSON validated by `CmsBlockValidator` and rendered by `CmsBlocks.tsx`. Card blocks (FEATURES, STEPS, TRUST, HERO points) share `cards` and the editor's card list in `BlockFields.tsx`. Text is edited in place with `Text`, which renders plain text outside the editor. The landing form's done state is `VisitorState` with the `RegThanks` heading.
## Approaches
1. **A FOOTER block built on `cards` (chosen).** Columns are cards with a title and text, the legal line is the block's `text`. The DTO gains nothing for the footer, and the editor reuses the card list. Staff get a footer that looks right without formatting.
2. **Columns and link colours on the Rich Text block.** This keeps one block type, but staff would have to build columns and links by hand, and every rich text block would gain layout options.
3. **Keep the footer in Custom HTML.** This is what the original page does; the native page exists to avoid it.
For the thank-you text, a field on the form-bearing blocks is the only sensible way: the message belongs to the page, not to the event, because one event can have several pages.
## Decisions
- **Links are found, not typed.** One helper splits plain text into text and links:
- `+` followed by digits, spaces and dashes (at least 8 digits) becomes `tel:` with only `+` and digits;
- an email address becomes `mailto:`;
- `https://…` and `www.…` become `https://` links that open in a new tab with `rel="noopener noreferrer"`.
It builds React elements, never HTML, so text stays text. `Text` gains a `links` flag that uses it outside the editor; in the editor the text stays editable as now.
- **Footer validation.** 1 to 4 cards, each with a required title (80) and required text (300), no icon. `text` at most 300. No heading.
- **Footer look.** `emptyBlock("FOOTER")` sets `look: "DARK"`. Links use the existing link colour (`text-primary`), which is the company's accent colour, so INS's footer links are gold.
- **Thank-you text.** `thanksText` (200) on FORM, and on HERO only with an event, like `formHeading`. `LandingForm` takes it as `thanks` and passes it to `VisitorState`'s text, through the link helper. Choosing "No form" on a hero, or changing company, clears it along with the event.
- **Shade.** The design-token test refuses raw colours, so the shade stays black-based: `from-black/55 to-black/10 to-70%` from the `md` width, and an even `black/60` below it. White text keeps contrast because the text sits on the darker left.
## Risks
- **Phone detection.** Only numbers written with `+` become links. A local number like "03-7623 9807" stays plain text. This is deliberate, to avoid linking dates or prices.
- **Lighter shade over a bright photo.** The headline could lose contrast. The hero heading is large and bold, and INS uses the same shade; staff can pick a darker photo.
@@ -0,0 +1,48 @@
# Proposal
## Why
The INS Hotel technology page is being rebuilt in Co-Lite without Custom HTML, to match INS's standalone page (`~/Projects/ins-landing-page`). After add-compact-landing-form, the content matches, but three things still differ, and marketing staff cannot fix them from the editor:
- After signing up, INS shows "Thanks! Our team will contact you shortly. Prefer to talk now? Call +60 12-833 2775", with the number as a tap-to-call link. Our landing form shows the same generic thank-you on every page.
- INS's footer has up to three columns (company and address, "Talk to us" with phone and email, website). The phone, email and web address are gold links, and the © line sits under a thin divider. Ours is one stacked column of plain rich text.
- INS's hero shade is lighter, so more of the photo shows. Ours is near-black on the text side.
## What Changes
- **Thank-you text.** The FORM block and a HERO with an event MAY carry `thanksText` (at most 200 characters). After a visitor signs up, it shows under the "Thank you" heading. Phone numbers that start with `+`, email addresses, and `https://` or `www.` web addresses in it become links. Without it, the thank-you stays as it is now. The server refuses it on a HERO without an event.
- **Footer block.** A new block type, FOOTER:
- 1 to 4 columns, each a bold title (80 characters) and text (300 characters, line breaks kept);
- an optional legal line (`text`, 300 characters) under a thin divider;
- phone numbers, emails and web addresses in the column text become links in the link colour;
- a new footer starts with the dark look; staff may change the look as on any block.
- **Lighter full-width hero shade.** The full-width hero's shade runs from about half dark on the text side to almost clear at 70% of the width, like INS. On phones, where the text sits over the whole photo, the shade is an even dark layer.
- New editor labels in English and Chinese, with an SQL label file for real environments.
Not changing:
- QR and invitation sign-up thank-you screens.
- The Rich Text block. Existing footers built with it keep working.
- Heroes that are not full width.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`: adds "Thank-You Text On Landing Forms" and "Footer Block".
## Impact
- services-counter: `CmsBlock` gains `thanksText`. `CmsBlockValidator` checks `thanksText` on FORM and HERO and validates the FOOTER type.
- mobile-api: none. Public blocks pass through as maps.
- Portal:
- `cmsPages.ts`: the FOOTER type, its empty block and label;
- a small link-finding helper used by the footer and the thank-you text;
- `CmsBlocks.tsx` renders the footer, passes the thank-you text and lightens the shade;
- `LandingForm.tsx` shows the thank-you text;
- `BlockFields.tsx` gets the footer's columns and legal line, and the thank-you field on FORM and HERO;
- labels in `defaultMessages.ts` and `zh_CN.seed.json`.
- Data: no schema change, because the blocks are JSON. The new labels need a SQL label file in this change folder.
@@ -0,0 +1,64 @@
## ADDED Requirements
### Requirement: Thank-You Text On Landing Forms
A FORM block, and a HERO block with an event, MAY carry a thank-you text of at most 200 characters. After a visitor signs up through that block's form, the page SHALL show the text, with contact links, under the thank-you heading. Without it, the thank-you SHALL look as before. The server SHALL refuse an over-long thank-you text, or one on a HERO without an event.
#### Scenario: Visitor sees the page's thank-you text with a call link
- **GIVEN** page `/p/INS/hotel-technology-native` whose hero form has the thank-you text "Prefer to talk now? Call +60 12-833 2775."
- **WHEN** a visitor signs up through the hero form
- **THEN** the page shows the thank-you heading and "Prefer to talk now? Call +60 12-833 2775."
- **AND** "+60 12-833 2775" is a link to `tel:+60128332775`
#### Scenario: No thank-you text keeps today's message
- **WHEN** a visitor signs up through a FORM block without a thank-you text
- **THEN** the page shows only the thank-you heading and the "register another" button, as before
#### Scenario: Thank-you text on a hero without a form is refused
- **WHEN** staff save a HERO block without an event but with a thank-you text
- **THEN** the save is refused with the reason naming the hero's thank-you field
#### Scenario: Set the thank-you text in the editor
- **GIVEN** staff editing a hero that has an event
- **WHEN** they type a thank-you text in the hero's settings and save
- **THEN** the page keeps the text
- **AND** choosing "No form" on the hero clears it
### Requirement: Footer Block
A page MAY hold FOOTER blocks: 1 to 4 columns, each a required title (80 characters) and text (300 characters), and an optional legal line (300 characters). The page SHALL show the columns side by side on wide screens and stacked on phones, keep line breaks, show contact links in the column text, and put the legal line under a thin divider. A new footer SHALL start with the dark look. The server SHALL refuse a footer that breaks these limits, or that has a heading or a column icon.
#### Scenario: Visitor sees a three-column footer with links
- **GIVEN** a published page whose footer has the columns "Infinity Networks Security Sdn Bhd", "Talk to us" with "+603-7623 9807" and "info@infinitynetworks.com.my", and "Website" with "www.infinitynetworks.com.my", and a legal line
- **WHEN** a visitor opens the page in a 1280 px window
- **THEN** the three columns sit side by side on a dark band
- **AND** the phone links to `tel:+60376239807`, the email to `mailto:info@infinitynetworks.com.my`, and the website to `https://www.infinitynetworks.com.my`
- **AND** the legal line sits under a divider
#### Scenario: Add a footer in the editor
- **GIVEN** staff editing a page
- **WHEN** they add a Footer section
- **THEN** the canvas shows a dark footer with two empty columns to type into
- **AND** they can add columns up to 4 and type the legal line
#### Scenario: Footer with five columns is refused
- **WHEN** a page is saved with a footer of 5 columns
- **THEN** the save is refused with the reason naming the footer's columns
### Requirement: Contact Links In Plain Text
Where this spec says text shows contact links, the page SHALL show phone numbers that start with `+` as `tel:` links holding only `+` and digits, email addresses as `mailto:` links, and `https://` or `www.` addresses as `https://` links that open in a new tab. Everything else SHALL stay plain text, never HTML.
#### Scenario: Text with markup stays text
- **GIVEN** a footer column text "<b>Call</b> +60 12-833 2775"
- **WHEN** a visitor opens the page
- **THEN** "<b>Call</b>" shows as written
- **AND** "+60 12-833 2775" links to `tel:+60128332775`
@@ -0,0 +1,13 @@
-- The labels added by add-landing-thanks-and-footer, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
SET NAMES utf8mb4;
USE `service-system`;
INSERT INTO message (code, content, area) SELECT 'PagesThanksText', JSON_OBJECT('en_US', 'Thank-you text', 'zh_CN', '感谢语'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesThanksText') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '感谢语') WHERE LOWER(code) = LOWER('PagesThanksText') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesBlockFooter', JSON_OBJECT('en_US', 'Footer', 'zh_CN', '页脚'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesBlockFooter') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '页脚') WHERE LOWER(code) = LOWER('PagesBlockFooter') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesColumnN', JSON_OBJECT('en_US', 'Column {number}', 'zh_CN', '第 {number} 栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesColumnN') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '第 {number} 栏') WHERE LOWER(code) = LOWER('PagesColumnN') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesAddColumn', JSON_OBJECT('en_US', 'Add column', 'zh_CN', '添加栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddColumn') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加栏') WHERE LOWER(code) = LOWER('PagesAddColumn') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFooterLegal', JSON_OBJECT('en_US', 'Legal line', 'zh_CN', '版权声明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFooterLegal') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '版权声明') WHERE LOWER(code) = LOWER('PagesFooterLegal') AND area = 'A';
@@ -0,0 +1,52 @@
# Tasks
## 1. Server
- [x] 1.1 services-counter `CmsBlock`: add `thanksText`. `CmsBlockValidator`:
- `thanksText` at most 200 on FORM and HERO; refused on a HERO without `eventUuid` and on every other type (`PagesUnusedField`);
- FOOTER: no heading; 1 to 4 cards, each with a required title (80) and required text (300) and no icon; `text` at most 300.
Verify: new validator tests fail first, then pass; `mvn -T 1C -pl solvway-services-counter verify`.
## 2. Portal
- [x] 2.1 Link helper and rendering:
- a helper that turns plain text into text and links (`+` phone numbers, emails, `https://` and `www.` addresses), building elements, never HTML;
- `Text` gains `links`;
- `CmsBlocks.tsx` renders FOOTER (columns, line breaks, legal line under a divider), passes `thanksText` to `LandingForm`, and lightens the full-width hero shade;
- `LandingForm.tsx` shows the thank-you text under the heading.
Verify: render tests fail first, then pass; vitest exit 0.
- [x] 2.2 Editor:
- `cmsPages.ts`: FOOTER type, label and empty block (dark look, two columns);
- `BlockFields.tsx`: the footer's columns (1 to 4) and legal line; the thank-you field on FORM, and on HERO when an event is picked; "No form" and company change clear it;
- labels in `defaultMessages.ts`, `zh_CN.seed.json`, `sql/01-thanks-footer-labels.sql`; regenerate `local/seed/04-zh-cn-messages.sql`.
Verify: editor tests fail first, then pass; tsc and lint clean.
## 3. Verification
- [x] 3.1 Rebuild services-counter. Use Playwright on port 3001 to edit `/p/INS/hotel-technology-native` through the editor:
- set the hero's thank-you text to "Prefer to talk now? Call +60 12-833 2775.";
- replace the rich text footer with a Footer section matching INS;
- publish.
Check the published page at 1280 px and 390 px. The thank-you screen needs a real sign-up, which writes a record: check it in the editor preview path only if it does not save, otherwise ask the owner first.
- [x] 3.2 Run the full portal vitest (exit 0), tsc, lint, Maven verify for services-counter, and `openspec validate add-landing-thanks-and-footer --strict`.
- [x] 3.3 Add a release note to `docs/deployment.md` (label SQL).
## Notes (2026-12-04)
- **Red first:**
- the validator tests failed on the thank-you text and the footer;
- the render tests failed on the thank-you text, the footer and the link helper (missing module);
- the editor tests failed on the Footer section, the hero's thank-you field and the company switch.
- **Changed existing tests:** none. Two of my own new editor tests were fixed before going green: column names shift after a removal, and the Form block has its own thank-you field, so the hero checks are scoped to block 1.
- **Design-token checks:** the phone shade uses an even black gradient (`bg-black/60` is refused), and the divider uses `border-muted-foreground/30` (`border-current/15` is not in Tailwind 3).
- **Live check** (port 3001, rebuilt counter), on `/p/INS/hotel-technology-native` through the editor:
- typed the hero's thank-you text "Prefer to talk now? Call +60 12-833 2775.";
- added a Footer section with three columns and the legal line, and removed the old Text footer;
- saved and published.
- **Published result:** at 1280 px the three columns sit side by side on the dark band with gold tel, mailto and https links, and the legal line sits under a divider; at 390 px they stack. The hero shade is lighter.
- **Not run live:** the thank-you screen itself, because it needs a real sign-up, which writes a record. The render tests cover it (thank-you text and the tel link after a mocked sign-up).
- **Not reachable in the UI, covered by the validator tests:** 5 footer columns (Add column stops at 4), and a thank-you text on a hero without a form (No form clears it).
+88
View File
@@ -0,0 +1,88 @@
# cluster-deployment Specification
## Purpose
Describe how Co-Lite is rolled out to Kubernetes from manifests in the repository, so that public exposure, secrets, image versions and rollback are fixed in reviewed files rather than typed by hand.
## Requirements
### Requirement: One manifest set deploys the whole system
The repository SHALL hold Kubernetes manifests that create a Deployment and a Service for each published image. The Service names and ports MUST be the ones the gateway, mobile-api and the portal already expect (`docs/deployment.md` section 1). Each Java service MUST have liveness and readiness probes on its actuator health endpoints. The admin portal MUST have a probe that needs no session.
#### Scenario: Apply brings every service up
- **GIVEN** a cluster where the Secrets, the mounted files, the database and the image pull secret already exist
- **WHEN** the deployer applies the `prod` overlay
- **THEN** a Deployment and a Service exist for all ten images under the expected names and ports
- **AND** every pod becomes ready
#### Scenario: Unhealthy pod gets no traffic
- **GIVEN** a Java service whose readiness endpoint reports down
- **WHEN** Kubernetes checks the pod
- **THEN** the pod is not ready and its Service sends it no requests
### Requirement: Only the portal and the WhatsApp webhook are public
The manifests SHALL route the public host, over TLS, to the admin-portal Service. They SHALL route exactly the path `/api/public/whatsapp/webhook` to the mobile-api Service. No other Service may be reachable from outside the cluster. The repository's manifest check MUST fail when a route targets any other Service or path.
#### Scenario: Gateway is not reachable from the internet
- **WHEN** the rendered `prod` manifests are checked
- **THEN** no route targets `api-gateway` or any `service-*`
- **AND** the only route to `mobile-api` matches exactly `/api/public/whatsapp/webhook`
#### Scenario: A new route is caught
- **GIVEN** a manifest change that adds a route to `api-gateway`
- **WHEN** the manifest check runs
- **THEN** it fails and names the route
### Requirement: Secrets never enter the repository
The manifests SHALL refer to Secrets and mounted files only by name. The repository MUST NOT hold any real secret value. Secret templates hold placeholders only. The script that creates the Secrets MUST read the values from files that git ignores.
#### Scenario: Rendered manifests hold no secret data
- **WHEN** the `prod` overlay is rendered
- **THEN** it contains no `Secret` object with data
- **AND** the manifest check fails if one appears
#### Scenario: Filled-in secret files cannot be committed
- **GIVEN** a deployer who fills in the secret files under the secrets folder
- **WHEN** they run `git status`
- **THEN** those files are ignored
### Requirement: Releases are pinned by commit and can be rolled back
The `prod` overlay SHALL pin every image to one commit SHA, never `latest`. Rolling back MUST be done by setting the previous SHA and applying again. The deployment docs MUST describe both steps. Before a real apply, a release check MUST refuse any cluster fact still left as a placeholder.
#### Scenario: latest is refused
- **GIVEN** a `prod` overlay where an image tag is `latest` or missing
- **WHEN** the manifest check runs
- **THEN** it fails and names the image
#### Scenario: Unfilled cluster fact refused before apply
- **GIVEN** a `prod` overlay that still holds a `<…>` placeholder, such as the MySQL host
- **WHEN** the deployer runs the release check
- **THEN** it fails and names each placeholder
#### Scenario: Roll back to the previous release
- **GIVEN** a release at SHA B that misbehaves, with SHA A deployed before it
- **WHEN** the deployer sets the overlay to SHA A and applies it
- **THEN** every Deployment rolls back to the SHA A images
### Requirement: Single-run jobs stay single
service-counter SHALL run as exactly one replica. It sends the daily follow-up summary, and two replicas would send it twice. The manifest check MUST fail when service-counter has more than one replica.
#### Scenario: Counter scaled by mistake
- **GIVEN** a manifest change that sets service-counter to two replicas
- **WHEN** the manifest check runs
- **THEN** it fails
+356 -8
View File
@@ -63,7 +63,7 @@ A page save SHALL be refused with the offending field path, writing nothing, whe
### Requirement: Block References Stay Inside The Company
A block's image SHALL be an image of the page's company, and a FORM block's event SHALL be an event of the page's company. Otherwise the save SHALL be refused on that field.
A block's image SHALL be an image of the page's company, and the event of a FORM block or of a HERO block that names one SHALL be an event of the page's company. Otherwise the save SHALL be refused on that field.
#### Scenario: Another company's event
@@ -71,6 +71,12 @@ A block's image SHALL be an image of the page's company, and a FORM block's even
- **WHEN** INS staff save a FORM block pointing at `CV Roadshow`
- **THEN** the save is refused on that block's event field
#### Scenario: Another company's event in a hero
- **GIVEN** event `CV Roadshow` belongs to CV
- **WHEN** INS staff save a HERO block whose event is `CV Roadshow`
- **THEN** the save is refused on that block's event field
### Requirement: Page Content Cannot Run Scripts
A button SHALL have both a label and a link or neither. The link SHALL start with a single `/`, `https://`, `mailto:`, `tel:`, or `#` plus a valid block link name. A save SHALL be refused when RICH_TEXT or IMAGE_TEXT HTML holds a `script` element, an `on*` attribute or a `javascript:` URL. The public page SHALL also sanitise that HTML against an allow-list. HTML blocks are exempt: they only run sealed.
@@ -209,7 +215,7 @@ Pages and page images SHALL follow the company scoping rules: staff see, edit an
### Requirement: The Page Editor
The editor SHALL offer the title, a slug filled from the title until edited, a meta description with a 160-character counter, the status and the block list. Blocks SHALL be added, moved up or down and removed. A chosen image SHALL be uploaded only when the page is saved. A FORM block SHALL pick from the company's enabled events that have not ended.
At 1024 px and wider the editor SHALL be the on-page editor. Below 1024 px it SHALL be the form editor. Both SHALL offer the title, a slug filled from the title until edited, a meta description with a 160-character counter, the status, adding, moving and removing blocks, and images uploaded only on save. A FORM block SHALL pick from the company's enabled events that have not ended.
#### Scenario: Slug follows the title until edited
@@ -217,14 +223,25 @@ The editor SHALL offer the title, a slug filled from the title until edited, a m
- **WHEN** staff type the title "Hotel Technology"
- **THEN** the slug becomes `hotel-technology`
#### Scenario: Narrow window keeps the form
- **WHEN** staff open a page in a window 900 px wide
- **THEN** the form editor shows, with Preview
### Requirement: Saving And Deleting In The Editor
Server field errors SHALL show next to their fields, keeping all entered values. After a save the editor SHALL offer a link to view the page. Deleting a page SHALL ask first, and unsaved edits SHALL be guarded.
Server field errors SHALL show at their fields, keeping all entered values. After a save the editor SHALL offer a link to view the page. Deleting a page SHALL ask first. With unsaved edits, reloading, closing and following an in-app link SHALL ask first.
#### Scenario: Server error at its field
- **WHEN** staff save a HERO button link `javascript:alert(1)`
- **THEN** the error shows next to that button link and every entered value stays
- **THEN** the error shows at that button link and every entered value stays
#### Scenario: Leaving by an in-app link
- **GIVEN** staff changed a heading and did not save
- **WHEN** they click Pages in the menu
- **THEN** the editor asks before leaving, and Cancel keeps them on the page with the change
### Requirement: Custom HTML Runs Sealed
@@ -261,7 +278,7 @@ The public frame address SHALL be `/p/<company>/<slug>/frame/<block index>` and
### Requirement: Custom HTML Frame Height
The frame SHALL grow to fit its content, between 100 and 20000 pixels, using height reports sent by that frame only. Before the first report it SHALL be 600 pixels tall.
The frame SHALL grow or shrink to fit its content, between 20 and 20000 pixels, using height reports sent by that frame only. Before the first report it SHALL be 600 pixels tall. The frame SHALL report the height of its content, not of its own window, and SHALL report again whenever the page asks, which the page SHALL do once it listens and when the frame loads.
#### Scenario: A tall paste grows the frame
@@ -269,6 +286,12 @@ The frame SHALL grow to fit its content, between 100 and 20000 pixels, using hei
- **WHEN** a visitor opens the page
- **THEN** the frame is 3000 pixels tall and shows no inner scroll bar
#### Scenario: A short top bar shrinks the frame
- **GIVEN** a published HTML block holding only a 68 pixel top bar
- **WHEN** a visitor opens the page, even if the frame loaded before the page was ready
- **THEN** the frame is 68 pixels tall, with no blank space below the bar
#### Scenario: Another frame cannot resize it
- **WHEN** a different window posts a height report to the page
@@ -276,13 +299,20 @@ The frame SHALL grow to fit its content, between 100 and 20000 pixels, using hei
### Requirement: The Custom HTML Block In The Editor
The editor SHALL offer "Add Custom HTML", which adds an HTML block with a monospace text box, a 200000-character counter and a note that forms inside the pasted HTML do not send and the sign-up form block collects leads. The editor SHALL also offer a "hide page header" switch for the page.
The editor SHALL offer adding a Custom HTML block, edited in a monospace text box with a 200000-character counter and a note that forms inside it do not send. On the canvas the block SHALL show its last saved version as a sealed frame, marked "Save to update" while its HTML has unsaved edits. The editor SHALL offer a "hide page header" switch.
#### Scenario: Adding a Custom HTML block
- **WHEN** staff add a Custom HTML block and paste HTML into it
- **THEN** the block shows the pasted HTML, the character count and the note about forms
#### Scenario: Unsaved HTML on the canvas
- **GIVEN** a saved page with a Custom HTML block
- **WHEN** staff change its HTML in the panel
- **THEN** the canvas marks the block "Save to update"
- **AND** after Save the canvas shows the new HTML
#### Scenario: Hiding the header
- **WHEN** staff turn on "hide page header" and save
@@ -412,13 +442,13 @@ A HERO block MAY have no image; it then shows its heading, text and button on it
### Requirement: New Sections In The Editor
The page editor SHALL offer adding FEATURES, STEPS, TRUST and CTA blocks, editing their fields, adding, removing and reordering cards, and choosing any block's look. Refusals SHALL show at the field they name, including card fields.
Both editors SHALL offer adding FEATURES, STEPS, TRUST and CTA blocks, editing their fields, adding, removing and reordering cards, and choosing any block's look. Refusals SHALL show at the field they name, including card fields.
#### Scenario: A refused card title shows at its field
- **GIVEN** staff editing a page with a FEATURES block
- **WHEN** the save is refused on field `blocks[0].cards[1].title`
- **THEN** the message shows under the second card's title field
- **THEN** the message shows at the second card's title field
### Requirement: Published Pages Keep A Separate Draft
@@ -483,3 +513,321 @@ Duplicate SHALL open the editor with a copy of the page's current content (its d
- **GIVEN** INS page `hotel` titled "Hotel day"
- **WHEN** staff press Duplicate on it and save
- **THEN** a new draft INS page `hotel-copy` titled "Hotel day (copy)" exists with the same sections
### Requirement: The Page Canvas
The on-page editor SHALL show the page on a canvas, rendered as visitors see it, with a Desktop view (1280 px wide, scaled to fit) and a Phone view (390 px wide). Changes SHALL show on the canvas as they are made, before saving. Links and buttons on the canvas SHALL NOT navigate, and the sign-up form SHALL show its preview note.
#### Scenario: Phone view uses the phone layout
- **GIVEN** a page with a FEATURES block of three cards
- **WHEN** staff switch to Phone
- **THEN** the cards stack in one column on the canvas
#### Scenario: A change shows before saving
- **WHEN** staff change a FEATURES card title in the side panel
- **THEN** the canvas shows the new title at once
### Requirement: Edit Text On The Page
Clicking a heading, short text, button label, card title or text, or FAQ question or answer on the canvas SHALL edit it in place as plain text, with the server's length limit shown when close. Rich text SHALL be edited in place with bold, italic, link, lists and alignment, and links SHALL follow the page link rule. An empty field SHALL show a faded cue naming it, and empty rich text SHALL keep room to click into. Clicking an image spot SHALL open the file picker.
#### Scenario: Edit a heading in place
- **WHEN** staff click the hero heading on the canvas and type "Hotel week"
- **THEN** the canvas and the side panel show "Hotel week"
#### Scenario: An unsafe link is refused in rich text
- **WHEN** staff add the link `javascript:alert(1)` in a Text block on the canvas
- **THEN** the link is not added and the toolbar says why
### Requirement: Section Selection And Actions
Clicking a section on the canvas SHALL select it, outline it and show its settings in the side panel. With none selected, the panel SHALL show the page settings. A selected section SHALL offer drag, up, down, duplicate and delete. "Add section" between sections and at the end SHALL offer every block type. Up and down SHALL work from the keyboard. A section that is added, duplicated or moved SHALL be brought into view on the canvas.
#### Scenario: Duplicate a section
- **WHEN** staff select the second section and press Duplicate
- **THEN** a copy appears as the third section and is selected
#### Scenario: Add a section between two
- **WHEN** staff press Add section between the first and second sections and choose Steps
- **THEN** a Steps section appears second and is selected
#### Scenario: Add a section from the side panel
- **GIVEN** the canvas shows the top of a long page
- **WHEN** staff press Add Text in the side panel
- **THEN** the canvas scrolls to the new Text section at the end, which shows a faded "Content" cue to type into
### Requirement: Undo And Redo
The on-page editor SHALL undo and redo page changes, up to 50 steps, by buttons and by Ctrl+Z and Ctrl+Shift+Z. The keys SHALL work wherever focus is in the editor, including after the focused control is removed or disabled, except inside a field outside the editor. Typing in one field SHALL be one step. Saving SHALL NOT clear the history.
#### Scenario: Undo a delete
- **GIVEN** staff deleted the FAQ section
- **WHEN** they press Ctrl+Z
- **THEN** the FAQ section is back in its place with its content
### Requirement: Refusals On The Canvas
When a save or publish is refused on a block field, the editor SHALL select that block, outline it, scroll it into view and show the message at the field in the side panel. A refusal on a page field SHALL show in the page settings.
#### Scenario: A form without an event
- **GIVEN** a page from the Event sign-up template
- **WHEN** staff save without choosing the form's event
- **THEN** the form section is selected and outlined and the panel shows the message at the Event field
### Requirement: Hero With A Sign-Up Form
A HERO block MAY name an event. When it does, the hero SHALL show Co-Lite's sign-up form for that event in a card beside its heading, text and button on wide screens, and below them on narrow screens. The hero's form SHALL follow every rule of the FORM block (see "The Form Block Registers For An Event" and "The Form Block Closes With Its Event"). A HERO block without an event SHALL show no form.
#### Scenario: Sign up from the hero
- **GIVEN** page `/p/INS/hotel-technology` has a HERO block whose event is `INS website enquiries`
- **WHEN** a new visitor submits the form in the hero from a URL with `utm_source=facebook`
- **THEN** a new lead and an event lead with source Web page, no salesperson and UTM source `facebook` are created
#### Scenario: Hero form closes with its event
- **GIVEN** the HERO block's event ended yesterday
- **WHEN** a visitor opens the page
- **THEN** the hero still shows its heading and text, and its form area says sign-up is closed
#### Scenario: Hero without an event
- **WHEN** a visitor opens a page whose HERO block names no event
- **THEN** the hero shows no form
- **AND** a submit addressed to that block is refused as not found
#### Scenario: Pick the hero's event in the editor
- **GIVEN** staff editing a page with a HERO block
- **WHEN** they pick `INS website enquiries` under the hero's sign-up form setting
- **THEN** the canvas shows the form card beside the hero text
- **AND** choosing "No form" removes it
### Requirement: Full-Width Hero
A HERO block MAY be marked full width. A full-width hero SHALL span the whole window with square corners, show its heading larger and centred top to bottom in the hero's opening height (not beside a long form), and use a shade that is darker on the text side than on the far side. A hero that is not marked full width SHALL look as it did before. The server SHALL refuse a `fullWidth` value that is not true or false.
#### Scenario: Hero runs edge to edge under a Custom HTML top bar
- **GIVEN** page `/p/INS/hotel-technology` with a Custom HTML top bar followed by a full-width HERO with an image and an event
- **WHEN** a visitor opens the page in a 1280 px window
- **THEN** the hero spans the full window width
- **AND** the form card sits beside the heading
#### Scenario: Existing hero unchanged
- **WHEN** a visitor opens a page whose HERO block is not marked full width
- **THEN** the hero sits inside the page width with rounded corners, as before
#### Scenario: Turn on full width in the editor
- **GIVEN** staff editing a page with a HERO block
- **WHEN** they switch on "Full width" in the hero's settings
- **THEN** the canvas shows the hero across the full width
### Requirement: Full-Width Blocks Join Without Gaps
A full-width HERO, a Custom HTML block, and a block with a non-default look SHALL join with no gap when two of them are next to each other. Other blocks SHALL keep their usual spacing.
#### Scenario: Top bar runs straight into the hero
- **GIVEN** a Custom HTML top bar followed by a full-width HERO
- **WHEN** a visitor opens the page
- **THEN** the hero starts directly under the top bar, with no gap
#### Scenario: Dark call to action runs into a dark footer
- **GIVEN** a CTA block with the Dark look followed by a text block with the Dark look
- **WHEN** a visitor opens the page
- **THEN** the two bands join with no gap between them
### Requirement: Hero Points
A HERO block MAY carry up to 6 points, each a non-empty title of at most 80 characters, with no icon and no text. The hero SHALL show its points as a bulleted list under its text. The server SHALL refuse more than 6 points, an empty or over-long point, and a point with an icon or text, naming the field.
#### Scenario: Points under the hero text
- **GIVEN** a HERO block with points "One accountable partner instead of five vendors" and "Local support team in Malaysia"
- **WHEN** a visitor opens the page
- **THEN** both points show as a bulleted list under the hero text
#### Scenario: Too many points refused
- **WHEN** staff save a HERO block with 7 points
- **THEN** the save is refused at `blocks[n].cards`
### Requirement: Hero Form Heading
A HERO block with an event MAY carry a form heading of at most 80 characters and a form text of at most 200 characters. The hero SHALL show them at the top of its form card, above the form. The server SHALL refuse either on a hero without an event. On the canvas, staff SHALL be able to type both in place.
#### Scenario: Card shows its heading
- **GIVEN** a HERO block with an event, form heading "Get a free consultation" and form text "Tell us about your property. It takes under a minute."
- **WHEN** a visitor opens the page
- **THEN** the form card starts with that heading and text, followed by the form
#### Scenario: Form heading without a form refused
- **WHEN** staff save a HERO block with a form heading and no event
- **THEN** the save is refused at `blocks[n].formHeading`
### Requirement: Image Upload For Custom HTML
A Custom HTML block's panel in the editor SHALL offer an image upload for the page's company, under the same checks as other page images. On success it SHALL show the image's preview and its public link with a copy button; on refusal it SHALL show the reason. The upload SHALL NOT change the block's HTML.
#### Scenario: Upload an image for the HTML
- **GIVEN** staff editing an INS page with a Custom HTML block
- **WHEN** they choose `lobby.webp` under "Upload image" in that block's panel
- **THEN** the image is stored for INS and the panel shows its preview and the link `/api/public/page-images/<id>`
- **AND** "Copy link" copies that link, and the block's HTML is unchanged
#### Scenario: Refused upload
- **WHEN** staff choose a 3 MB JPEG under "Upload image"
- **THEN** the panel shows that the image is too large, and no link appears
#### Scenario: New page without a company
- **GIVEN** a super admin's new page with no company chosen
- **WHEN** they choose a file under "Upload image"
- **THEN** nothing is uploaded and the panel asks them to choose a company
### Requirement: Compact Landing-Page Form
A landing page's sign-up form, in a FORM block or a hero, SHALL show name, mobile, email and company, the event's interests as one optional dropdown, the privacy notice folded behind a single line that opens it in full, and the consent box. It SHALL NOT show a job-title field. QR, invitation and customer sign-up forms SHALL keep their full layout.
#### Scenario: Short form on the page
- **GIVEN** a page whose hero has an event with five interests
- **WHEN** a visitor opens the page
- **THEN** the form shows name, mobile, email, company, a "Service interested in" dropdown and the consent box, with no job title and no interest checkboxes
- **AND** the privacy notice is folded behind "How we use your details"
#### Scenario: Pick one service
- **WHEN** the visitor chooses "Cloud IP PABX" in the dropdown and submits
- **THEN** the submission carries that one interest
#### Scenario: Read the notice
- **WHEN** the visitor opens "How we use your details"
- **THEN** the full English and Malay notice shows above the consent box
#### Scenario: QR form unchanged
- **WHEN** a visitor opens an event's QR sign-up form
- **THEN** it shows job title, the interest checkboxes and the full notice as before
### Requirement: Thank-You Text On Landing Forms
A FORM block, and a HERO block with an event, MAY carry a thank-you text of at most 200 characters. After a visitor signs up through that block's form, the page SHALL show the text, with contact links, under the thank-you heading. Without it, the thank-you SHALL look as before. The server SHALL refuse an over-long thank-you text, or one on a HERO without an event.
#### Scenario: Visitor sees the page's thank-you text with a call link
- **GIVEN** page `/p/INS/hotel-technology-native` whose hero form has the thank-you text "Prefer to talk now? Call +60 12-833 2775."
- **WHEN** a visitor signs up through the hero form
- **THEN** the page shows the thank-you heading and "Prefer to talk now? Call +60 12-833 2775."
- **AND** "+60 12-833 2775" is a link to `tel:+60128332775`
#### Scenario: No thank-you text keeps today's message
- **WHEN** a visitor signs up through a FORM block without a thank-you text
- **THEN** the page shows only the thank-you heading and the "register another" button, as before
#### Scenario: Thank-you text on a hero without a form is refused
- **WHEN** staff save a HERO block without an event but with a thank-you text
- **THEN** the save is refused with the reason naming the hero's thank-you field
#### Scenario: Set the thank-you text in the editor
- **GIVEN** staff editing a hero that has an event
- **WHEN** they type a thank-you text in the hero's settings and save
- **THEN** the page keeps the text
- **AND** choosing "No form" on the hero clears it
### Requirement: Footer Block
A page MAY hold FOOTER blocks: 1 to 4 columns, each a required title (80 characters) and text (300 characters), and an optional legal line (300 characters). The page SHALL show the columns side by side on wide screens and stacked on phones, keep line breaks, show contact links in the column text, and put the legal line under a thin divider. A new footer SHALL start with the dark look. The server SHALL refuse a footer that breaks these limits, or that has a heading or a column icon.
#### Scenario: Visitor sees a three-column footer with links
- **GIVEN** a published page whose footer has the columns "Infinity Networks Security Sdn Bhd", "Talk to us" with "+603-7623 9807" and "info@infinitynetworks.com.my", and "Website" with "www.infinitynetworks.com.my", and a legal line
- **WHEN** a visitor opens the page in a 1280 px window
- **THEN** the three columns sit side by side on a dark band
- **AND** the phone links to `tel:+60376239807`, the email to `mailto:info@infinitynetworks.com.my`, and the website to `https://www.infinitynetworks.com.my`
- **AND** the legal line sits under a divider
#### Scenario: Add a footer in the editor
- **GIVEN** staff editing a page
- **WHEN** they add a Footer section
- **THEN** the canvas shows a dark footer with two empty columns to type into
- **AND** they can add columns up to 4 and type the legal line
#### Scenario: Footer with five columns is refused
- **WHEN** a page is saved with a footer of 5 columns
- **THEN** the save is refused with the reason naming the footer's columns
### Requirement: Contact Links In Plain Text
Where this spec says text shows contact links, the page SHALL show phone numbers that start with `+` as `tel:` links holding only `+` and digits, email addresses as `mailto:` links, and `https://` or `www.` addresses as `https://` links that open in a new tab. Everything else SHALL stay plain text, never HTML.
#### Scenario: Text with markup stays text
- **GIVEN** a footer column text "<b>Call</b> +60 12-833 2775"
- **WHEN** a visitor opens the page
- **THEN** "<b>Call</b>" shows as written
- **AND** "+60 12-833 2775" links to `tel:+60128332775`
### Requirement: Top Bar Block
A page's first block MAY be a top bar. The top bar SHALL show the company logo, or the company name when there is no logo, and an optional button, and SHALL stay at the top of the window while the page scrolls. The server SHALL refuse a top bar that is not the first block, or one that carries fields other than its button and link name.
#### Scenario: Logo and button without the page title
- **GIVEN** page `/p/INS/hotel-technology-native` with "hide page header" on, a top bar with the button "Get My Free Consultation" linking to `#consult`, and a full-width hero
- **WHEN** a visitor opens the page and scrolls down
- **THEN** the INS logo and the button stay at the top of the window
- **AND** no page title heading shows, and the hero starts directly under the bar
#### Scenario: Top bar further down is refused
- **WHEN** staff save a page whose top bar is the second block
- **THEN** the save is refused with the reason naming that block
### Requirement: Section Labels
Feature cards, Steps, Image with text, FAQ and Call to action blocks MAY carry a label of at most 40 characters. The page SHALL show the label above the block's heading, in small uppercase letters in the accent colour. The server SHALL refuse a longer label, or a label on any other block type.
#### Scenario: Label above a heading
- **GIVEN** a Feature cards block with the label "Services" and the heading "Everything your guests touch, handled by one team"
- **WHEN** a visitor opens the page
- **THEN** "Services" shows in small uppercase letters directly above the heading
#### Scenario: Type a label in the editor
- **GIVEN** staff editing a Steps block
- **WHEN** they type "How we work" in its label field and save
- **THEN** the page keeps the label
### Requirement: Serif Section Headings
Section headings on landing pages SHALL use the serif typeface that the full-width hero uses.
#### Scenario: Feature heading in serif
- **WHEN** a visitor opens a page with a Feature cards block
- **THEN** its heading uses the serif typeface
@@ -1,29 +1,33 @@
"use client";
import type { ReactNode } from "react";
import { useState, type ReactNode } from "react";
import { ArrowDown, ArrowUp, Plus, Trash2 } from "lucide-react";
import { BLOCK_LABELS, ICONS, LOOKS, imageSrc, type CmsBlock, type CmsCard, type Look } from "@/app/lib/cmsPages";
import { Button } from "@/app/components/ui/button";
import { Input } from "@/app/components/ui/input";
import { Label } from "@/app/components/ui/label";
import { Switch } from "@/app/components/ui/switch";
import { Textarea } from "@/app/components/ui/textarea";
import { useT } from "@/app/lib/i18n/MessagesProvider";
import { RichTextEditor } from "./RichTextEditor";
import { CopyAddress } from "./CopyAddress";
// One block of the page editor, ported from babyboo's BlockFields: a fieldset with move/remove and its type's fields.
/** Field paths (relative to the block) each type shows inline; any other error shows at the block's top. Every type also shows "anchor". */
const INLINE: Record<string, string[]> = {
HERO: ["imageId", "heading", "text", "buttonLabel", "buttonUrl"],
HERO: ["imageId", "heading", "text", "buttonLabel", "buttonUrl", "eventUuid", "fullWidth", "formHeading", "formText", "thanksText", "cards"],
RICH_TEXT: ["html"],
IMAGE_TEXT: ["imageId", "imagePosition", "heading", "html", "buttonLabel", "buttonUrl"],
FAQ: ["heading", "items"],
FORM: ["heading", "eventUuid"],
IMAGE_TEXT: ["imageId", "imagePosition", "eyebrow", "heading", "html", "buttonLabel", "buttonUrl"],
FAQ: ["eyebrow", "heading", "items"],
FORM: ["heading", "eventUuid", "thanksText"],
HTML: ["html"],
FEATURES: ["heading", "text", "cards"],
STEPS: ["heading", "cards"],
FEATURES: ["eyebrow", "heading", "text", "cards"],
STEPS: ["eyebrow", "heading", "cards"],
TRUST: ["cards"],
CTA: ["heading", "text", "buttonLabel", "buttonUrl"],
CTA: ["eyebrow", "heading", "text", "buttonLabel", "buttonUrl"],
FOOTER: ["cards", "text"],
TOPBAR: ["buttonLabel", "buttonUrl"],
};
const LISTED = /^(items\[\d+\]\.(question|answer)|cards\[\d+\]\.(icon|title|text))$/;
@@ -34,10 +38,14 @@ const ICON_LABELS: Record<string, string> = {
"shield-check": "PagesIconShieldCheck", cloud: "PagesIconCloud", wrench: "PagesIconWrench", headset: "PagesIconHeadset",
users: "PagesIconUsers", calendar: "PagesIconCalendar", star: "PagesIconStar",
};
const CARD_KINDS: Record<string, { legend: string; add: string; icon: boolean; text: boolean; empty: CmsCard }> = {
FEATURES: { legend: "PagesCardN", add: "PagesAddCard", icon: true, text: true, empty: { icon: "star", title: "", text: "" } },
STEPS: { legend: "PagesStepN", add: "PagesAddStep", icon: false, text: true, empty: { title: "", text: "" } },
TRUST: { legend: "PagesItemN", add: "PagesAddItem", icon: false, text: false, empty: { title: "" } },
// add-hero-full-width: a hero's points are title-only cards, and it may have none.
// add-landing-thanks-and-footer: a footer's columns are title-and-text cards, 1 to 4.
const CARD_KINDS: Record<string, { legend: string; add: string; icon: boolean; text: boolean; min: number; max: number; empty: CmsCard }> = {
FEATURES: { legend: "PagesCardN", add: "PagesAddCard", icon: true, text: true, min: 2, max: 6, empty: { icon: "star", title: "", text: "" } },
STEPS: { legend: "PagesStepN", add: "PagesAddStep", icon: false, text: true, min: 2, max: 6, empty: { title: "", text: "" } },
TRUST: { legend: "PagesItemN", add: "PagesAddItem", icon: false, text: false, min: 2, max: 6, empty: { title: "" } },
HERO: { legend: "PagesPointN", add: "PagesAddPoint", icon: false, text: false, min: 0, max: 6, empty: { title: "" } },
FOOTER: { legend: "PagesColumnN", add: "PagesAddColumn", icon: false, text: true, min: 1, max: 4, empty: { title: "", text: "" } },
};
const SELECT = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm disabled:cursor-not-allowed disabled:opacity-50";
@@ -76,6 +84,8 @@ export function BlockFields(props: {
onMove: (delta: -1 | 1) => void;
onRemove: () => void;
onChooseImage: (file: File) => void;
/** Uploads an image for a Custom HTML block at once (add-html-image-upload); rejects with the reason to show. */
onUploadImage?: (file: File) => Promise<number>;
}) {
const { block, id, index, count, errors, saving, events, pendingImage, onChange, onMove, onRemove } = props;
const t = useT();
@@ -83,7 +93,7 @@ export function BlockFields(props: {
const fid = (name: string) => `block-${id}-${name}`;
const topErrors = Object.entries(errors).filter(([path]) => path !== "anchor" && path !== "look" && !INLINE[block.type]?.includes(path) && !LISTED.test(path));
const text = (name: "heading" | "text" | "buttonLabel" | "buttonUrl" | "anchor", labelCode: string) => (
const text = (name: "heading" | "text" | "buttonLabel" | "buttonUrl" | "anchor" | "formHeading" | "formText" | "thanksText" | "eyebrow", labelCode: string) => (
<Field id={fid(name)} label={t(labelCode)} error={errors[name]}>
<Input id={fid(name)} value={block[name] ?? ""} disabled={saving} aria-invalid={!!errors[name]} onChange={(e) => set({ [name]: e.target.value })} />
</Field>
@@ -95,7 +105,39 @@ export function BlockFields(props: {
</Field>
);
// add-html-image-upload: this panel's uploads, newest first; their links are pasted into the HTML by hand.
const [uploads, setUploads] = useState<number[]>([]);
const [uploadError, setUploadError] = useState<string | null>(null);
const [uploading, setUploading] = useState(false);
async function upload(file: File) {
if (!props.onUploadImage) return;
setUploadError(null);
setUploading(true);
try {
const imageId = await props.onUploadImage(file);
setUploads((u) => [imageId, ...u]);
} catch (err) {
setUploadError(err instanceof Error ? err.message : String(err));
} finally {
setUploading(false);
}
}
const preview = pendingImage?.preview ?? (block.imageId ? imageSrc(block.imageId) : undefined);
// The FORM block's event, and the hero's optional sign-up form (add-hero-signup-form): the same picker and hint.
const eventPicker = (labelCode: string, emptyCode: string) => (
<Field id={fid("event")} label={t(labelCode)} error={errors.eventUuid}>
<select id={fid("event")} className={SELECT} value={block.eventUuid ?? ""} disabled={saving} aria-invalid={!!errors.eventUuid}
onChange={(e) => set(e.target.value ? { eventUuid: e.target.value } : { eventUuid: null, formHeading: undefined, formText: undefined, thanksText: undefined })}>
<option value="">{t(emptyCode)}</option>
{events.map((ev) => <option key={ev.uuid} value={ev.uuid}>{ev.name}</option>)}
{block.eventUuid && !events.some((ev) => ev.uuid === block.eventUuid) ? (
<option value={block.eventUuid}>{t("PagesUnavailableEvent")}</option>
) : null}
</select>
<p className="text-xs text-muted-foreground">{t("PagesFormEventHint")}</p>
</Field>
);
const image = (
<Field id={fid("image")} label={t("PagesImage")} error={errors.imageId}>
<Input
@@ -126,8 +168,8 @@ export function BlockFields(props: {
<>
{cards.map((card, i) => {
const err = (f: string) => errors[`cards[${i}].${f}`];
const cardField = (f: "title" | "text", labelCode: string, multiline: boolean) => (
<Field id={fid(`c${i}${f}`)} label={t(labelCode)} error={err(f)}>
const cardField = (f: "title" | "text", label: string, multiline: boolean) => (
<Field id={fid(`c${i}${f}`)} label={label} error={err(f)}>
{multiline
? <Textarea id={fid(`c${i}${f}`)} rows={2} value={card[f] ?? ""} disabled={saving} aria-invalid={!!err(f)}
onChange={(e) => setCards(cards.map((c, j) => (j === i ? { ...c, [f]: e.target.value } : c)))} />
@@ -146,18 +188,18 @@ export function BlockFields(props: {
</select>
</Field>
) : null}
{cardField("title", "PagesCardTitle", false)}
{kind.text ? cardField("text", "PagesCardText", true) : null}
{cardField("title", kind.min ? t("PagesCardTitle") : t(kind.legend, { number: i + 1 }), false)}
{kind.text ? cardField("text", t("PagesCardText"), true) : null}
<div className="flex flex-wrap gap-1">
<Button type="button" variant="ghost" size="sm" disabled={saving || i === 0} onClick={() => moveCard(i, -1)}>{t("PagesMoveUp")}</Button>
<Button type="button" variant="ghost" size="sm" disabled={saving || i === cards.length - 1} onClick={() => moveCard(i, 1)}>{t("PagesMoveDown")}</Button>
<Button type="button" variant="ghost" size="sm" disabled={saving || cards.length <= 2} onClick={() => setCards(cards.filter((_, j) => j !== i))}>{t("PagesRemoveCard")}</Button>
<Button type="button" variant="ghost" size="sm" disabled={saving || cards.length <= kind.min} onClick={() => setCards(cards.filter((_, j) => j !== i))}>{t("PagesRemoveCard")}</Button>
</div>
</fieldset>
);
})}
<FieldError message={errors.cards} />
<Button type="button" variant="outline" size="sm" disabled={saving || cards.length >= 6} onClick={() => setCards([...cards, { ...kind.empty }])}>
<Button type="button" variant="outline" size="sm" disabled={saving || cards.length >= kind.max} onClick={() => setCards([...cards, { ...kind.empty }])}>
<Plus aria-hidden="true" className="size-4" />
{t(kind.add)}
</Button>
@@ -190,6 +232,19 @@ export function BlockFields(props: {
{text("text", "PagesText")}
{text("buttonLabel", "PagesButtonLabel")}
{text("buttonUrl", "PagesButtonLink")}
<div className="flex items-center gap-2">
<Switch id={fid("fullWidth")} checked={!!block.fullWidth} disabled={saving} onCheckedChange={(on) => set({ fullWidth: on || undefined })} />
<Label htmlFor={fid("fullWidth")}>{t("PagesFullWidth")}</Label>
</div>
{cardList}
{eventPicker("PagesHeroForm", "PagesNoForm")}
{block.eventUuid ? (
<>
{text("formHeading", "PagesFormHeading")}
{text("formText", "PagesFormText")}
{text("thanksText", "PagesThanksText")}
</>
) : null}
</>
)}
@@ -204,6 +259,7 @@ export function BlockFields(props: {
<option value="RIGHT">{t("PagesImageRight")}</option>
</select>
</Field>
{text("eyebrow", "PagesEyebrow")}
{text("heading", "PagesHeading")}
{richText("PagesText")}
{text("buttonLabel", "PagesButtonLabel")}
@@ -213,6 +269,7 @@ export function BlockFields(props: {
{block.type === "FAQ" && (
<>
{text("eyebrow", "PagesEyebrow")}
{text("heading", "PagesHeading")}
{items.map((item, i) => (
<div key={i} className="space-y-2 rounded-md border p-3">
@@ -245,26 +302,36 @@ export function BlockFields(props: {
<p className="text-xs text-muted-foreground">{t("PagesHtmlHint")}</p>
</Field>
)}
{block.type === "HTML" && props.onUploadImage && (
<Field id={fid("upload")} label={t("PagesUploadImage")} error={uploadError ?? undefined}>
<Input id={fid("upload")} type="file" accept="image/png,image/jpeg,image/webp" disabled={saving || uploading}
onChange={(e) => {
const file = e.target.files?.[0];
e.target.value = "";
if (file) void upload(file);
}} />
<p className="text-xs text-muted-foreground">{t("PagesUploadImageHint")}</p>
{uploads.map((imageId) => (
<div key={imageId} className="flex items-center gap-2 rounded-md border p-2">
{/* eslint-disable-next-line @next/next/no-img-element -- an uploaded image of unknown size */}
<img src={imageSrc(imageId)} alt={t("PagesImagePreview")} className="size-12 rounded object-cover" />
<CopyAddress address={imageSrc(imageId)} relative />
</div>
))}
</Field>
)}
{block.type === "FORM" && (
<>
{text("heading", "PagesHeading")}
<Field id={fid("event")} label={t("PagesFormEvent")} error={errors.eventUuid}>
<select id={fid("event")} className={SELECT} value={block.eventUuid ?? ""} disabled={saving} aria-invalid={!!errors.eventUuid}
onChange={(e) => set({ eventUuid: e.target.value || null })}>
<option value="">{t("PagesChooseEvent")}</option>
{events.map((ev) => <option key={ev.uuid} value={ev.uuid}>{ev.name}</option>)}
{block.eventUuid && !events.some((ev) => ev.uuid === block.eventUuid) ? (
<option value={block.eventUuid}>{t("PagesUnavailableEvent")}</option>
) : null}
</select>
<p className="text-xs text-muted-foreground">{t("PagesFormEventHint")}</p>
</Field>
{eventPicker("PagesFormEvent", "PagesChooseEvent")}
{text("thanksText", "PagesThanksText")}
</>
)}
{block.type === "FEATURES" && (
<>
{text("eyebrow", "PagesEyebrow")}
{text("heading", "PagesHeading")}
<Field id={fid("text")} label={t("PagesIntro")} error={errors.text}>
<Textarea id={fid("text")} rows={2} value={block.text ?? ""} disabled={saving} aria-invalid={!!errors.text} onChange={(e) => set({ text: e.target.value })} />
@@ -275,6 +342,7 @@ export function BlockFields(props: {
{block.type === "STEPS" && (
<>
{text("eyebrow", "PagesEyebrow")}
{text("heading", "PagesHeading")}
{cardList}
</>
@@ -282,8 +350,24 @@ export function BlockFields(props: {
{block.type === "TRUST" && cardList}
{/* add-landing-page-polish: the top bar's button; its logo comes from the company. */}
{block.type === "TOPBAR" && (
<>
{text("buttonLabel", "PagesButtonLabel")}
{text("buttonUrl", "PagesButtonLink")}
</>
)}
{block.type === "FOOTER" && (
<>
{cardList}
{text("text", "PagesFooterLegal")}
</>
)}
{block.type === "CTA" && (
<>
{text("eyebrow", "PagesEyebrow")}
{text("heading", "PagesHeading")}
{text("text", "PagesText")}
{text("buttonLabel", "PagesButtonLabel")}
@@ -291,7 +375,7 @@ export function BlockFields(props: {
</>
)}
{block.type !== "HTML" && (
{block.type !== "HTML" && block.type !== "TOPBAR" && (
<Field id={fid("look")} label={t("PagesLook")} error={errors.look}>
<select id={fid("look")} className={SELECT} value={block.look ?? "DEFAULT"} disabled={saving} aria-invalid={!!errors.look}
onChange={(e) => set({ look: e.target.value as Look })}>
Loaded 100 of 142 files, more files were not shown because too many files have changed in this diff. Show more