Files
co-lite/openspec/specs/landing-pages/spec.md
T

36 KiB

landing-pages Specification

Purpose

Public landing pages per company, built by staff from blocks in the back office without a developer. A page's sign-up form registers visitors into an event as web sign-ups, with the page address and campaign tags, so they enter the lead pipeline. Each page shows its company's logo and accent colour.

Requirements

Requirement: A Page Is An Ordered List Of Typed Blocks

A page SHALL belong to one company and have a slug, a title, an optional meta description, a status (Draft or Published), a "hide header" flag that defaults to off, and an ordered list of zero to 30 blocks. The block types SHALL be HERO, RICH_TEXT, IMAGE_TEXT, FAQ, FORM, HTML, FEATURES, STEPS, TRUST and CTA. Blocks SHALL be returned in the order they were saved, and a valid save SHALL replace all of a page's blocks.

Scenario: Blocks read back in order

  • WHEN staff save page hotel-technology with blocks HERO, RICH_TEXT, FORM
  • THEN reading the page returns those three blocks in that order with their fields

Scenario: A save replaces the blocks

  • GIVEN a page whose blocks are HERO and FAQ
  • WHEN it is saved with only a RICH_TEXT block
  • THEN the page has only that RICH_TEXT block

Scenario: An HTML block and the header flag read back

  • WHEN staff save a page with "hide header" on and blocks HTML, FORM
  • THEN reading the page returns "hide header" on and the HTML block with its HTML unchanged

Scenario: New section types read back

  • WHEN staff save a page with blocks FEATURES, STEPS, TRUST and CTA
  • THEN reading the page returns those four blocks in that order with their cards and fields

Requirement: Page Fields Are Validated Server-Side

A page save SHALL be refused with the offending field path, writing nothing, when the slug does not match ^[a-z0-9]+(-[a-z0-9]+)*$, is longer than 80 characters or is used by another page of the same company, ignoring case; or when the title is blank or longer than 120 characters; or when the meta description is longer than 160 characters.

Scenario: Duplicate slug in one company

  • GIVEN INS has a page hotel-technology
  • WHEN INS staff save another page with slug hotel-technology
  • THEN the save is refused on field slug

Scenario: Same slug in two companies

  • GIVEN INS has a page about
  • WHEN CV staff save a page with slug about
  • THEN the save succeeds

Requirement: Block Fields Are Validated Server-Side

A page save SHALL be refused with the offending field path, writing nothing, when a block has an unknown type, a required field is blank, or a text exceeds its limit: heading 120, text and FAQ question 300, button label 40, FAQ answer 2000, rich-text HTML 100000 characters, and an HTML block's HTML 200000 characters. An HTML block's HTML SHALL NOT be blank. A FAQ SHALL have 1 to 30 items. imagePosition SHALL be LEFT or RIGHT.

Scenario: Too many blocks

  • WHEN a page is saved with 31 blocks
  • THEN the save is refused and nothing is written

Scenario: HTML block too long

  • WHEN a page is saved with an HTML block of 200001 characters
  • THEN the save is refused on field blocks[0].html and nothing is written

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

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.

  • WHEN a page is saved with a HERO button link javascript:alert(1)
  • THEN the save is refused on field blocks[0].buttonUrl

Scenario: Script in rich text

  • WHEN a page is saved with rich text holding <img src=x onerror=alert(1)>
  • THEN the save is refused on that block's HTML field

Scenario: Script in an HTML block

  • WHEN a page is saved with an HTML block holding <script>document.title = "x"</script>
  • THEN the save succeeds
  • WHEN a page is saved with a HERO button link #signup
  • THEN the save succeeds
  • WHEN a page is saved with a HERO button link #Sign Up
  • THEN the save is refused on field blocks[0].buttonUrl

Requirement: Page Images

Staff with BO_PAGES SHALL upload images for their company in PNG, JPEG or WebP, each at most 2 MB, checked by the file's content and not by its name. Anyone SHALL be able to read an image by its id, so that public pages can show it.

Scenario: Wrong file type

  • WHEN staff upload a PDF renamed to banner.png
  • THEN the upload is refused and nothing is stored

Scenario: Too large

  • WHEN staff upload a 3 MB JPEG
  • THEN the upload is refused and nothing is stored

Requirement: Company Branding

