Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
336 lines
17 KiB
Markdown
336 lines
17 KiB
Markdown
# 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 and HTML. 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
|
|
|
|
### 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 a FORM block's event 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
|
|
|
|
### 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.
|
|
|
|
#### Scenario: Script link on a button
|
|
|
|
- **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
|
|
|
|
#### Scenario: Same-page button link
|
|
|
|
- **WHEN** a page is saved with a HERO button link `#signup`
|
|
- **THEN** the save succeeds
|
|
|
|
#### Scenario: Malformed same-page link
|
|
|
|
- **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 and last update, with a search by title or slug and an Add page action. Each row SHALL open its editor. 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`
|
|
|
|
### 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.
|
|
|
|
#### Scenario: Slug follows the title until edited
|
|
|
|
- **GIVEN** a new page
|
|
- **WHEN** staff type the title "Hotel Technology"
|
|
- **THEN** the slug becomes `hotel-technology`
|
|
|
|
### 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.
|
|
|
|
#### 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
|
|
|
|
### 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 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.
|
|
|
|
#### 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: 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 "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.
|
|
|
|
#### 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: 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
|
|
|
|
### Requirement: Block Link Names
|
|
|
|
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
|
|
|
|
#### Scenario: Duplicate link name
|
|
|
|
- **WHEN** a page is saved with two blocks named `signup`
|
|
- **THEN** the save is refused on field `blocks[1].anchor` and nothing is written
|
|
|
|
#### Scenario: Reserved link name
|
|
|
|
- **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
|
|
|
|
#### Scenario: Bad link name
|
|
|
|
- **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
|
|
|
|
### Requirement: Same-Page Links From A Custom HTML Frame
|
|
|
|
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.
|
|
|
|
#### Scenario: Link to the form below the frame
|
|
|
|
- **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
|
|
|
|
#### Scenario: Link inside the frame
|
|
|
|
- **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
|