Skip to main content

Module comments

Module comments 

Source
Expand description

Comments: threads readers leave on a page, kept by a comment store. Comments is the only way a thread is written — from a page, from the API, or by a publish carrying threads onto a new version — and it holds every rule of a write: the page key, a new thread’s page being a file in the served or version folder, replies and resolves going by thread id, where a carry moves each thread, and the one announcement each write makes on the change bus. A carry is the one write it hands over: the publish commits it together with the version, so both land or neither does. Identity says who writes. The Store port is only where threads are kept, by thread id: the YAML files under .devpage/comments/ (yaml), server mode’s SQLite store, and memory for tests ([memory]). anchor finds a carried thread’s quote in the new version’s text.

Modules§

anchor
Carrying a thread onto a new version of its page: the page’s text as the page script reads it, and where a thread’s quote is in it now. Pure — the server hands it the new version’s HTML and stores what it answers.
yaml
The comment store as files: one YAML file per thread, .devpage/comments/<page>/<id>.yml, under the served folder. It writes nothing outside .devpage/, and finds a thread by its id through the served folder, so a thread file that leads out of it is never read.

Structs§

Anchor
What a thread is attached to: rendered text, with a little context.
Carry
Where a publish carries a document’s threads: each one that moves, and the pages they are on. Made by Comments::carry.
Comments
The comments of one served or version folder: its store, the bus every successful write is announced on — comments <page>, once, as the write lands — so open pages fetch that page’s threads again, and the folder a new thread’s page must be a file in.
Listed
A thread with its id, as the page receives it.
Message
Moved
A thread carried onto a new version: to anchor, or detached — None — when its text is gone.
Thread
A thread as stored: its anchor and its messages, oldest first.

Enums§

Identity
Who writes: one local author — the git name locally, anonymous on a server with no header — or, deployed, whoever the auth proxy names in a header. devpage authenticates no one itself.
Refused
Why a comment request is refused.

Traits§

Store
The comment store port: where one served folder’s — or one published document’s — threads are kept, by thread id. A page here is always a page key, /a.md, made by Comments; an id is always one that is_id accepts. Writes are silent — announcing them is Comments’s job.

Functions§

is_id
Whether id can be a thread’s: letters, digits and dashes, never empty.
new_id
A new thread’s id: the UTC time it was started, to the second, and four hex digits from the clock’s nanoseconds — so a page’s threads list oldest first.