Each company SHALL have an optional logo, an image of that company, and an optional accent colour in #RRGGBB form. These SHALL be edited on the Companies screen. Its public pages SHALL show the logo in the header and use the accent colour on buttons, with black or white button text, whichever contrasts more. Without these, the pages SHALL use the neutral Co-Lite look.

Scenario: Accent colour

  • GIVEN INS has accent colour #0B5FFF
  • WHEN a visitor opens an INS page
  • THEN its buttons are #0B5FFF with white text

Scenario: Invalid colour

  • WHEN a super admin saves the accent colour blue
  • THEN the save is refused on that field

Requirement: Public Page Address

A published page SHALL be public at /p/<company-code>/<slug>, matching the company code and the slug ignoring case. It SHALL be rendered on the server with the page title, the meta description and Open Graph tags. An unknown company, an unknown slug or a draft SHALL show the same not-found page to a visitor.

Scenario: Draft hidden from visitors

  • GIVEN INS page launch is a draft
  • WHEN a signed-out visitor opens /p/INS/launch
  • THEN they see the not-found page

Scenario: Staff preview a draft

  • GIVEN INS page launch is a draft
  • WHEN INS staff with BO_PAGES open its preview from the editor
  • THEN they see the page as it would be published, marked as a preview

Requirement: The Form Block Registers For An Event

A FORM block SHALL show Co-Lite's sign-up form for its event, with that event's interests and the company's privacy notice. A submit SHALL follow the QR registration rules for matching, the existing-lead notes, consent and abuse limits. It SHALL create the event lead with source Web page and no salesperson, and SHALL record the page address and the utm_source, utm_medium and utm_campaign values from the page URL, each cut to 100 characters.

Scenario: New enquiry

  • GIVEN page /p/INS/hotel-technology has a FORM block for INS website enquiries
  • WHEN a new visitor submits it 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: Known visitor

  • GIVEN a lead with the same mobile exists in INS
  • WHEN they submit the form with a different email
  • THEN the lead is not edited, and the new email is written into the event lead's notes

Requirement: The Form Block Closes With Its Event

A FORM block SHALL accept a submit only while its event is enabled, the event's end date in Malaysia time has not passed and the company has a privacy notice. Otherwise the page SHALL still show its other blocks, and the form area SHALL say that sign-up is closed.

Scenario: Ended event

  • GIVEN the FORM block's event ended yesterday
  • WHEN a visitor opens the page
  • THEN the other blocks show and the form area says sign-up is closed

Requirement: Web Sign-Up Details For Staff

The event lead detail SHALL show the page address and the UTM values of a Web page sign-up.

Scenario: Campaign shown

  • GIVEN an event lead from a page opened with utm_campaign=jan-launch
  • WHEN staff open the event lead
  • THEN its detail shows the page address and campaign jan-launch

Requirement: Pages Are Company-Scoped

Pages and page images SHALL follow the company scoping rules: staff see, edit and delete only their own company's pages, and a super admin sees every company's pages with their company. The Pages screens SHALL need BO_PAGES, which no role has at first. Page saves and deletes SHALL be audited.

Scenario: Another company's page

  • GIVEN page 12 belongs to CV
  • WHEN INS staff ask for page 12
  • THEN they get not found

Requirement: The Pages List

/pages SHALL list the pages in scope with their title, public address, status, an "Unpublished changes" mark when a published page has a draft, and last update, with a search by title or slug and an Add page action. Each row SHALL open its editor and offer Duplicate. Pages SHALL appear in the sidebar for users with BO_PAGES.

Scenario: Draft in the list

  • GIVEN INS page launch is a draft
  • WHEN INS staff open /pages
  • THEN its row shows status Draft and address /p/INS/launch

Scenario: Unpublished changes in the list

  • GIVEN INS page hotel is published and has a saved draft
  • WHEN INS staff open /pages
  • THEN its row shows status Published and "Unpublished changes"

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
  • 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

The public page and the staff preview SHALL show each HTML block in a sandboxed frame loaded from its own address. Each frame response SHALL carry a Content-Security-Policy whose sandbox directive allows scripts and pop-ups only, so the HTML runs with an opaque origin even when the address is opened directly, and whose frame-ancestors directive allows only the Co-Lite site. The frame element SHALL NOT grant same-origin, form submission, top-level navigation or modal dialogs.

