- TypeScript 99.5%
- Shell 0.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| .githooks | ||
| access | ||
| approval | ||
| checks | ||
| client | ||
| config | ||
| desired | ||
| export | ||
| libs | ||
| lifecycle | ||
| locales | ||
| model | ||
| policy | ||
| preview | ||
| publish | ||
| routes | ||
| scripts | ||
| serve | ||
| setup | ||
| store | ||
| tests | ||
| transform | ||
| ui | ||
| vendor | ||
| .gitignore | ||
| LICENSE.md | ||
| limedoc.project.json | ||
| plugin.devkit.json | ||
| README.md | ||
| sites.plugin.json | ||
| sites.ts | ||
| sites_admin_pages.tsx | ||
| sites_dashboard_widget.tsx | ||
| sites_folder_action.tsx | ||
| vendor.deno.lock | ||
| vendor.lock.json | ||
Sites (Limedoc plugin)
Turns a Limedoc folder into a static website. Pupils and staff write HTML, CSS
and JavaScript in Limedoc; the pack previews the folder on its own subdomain,
publishes immutable, content-addressed snapshots and hands a signed desired
state to an unprivileged deployer
(limedoc-sites-deployer),
which turns it into Caddy host files. Protected sites sit behind the OIDC gate
(limedoc-sites-gate)
or basic auth.
Requires Limedoc 0.85.0 (host routes, folder actions, pack admin pages, governance hooks, durable pack data).
Status
| Phase | What | State |
|---|---|---|
| 1 | Targets, setup "Set up as website", folder panel, admin pages | done |
| 2 | Preview on <siteKey>.site.<preview-domain> |
done |
| 3 | Publish: checks, info notice, snapshots | done |
| 4 | Approval, person release, access, capabilities | done |
| 5 | Desired state + deployer API | done |
| 8 | Library catalog (/_lib/…) |
done |
| 9 | Space lifecycle, deprovisioning, export, GC | done |
| — | Private sites, visitors, access lock (ADR 0007 P2/P3) | done |
| — | Guardians at the gate (ADR 0007 P5) | gate |
Deploy targets
Admin → Pack pages → Sites: targets
(/{locale}/admin/plugins/sites/targets). A target is JSON:
{
"id": "schule",
"label": "School websites",
"context": "school",
"domain": "sites.example.org",
"publishers": { "claims": ["aivopod:student", "aivopod:teacher"] },
"approvers": { "claims": ["aivopod:teacher"] },
"access": { "allowed": ["oidc", "public"], "default": "oidc" },
"capabilities": ["wasm", "camera"],
"oidc": {
"issuer": "https://forge.example.org/oidc",
"clientId": "sites-gate-schule",
"sameSubjects": true
},
"visitors": { "max": 30, "invite": true },
"guardians": "always",
"limits": { "fileBytes": 5242880, "siteBytes": 26214400, "files": 300 }
}
context:school(approval, OIDC default, info notice,noindexforced) orgeneral(no approval, basic auth default).publishers/approvers: any listed role or claim of the IdP token union. Approvers must also be able to read the site folder (a teacher of school A never approves school B); app admins always may.noindex:forced(school, required there),default-onordefault-off(general; per site switchable).injectInfo(always on in school targets),infoUrl(defaulthttps://<domain>/),infoText(default "Eine Seite aus der Schule · Info" in school targets): the noticeinject-info@1adds to published and previewed HTML.oidc(optional):{ issuer, clientId, sameSubjects? }of the target's gate.sameSubjects: truesays the gate sees the samesubas Limedoc (Aivopod 0.86.0:apcmd idp client subject-from set --id <gate> --subject-from limedoc; IdPs with public subs: always). Only then, and only whenissueris Limedoc's ownOIDC_ISSUER(Limedoc 0.90; the target list warns otherwise), areprivatesites, visitors and guardians offered (ADR 0007 D1).visitors(optional, needssameSubjects):{ max (1–200, default 30), invite (default true) }. Absent: no visitor lists.guardians:always(default in school targets),site(the owner decides per site) oroff(default in general targets). Guardians sign in at the gate with their Aivopod guardian code (ADR 0007 D4, gate 0.2.0; Aivopod 0.88.0:apcmd idp client guardians --id <gate> --portal-uri https://auth.<domain>/family, and the school switches guardian links on).- School targets: leave
basicout ofallowednow that guardians have their own access; the target list says so when it is still there. blocklist(optional): reserved slugs; defaults towww auth admin mail api lib ….- New deployer token issues the bearer token the deployer polls with (only its SHA-256 is stored; shown once). New signing key creates the Ed25519 key that signs the desired state; configure the deployer with the shown public key and key id.
Targets live in data/config/sites-targets.json (encrypted in encrypted mode);
site records, snapshots and states in data/plugin-data/sites/. Both belong in
the backup.
Using it
On /d/<folder> the Set up as website action (folder header) asks for the
target and the address. School targets suggest an anonymous
adjective-animal-number address. Setup turns on the folder's file listing and
adds index.html, style.css, script.js and an images folder; it never
overwrites existing files.
Publishing
Publish freezes the folder: every file below it (documents are skipped with
a note) is checked, HTML gets the target's info notice, and the bytes are stored
by SHA-256 together with a canonical manifest (files sorted by path, keys
sorted, no whitespace; its SHA-256 is the version's identity). The source files
are never changed. Check runs the checks only.
Errors block: no index.html, extensions outside the allowlist, limits, unsafe
paths, a _lib/ folder, files the publisher cannot read. Warnings do not:
missing or case-mismatched references (with line numbers), external resources,
unknown /_lib/ entries, <form action>, camera / WebAssembly / WebRTC use
without the capability.
general targets go live at once. In school targets the first publish, a new
address, wider access or an added capability wait for an approver; later content
changes go live at once unless the site is frozen. Publishing the same content
twice does nothing.
Approval and access
In school targets a pupil is released once per target by an approver, who
confirms the guardians' consent (dashboard widget "Websites to approve"; one
person at a time, no bulk release). An unreleased pupil's first publish attempt
files the request. Revoking a release takes every site of that person in the
target offline.
Approvers (listed in the target and able to read the site folder; app admins
everywhere) review a pending version — reasons, file diff, a preview of exactly
that snapshot — and approve or reject it with a message. They can freeze a site
(every change waits again), take it offline, and roll it back to an earlier
version; owners of general sites can roll back too. Every action is in the
folder's entity audit with subject, site and manifest hash.
Access per site within the target's modes: public, basic (up to five user
name / password pairs, bcrypt cost 12, passwords of at least 10 characters shown
once, three-word suggestions) or oidc (private, course or school in school
targets, private or every account in general ones). Capabilities (wasm,
camera, microphone, youtube) widen the header profile. Settings take
effect with the next publish; wider access and new capabilities need approval in
school targets. Credentials apply at once.
Private sites and visitors (ADR 0007)
private (the default of new sites in school targets with sameSubjects) lets
in the owner, the teachers of the folder's claim space (the teacherClaim its
claim-space template names; Limedoc before 0.90: <claim>:teacher), the people
on the site's visitor list and, as the target says, the owner's guardians.
private never widens: when a target loses its people rules (sameSubjects or
oidc taken away, another issuer), its private sites admit the teachers alone
until they are published with another audience. The owner's panel says who can
see the site as published and, when the draft differs, who will after the next
publish. Visitors are added to any oidc audience:
- Picker: people who share a course or workspace with the owner (local
directory scopes,
plugin_principals.ts; at least two letters, names as the directory shows them). Active at once. - Invite code (
XXXXX-XXXXX, Crockford Base32, single use, 7 days, at most 10 open; stored as an HMAC): the invitee enters it in the dashboard widget "Websites shared with me" (or opens/{locale}/dashboard#sites-invite=CODE). School targets: someone of the site's school who shares no course or workspace with the owner waits for an approver; another school is refused (the picker too: a course the owner shares with someone of another school does not count). An open code does nothing while access is locked or the target's invites are off; a code works once, also when two people try at the same time. Wrong codes: at most 10 per person and hour. - The widget lists the sites a person is on (the address only once they are allowed in); they can leave a list.
- A deprovisioned person leaves every list and every access record (events
about them go; where they acted, set the lock or made a code they are
replaced by
system:deprovisioned); their codes, and all codes of sites they own, stop working. Merged: everything moves to the surviving subject, and live sites of a merged owner are served again at once. - In the desired state an oidc site of a target with
sameSubjectscarriespeople:ownerand activevisitorsas subject hashes (base64url(sha256(issuer + "\n" + sub))[0..22]), the space'sschoolclaims a visitor must still hold (none in general targets) andguardians. Changes are served at once (no publish).
Oversight: approvers see every site's visitors with names, how and by whom they were added, pending visitors (Allow / Decline, also in the dashboard widget) and an access change feed (visitors, invites, passwords, access settings; 14 days; at most 100 events about people and 50 others, so codes made and withdrawn never push a visitor out). Lock access settings stops the owner from changing access (the guardians choice included), visitors, invites and passwords until it is unlocked, and open codes from adding anyone; teachers keep doing all of it. Who opened a site is never recorded.
bcrypt comes from bcryptjs 3.0.2, bundled into vendor/bcrypt.js (BSD-3-Clause,
vendor/bcrypt.LICENSE) from vendor.lock.json with the frozen
vendor.deno.lock by scripts/bundle-vendor.ts (run by plugin:build and the
pack; never through a node_modules directory).
Deployer API
Each target publishes a signed desired state: every live site's host, manifest,
access (bcrypt hashes for basic, the claim values a visitor needs for oidc,
the people of private sites and visitor lists), noindex and capabilities. It is
rebuilt when a site goes live, is rolled back or taken down, when credentials
change and when the targets are saved; the serial grows only when the content
(or the signing key) changed. The last 10 states are kept.
Read-only routes, bearer token of that target only (an unknown target and a wrong token both answer 401):
| Route | Answer |
|---|---|
GET /api/plugins/sites/targets/<id>/desired?since=&wait= |
the state when its serial is above since; otherwise waits up to wait (≤ 30) seconds, then 204 |
GET /api/plugins/sites/targets/<id>/manifests/<sha256> |
canonical manifest bytes |
GET /api/plugins/sites/targets/<id>/objects/<sha256> |
file bytes, immutable |
Manifests and objects are served only when a kept desired state refers to them
(the site manifests and the library catalog manifest of payload.libs): drafts
and pending versions are never reachable. The signature is Ed25519 over the
canonical JSON of payload (sorted keys, no whitespace), base64url; keyId
names the public key the deployer pins. An oidc site of a school target whose
folder lies in no claim space gets an empty audience (nobody), never everybody.
Library catalog
Admin → Sites → libs (/admin/plugins/sites/libs): an operator picks a
package and version (or latest) from registry.npmjs.org. The tarball is
checked against the registry's dist.integrity (sha512) before anything is
kept; the license is shown, HTML files cannot be picked, at most 300 files / 60
MiB per library. The chosen files go into the content store; the catalog
manifest ({v: 1, kind: 'libs', files}, paths <id>/<version>/<file>, id =
the package name with @scope/ → scope-) is part of every target's desired
state, so each hosting server serves the same files at /_lib/<id>/<version>/…
(immutable). The preview serves them from the store. Removing a library takes it
off the servers with the next state; sites that still link it get the
lib-unknown warning when they are published.
Kinds: ES module (entry .js/.mjs, snippet = import map +
import * as <alias> from '<package>' in script.js), classic script
(entry first, then the other chosen .js files as <script src> in name
order), stylesheet only. CSS files of a library are linked in every snippet.
In the folder panel, Include a library shows the snippet to copy.
Suggestions in the admin page (the operator still checks license and files):
| Package | Files | Note |
|---|---|---|
pixi.js |
dist/pixi.min.js, dist/packages/unsafe-eval.min.js |
classic build + the CSP add-on: the ESM build needs 'unsafe-eval', which the site CSP never allows (checked in Chromium) |
three |
build/three.module.js, build/three.core.js |
the module imports ./three.core.js |
phaser |
dist/phaser.min.js |
|
p5 |
lib/p5.min.js |
LGPL |
js-aruco2 |
src/cv.js, src/aruco.js, src/dictionaries/aruco_4x4_1000.js |
ArUco markers; see below |
ArUco: Aivopod's marker scan is js-aruco2 2.0.0 (vendored and trimmed in
aivopod-app, apps/web/src/games/markers/vendor/) with OpenCV's DICT_4X4_250,
whose first 50 codes are DICT_4X4_50. The npm package's ARUCO_4X4_1000 holds
the same codes in the same order (all 250 compared), so a site detects the cards
of Aivopod's packs with new AR.Detector({ dictionaryName: 'ARUCO_4X4_1000' });
marker ids are the card ids. Load order matters: cv.js (the entry) before
aruco.js, the dictionary after it, which is what the classic-script snippet
emits. Checked in Chromium under the site CSP: markers 0, 7, 23 and 49 drawn
from Aivopod's table are found, no CSP violation. No WASM is involved (Aivopod's
WASM is zxing for QR codes). Aivopod tunes the threshold window (kernelSize 4,
npm: 2) and looks only for a pack's card ids, so its detection is somewhat more
robust on camera images.
Lifecycle, export and storage
- Space frozen: publishing is refused (checked at publish time), the sites
stay online. Space closed or archived: its sites go offline (notice
space-closed). Reopening or thawing allows publishing again; a removed site comes back only through a new publish and approval. - Person deprovisioned (IdP event): removed from every visitor list,
releases in every target revoked, their sites offline (
owner-deprovisioned), no export. Merged into another subject: the sites stay and belong to the surviving account, which needs its own release to publish in a school target again. - Reconcile every 5 minutes (one instance at a time) repeats these rules for
missed hook calls: a closed space, or a folder missing on two passes at least
10 minutes apart (
folder-gone). - Export: the published snapshot as ZIP (as served, info notice included),
GET /api/plugins/sites/sites/<id>/export, for the owner, approvers and admins; while the site is online and for 30 days after it went offline ("Download the published version" in the panel). - Garbage collection (hourly, in the reconcile pass): content no longer named by a site (live, pending, history; removed sites for 30 days), a kept desired state or the library catalog is deleted once it has been unreferenced for an hour. A publish (not the separate "Check") and adding a library hold the same lock as the collector, so publishes run one after another across all sites.
Preview
Admin → Plugins → Sites settings: Preview domain, e.g.
preview.example.org. A site's draft is then served by Limedoc itself at
https://<siteKey>.site.preview.example.org/ (the key is random and does not
reveal the address). Preview in the folder panel opens it in a new tab with
a one-time link (2 minutes); the host turns it into a __Host-preview cookie
for 2 hours. Every request checks read on the folder again; responses carry the
site's header profile, the info notice of the target, X-Robots-Tag: noindex
and Cache-Control: no-store.
DNS: a wildcard record *.site.preview.example.org pointing at the proxy in
front of Limedoc. That proxy holds one wildcard certificate for
*.site.preview.example.org (DNS-01 challenge, Caddy built with the DNS module
of the domain's provider), so a new site never needs a certificate or a proxy
change:
*.site.preview.example.org {
tls {
dns <provider> {env.DNS_API_TOKEN}
}
reverse_proxy limedoc:8000
}
The proxy must pass the original Host header (Caddy does); Limedoc answers
only hosts <siteKey>.site.<preview domain> of existing sites and 404
otherwise. Without DNS API access, on-demand certificates work too:
on_demand_tls { ask https://limedoc.example.org/api/plugins/sites/preview/ask }
and tls { on_demand } in the block; the endpoint answers 200 only for the
preview host of an existing site.
Development
# from the Limedoc app checkout, with this pack under plugins/
deno task plugin:build plugins/sites.plugin
DATA_DIR=$(mktemp -d) deno test --no-check --env-file=.env \
--preload=lib/plugin-sdk/test/env.ts -A plugins/sites.plugin/
The integration tests (tests/) need Redis (REQUIRE_REDIS=1 makes a missing
Redis fail) and write to the data directory, targets config included: point
DATA_DIR at a scratch directory.
License
FSL-1.1-ALv2, see LICENSE.md.