Scenario: Public frame is sealed

  • GIVEN INS page hotel-technology is published with an HTML block at index 0
  • WHEN a visitor's browser loads /p/INS/hotel-technology/frame/0
  • THEN the response is the block's HTML with a sandbox policy that allows scripts and pop-ups and not same-origin
  • AND its frame-ancestors allows only the Co-Lite site

Scenario: Pasted HTML cannot reach the visitor's session

  • GIVEN a published HTML block whose script reads document.cookie and calls /api/auth/session
  • WHEN the page is shown
  • THEN the script sees no Co-Lite cookies and its call carries no Co-Lite session

Requirement: Custom HTML Frame Addresses

The public frame address SHALL be /p/<company>/<slug>/frame/<block index> and SHALL answer only for an HTML block of a published page; every other request SHALL get the same not-found response. The preview frame address SHALL be /pages/<id>/preview/frame/<block index> and SHALL require a signed-in user with BO_PAGES who may see that page.

Scenario: No frame for a draft, a missing block or a non-HTML block

  • WHEN a visitor loads the frame address of a draft page, of block 7 of a page with 3 blocks, or of a FORM block
  • THEN each answers with the same not-found response

Scenario: Staff preview of a draft frame

  • GIVEN a draft page with an HTML block
  • WHEN a signed-in user with BO_PAGES of that page's company opens the preview
  • THEN the frame shows the draft HTML, sealed as on the public page
  • AND the same address without a session sends the browser to sign in

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

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: Hide Page Header

When a page's "hide header" flag is on, its public page and its preview SHALL NOT show the company header or the page title, and SHALL still use the page title in the browser title and the page metadata.

Scenario: Header hidden

  • GIVEN INS page hotel-technology has "hide header" on
  • WHEN a visitor opens it
  • THEN no company logo bar or page title heading shows above the first block
  • AND the browser title is still the page title

Any block MAY carry a link name. A link name SHALL be 1 to 40 characters of lowercase letters, digits and -, starting with a letter or digit, SHALL NOT start with reg- (the sign-up form's own field ids), and SHALL be unique within the page. A save breaking either rule SHALL be refused on that block's link-name field, writing nothing. The public page and the staff preview SHALL give the block that name as its element id, so a #name link scrolls to it.

Scenario: Hero button jumps to the form

  • GIVEN a published page whose FORM block has the link name signup and whose HERO button links to #signup
  • WHEN a visitor clicks the button
  • THEN the page scrolls to the form
  • WHEN a page is saved with two blocks named signup
  • THEN the save is refused on field blocks[1].anchor and nothing is written
  • WHEN a page is saved with a block named reg-email
  • THEN the save is refused on field blocks[0].anchor and nothing is written
  • WHEN a page is saved with a block named Sign Up
  • THEN the save is refused on field blocks[0].anchor and nothing is written

A click on a #name link inside a Custom HTML block SHALL scroll the page, without navigating the frame. The target SHALL be the element with that id inside the same frame when there is one, otherwise the block on the page with that link name, otherwise nothing happens. The page SHALL act only on such requests from its own frames and only for names of the link-name pattern. The frame SHALL gain no new sandbox permissions.

  • GIVEN a published page with an HTML block holding <a href="#signup"> and a FORM block named signup
  • WHEN a visitor clicks that link
  • THEN the page scrolls to the form
  • GIVEN a published HTML block whose content holds <a href="#top"> near its bottom and an element with id top at its start
  • WHEN a visitor scrolls down and clicks that link
  • THEN the page scrolls back to the start of the frame

Scenario: Another window asks to scroll

  • WHEN a different window posts a same-page link request to the page
  • THEN the page does not scroll

Requirement: Card Sections

A FEATURES, STEPS or TRUST block SHALL have 2 to 6 cards, with titles of at most 80 characters and texts of at most 300. FEATURES SHALL have a heading, an optional intro and cards with an icon from the fixed list, a title and a text. STEPS SHALL have a heading and numbered cards with a title and a text. TRUST SHALL have only card titles. A save breaking these rules, or using a card field its type lacks, SHALL be refused on that field.

Scenario: Feature cards show their icons

  • GIVEN a published page with a FEATURES block of three cards with icons wifi, tv and lock
  • WHEN a visitor opens it
  • THEN the page shows the heading and three cards, each with its icon, title and text

Scenario: Unknown icon

  • WHEN a page is saved with a FEATURES card whose icon is rocket-launcher
  • THEN the save is refused on field blocks[0].cards[0].icon

Scenario: Too few cards

  • WHEN a page is saved with a STEPS block of one card
  • THEN the save is refused on field blocks[0].cards

Scenario: Steps are numbered

  • GIVEN a published page with a STEPS block of three steps
  • WHEN a visitor opens it
  • THEN the steps show the numbers 1, 2 and 3 in order

Requirement: Call-To-Action Band

A CTA block SHALL have a heading of at most 120 characters, an optional text of at most 300, and a button with both a label and a link following the button link rule. A save without the button SHALL be refused on the button field.

Scenario: A CTA needs its button

  • WHEN a page is saved with a CTA block that has a heading and no button
  • THEN the save is refused on field blocks[0].buttonLabel

Requirement: Section Looks

Any block MAY carry a look: Default, Muted, Dark or Accent. Default, or no look, SHALL render as before. Muted, Dark and Accent SHALL render the block as a full-width band in that colour with text readable on it; Accent SHALL use the company's accent colour, or the default primary colour when the company has none. Any other look SHALL be refused on that block's look field.

Scenario: A dark band

  • GIVEN a published page whose CTA block has the Dark look
  • WHEN a visitor opens it
  • THEN the CTA shows as a dark full-width band with light text

Scenario: Existing pages unchanged

  • GIVEN a page saved before this change, whose blocks have no look
  • WHEN a visitor opens it
  • THEN it renders as it did before

Scenario: Unknown look

  • WHEN a page is saved with a block whose look is NEON
  • THEN the save is refused on field blocks[0].look

Requirement: Hero Image Is Optional

A HERO block MAY have no image; it then shows its heading, text and button on its look's background. When it has an image, the image SHALL still belong to the page's company.

Scenario: Hero without an image

  • WHEN a page is saved with a HERO block that has a heading and no image
  • THEN the save succeeds

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

Requirement: Published Pages Keep A Separate Draft

Saving a published page with status Published SHALL store the content as the page's draft, checked by the same rules as any save, and SHALL NOT change what visitors see. Saving a published page with status Draft SHALL unpublish it, write the content to the page and drop any draft. A page that is not published SHALL save directly, as before. The staff preview and the editor SHALL show the draft when there is one.

Scenario: Editing a live page does not change it for visitors

  • GIVEN INS page hotel is published with heading "Hotel day"
  • WHEN staff change the heading to "Hotel week" and save
  • THEN visitors still see "Hotel day"
  • AND the editor and the staff preview show "Hotel week"

Scenario: Unpublishing drops the draft

  • GIVEN a published page with a draft
  • WHEN staff choose status Draft and save
  • THEN the page is a draft with the saved content and no separate draft

Requirement: Publish And Discard Changes

Publishing a page's changes SHALL check its draft again by the same rules, including a unique slug, then make it the page's content and drop the draft. A refusal SHALL show at its field and change nothing. Discarding changes SHALL ask first, then drop the draft so the editor shows the published content again. Both SHALL be limited to pages in the caller's company scope.

Scenario: Publish changes

  • GIVEN published page hotel has a draft with heading "Hotel week"
  • WHEN staff press Publish changes
  • THEN visitors see "Hotel week" and the page has no draft

Scenario: Publish refused for a taken slug

  • GIVEN a draft with slug launch and another page published with slug launch since
  • WHEN staff press Publish changes
  • THEN the publish is refused on field slug and visitors still see the old content

Scenario: Discard changes

  • GIVEN published page hotel has a draft
  • WHEN staff press Discard changes and confirm
  • THEN the draft is gone and the editor shows the published content

Scenario: Another company's page

  • WHEN CV staff ask to publish INS page hotel
  • THEN the request is answered "not found" and nothing changes

Requirement: Starter Templates

New page SHALL first offer Blank, Event sign-up and Service showcase. A template SHALL fill the editor with its sections, placeholder text, a sign-up form with link name signup and no event, and buttons linking to #signup; nothing is stored until staff save. Every template's sections SHALL pass the server's block rules once an event is chosen.

Scenario: Start from the event template

  • WHEN staff choose New page, then Event sign-up
  • THEN the editor shows a hero, trust strip, feature cards, steps, FAQ and a sign-up form, filled with placeholder text
  • AND saving it without choosing the form's event is refused on that event field

Requirement: Duplicate A Page

Duplicate SHALL open the editor with a copy of the page's current content (its draft when there is one), as a new unsaved draft page of the same company titled "