Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67d61f339c | ||
|
|
07d5bd7e9a | ||
|
|
ce217fc952 |
No files matched your search
+313
@@ -2,6 +2,319 @@
|
|||||||
|
|
||||||
All notable changes are recorded here. Versions follow [Semantic Versioning](https://semver.org/).
|
All notable changes are recorded here. Versions follow [Semantic Versioning](https://semver.org/).
|
||||||
|
|
||||||
|
## [1.1.1] — 2026-10-29
|
||||||
|
|
||||||
|
_A patch release: the slow-request-body limit 1.1.0 introduced now covers form posts and multipart uploads too, and
|
||||||
|
after a restore the Backups screen shows how the site is reached, for review._
|
||||||
|
|
||||||
|
### Upgrading — read this first
|
||||||
|
|
||||||
|
**From `1.1.0`: a kernel upgrade, no flag.** From `1.0.1` or `1.0.0`, read `1.1.0`'s *Upgrading* first (behind a
|
||||||
|
reverse proxy its step 1 matters), then install this release directly: `1.1.0` itself is not needed in between. Paths
|
||||||
|
are the installer defaults (`/opt/runway`, `/opt/runway-data`).
|
||||||
|
|
||||||
|
**1. Back up.** Take each site's backup (**Backups**) and copy `/opt/runway-data/external/` somewhere **outside**
|
||||||
|
`external/plugins/`.
|
||||||
|
|
||||||
|
**2. Upgrade the kernel:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x runway-1.1.1.bin
|
||||||
|
sudo ./runway-1.1.1.bin -y
|
||||||
|
```
|
||||||
|
|
||||||
|
The essential plugin moves with the kernel to `1.1.1` (its descriptor changes in version only, and its jar is
|
||||||
|
rebuilt), so the installer refreshes it; expect these lines, once:
|
||||||
|
|
||||||
|
```
|
||||||
|
refreshing bundled plugin 'protection' from this release (it moves with the kernel; files you edited are backed up)
|
||||||
|
plugin 'protection': plugin.yml replaced (the previous one kept as plugin.yml.bak, for a rollback)
|
||||||
|
plugin 'protection': runway-plugin-protection.jar replaced (the previous one kept as runway-plugin-protection.jar.bak, for a rollback)
|
||||||
|
keeping the bundled plugins in the release: /opt/runway-1.1.1/seed/ (the repair copy — Administration §12)
|
||||||
|
```
|
||||||
|
|
||||||
|
**3. Check.**
|
||||||
|
- **About Runway** shows `1.1.1`.
|
||||||
|
- On **Plugins**, every row is *Loaded* and none *Blocked*; protection shows `1.1.1`.
|
||||||
|
- The start log says `request bodies slower than 4096 bytes/s are refused (runway.http.min-request-data-rate)`, with
|
||||||
|
your value if you changed it.
|
||||||
|
|
||||||
|
**4. Rollback**, if needed: `sudo bash runway-1.1.0.bin -y` puts 1.1.0 back, its protection files included; slow form
|
||||||
|
posts are then held until the idle timeout again. Nothing this release saves is read differently by 1.1.0.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Slow request bodies are refused on every path, as 1.1.0 said they would be.** In 1.1.0
|
||||||
|
`runway.http.min-request-data-rate` was enforced only where a body was read as a stream. Form posts — every login
|
||||||
|
form, the console's forms, a plugin's form — and multipart uploads were read past it, so a client trickling one in
|
||||||
|
still held a request thread until the 30-second idle timeout, as in 1.0.1. Runway now checks the rate on every read
|
||||||
|
of a request body and answers `408 Request Timeout`: within about two seconds for a steady drip (measured: form and
|
||||||
|
multipart posts at 20 bytes a second, on both login pages and a plugin's form route), and for a client that pauses
|
||||||
|
between packets when its next packet arrives, within one idle timeout. Only time spent waiting for the client
|
||||||
|
counts, and a body that has arrived complete is never refused, however late its last packet came. A proxy that
|
||||||
|
buffers the whole request body before forwarding it kept such clients off Runway already, in 1.1.0 too.
|
||||||
|
- **Sending part of a body fast no longer buys a long drip.** 1.1.0 averaged over the whole body, so a client that
|
||||||
|
sent most of a large one at full speed could then drip the rest for the body's size divided by the rate (16 MiB at
|
||||||
|
4 KiB/s: over an hour). Bytes sent early now earn at most 30 seconds of waiting.
|
||||||
|
- **A request refused for a slow body is answered `408`.** Depending on how the code above handled the failed read,
|
||||||
|
1.1.0 could answer it `400` (a form parser's "unable to parse") or an empty `200`.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **After a restore, the Backups screen shows how the site is reached.** On the application console, after a restore
|
||||||
|
or after creating a site from a backup, the screen shows the site's hosts and base URL as they now are, with the
|
||||||
|
same editor as **Sites → Edit hosts**: a restore made there brings back the hosts and base URL saved in the backup,
|
||||||
|
which may not be how this installation reaches the site. On a site's own console the hosts are shown read-only: a
|
||||||
|
restore made there keeps them. See `docs/ADMINISTRATION.md` §10.
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
- **Exempting a same-host proxy's health check from the rate limit** (`docs/ADMINISTRATION.md` §12.4): the proxy sends
|
||||||
|
its check with a fixed `X-Forwarded-For` that no visitor can produce, and that one address is listed in protection's
|
||||||
|
allowlist, so the check never shares a rate-limit bucket with a local crawl and loopback stays limited.
|
||||||
|
|
||||||
|
## [1.1.0] — 2026-10-29
|
||||||
|
|
||||||
|
_A minor release: plugins can keep their data in PostgreSQL or MariaDB through the new database plugins, platform
|
||||||
|
mail can sign in with OAuth2 (Microsoft 365), the client address is read from the right of `X-Forwarded-For`, slow
|
||||||
|
request bodies are refused, and password-reset links go only to an address an administrator set. The plugin contract
|
||||||
|
gains one method (SPI `1.1.0`); every plugin that runs on 1.0.1 loads unchanged._
|
||||||
|
|
||||||
|
### Upgrading — read this first
|
||||||
|
|
||||||
|
**From `1.0.1` or `1.0.0`: a kernel upgrade, no flag. Behind a reverse proxy, check it first (step 1).** Coming from
|
||||||
|
an older release: read each newer release's *Upgrading* first, oldest first. Paths are the installer defaults
|
||||||
|
(`/opt/runway`, `/opt/runway-data`).
|
||||||
|
|
||||||
|
**1. Behind a reverse proxy: before you upgrade.** This release reads the client address from the right of
|
||||||
|
`X-Forwarded-For` and no longer reads the `Forwarded` header (see *Security* and *Changed*). Without a proxy, when
|
||||||
|
visitors reach Runway directly, skip this step.
|
||||||
|
|
||||||
|
- **List every proxy of yours in `runway.proxy.trusted-cidrs`:** the reverse proxy and anything in front of it, such
|
||||||
|
as a CDN, a load balancer or a second proxy (for a CDN, its published address ranges). Runway now walks
|
||||||
|
`X-Forwarded-For` from the right and stops at the first address that is not listed. An outer hop that is missing
|
||||||
|
from the list becomes every visitor's address, so all visitors share one set of login lockouts and rate limits.
|
||||||
|
Until now the leftmost entry was used, so a missing outer hop went unnoticed.
|
||||||
|
- **A proxy that sends only `Forwarded`** must be set to send `X-Forwarded-For`, `X-Forwarded-Proto` and
|
||||||
|
`X-Forwarded-Host` instead. Otherwise every visitor appears as the proxy, and the scheme and host as the proxy's
|
||||||
|
connection.
|
||||||
|
- **Recommended for every release:** the proxy sets `X-Forwarded-Proto` and `X-Forwarded-Host` and deletes
|
||||||
|
`X-Forwarded-Port`, `X-Forwarded-Prefix` and `X-Forwarded-Ssl`. `docs/ADMINISTRATION.md` §7 has the HAProxy and
|
||||||
|
nginx lines.
|
||||||
|
|
||||||
|
**2. Password-reset links.** A reset link now points at a site's own address and, on the application console, at a
|
||||||
|
host listed in `runway.console.hosts` or else at the default site's address (see *Security*). A site's address is
|
||||||
|
its base URL, or else `https://` and its **first** host name, with no port:
|
||||||
|
|
||||||
|
- **A site served over plain `http` or on a port other than 443** must have its **base URL** set (**Sites → Edit
|
||||||
|
hosts**), or its reset links point at `https://` and port 443. The same goes for the default site when
|
||||||
|
`runway.console.hosts` is not set, for the console's links.
|
||||||
|
- Where there is no address, the login page no longer offers **Forgot your password?**: on a site with no host name,
|
||||||
|
or whose first host is `localhost` (as the setup wizard leaves the default site) and that has no base URL; on the
|
||||||
|
application console, when `runway.console.hosts` is not set and the default site has no such address. To keep it,
|
||||||
|
set `runway.console.hosts`, or give the default site its public host name first, or a base URL.
|
||||||
|
- Without `runway.console.hosts`, the default site's address decides where the platform accounts' reset links go,
|
||||||
|
so its hosts and base URL can now be edited only by the application master or a wildcard administrator, even where
|
||||||
|
`MANAGE_SITE_HOSTS` is delegated, and a restore made from a site's own console keeps the site's hosts and base URL
|
||||||
|
instead of the backup's.
|
||||||
|
|
||||||
|
See `docs/ADMINISTRATION.md` §8.3.
|
||||||
|
|
||||||
|
**3. Back up.** Take each site's backup (**Backups**) and copy `/opt/runway-data/external/` somewhere **outside**
|
||||||
|
`external/plugins/`.
|
||||||
|
|
||||||
|
**4. Upgrade the kernel:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x runway-1.1.0.bin
|
||||||
|
sudo ./runway-1.1.0.bin -y
|
||||||
|
```
|
||||||
|
|
||||||
|
The essential plugin moves with the kernel to `1.1.0` (its descriptor changes in version only, and its jar is
|
||||||
|
rebuilt), so the installer refreshes it; expect these lines, once:
|
||||||
|
|
||||||
|
```
|
||||||
|
refreshing bundled plugin 'protection' from this release (it moves with the kernel; files you edited are backed up)
|
||||||
|
plugin 'protection': plugin.yml replaced (the previous one kept as plugin.yml.bak, for a rollback)
|
||||||
|
plugin 'protection': runway-plugin-protection.jar replaced (the previous one kept as runway-plugin-protection.jar.bak, for a rollback)
|
||||||
|
keeping the bundled plugins in the release: /opt/runway-1.1.0/seed/ (the repair copy — Administration §12)
|
||||||
|
```
|
||||||
|
|
||||||
|
**5. Check.**
|
||||||
|
- **About Runway** shows `1.1.0`.
|
||||||
|
- On **Plugins**, every row is *Loaded* and none *Blocked*; protection shows `1.1.0`.
|
||||||
|
- The start log says `plugins: N registered, 0 blocked`.
|
||||||
|
- Behind a proxy, **About Runway → This request** shows your own public address as the client address, and the
|
||||||
|
connection as a trusted proxy.
|
||||||
|
|
||||||
|
**What changes without any action.** None of these needs a setting changed, unless it affects you:
|
||||||
|
- **Slow request bodies are refused.** A request body that arrives at fewer than 4096 bytes per second is answered
|
||||||
|
`408` (`runway.http.min-request-data-rate`; Settings → Server settings → Request limits; `0` turns the check off).
|
||||||
|
Lower it only if your users upload large files over very slow links.
|
||||||
|
- **Sign-in lines in a site's audit log now carry the address in full** (`ip=…`). A site's setting to anonymize
|
||||||
|
client addresses applies to its access log only.
|
||||||
|
- **Platform mail can sign in with OAuth2 (Microsoft 365).** This is optional; password accounts work as before.
|
||||||
|
- **Plugins.** Every plugin that runs on 1.0.1 loads unchanged: SPI `1.1.0` only adds a method. This release also
|
||||||
|
carries:
|
||||||
|
- the database plugins (`database`, `database-postgresql`, `database-mariadb`) and the `runway-demo-database`
|
||||||
|
example, all new and optional; see `docs/ADMINISTRATION.md` §11.1;
|
||||||
|
- demo `2.1.1`, whose feedback form now asks the site's CAPTCHA.
|
||||||
|
|
||||||
|
**6. Rollback**, if needed: `sudo bash runway-1.0.1.bin -y` puts 1.0.1 back, its protection files included.
|
||||||
|
- The database plugins need 1.1.0 and are *Blocked* on 1.0.1; their data stays in the database.
|
||||||
|
- 1.0.1 has no OAuth2 sign-in, so an OAuth2 mail account stops sending there. Anything 1.0.1 saves to the platform
|
||||||
|
settings also drops the OAuth2 fields.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **SPI 1.1.0: `PluginSettings.appSecret(key)`.** A plugin can now read its own `secret`-typed app-level setting
|
||||||
|
(`settings:` in `plugin.yml`) in clear: a credential that belongs to the whole installation, such as a database
|
||||||
|
password. Until now only per-site secrets could be read in clear; an app-level one reached the plugin only in its
|
||||||
|
encrypted `ENC(...)` form. The value is the one the running application started with, so a change saved on the
|
||||||
|
console applies after a restart, like every app-level setting. A plugin that uses it declares
|
||||||
|
`requiresSpi: ">=1.1.0"`. See `docs/SPI-STABILITY.md`.
|
||||||
|
- **Database plugins, published with this release:** `database`, `database-postgresql` and `database-mariadb`
|
||||||
|
`1.0.0`, and the example `runway-demo-database` `1.0.0`. Plugins can keep their own data in PostgreSQL 14+ or
|
||||||
|
MariaDB 10.11+: one schema per site, per-plugin migrations, per-site backup and restore (also between the two
|
||||||
|
products), and a **Database** screen in the application console. Runway's own data stays on files, and Runway
|
||||||
|
starts whether or not the database is reachable. See `docs/ADMINISTRATION.md` §11.1.
|
||||||
|
- **Testkit: `FakePluginSettings.appSecret(key, clearValue)`**, so a plugin's unit tests can hand it an app-level
|
||||||
|
secret the way the running application would.
|
||||||
|
- **About Runway → This request.** The request that loaded the page as Runway saw it: the connection it came from and
|
||||||
|
whether that is a trusted proxy, the `X-Forwarded-For` list as received, the client address Runway used, and the
|
||||||
|
scheme and host. A reverse-proxy setup (`runway.proxy.*`) can now be checked from the browser. See
|
||||||
|
`docs/ADMINISTRATION.md` §7.
|
||||||
|
- **`runway.http.min-request-data-rate`** (default `4096` bytes per second; Settings → Server settings → Request
|
||||||
|
limits). A request body that arrives more slowly is answered `408 Request Timeout` and its request thread freed. Until now a client sending a byte now and then could
|
||||||
|
hold a request thread for as long as it kept sending. `server.jetty.connection-idle-timeout` (`30s`, Jetty's own
|
||||||
|
default) is now stated in the shipped configuration.
|
||||||
|
- **Platform mail can sign in with an OAuth2 token (Microsoft 365).** Settings → Platform settings → Platform mail
|
||||||
|
gains a sign-in method: *OAuth2 token*. Runway obtains an access token from the configured token endpoint with a
|
||||||
|
client ID and client secret (the client-credentials grant), keeps it until shortly before it expires, and signs in
|
||||||
|
to the mail server with SASL `XOAUTH2`. This is how Microsoft 365 accepts application mail once password sign-in
|
||||||
|
to SMTP is retired. The client secret is stored encrypted, like the password; an OAuth2 account requires STARTTLS or
|
||||||
|
implicit TLS and an `https` token endpoint. **Send test email** says whether the token or the mail server failed.
|
||||||
|
Existing password accounts are unchanged. See `docs/ADMINISTRATION.md` §8.1.
|
||||||
|
- **A site's audit log records where a sign-in came from.** `login.success`, `login.failure` and `logout` now carry
|
||||||
|
the client address (`ip=…`), as the application activity log already did; behind a trusted proxy, the visitor's
|
||||||
|
address. Until now the field was empty. The address is kept in full: a site's setting to anonymize client
|
||||||
|
addresses applies to its access log only.
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
- **The client address behind a trusted proxy is read from the right of `X-Forwarded-For`.** Runway took the
|
||||||
|
leftmost entry, which the client can write itself: behind a proxy that appends to the header (HAProxy's
|
||||||
|
`option forwardfor`, nginx's `$proxy_add_x_forwarded_for`), a client could choose the address that rate limits,
|
||||||
|
login lockouts, the access log and plugins saw. Runway now skips the addresses in `runway.proxy.trusted-cidrs` from
|
||||||
|
the right and takes the first one that is not a trusted proxy. An entry that is not an IP address there attributes
|
||||||
|
the request to the proxy. **Every proxy in front of Runway, a CDN included, must now be listed in
|
||||||
|
`trusted-cidrs`** (*Upgrading*, step 1).
|
||||||
|
- **A password-reset email no longer links to the host name the request named.** The link was built from the
|
||||||
|
request's `Host` (or the `X-Forwarded-Host` of a trusted proxy), so anyone could have the platform mail a real user
|
||||||
|
a genuine reset link pointing at a site of the sender's choosing, and take over the account if the link was
|
||||||
|
opened. A site's link now points at the site's own address (its base URL, or its first host name), and the
|
||||||
|
application console's at a host listed in `runway.console.hosts` (spelled and, if listed with one, numbered as
|
||||||
|
listed) or else at the default site's address. Where there is no such address, or only `localhost`, "Forgot your
|
||||||
|
password?" is not offered. See `docs/ADMINISTRATION.md` §8.3.
|
||||||
|
- **Only a platform administrator can change where the console's reset links go.** Without `runway.console.hosts`
|
||||||
|
they go to the default site's address, which anyone holding the delegable `MANAGE_SITE_HOSTS` permission could
|
||||||
|
edit, and a site manager could set through a restore of a backup file they wrote. The default site's hosts and
|
||||||
|
base URL now need the application master or a wildcard administrator, and a restore made from a site's own
|
||||||
|
console keeps the site's hosts and base URL.
|
||||||
|
- **A stored platform-mail secret is no longer sent to a server it was not saved for.** A blank password field kept
|
||||||
|
the stored password even when the same save changed the mail host, so anyone allowed to edit Platform settings
|
||||||
|
could point the account at a server of theirs and receive the password at the next send, without knowing it. The
|
||||||
|
password is now kept only while the host, port and username stay the same, and the OAuth2 client secret only while
|
||||||
|
the token endpoint, client ID, mail server and scope do (the token minted from it goes to the mail server);
|
||||||
|
otherwise the password is cleared and must be entered again, and an OAuth2
|
||||||
|
account is not saved without its secret. The activity log's `platform.settings-changed` line now names the
|
||||||
|
settings each save changed (never their values). See `docs/ADMINISTRATION.md` §8.1.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **The standard `Forwarded` header (RFC 7239) is no longer read**, even from a trusted proxy; Runway reads the
|
||||||
|
`X-Forwarded-*` headers only. A client could otherwise send its own `Forwarded` through a proxy that manages only
|
||||||
|
`X-Forwarded-*` and choose its address, host and scheme. A proxy that sends only `Forwarded` must send
|
||||||
|
`X-Forwarded-For`, `X-Forwarded-Proto` and `X-Forwarded-Host` instead.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **`PluginSiteFiles.readText`, `stat` and `list` no longer report a file or folder they cannot reach as absent.**
|
||||||
|
When a folder cannot be searched (its permissions, a stale network mount), these calls now throw `IOException`, as
|
||||||
|
their contract said; only a path that is certainly not there answers empty. A plugin that treated "absent" as "start
|
||||||
|
afresh" could otherwise act on a passing read failure. The testkit's `TempDirSiteFiles` behaves the same way.
|
||||||
|
- **`Sites.find` no longer answers "no such site" for a site whose folder it cannot read.** It throws instead, so a
|
||||||
|
plugin cannot take a live site for a deleted one; site lists leave such a site out and log it, as before.
|
||||||
|
|
||||||
|
## [1.0.1] — 2026-10-21
|
||||||
|
|
||||||
|
_A patch release: every first-party plugin is now published with Runway — blog, carousel-manager, contact and
|
||||||
|
discoverability join demo, search, search-lucene and lucene-provider — the installed release carries its license
|
||||||
|
files, the install instructions work as written, and the 1.0.0 upgrade notes are corrected. The plugin contract is unchanged (SPI `1.0.0`); every plugin release that
|
||||||
|
`1.0.0` paired with loads unchanged. Built on the `1.0.1-SNAPSHOT` line after `1.0.0`._
|
||||||
|
|
||||||
|
### Upgrading — read this first
|
||||||
|
|
||||||
|
**From `1.0.0`: a kernel upgrade, no flag, no setting; plugin upgrades optional.** Coming from an older release: read each
|
||||||
|
newer release's *Upgrading* first, oldest first. Paths are the installer defaults (`/opt/runway`, `/opt/runway-data`).
|
||||||
|
|
||||||
|
**1. Back up.** Take each site's backup (**Backups**) and copy `/opt/runway-data/external/` somewhere **outside**
|
||||||
|
`external/plugins/`. Nothing in `platform.yml` changes in this release.
|
||||||
|
|
||||||
|
**2. Upgrade the kernel:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x runway-1.0.1.bin
|
||||||
|
sudo ./runway-1.0.1.bin -y
|
||||||
|
```
|
||||||
|
|
||||||
|
The essential plugin moves with the kernel to `1.0.1` (its descriptor changes in comments and version only, and its
|
||||||
|
jar is rebuilt), so the installer refreshes it; expect these lines, once:
|
||||||
|
|
||||||
|
```
|
||||||
|
refreshing bundled plugin 'protection' from this release (it moves with the kernel; files you edited are backed up)
|
||||||
|
plugin 'protection': plugin.yml replaced (the previous one kept as plugin.yml.bak, for a rollback)
|
||||||
|
plugin 'protection': runway-plugin-protection.jar replaced (the previous one kept as runway-plugin-protection.jar.bak, for a rollback)
|
||||||
|
keeping the bundled plugins in the release: /opt/runway-1.0.1/seed/ (the repair copy — Administration §12)
|
||||||
|
```
|
||||||
|
|
||||||
|
**3. Check.** **About Runway** shows `1.0.1`; on **Plugins** every row is *Loaded*, none *Blocked*, and protection
|
||||||
|
shows `1.0.1`; the start log says `plugins: N registered, 0 blocked`. `/opt/runway-1.0.1/` now holds `LICENSE`,
|
||||||
|
`LICENSE-EXCEPTION` and `THIRD-PARTY-NOTICES`.
|
||||||
|
|
||||||
|
**4. Plugins (optional).** This release carries blog 2.1.0, carousel-manager 2.1.0, contact 2.1.0 and
|
||||||
|
discoverability 2.3.0, each built for Runway 1.0.0 with its license files, and search 2.3.1 (French strings for
|
||||||
|
visitors); their earlier releases keep working on 1.0.1. To upgrade one, read its CHANGELOG section, replace its folder with the new zip and restart.
|
||||||
|
|
||||||
|
**5. Rollback**, if needed: `sudo bash runway-1.0.0.bin -y` puts 1.0.0 back, its protection files included.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- **The installed release carries its license files.** The installer now copies `LICENSE`, `LICENSE-EXCEPTION`
|
||||||
|
and `THIRD-PARTY-NOTICES` into the release directory (`/opt/runway-<version>/`). In `1.0.0` they were in the
|
||||||
|
distribution zip and inside the jars (`META-INF/`), but not at the top of an installed release.
|
||||||
|
- **The install and upgrade instructions set the execute bit.** A downloaded `.bin` is not executable, so the
|
||||||
|
documented `sudo ./runway-<version>.bin` failed; README, Administration §3 and §15 and
|
||||||
|
Operations now run `chmod +x` first (`sudo bash runway-<version>.bin` works too).
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- **blog, carousel-manager, contact and discoverability are published**, under the GNU AGPL v3.0 with the additional
|
||||||
|
permission for plugins, and attached to this release beside demo, search, search-lucene and lucene-provider.
|
||||||
|
`KNOWN-LIMITATIONS.md` no longer lists the missing sitemap/robots/llms.txt/structured-data plugin, and the docs list
|
||||||
|
all eight plugins.
|
||||||
|
- **search 2.3.1 speaks French to visitors**: the search box, the results heading and count, "no results" and the
|
||||||
|
rate-limit notice.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Code comments across the kernel, the SPI's version log (`RunwaySpi`) and the protection descriptor no longer refer
|
||||||
|
to releases before `1.0.0`.
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
- **An upgrade to 1.0.0 printed more protection-refresh lines than its notes listed:** besides the jar, the installer
|
||||||
|
replaced protection's `plugin.yml` (keeping `plugin.yml.bak`) and updated `templates/admin-app.th.xml` and
|
||||||
|
`templates/app-dos.th.xml`, which changed in comments only. Upgrading to 1.0.1 prints the four lines listed above.
|
||||||
|
- The documentation links the releases page directly (<https://g.quest.mx/quest/runway/releases>), and
|
||||||
|
Administration §11 says where each plugin's zip comes from.
|
||||||
|
|
||||||
## [1.0.0] — 2026-10-21
|
## [1.0.0] — 2026-10-21
|
||||||
|
|
||||||
The first public release of Runway: a multi-site web platform built as a small multi-tenant kernel, with every
|
The first public release of Runway: a multi-site web platform built as a small multi-tenant kernel, with every
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ feature delivered as a plugin or a first-class SPI implementation.
|
|||||||
| Version | `1.0.0` (plugin contract: SPI `1.0.0`) — the exact version is in the root `pom.xml` and each release in [CHANGELOG.md](CHANGELOG.md) |
|
| Version | `1.0.0` (plugin contract: SPI `1.0.0`) — the exact version is in the root `pom.xml` and each release in [CHANGELOG.md](CHANGELOG.md) |
|
||||||
| Java | 25+ |
|
| Java | 25+ |
|
||||||
| Framework | Spring Boot 4 on embedded Jetty |
|
| Framework | Spring Boot 4 on embedded Jetty |
|
||||||
| Storage | Filesystem / YAML (no database) |
|
| Storage | Filesystem / YAML (no database); plugins may use PostgreSQL or MariaDB through the database plugins |
|
||||||
| Status | **Stable.** Semantic Versioning from `1.0.0`. The kernel, both realms, the setup wizard (with a catch-all default site), the page editor, per-site backups and optional in-app TLS termination run today; open items are in [docs/KNOWN-LIMITATIONS.md](docs/KNOWN-LIMITATIONS.md). |
|
| Status | **Stable.** Semantic Versioning from `1.0.0`. The kernel, both realms, the setup wizard (with a catch-all default site), the page editor, per-site backups and optional in-app TLS termination run today; open items are in [docs/KNOWN-LIMITATIONS.md](docs/KNOWN-LIMITATIONS.md). |
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
@@ -23,11 +23,13 @@ runway/ reactor (this pom)
|
|||||||
├── runway-plugin-protection/ the essential protection plugin (rate-limit edge guard, login gate, CAPTCHA;
|
├── runway-plugin-protection/ the essential protection plugin (rate-limit edge guard, login gate, CAPTCHA;
|
||||||
│ shipped inside the installer and seeded on a fresh install)
|
│ shipped inside the installer and seeded on a fresh install)
|
||||||
├── runway-dist/ packaging only: the dist zip, the self-extracting .bin installer, checksums
|
├── runway-dist/ packaging only: the dist zip, the self-extracting .bin installer, checksums
|
||||||
└── plugins/ the plugins demo, search, search-lucene, lucene-provider (not reactor modules)
|
└── plugins/ every first-party plugin, each a standalone project (not reactor modules)
|
||||||
```
|
```
|
||||||
|
|
||||||
The plugins under `plugins/` are **standalone** projects, each with its own build; one with code is built
|
The plugins under `plugins/` are **standalone** projects, each with its own build; one with code is built
|
||||||
against `runway-spi` alone as a `provided` dependency (with `runway-spi-testkit` for its tests). A plugin that links `runway-app` classes is refused at
|
against `runway-spi` as a `provided` dependency (with `runway-spi-testkit` for its tests), plus another plugin's
|
||||||
|
published SPI when it implements or uses one (search-lucene uses search's; the database providers and the guestbook
|
||||||
|
example use database's). A plugin that links `runway-app` classes is refused at
|
||||||
load time — the 1.0 plugin contract is the SPI ([SPI-STABILITY.md](docs/SPI-STABILITY.md)).
|
load time — the 1.0 plugin contract is the SPI ([SPI-STABILITY.md](docs/SPI-STABILITY.md)).
|
||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
@@ -42,6 +44,7 @@ bundle appended — no `makeself`, only stock `bash`/`tar`/`gzip`). Run it as ro
|
|||||||
**idempotent**, so re-running the same or a newer `.bin` upgrades in place:
|
**idempotent**, so re-running the same or a newer `.bin` upgrades in place:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
chmod +x runway-<version>.bin # a download has no execute bit
|
||||||
sudo ./runway-<version>.bin # interactive: prompts on a TTY
|
sudo ./runway-<version>.bin # interactive: prompts on a TTY
|
||||||
sudo ./runway-<version>.bin -y # unattended, all defaults
|
sudo ./runway-<version>.bin -y # unattended, all defaults
|
||||||
sudo ./runway-<version>.bin -y --no-firewall # ...and never touch the host firewall
|
sudo ./runway-<version>.bin -y --no-firewall # ...and never touch the host firewall
|
||||||
@@ -56,8 +59,8 @@ The installer lays the code under `/opt/runway-<version>`, points `/opt/runway`
|
|||||||
keeps editable state (`external/`, `logs/`, `backups/`) in the version-independent
|
keeps editable state (`external/`, `logs/`, `backups/`) in the version-independent
|
||||||
`/opt/runway-data/` so upgrades never clobber it, installs a systemd unit, relabels
|
`/opt/runway-data/` so upgrades never clobber it, installs a systemd unit, relabels
|
||||||
SELinux contexts (required on enforcing RHEL-family hosts), and starts the service.
|
SELinux contexts (required on enforcing RHEL-family hosts), and starts the service.
|
||||||
There is **no database to configure** — Runway is filesystem/YAML-backed; first-run
|
There is **no database to configure** — Runway is filesystem/YAML-backed (plugins that need a database use
|
||||||
configuration happens in the app's own wizard (below).
|
the optional database plugins); first-run configuration happens in the app's own wizard (below).
|
||||||
|
|
||||||
Confirm it is up:
|
Confirm it is up:
|
||||||
|
|
||||||
|
|||||||
+340
-25
@@ -65,7 +65,7 @@ a listing table's column menu). Day-to-day operational troubleshooting lives in
|
|||||||
|---|---|
|
|---|---|
|
||||||
| **OS** | Linux with **systemd** (the installer and unit target it; tested on RHEL-family — Rocky/Fedora/Alma — and Debian-family). macOS/Windows are not covered by the installer. |
|
| **OS** | Linux with **systemd** (the installer and unit target it; tested on RHEL-family — Rocky/Fedora/Alma — and Debian-family). macOS/Windows are not covered by the installer. |
|
||||||
| **Java** | A **JDK or JRE 25+** on the host. A JRE is sufficient — Runway does **not** compile at runtime. The installer auto-detects a 25+ runtime (Zulu, Temurin, generic OpenJDK) or you point it with `--java-home`. |
|
| **Java** | A **JDK or JRE 25+** on the host. A JRE is sufficient — Runway does **not** compile at runtime. The installer auto-detects a 25+ runtime (Zulu, Temurin, generic OpenJDK) or you point it with `--java-home`. |
|
||||||
| **Database** | **None.** The kernel is filesystem/YAML-backed on purpose; there is no SQL server to install or configure, and the first-run wizard never asks for one. A deployment that genuinely needs a database adds it as a plugin. |
|
| **Database** | **None.** The kernel is filesystem/YAML-backed on purpose; there is no SQL server to install or configure, and the first-run wizard never asks for one. Plugins that need one use PostgreSQL or MariaDB through the **database plugins** (§11.1). |
|
||||||
| **CPU / RAM** | Modest. The service runs in one JVM; the shipped heap is `-Xms256m -Xmx1g` (`JAVA_OPTS` in the unit), which suits a small VM. Note the sizing interlock: each Argon2id password verification costs 19–32 MiB, and the hash pool is bounded (`runway.security.max-concurrent-hashes`, default 8) precisely so a login flood cannot exhaust heap — keep `-Xmx` comfortably above `max-concurrent-hashes × memory-cost`. |
|
| **CPU / RAM** | Modest. The service runs in one JVM; the shipped heap is `-Xms256m -Xmx1g` (`JAVA_OPTS` in the unit), which suits a small VM. Note the sizing interlock: each Argon2id password verification costs 19–32 MiB, and the hash pool is bounded (`runway.security.max-concurrent-hashes`, default 8) precisely so a login flood cannot exhaust heap — keep `-Xmx` comfortably above `max-concurrent-hashes × memory-cost`. |
|
||||||
| **Disk** | The code footprint is small (a single fat jar). Plan capacity for **editable state**: `external/` (config + all site folders), `logs/`, and `backups/` (site backup archives can be large — see **§13**). |
|
| **Disk** | The code footprint is small (a single fat jar). Plan capacity for **editable state**: `external/` (config + all site folders), `logs/`, and `backups/` (site backup archives can be large — see **§13**). |
|
||||||
| **Network / ports** | One HTTP listener. By default Runway serves **plain HTTP on port 8080** and expects a reverse proxy (HAProxy/nginx/Caddy) in front to terminate TLS (**§7**). Change the port with `--server.port=` (`RUNWAY_OPTS`). Binding a privileged port (80/443) directly needs `CAP_NET_BIND_SERVICE` — see the unit (**§6**). |
|
| **Network / ports** | One HTTP listener. By default Runway serves **plain HTTP on port 8080** and expects a reverse proxy (HAProxy/nginx/Caddy) in front to terminate TLS (**§7**). Change the port with `--server.port=` (`RUNWAY_OPTS`). Binding a privileged port (80/443) directly needs `CAP_NET_BIND_SERVICE` — see the unit (**§6**). |
|
||||||
@@ -182,6 +182,7 @@ curl -fL -O \
|
|||||||
curl -fL -O \
|
curl -fL -O \
|
||||||
https://g.quest.mx/quest/runway/releases/download/latest/SHA256SUMS
|
https://g.quest.mx/quest/runway/releases/download/latest/SHA256SUMS
|
||||||
sha256sum -c SHA256SUMS --ignore-missing # must print: runway-latest.bin: OK
|
sha256sum -c SHA256SUMS --ignore-missing # must print: runway-latest.bin: OK
|
||||||
|
chmod +x runway-latest.bin # a download has no execute bit
|
||||||
sudo ./runway-latest.bin
|
sudo ./runway-latest.bin
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -202,6 +203,7 @@ your own high-volume clients*.
|
|||||||
**Install (interactive).** Copy the `.bin` to the target host and run it as root:
|
**Install (interactive).** Copy the `.bin` to the target host and run it as root:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
chmod +x runway-<version>.bin # a download has no execute bit
|
||||||
sudo ./runway-<version>.bin
|
sudo ./runway-<version>.bin
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -445,7 +447,7 @@ host is bound).
|
|||||||
|
|
||||||
## 7. TLS & reverse-proxy setup
|
## 7. TLS & reverse-proxy setup
|
||||||
|
|
||||||
**Trusting forwarded headers (implemented).** Runway honors `X-Forwarded-*`/`Forwarded` headers (client IP,
|
**Trusting forwarded headers (implemented).** Runway honors `X-Forwarded-*` headers (client IP,
|
||||||
host, scheme) **only** from proxy peers you list in `runway.proxy.trusted-cidrs`; from any other peer the
|
host, scheme) **only** from proxy peers you list in `runway.proxy.trusted-cidrs`; from any other peer the
|
||||||
headers are ignored and the raw connection is used, so a directly-reachable instance cannot spoof them. The
|
headers are ignored and the raw connection is used, so a directly-reachable instance cannot spoof them. The
|
||||||
container's own forwarded-header handling is off (`server.forward-headers-strategy: none`) — Runway's gated
|
container's own forwarded-header handling is off (`server.forward-headers-strategy: none`) — Runway's gated
|
||||||
@@ -456,6 +458,48 @@ nothing (every request attributed to its direct peer, logged at startup). A catc
|
|||||||
or ranges that add up to one, such as `0.0.0.0/1` with `128.0.0.0/1`) trusts every client to fake its address:
|
or ranges that add up to one, such as `0.0.0.0/1` with `128.0.0.0/1`) trusts every client to fake its address:
|
||||||
Server settings refuses it, and one set in `application.yml` is warned about at startup. Never put a tenant-editable value here — it is an isolation/abuse boundary.
|
Server settings refuses it, and one set in `application.yml` is warned about at startup. Never put a tenant-editable value here — it is an isolation/abuse boundary.
|
||||||
|
|
||||||
|
**Which address is the client.** Each proxy *appends* the address it received the request from to
|
||||||
|
`X-Forwarded-For`, so everything to the left of what your own proxies wrote may have come from the client itself.
|
||||||
|
Runway therefore reads the list **from the right**: it skips the addresses in `trusted-cidrs` and takes the first
|
||||||
|
one that is not a proxy you trust. That is the address your nearest trusted proxy saw, and it is what rate limits,
|
||||||
|
login lockouts, the access log and every plugin see. An entry that is not an IP address where one is needed
|
||||||
|
(`unknown`, a host name) attributes the request to the proxy instead; Runway never looks names up. So list
|
||||||
|
**every** proxy of yours in `trusted-cidrs`, a CDN in front of the reverse proxy included, or the client will be
|
||||||
|
taken to be the outermost one.
|
||||||
|
|
||||||
|
**Only the `X-Forwarded-*` headers are read.** The standard `Forwarded` header (RFC 7239) is ignored, even from a
|
||||||
|
trusted proxy: a client could otherwise send its own `Forwarded` through a proxy that only manages
|
||||||
|
`X-Forwarded-*` and choose its address, host and scheme. A proxy that sends only `Forwarded` must be set to send
|
||||||
|
`X-Forwarded-For`, `X-Forwarded-Proto` and `X-Forwarded-Host` instead. From a trusted proxy Runway also applies
|
||||||
|
`X-Forwarded-Port` and `X-Forwarded-Prefix` (and `X-Forwarded-Ssl`), so whatever of these the proxy does not write
|
||||||
|
itself comes from the client. The proxy should **set** (replace) `X-Forwarded-Proto` and `X-Forwarded-Host`, and
|
||||||
|
**delete** the others it does not set:
|
||||||
|
|
||||||
|
```
|
||||||
|
# HAProxy
|
||||||
|
http-request set-header X-Forwarded-Proto https if { ssl_fc }
|
||||||
|
http-request set-header X-Forwarded-Proto http if !{ ssl_fc }
|
||||||
|
http-request set-header X-Forwarded-Host %[req.hdr(host)]
|
||||||
|
http-request del-header X-Forwarded-Port
|
||||||
|
http-request del-header X-Forwarded-Prefix
|
||||||
|
http-request del-header X-Forwarded-Ssl
|
||||||
|
option forwardfor
|
||||||
|
```
|
||||||
|
|
||||||
|
nginx: `proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;`, `proxy_set_header X-Forwarded-Proto
|
||||||
|
$scheme;`, `proxy_set_header X-Forwarded-Host $host;`, and `proxy_set_header X-Forwarded-Port "";`,
|
||||||
|
`proxy_set_header X-Forwarded-Prefix "";`, `proxy_set_header X-Forwarded-Ssl "";` (an empty value removes the
|
||||||
|
header).
|
||||||
|
|
||||||
|
**Check it.** **Settings → About Runway → This request** shows the request that loaded the page as Runway saw it:
|
||||||
|
the connection it came from and whether that is a trusted proxy, the `X-Forwarded-For` list as received (marked
|
||||||
|
*ignored* when the peer is not trusted), the client address Runway used, and the scheme and host. Behind a correctly
|
||||||
|
trusted proxy the client address is your own public address, not the proxy's. To check that a client cannot choose
|
||||||
|
its address, open the page once with a forged header (a browser extension that adds `X-Forwarded-For: 192.0.2.1`, or
|
||||||
|
`curl -H 'X-Forwarded-For: 192.0.2.1'` with a signed-in session cookie). Behind a proxy that appends to the header
|
||||||
|
(`option forwardfor`, `$proxy_add_x_forwarded_for`) the list shows `192.0.2.1` on its left; behind one that replaces
|
||||||
|
it, `192.0.2.1` does not appear at all. Either way the client address stays yours.
|
||||||
|
|
||||||
**The host name behind a proxy.** Runway decides which site a request is for, and whether the operator console
|
**The host name behind a proxy.** Runway decides which site a request is for, and whether the operator console
|
||||||
answers (**§8.6**), from the host name it sees: the request's own `Host`, or the forwarded host from a trusted proxy.
|
answers (**§8.6**), from the host name it sees: the request's own `Host`, or the forwarded host from a trusted proxy.
|
||||||
So the proxy must pass the visitor's host name on (`proxy_set_header Host $host;` in nginx, the default in HAProxy
|
So the proxy must pass the visitor's host name on (`proxy_set_header Host $host;` in nginx, the default in HAProxy
|
||||||
@@ -663,9 +707,10 @@ from the configuration metadata shipped in the jar.
|
|||||||
| `runway.security.password-strength` | `STANDARD` | Argon2id memory-cost profile for **new** passwords: `STANDARD` (19 MiB) or `HIGH` (32 MiB). The Settings screen can override this (**§8.1**). |
|
| `runway.security.password-strength` | `STANDARD` | Argon2id memory-cost profile for **new** passwords: `STANDARD` (19 MiB) or `HIGH` (32 MiB). The Settings screen can override this (**§8.1**). |
|
||||||
| `runway.security.max-concurrent-hashes` | `8` | Most password hashes computed at once before requests fail "busy" — bounds heap under a login flood. Read once at startup (Settings → Server settings → Capacity, or here); at least `1` — `0` or a negative value stops startup. |
|
| `runway.security.max-concurrent-hashes` | `8` | Most password hashes computed at once before requests fail "busy" — bounds heap under a login flood. Read once at startup (Settings → Server settings → Capacity, or here); at least `1` — `0` or a negative value stops startup. |
|
||||||
| `runway.security.acquire-timeout-millis` | `2000` | How long a request waits for a hashing slot before failing "busy". |
|
| `runway.security.acquire-timeout-millis` | `2000` | How long a request waits for a hashing slot before failing "busy". |
|
||||||
| `runway.security.secret-key` | _(installer-set)_ | Master key for AES-256-GCM encryption of every stored secret (platform SMTP password, per-site CAPTCHA secrets, `secret`-typed plugin settings). The installer generates one on first install and stores it in a root-only systemd drop-in as `RUNWAY_SECURITY_SECRET_KEY` (see `--secret-key`, §3); Spring's relaxed binding maps that env var to this property. **While blank the secret cipher is unavailable and no secret can be saved** — the app console shows a persistent warning on every page until it is set. Holds a real secret — never in the classpath default. |
|
| `runway.security.secret-key` | _(installer-set)_ | Master key for AES-256-GCM encryption of every stored secret (platform SMTP password or OAuth2 client secret, per-site CAPTCHA secrets, `secret`-typed plugin settings). The installer generates one on first install and stores it in a root-only systemd drop-in as `RUNWAY_SECURITY_SECRET_KEY` (see `--secret-key`, §3); Spring's relaxed binding maps that env var to this property. **While blank the secret cipher is unavailable and no secret can be saved** — the app console shows a persistent warning on every page until it is set. Holds a real secret — never in the classpath default. |
|
||||||
| `runway.proxy.forwarded-headers` | `true` | Whether to honor `X-Forwarded-*` / `Forwarded` at all (still only from trusted peers) — see **§7**. |
|
| `runway.proxy.forwarded-headers` | `true` | Whether to honor `X-Forwarded-*` at all (still only from trusted peers; the standard `Forwarded` header is never read) — see **§7**. |
|
||||||
| `runway.proxy.trusted-cidrs` | `127.0.0.1/32`, `::1/128` | Proxy peers whose forwarded headers are trusted. The **bound default is empty** (trust nothing); the shipped file seeds loopback. **§7**. |
|
| `runway.proxy.trusted-cidrs` | `127.0.0.1/32`, `::1/128` | Proxy peers whose forwarded headers are trusted. The **bound default is empty** (trust nothing); the shipped file seeds loopback. **§7**. |
|
||||||
|
| `runway.http.min-request-data-rate` | `4096` | The slowest a request body may arrive, in **bytes per second**, before Runway answers `408 Request Timeout` and frees the request thread. It applies to every body — login and other forms, multipart uploads, raw bodies alike. Without it a client sending a byte now and then kept a thread for as long as it liked (the idle timeout only limits one stalled read). Only the time spent waiting for the client counts, from the first second of waiting on, so a server slow to start reading is never blamed, and a body that has arrived complete is never refused, however late its last packet came. Sending part of a body fast earns at most 30 seconds of waiting, so a large body cannot buy a long drip; a client pausing between packets is cut when its next packet arrives, within one idle timeout. 4096 (4 KiB/s) is below any real connection; `0` turns the check off. Set on **Settings → Server settings → Request limits**; applies after a restart. |
|
||||||
| `runway.i18n.cache-seconds` | `5` | How often a message lookup **outside** a public page (an error page, a plugin's background text) and the operator console's own bundle re-check their files on disk (`0` = on every lookup). Public pages re-check on every request, so a bundle edited on disk shows on the next page view, under a new ETag. |
|
| `runway.i18n.cache-seconds` | `5` | How often a message lookup **outside** a public page (an error page, a plugin's background text) and the operator console's own bundle re-check their files on disk (`0` = on every lookup). Public pages re-check on every request, so a bundle edited on disk shows on the next page view, under a new ETag. |
|
||||||
| `runway.csp.mode` | `report` | Content-Security-Policy delivery: `report` (report-only — violations are logged, nothing is blocked), `enforce`, or `off`. Upper or lower case; blank means `report`. Any other value (`enforced`, say) stops startup with a message naming it. See **§8.4**. |
|
| `runway.csp.mode` | `report` | Content-Security-Policy delivery: `report` (report-only — violations are logged, nothing is blocked), `enforce`, or `off`. Upper or lower case; blank means `report`. Any other value (`enforced`, say) stops startup with a message naming it. See **§8.4**. |
|
||||||
| `runway.csp.strict-dynamic` | `true` | `'strict-dynamic'` on the nonced pages. `false` rolls the whole estate (console **and** public pages) back to the host allowlist. **§8.4**. |
|
| `runway.csp.strict-dynamic` | `true` | `'strict-dynamic'` on the nonced pages. `false` rolls the whole estate (console **and** public pages) back to the host allowlist. **§8.4**. |
|
||||||
@@ -693,6 +738,7 @@ from the configuration metadata shipped in the jar.
|
|||||||
| `spring.thymeleaf.servlet.produce-partial-output-while-processing` | `false` | A page is rendered whole before its first byte is sent. Streamed instead (Boot's default), an error halfway through a render would leave the visitor a blank or cut-off page instead of the error page. Do not turn it on. |
|
| `spring.thymeleaf.servlet.produce-partial-output-while-processing` | `false` | A page is rendered whole before its first byte is sent. Streamed instead (Boot's default), an error halfway through a render would leave the visitor a blank or cut-off page instead of the error page. Do not turn it on. |
|
||||||
| `server.servlet.session.timeout` | `30m` | How long a signed-in session (the operator console and every site console) may sit idle before it signs out. A duration such as `30m`, `2h` or `1d`; a bare number means seconds. Set on **Settings → Server settings → Sessions**; applies after a restart. With clustering on, `runway.cluster.session-ttl` decides instead — keep the two equal (§2). |
|
| `server.servlet.session.timeout` | `30m` | How long a signed-in session (the operator console and every site console) may sit idle before it signs out. A duration such as `30m`, `2h` or `1d`; a bare number means seconds. Set on **Settings → Server settings → Sessions**; applies after a restart. With clustering on, `runway.cluster.session-ttl` decides instead — keep the two equal (§2). |
|
||||||
| `server.jetty.threads.max` / `.min` | `200` / `8` | The request thread pool (§2, *Capacity*). Set on **Settings → Server settings → Capacity**; applies after a restart; the minimum may not exceed the maximum. |
|
| `server.jetty.threads.max` / `.min` | `200` / `8` | The request thread pool (§2, *Capacity*). Set on **Settings → Server settings → Capacity**; applies after a restart; the minimum may not exceed the maximum. |
|
||||||
|
| `server.jetty.connection-idle-timeout` | `30s` | How long a connection may make no progress before Jetty closes it — a request with nothing more to read, or a response the client has stopped reading. Jetty's own default, stated so it has one home. It is what ends a client that reads a large response too slowly; a request body that keeps trickling in is ended by `runway.http.min-request-data-rate` instead. |
|
||||||
| `server.ssl.*` | from `runway.tls.*` | Filled from `runway.tls.*` (§7.1). Never set these yourself: they would bypass Runway's TLS startup checks. |
|
| `server.ssl.*` | from `runway.tls.*` | Filled from `runway.tls.*` (§7.1). Never set these yourself: they would bypass Runway's TLS startup checks. |
|
||||||
| `management.endpoints.web.exposure.include` | `health, prometheus` | The only actuator endpoints served. Do not add others: everything under `/actuator/` is open to the superadmin and System admins without the console's CSRF protection, and an endpoint such as `heapdump` would hand out what the server holds in memory, secrets included. |
|
| `management.endpoints.web.exposure.include` | `health, prometheus` | The only actuator endpoints served. Do not add others: everything under `/actuator/` is open to the superadmin and System admins without the console's CSRF protection, and an endpoint such as `heapdump` would hand out what the server holds in memory, secrets included. |
|
||||||
| `management.endpoint.health.probes.enabled` | `true` | Adds `/actuator/health/liveness` and `/actuator/health/readiness` for a supervisor or load balancer. |
|
| `management.endpoint.health.probes.enabled` | `true` | Adds `/actuator/health/liveness` and `/actuator/health/readiness` for a supervisor or load balancer. |
|
||||||
@@ -739,14 +785,14 @@ it never travels in a per-site backup:
|
|||||||
`RUNWAY_NODE_NAME=web-1` suits that); a value saved in the field wins over it. The name is only displayed; nothing
|
`RUNWAY_NODE_NAME=web-1` suits that); a value saved in the field wins over it. The name is only displayed; nothing
|
||||||
else uses it.
|
else uses it.
|
||||||
- **Platform mail (SMTP)** — the application's own mail account: host, port, From address, and optional
|
- **Platform mail (SMTP)** — the application's own mail account: host, port, From address, and optional
|
||||||
authentication (username + password) with STARTTLS or implicit TLS. With STARTTLS chosen, a relay that does
|
authentication (a username and password, or an OAuth2 token for Microsoft 365) with STARTTLS or implicit TLS. With STARTTLS chosen, a relay that does
|
||||||
not offer it fails the send rather than receiving the password in the clear, and with either TLS mode the
|
not offer it fails the send rather than receiving the password in the clear, and with either TLS mode the
|
||||||
relay's certificate must name its host. A relay that does not accept the connection within 10 seconds, or
|
relay's certificate must name its host. A relay that does not accept the connection within 10 seconds, or
|
||||||
stalls for 30 seconds while sending, fails the send. It is used to send
|
stalls for 30 seconds while sending, fails the send. It is used to send
|
||||||
**password-recovery** links and any future operator notifications, for **both** the application and
|
**password-recovery** links and any future operator notifications, for **both** the application and
|
||||||
site consoles — and is **never** used for mail a site sends itself (a site keeps its own SMTP
|
site consoles — and is **never** used for mail a site sends itself (a site keeps its own SMTP
|
||||||
relay). The password is stored **encrypted** (leave the field blank on a later save to keep the stored
|
relay). The password is stored **encrypted** (leave the field blank on a later save to keep the stored
|
||||||
one), and a **Send test email** button verifies the account. See **§8.3**. The fields in detail:
|
one, as long as the server stays the same: see below), and a **Send test email** button verifies the account. See **§8.3**. The fields in detail:
|
||||||
- Mail counts as configured — the *Forgot your password?* links appear and the test button works — only when
|
- Mail counts as configured — the *Forgot your password?* links appear and the test button works — only when
|
||||||
**both** the host and the From address are set.
|
**both** the host and the From address are set.
|
||||||
- **Port** — blank means `587`; otherwise a number from 1 to 65535.
|
- **Port** — blank means `587`; otherwise a number from 1 to 65535.
|
||||||
@@ -754,9 +800,77 @@ it never travels in a per-site backup:
|
|||||||
usually port `465`). If both are ticked, SSL is used and STARTTLS is ignored. With neither, the connection is
|
usually port `465`). If both are ticked, SSL is used and STARTTLS is ignored. With neither, the connection is
|
||||||
not encrypted, and neither is the password when authentication is on.
|
not encrypted, and neither is the password when authentication is on.
|
||||||
- **Authentication** — off by default; while it is off the username and password are not sent.
|
- **Authentication** — off by default; while it is off the username and password are not sent.
|
||||||
- **The password cannot be removed from this form:** a blank field always keeps the stored one, even when you
|
- **Sign-in method** — *Username and password*, or *OAuth2 token (Microsoft 365)*: see *Microsoft 365 and other
|
||||||
empty every other field. To remove it, delete the `smtp:` block (or its `password:` line) from
|
OAuth2 mail servers* below. The fields of the method not chosen are hidden but kept, so switching back does not
|
||||||
`external/platform.yml` and restart (see *Editing platform.yml by hand* below).
|
lose them.
|
||||||
|
- **A stored secret follows its server.** A blank password field keeps the stored password only while the host,
|
||||||
|
port and username stay the same; when one of them changes, the password is cleared, the page says so, and it
|
||||||
|
must be entered again. The OAuth2 client secret is kept only while the token endpoint, the client ID, the mail
|
||||||
|
server (host and port) and the scope stay the same, because the secret goes to the endpoint and the token minted
|
||||||
|
from it goes to the mail server; an OAuth2 account where one of them changes is not saved until the secret is
|
||||||
|
entered again. This way someone who may edit this screen, but does not know the secret, cannot have Runway send
|
||||||
|
it, or a token made from it, to a server of their choosing. The activity log's `platform.settings-changed` line names the settings each save
|
||||||
|
changed (never their values) and any secret it cleared.
|
||||||
|
- **Otherwise the password cannot be removed from this form:** with the same server, a blank field keeps the
|
||||||
|
stored one. To remove it, delete the `smtp:` block (or its `password:` line) from `external/platform.yml` and
|
||||||
|
restart (see *Editing platform.yml by hand* below). The same goes for the OAuth2 client secret
|
||||||
|
(`oauthClientSecret:`).
|
||||||
|
|
||||||
|
**Microsoft 365 and other OAuth2 mail servers.** Microsoft is retiring password sign-in to SMTP (SMTP AUTH with
|
||||||
|
"Basic authentication") in Exchange Online: Microsoft has announced that it is turned off by default from the end
|
||||||
|
of December 2026 (Message Center MC786329), and it already fails in a tenant whose security defaults or
|
||||||
|
Conditional Access block legacy sign-in. Runway can sign in the way Microsoft
|
||||||
|
requires instead: it obtains an **OAuth2 access token** with an application's own credentials (the
|
||||||
|
*client-credentials* grant) and presents it to the mail server with SASL `XOAUTH2`. In the Microsoft 365 admin
|
||||||
|
tools, once:
|
||||||
|
|
||||||
|
1. In **Microsoft Entra ID → App registrations**, register an application. Note its **Application (client) ID** and
|
||||||
|
the **Directory (tenant) ID**, and under **Certificates & secrets** create a **client secret** (note its *value*,
|
||||||
|
and when it expires).
|
||||||
|
2. Under **API permissions**, add the application permission **Office 365 Exchange Online → SMTP.SendAsApp** and
|
||||||
|
**grant admin consent**.
|
||||||
|
3. In Exchange Online PowerShell, register the application's service principal and give it the mailbox Runway sends
|
||||||
|
as: `New-ServicePrincipal -AppId <client id> -ObjectId <object id of the enterprise application>`, then
|
||||||
|
`Add-MailboxPermission -Identity <mailbox> -User <service principal id> -AccessRights FullAccess`.
|
||||||
|
4. Make sure **Authenticated SMTP** is enabled for that mailbox (Microsoft 365 admin center → the user → Mail →
|
||||||
|
Manage email apps). OAuth2 still goes through SMTP AUTH.
|
||||||
|
|
||||||
|
Then on this page: host `smtp.office365.com`, port `587`, **STARTTLS** on, **Authentication** on, sign-in method
|
||||||
|
**OAuth2 token**, and:
|
||||||
|
|
||||||
|
| Field | Microsoft 365 value |
|
||||||
|
|---|---|
|
||||||
|
| Username | the mailbox to send as (blank uses the From address) |
|
||||||
|
| Token endpoint | `https://login.microsoftonline.com/<tenant id>/oauth2/v2.0/token` |
|
||||||
|
| Client ID | the application (client) ID |
|
||||||
|
| Client secret | the secret's value (stored encrypted, like the password) |
|
||||||
|
| Scope | `https://outlook.office365.com/.default` |
|
||||||
|
|
||||||
|
Save, then **Send test email**. A failure says which step failed: *"no OAuth2 token"* means the token endpoint
|
||||||
|
refused or could not be reached, and the message carries Microsoft's reason (an `AADSTS…` code: a wrong secret, a
|
||||||
|
wrong tenant, missing consent); any other failure came from the mail server after the token was issued (for
|
||||||
|
Microsoft, a missing `SMTP.SendAsApp` permission or mailbox permission, or Authenticated SMTP turned off).
|
||||||
|
|
||||||
|
How it behaves:
|
||||||
|
|
||||||
|
- **TLS is required.** An OAuth2 account must use STARTTLS or implicit TLS; the page refuses to save one without it,
|
||||||
|
because a token, like a password, signs in whoever reads it.
|
||||||
|
- **The token endpoint must be `https`** (`http` only to this machine's loopback address, for a local identity
|
||||||
|
provider). Runway does not follow a redirect from it, so the client secret is only ever sent to the address you
|
||||||
|
entered.
|
||||||
|
- **Tokens are reused** until five minutes before they expire (Microsoft's last about an hour), so a burst of
|
||||||
|
recovery mails costs one token request. A mail server that rejects a token makes Runway fetch a new one on the
|
||||||
|
next send.
|
||||||
|
- **Only `XOAUTH2` is offered** once OAuth2 is chosen: a server that does not support it fails the sign-in rather
|
||||||
|
than receiving the token as a password.
|
||||||
|
- **Remember the secret's expiry.** Microsoft client secrets expire (24 months at most); when it does, recovery mail
|
||||||
|
stops with an `AADSTS7000222` error. Create a new secret and enter it here before then.
|
||||||
|
- **Other providers.** Any mail server that accepts `XOAUTH2` tokens issued by a client-credentials grant works the
|
||||||
|
same way; enter that provider's token endpoint and scope. (Google Workspace issues such tokens to service accounts
|
||||||
|
through a signed JWT instead, which Runway does not do; use an app password or an SMTP relay there.)
|
||||||
|
- **Instead of OAuth2**, Microsoft 365 also accepts mail without any sign-in through an **inbound connector** that
|
||||||
|
trusts the server's fixed public IP address (port 25, Authentication off in Runway). That is set up entirely in
|
||||||
|
Exchange Online.
|
||||||
|
|
||||||
Leaving a field blank restores its default (no catch-all site; the `application.yml` password
|
Leaving a field blank restores its default (no catch-all site; the `application.yml` password
|
||||||
strength; the node name from `runway.node.name` or the host name; no platform mail). The three compression
|
strength; the node name from `runway.node.name` or the host name; no platform mail). The three compression
|
||||||
@@ -783,6 +897,11 @@ smtp:
|
|||||||
from: runway@example.com
|
from: runway@example.com
|
||||||
starttls: true
|
starttls: true
|
||||||
ssl: false
|
ssl: false
|
||||||
|
authMethod: password # password | oauth2
|
||||||
|
oauthTokenUrl: https://login.microsoftonline.com/<tenant id>/oauth2/v2.0/token # oauth2 only
|
||||||
|
oauthClientId: 00000000-0000-0000-0000-000000000000
|
||||||
|
oauthClientSecret: ENC(...)
|
||||||
|
oauthScope: https://outlook.office365.com/.default
|
||||||
```
|
```
|
||||||
|
|
||||||
The same file also keeps `settings:` (Server settings and the policy cards, §8.5), `siteQuotas:` (each site's
|
The same file also keeps `settings:` (Server settings and the policy cards, §8.5), `siteQuotas:` (each site's
|
||||||
@@ -810,7 +929,7 @@ Restricted to the application superadmin or a wildcard admin.
|
|||||||
|
|
||||||
**Settings → About Runway** (`/__app/about`) is a **read-only** view of the running platform — useful
|
**Settings → About Runway** (`/__app/about`) is a **read-only** view of the running platform — useful
|
||||||
when diagnosing an install or filing a report. Unlike Platform settings it changes nothing and exposes
|
when diagnosing an install or filing a report. Unlike Platform settings it changes nothing and exposes
|
||||||
no secret, so it is visible to **any** signed-in operator. It has three parts:
|
no secret, so it is visible to **any** signed-in operator. It has four parts:
|
||||||
|
|
||||||
- **Version & build** — the running version and, when the build carries it, the build timestamp.
|
- **Version & build** — the running version and, when the build carries it, the build timestamp.
|
||||||
- **Effective configuration** — a curated table of the non-secret settings in force: whether TLS
|
- **Effective configuration** — a curated table of the non-secret settings in force: whether TLS
|
||||||
@@ -823,14 +942,17 @@ no secret, so it is visible to **any** signed-in operator. It has three parts:
|
|||||||
heap, data-disk free/total, uptime, start time, PID, host name, time zone and locale — plus the
|
heap, data-disk free/total, uptime, start time, PID, host name, time zone and locale — plus the
|
||||||
versions of the bundled components (Spring Boot, Jetty, Thymeleaf, Jackson, and more). In a
|
versions of the bundled components (Spring Boot, Jetty, Thymeleaf, Jackson, and more). In a
|
||||||
multi-node deployment these describe **whichever node answered you**.
|
multi-node deployment these describe **whichever node answered you**.
|
||||||
|
- **This request** — the request that loaded the page as Runway saw it: the connection it came from and whether
|
||||||
|
that is a trusted proxy, the `X-Forwarded-For` list as received, the client address Runway used, and the scheme
|
||||||
|
and host. It checks a reverse-proxy setup from the browser (§7).
|
||||||
|
|
||||||
### 8.3 Password recovery
|
### 8.3 Password recovery
|
||||||
|
|
||||||
Both sign-in pages — the application login (`/app/login`) and each site's login (`/login`) — offer a
|
Both sign-in pages — the application login (`/app/login`) and each site's login (`/login`) — offer a
|
||||||
**"Forgot your password?"** link that lets a user reset their own password by email, without an operator.
|
**"Forgot your password?"** link that lets a user reset their own password by email, without an operator.
|
||||||
The link appears **only when platform mail is configured** (§8.1); until then, recovery is done manually
|
The link appears **only when platform mail is configured** (§8.1) **and the emailed link has an address to point
|
||||||
(reset an application user from **§9**, a tenant-superadmin from **§10**, or a site sub-user from the
|
at** (below); until then, recovery is done manually (reset an application user from **§9**, a tenant-superadmin
|
||||||
site console).
|
from **§10**, or a site sub-user from the site console).
|
||||||
|
|
||||||
How it works:
|
How it works:
|
||||||
|
|
||||||
@@ -853,8 +975,35 @@ How it works:
|
|||||||
account, and a site's link works **only on that site's own host**. A tenant-superadmin who manages
|
account, and a site's link works **only on that site's own host**. A tenant-superadmin who manages
|
||||||
several sites has one password; recovering it from any of their sites resets that single account.
|
several sites has one password; recovering it from any of their sites resets that single account.
|
||||||
|
|
||||||
There is nothing to configure beyond the platform mail account — recovery is on automatically once mail
|
**Where the emailed link points.** Never at the host name the request came in on: anyone can send a request that
|
||||||
works. Verify it with **Send test email** (§8.1), then exercise a full round-trip from a login page.
|
names any host (a made-up `Host`, or `X-Forwarded-Host` through a proxy that passes it on), and a reset mail with a
|
||||||
|
link to that host would hand the sender the token. The address comes from what Runway was told:
|
||||||
|
|
||||||
|
- **A site's sign-in:** the site's own address: its **base URL**, or else `https://` and its **first** host name,
|
||||||
|
with no port. A site with no host name offers no recovery, and nor does one whose first host is `localhost` (or
|
||||||
|
`127.0.0.1`, `::1`) and that has no base URL: that is what the setup wizard gives the default site, and
|
||||||
|
`https://localhost` reaches nobody who reads the mail. **A site served over plain `http` or on a port other than
|
||||||
|
443 needs its base URL set** (§10, *The site's base URL*), or its links point at `https://` and port 443.
|
||||||
|
- **The application console:** with `runway.console.hosts` set (§8.6), the listed name the request came in on (as
|
||||||
|
listed: case and a trailing dot in the request do not count), the request's scheme, and the port listed with the
|
||||||
|
name if any, else the request's. The request's port is whatever the client wrote in its `Host` header (through a
|
||||||
|
proxy too: `X-Forwarded-Host` carries it), so list the name with its port (`ops.example.com:443`) to fix it.
|
||||||
|
Without `runway.console.hosts`, the **default site**'s address as above, on which the console also answers;
|
||||||
|
without one, the console offers no recovery: set `runway.console.hosts`, or give the default site a public host
|
||||||
|
name first, or a base URL.
|
||||||
|
|
||||||
|
**Who decides the console's link.** Without `runway.console.hosts`, whoever sets the default site's hosts or base URL
|
||||||
|
decides where the platform accounts' reset links go. So only a platform administrator (the application master or a
|
||||||
|
wildcard administrator) can edit the default site's hosts, even where `MANAGE_SITE_HOSTS` is delegated, and a
|
||||||
|
restore made from the site's own console keeps the site's hosts and base URL (§10). Setting `runway.console.hosts`
|
||||||
|
takes the default site out of it altogether.
|
||||||
|
|
||||||
|
The address a link points at is logged at INFO when one is requested (`a link, if mailed, points at …`), and a
|
||||||
|
request that finds no address is logged at WARN with the reason.
|
||||||
|
|
||||||
|
Beyond that there is nothing to configure: recovery is on once mail works. Verify it with **Send test email**
|
||||||
|
(§8.1), then exercise a full round-trip from a login page and check that the link in the mail points at the
|
||||||
|
address you expect.
|
||||||
|
|
||||||
### 8.4 Content-Security-Policy and the public-page nonce secret
|
### 8.4 Content-Security-Policy and the public-page nonce secret
|
||||||
|
|
||||||
@@ -1437,9 +1586,14 @@ entries are lowercased, trimmed and de-duplicated, each is validated as a hostna
|
|||||||
bound to **another** site is rejected (two sites can never claim the same host). The same rule applies
|
bound to **another** site is rejected (two sites can never claim the same host). The same rule applies
|
||||||
wherever a site gets hosts: creating a site, installing a demo, and creating a site from a backup refuse a
|
wherever a site gets hosts: creating a site, installing a demo, and creating a site from a backup refuse a
|
||||||
malformed host or one another site answers on, before anything is created. Restoring a backup brings back the
|
malformed host or one another site answers on, before anything is created. Restoring a backup brings back the
|
||||||
hosts the site had when the backup was taken; a host given to another site since then is left off, the log
|
hosts and base URL the site had when the backup was taken when it is made from the application console (a host
|
||||||
says which (`restored site '…' without host(s) […]`), and you can add it back with **Edit hosts** once it is
|
given to another site since then is left off, the log says which: `restored site '…' without host(s) […]`, and you
|
||||||
free. A host is a plain DNS name: no scheme, path,
|
can add it back with **Edit hosts** once it is free). After such a restore, and after creating a site from a backup,
|
||||||
|
the Backups screen shows the site's hosts and base URL **as they now are**, with the same editor as **Edit hosts**:
|
||||||
|
check them before anything else, because a backup taken on another installation, or before the site moved, brings
|
||||||
|
back how it was reached then. A restore made from the site's own console keeps the hosts and
|
||||||
|
base URL the site has: how a site is reached is yours to set, never the site manager's, and a backup file is
|
||||||
|
theirs to write. A host is a plain DNS name: no scheme, path,
|
||||||
port (`example.com:8080`), wildcard (`*.example.com`) or underscore, and an international name is written in its
|
port (`example.com:8080`), wildcard (`*.example.com`) or underscore, and an international name is written in its
|
||||||
`xn--` form. The port is never part of the match: a site answers on its hosts on whatever port Runway listens on.
|
`xn--` form. The port is never part of the match: a site answers on its hosts on whatever port Runway listens on.
|
||||||
The **first** host is the primary one: the site's links are built on it unless a base URL is set. Leaving the list empty
|
The **first** host is the primary one: the site's links are built on it unless a base URL is set. Leaving the list empty
|
||||||
@@ -1447,7 +1601,9 @@ makes the site reachable only as the catch-all **default** (below). The change t
|
|||||||
request — no restart. Unlike the create/suspend/delete lifecycle actions (which are master-only), host
|
request — no restart. Unlike the create/suspend/delete lifecycle actions (which are master-only), host
|
||||||
editing is gated by the **grantable** `MANAGE_SITE_HOSTS` permission, so you can **delegate** it to an
|
editing is gated by the **grantable** `MANAGE_SITE_HOSTS` permission, so you can **delegate** it to an
|
||||||
operator role or user on the **Permissions** screen (**§9.1**) without granting the full tenancy
|
operator role or user on the **Permissions** screen (**§9.1**) without granting the full tenancy
|
||||||
lifecycle. The application superadmin always has it.
|
lifecycle. The application superadmin always has it. The **default site** is the exception: its hosts and base
|
||||||
|
URL can be edited only by a platform administrator (the application master or a wildcard administrator), because
|
||||||
|
without `runway.console.hosts` the console's password-reset links go to its address (§8.3).
|
||||||
|
|
||||||
**The site's base URL.** The same dialog has a **Base URL** field (`baseUrl` in the site's `site.yml`): the origin
|
**The site's base URL.** The same dialog has a **Base URL** field (`baseUrl` in the site's `site.yml`): the origin
|
||||||
every absolute link of the site is built on — canonical and alternate-language links, the sitemap, structured data
|
every absolute link of the site is built on — canonical and alternate-language links, the sitemap, structured data
|
||||||
@@ -1604,7 +1760,9 @@ plugin installed). Delete it afterward to confirm it removes cleanly like any ot
|
|||||||
|
|
||||||
**Where the plugins come from.** Each Runway release on the releases page
|
**Where the plugins come from.** Each Runway release on the releases page
|
||||||
(<https://g.quest.mx/quest/runway/releases>) also carries the public plugins built for it —
|
(<https://g.quest.mx/quest/runway/releases>) also carries the public plugins built for it —
|
||||||
`runway-plugin-<id>-<version>.zip` for `runway-demo`, `search`, `search-lucene` and `lucene-provider` — listed in
|
`runway-plugin-<id>-<version>.zip` for `blog`, `carousel-manager`, `contact`, `discoverability`, `runway-demo`, `search`,
|
||||||
|
`search-lucene`, `lucene-provider` and, from 1.1.0, `database`, `database-postgresql`, `database-mariadb` and
|
||||||
|
`runway-demo-database` (**§11.1**) — listed in
|
||||||
the same `SHA256SUMS`. Install one by uploading its zip on **Plugins** (below), then restart.
|
the same `SHA256SUMS`. Install one by uploading its zip on **Plugins** (below), then restart.
|
||||||
|
|
||||||
> ### ⚠️ Never park an old plugin version inside `external/plugins/`
|
> ### ⚠️ Never park an old plugin version inside `external/plugins/`
|
||||||
@@ -1783,6 +1941,141 @@ Authoring plugins is covered in [PLUGIN-DEVELOPMENT.md](PLUGIN-DEVELOPMENT.md).
|
|||||||
> other plugin (search and search-lucene, for example) is installed
|
> other plugin (search and search-lucene, for example) is installed
|
||||||
> separately, so `external/plugins/` otherwise starts empty.
|
> separately, so `external/plugins/` otherwise starts empty.
|
||||||
|
|
||||||
|
### 11.1 The database plugins (PostgreSQL or MariaDB)
|
||||||
|
|
||||||
|
Runway keeps its own data — sites, pages, users, settings — on files, and that does not change. The **database
|
||||||
|
plugins** let *other plugins* keep their data in a database server: one per installation, PostgreSQL or MariaDB,
|
||||||
|
chosen in settings. Nothing uses them unless a plugin that needs a database is installed (the first one is the
|
||||||
|
`runway-demo-database` guestbook example).
|
||||||
|
|
||||||
|
| Plugin | What it is |
|
||||||
|
|---|---|
|
||||||
|
| `database` | The generic plugin: the connection pool, the settings, one schema per site, migrations, backups, the **Database** screen. Requires Runway 1.1.0 or later. |
|
||||||
|
| `database-postgresql` | The PostgreSQL provider: bundles the pgjdbc driver. PostgreSQL **14 or later**, database encoding `UTF8`. |
|
||||||
|
| `database-mariadb` | The MariaDB provider: bundles MariaDB Connector/J (LGPL-2.1; its unmodified sources are published next to the zip). MariaDB **10.11 or later**; MySQL is not supported. |
|
||||||
|
|
||||||
|
Install `database` and the provider for your server (installing both providers is harmless: the setting picks one),
|
||||||
|
then restart. A plugin that needs the database declares it, so without `database` it shows as **Blocked** with the
|
||||||
|
reason, and Runway runs normally.
|
||||||
|
|
||||||
|
**What Runway creates.** Every name starts with the **namespace** (setting `namespace`, default `rw`):
|
||||||
|
|
||||||
|
- `<ns>_app` — Runway's own registry tables (`rw_…`) and data that belongs to no site;
|
||||||
|
- `<ns>_s_<site>_<n>` — one per site, created the first time a plugin uses the database for that site. `<n>` is a
|
||||||
|
generation number that is never reused: a site that is deleted and created again under the same id gets a new
|
||||||
|
schema, never the old data.
|
||||||
|
|
||||||
|
On PostgreSQL these are **schemas** inside the database you name in the settings. On MariaDB, where a schema *is* a
|
||||||
|
database, they are **databases** next to the one you name, which only serves as the place to connect to and stays
|
||||||
|
empty. If several Runway installations share a server, give each its own namespace.
|
||||||
|
|
||||||
|
**Preparing the server.** The account needs to create and drop what it owns, and nothing more:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
-- PostgreSQL (as a superuser)
|
||||||
|
CREATE ROLE runway LOGIN PASSWORD '…';
|
||||||
|
CREATE DATABASE runway OWNER runway ENCODING 'UTF8' TEMPLATE template0;
|
||||||
|
```
|
||||||
|
|
||||||
|
`TEMPLATE template0` lets the database be UTF-8 even on a cluster created with another encoding, whose `template1`
|
||||||
|
would refuse it; on a UTF-8 cluster it changes nothing. If PostgreSQL then answers that the encoding does not match
|
||||||
|
the locale, the cluster's locale is not UTF-8 either: add `LOCALE 'C.UTF-8'` (PostgreSQL 14 and later).
|
||||||
|
|
||||||
|
```sql
|
||||||
|
-- MariaDB (as root). The pattern is the namespace, then an escaped underscore: `rw\_%` for the default `rw`.
|
||||||
|
CREATE USER 'runway'@'10.0.0.%' IDENTIFIED BY '…';
|
||||||
|
CREATE DATABASE runway CHARACTER SET utf8mb4;
|
||||||
|
GRANT ALL PRIVILEGES ON `runway`.* TO 'runway'@'10.0.0.%';
|
||||||
|
GRANT ALL PRIVILEGES ON `rw\_%`.* TO 'runway'@'10.0.0.%';
|
||||||
|
```
|
||||||
|
|
||||||
|
A MariaDB account without the pattern grant connects but cannot create the namespace's databases: the **Database**
|
||||||
|
screen stays at *Connecting* with an "Access denied" error until the grant exists.
|
||||||
|
|
||||||
|
**Settings** (**Plugins → database → Settings**, Runway-wide, applied on **restart**):
|
||||||
|
|
||||||
|
| Setting | Meaning |
|
||||||
|
|---|---|
|
||||||
|
| `provider` | `postgresql` or `mariadb`. |
|
||||||
|
| `host`, `port` | One server: a host name or an IP address (no lists, no options). A blank port means 5432 / 3306. |
|
||||||
|
| `database` | The database to connect to (see above). |
|
||||||
|
| `username`, `password` | The account. The password is stored encrypted. It is **bound** to provider, host, port, database, username, TLS and the CA certificate: change any of them without typing the password again and the stored password is removed, so it can never be sent to a server someone else chose. |
|
||||||
|
| `tls` | `verify-full` (default: encrypted, the certificate and the host name checked against the Java trust store or `caCertificate`), `require` (encrypted, the server **not** checked), `disable`. Use `disable` only for a database on the same host or a private network you trust. |
|
||||||
|
| `caCertificate` | Advanced. The PEM certificate of the CA that signed the server's certificate, when the Java trust store does not know it. |
|
||||||
|
| `namespace` | Advanced. Default `rw`; lower-case letters and digits, up to 12. Changing it later starts from empty schemas: the old ones stay on the server. |
|
||||||
|
| `poolMax` | Connections plugins may hold at once (default 10). One site may use at most half, so a busy site cannot starve the others. |
|
||||||
|
| `statementTimeoutSeconds` | A plugin's statement that runs longer is stopped (default 10). Migrations, backups and restores have their own 30-minute limit. |
|
||||||
|
| `backupBudgetMiB` | The compressed size a site's database data may reach in its backup (default 128). |
|
||||||
|
| `collation` | Advanced, MariaDB only: for plugins' tables. Blank means `utf8mb4_uca1400_ai_ci`. Runway's own identifier columns are always binary. |
|
||||||
|
|
||||||
|
**Runway never fails to start because of the database.** Nothing connects while Runway starts; the plugin connects
|
||||||
|
right after, on its own thread, retrying with back-off. Until it succeeds, plugins that need it say so (for example
|
||||||
|
the guestbook shows "This example needs the database …"), and everything else works.
|
||||||
|
|
||||||
|
**The Database screen** (**Settings → Database**, needs `CONFIGURE_PLATFORM`, which the master and wildcard
|
||||||
|
administrators hold) shows:
|
||||||
|
|
||||||
|
- the status: *Connected*, *Connecting* (with the last error), *Not configured* (with the setting at fault), *No
|
||||||
|
provider*, or *Server not supported*; the provider, server version, driver, pool use and the number of sites with
|
||||||
|
data;
|
||||||
|
- **Test running connection** (the live pool) and **Test these settings** (typed values, one throwaway connection,
|
||||||
|
nothing saved). Answers are fixed categories — unreachable, TLS failure, authentication failed, database missing or
|
||||||
|
no access, unsupported server — and the driver's own message goes only to the server log, never with a password.
|
||||||
|
A blank password in the test reuses the saved one only for exactly the same provider, server, database, account and
|
||||||
|
TLS settings;
|
||||||
|
- **Plugin tables needing attention**, with recovery actions (below);
|
||||||
|
- the plugins using the database, the nodes seen in the last five minutes, the largest site backup against the
|
||||||
|
budget (a warning from 75%), and the last failed restore.
|
||||||
|
|
||||||
|
Each site's dashboard shows one line: whether the site keeps data in the database, its size, and the last database
|
||||||
|
restore.
|
||||||
|
|
||||||
|
**Plugin tables needing attention.** Each plugin brings its tables up to date by itself the first time it uses a
|
||||||
|
schema (its *migrations*). If that cannot happen, only *that plugin* in *that schema* stops — other plugins and other
|
||||||
|
sites carry on — and the screen lists the case:
|
||||||
|
|
||||||
|
| Problem | Meaning | Action |
|
||||||
|
|---|---|---|
|
||||||
|
| Script failed | A migration script stopped at a statement (the detail names it). On PostgreSQL nothing of it was kept, nor of the plugin's other scripts that ran with it (the detail lists them); on MariaDB the statements before it were. | Fix the cause (often a permission, or data the script did not expect), then **Retry**. On MariaDB it continues from the failed statement; on PostgreSQL it runs the whole script again, and the scripts rolled back with it, so do not run part of it by hand first. **Mark applied** only if you completed the script by hand, on PostgreSQL every script the detail lists. If the detail says a script *was never applied* although a later one was, apply it by hand and **Mark applied** (**Retry** cannot run it), or restore the schema. |
|
||||||
|
| Script changed | A script already applied is no longer the one the installed plugin ships. Released scripts must not change: report it to the plugin's author. | **Accept shipped checksum** once you know the change is harmless. |
|
||||||
|
| Newer than installed | The schema was migrated by a newer version of the plugin (a downgrade, or nodes on different versions), or data a restore kept for the plugin (when it was not installed) is from a newer version. | Install that version or later; kept data then loads on the plugin's first use. |
|
||||||
|
| Kept data cannot be loaded | A restore kept data for a plugin that was not installed then (in `deferred/<plugin>/` in the site's folder), and it cannot be read now, or the plugin's tables are already past its version. The plugin is refused on that site rather than started empty. | Fix the cause the detail names (often the folder's permissions) and the next use loads it. To go on without that data, remove `deferred/<plugin>/` from the site's folder, or restore the backup again. |
|
||||||
|
|
||||||
|
Every recovery action is written to the server log with the operator's name.
|
||||||
|
|
||||||
|
**Clusters.** Every node needs the same `external/plugin-settings/database.yml` and the same platform secret key
|
||||||
|
(`runway.security.secret-key`), because the password is stored encrypted with it. The database is shared, so a site
|
||||||
|
deleted on one node has its schema dropped once, by that node. To change the server or the provider, stop **every**
|
||||||
|
node first.
|
||||||
|
|
||||||
|
**Backups and restore.**
|
||||||
|
|
||||||
|
- A site's **full backup** carries its database data (every plugin's tables in that site's schema), in a portable
|
||||||
|
format: a backup taken on PostgreSQL restores on MariaDB and the other way round. If the database is unreachable
|
||||||
|
when a backup runs, the backup **fails** and names the site — a backup is complete or it is not a backup.
|
||||||
|
- A **transfer copy** of a site carries **no** database data, and the copy gets its own, empty schema. Plugins are
|
||||||
|
asked to keep in the database only data that a transfer may leave behind (visitors' entries, caches); content
|
||||||
|
that must travel stays in files.
|
||||||
|
- A restore builds the data in a **new** schema next to the live one and switches the site to it only when
|
||||||
|
everything is loaded; the old schema is dropped later by a cleanup that runs every 15 minutes and waits until it
|
||||||
|
has been retired for at least 10. If anything fails, the new schema is
|
||||||
|
dropped, **the previous data stays live**, and the failure shows on the **Database** screen and the site's dashboard
|
||||||
|
("Last database restore"). The site's files are restored either way.
|
||||||
|
- A restore is refused when an installed plugin is **older** than the backup's data (upgrade it first). Data of a
|
||||||
|
plugin that is **not installed** is kept in the site's folder and loaded when that plugin is installed, at the
|
||||||
|
backup's version or later; an older one is refused with "newer than the installed plugin" and the data waits.
|
||||||
|
- The backup budget (`backupBudgetMiB`) caps a site's database data in one backup; above it, the backup fails with a
|
||||||
|
message, and you back that data up with the database's own tools.
|
||||||
|
- `<ns>_app` (Runway-wide data) is in **no** site backup. Back it up with the database's own tools (`pg_dump -n
|
||||||
|
rw_app`, `mariadb-dump rw_app`). The **Database** screen names the plugins that keep data there.
|
||||||
|
|
||||||
|
**Moving to another server or provider.** Take a full backup of each site, change the settings, restart, then
|
||||||
|
restore each site. Runway-wide data (`<ns>_app`) does not move this way: copy it with the database's tools if a
|
||||||
|
plugin keeps data there.
|
||||||
|
|
||||||
|
**Removing.** Uninstalling the database plugins leaves the schemas on the server. Drop them there (every name starts
|
||||||
|
with the namespace) once you no longer need the data.
|
||||||
|
|
||||||
## 12. Protection & abuse defense
|
## 12. Protection & abuse defense
|
||||||
|
|
||||||
**Posture.** The kernel ships the protection *floor* (the request-pipeline seams: the outermost reject point
|
**Posture.** The kernel ships the protection *floor* (the request-pipeline seams: the outermost reject point
|
||||||
@@ -1796,9 +2089,11 @@ upstream at the proxy/edge regardless.
|
|||||||
The protection plugin is an **allowlisted-essential** plugin: once its folder is present, it is **fail-closed**
|
The protection plugin is an **allowlisted-essential** plugin: once its folder is present, it is **fail-closed**
|
||||||
— if it is present but fails to load, the kernel serves tenant hosts a `503` (the app realm stays reachable)
|
— if it is present but fails to load, the kernel serves tenant hosts a `503` (the app realm stays reachable)
|
||||||
rather than booting open. **Every upgrade refreshes it** from the new release (§15): it is lockstep with the
|
rather than booting open. **Every upgrade refreshes it** from the new release (§15): it is lockstep with the
|
||||||
kernel — the one plugin allowed to use kernel internals, with a descriptor naming the kernel's own SPI level — so an
|
kernel — the one plugin allowed to use kernel internals; its descriptor's SPI floor is the major line's (`>=1.0.0`,
|
||||||
older copy beside a newer kernel can be refused (Blocked) — and a refused essential plugin is the fail-closed `503`
|
met by every 1.x kernel, raised only when it uses a newer SPI member) — so an older copy beside a newer kernel can
|
||||||
on every site — or load and run code written for the previous kernel. Your settings (`external/plugin-settings/protection.yml` and each site's `plugins/protection.yml`) live
|
fail on a missing internal class, or be refused (Blocked) if its floor is ever above the kernel's — and a refused
|
||||||
|
or failing essential plugin is the fail-closed `503` on every site — or load and run code written for the previous
|
||||||
|
kernel. Your settings (`external/plugin-settings/protection.yml` and each site's `plugins/protection.yml`) live
|
||||||
outside the folder and are never touched. There is no supported opt-out: setting `enabled: false` in its
|
outside the folder and are never touched. There is no supported opt-out: setting `enabled: false` in its
|
||||||
`plugin.yml` counts as a broken floor (`503`) and the next upgrade puts the shipped descriptor back, and removing the
|
`plugin.yml` counts as a broken floor (`503`) and the next upgrade puts the shipped descriptor back, and removing the
|
||||||
folder runs the sites without abuse defense until the next installer run seeds it again.
|
folder runs the sites without abuse defense until the next installer run seeds it again.
|
||||||
@@ -2139,6 +2434,24 @@ runway:
|
|||||||
- "198.51.100.7" # the audit runner
|
- "198.51.100.7" # the audit runner
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**A health check from a proxy on the same host.** Behind a same-host reverse proxy, the proxy's own health check
|
||||||
|
(`GET /actuator/health` or a site's `/__health`) usually reaches Runway from loopback with no `X-Forwarded-For`, so it
|
||||||
|
shares one rate-limit bucket with everything else run on that host — a local crawl or audit can then earn the check
|
||||||
|
`429`s and push the proxy towards marking the server down. Exempt the check alone, not loopback: have the proxy send
|
||||||
|
it with a fixed `X-Forwarded-For` from a documentation range, and list that address here. No visitor can pose as
|
||||||
|
it: on real traffic the proxy adds the visitor's own address to the right of anything the visitor sent (or replaces
|
||||||
|
the header), and Runway reads the header from the right. With HAProxy 2.2 or later:
|
||||||
|
|
||||||
|
```
|
||||||
|
backend runway
|
||||||
|
option httpchk
|
||||||
|
http-check send meth GET uri /actuator/health ver HTTP/1.1 hdr Host www.example.com hdr X-Forwarded-For 192.0.2.53
|
||||||
|
```
|
||||||
|
|
||||||
|
and `192.0.2.53` in `allowlist`. Loopback must be in `runway.proxy.trusted-cidrs` (it is, for a same-host proxy);
|
||||||
|
leave the probe's address out of it, which is for real proxies only. Checking
|
||||||
|
`/actuator/health` from outside the proxy (a monitoring service) needs no header: list that service's own address.
|
||||||
|
|
||||||
> **If you are blocked, stop — do not keep probing.** Once an address is auto-blocked, requests no longer
|
> **If you are blocked, stop — do not keep probing.** Once an address is auto-blocked, requests no longer
|
||||||
> reach the rate limiter at all; they hit the blocklist. So the `rate-limit` counter freezes while
|
> reach the rate limiter at all; they hit the blocklist. So the `rate-limit` counter freezes while
|
||||||
> `blocklist-auto` keeps climbing, and continued probing simply confirms the block rather than measuring it.
|
> `blocklist-auto` keeps climbing, and continued probing simply confirms the block rather than measuring it.
|
||||||
@@ -2488,6 +2801,7 @@ restart.
|
|||||||
installs and upgrades, and it is idempotent:
|
installs and upgrades, and it is idempotent:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
chmod +x runway-<newer-version>.bin
|
||||||
sudo ./runway-<newer-version>.bin -y # or interactively
|
sudo ./runway-<newer-version>.bin -y # or interactively
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -2519,8 +2833,9 @@ live outside the folder and are never touched. No flag is needed; `--update-esse
|
|||||||
and does nothing.
|
and does nothing.
|
||||||
|
|
||||||
*Why always.* The essential plugin moves in lockstep with the kernel: it is the one plugin allowed to use kernel
|
*Why always.* The essential plugin moves in lockstep with the kernel: it is the one plugin allowed to use kernel
|
||||||
internals, and its descriptor declares the kernel's own SPI level. An older copy beside a newer kernel can be
|
internals; its descriptor's SPI floor is the major line's (`>=1.0.0`, met by every 1.x kernel, raised only when it
|
||||||
refused (Blocked) or crash on a missing class — and because it is the essential, fail-closed plugin, either way
|
uses a newer SPI member). An older copy beside a newer kernel can crash on a missing internal class, or be refused
|
||||||
|
(Blocked) if its floor is ever above the kernel's — and because it is the essential, fail-closed plugin, either way
|
||||||
every tenant page answers `503` — or it loads and runs the previous release's code. What makes "always" safe is what the refresh keeps, below.
|
every tenant page answers `503` — or it loads and runs the previous release's code. What makes "always" safe is what the refresh keeps, below.
|
||||||
|
|
||||||
*What you see.* The installer logs `refreshing bundled plugin 'protection' from this release`, then one line per
|
*What you see.* The installer logs `refreshing bundled plugin 'protection' from this release`, then one line per
|
||||||
|
|||||||
@@ -243,6 +243,12 @@ starts normally; the key is ignored.
|
|||||||
| `forwarded-headers` | boolean | `true` |
|
| `forwarded-headers` | boolean | `true` |
|
||||||
| `trusted-cidrs` | list of CIDR | empty (trust nothing); the shipped `application.yml` sets `127.0.0.1/32`, `::1/128` |
|
| `trusted-cidrs` | list of CIDR | empty (trust nothing); the shipped `application.yml` sets `127.0.0.1/32`, `::1/128` |
|
||||||
|
|
||||||
|
**`runway.http.*`**
|
||||||
|
|
||||||
|
| Key | Type | Default |
|
||||||
|
|---|---|---|
|
||||||
|
| `min-request-data-rate` | long, bytes per second | `4096` (`0` = off) |
|
||||||
|
|
||||||
**`runway.reload.*`** — `/__reload/**`
|
**`runway.reload.*`** — `/__reload/**`
|
||||||
|
|
||||||
| Key | Type | Default |
|
| Key | Type | Default |
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
> **What this is:** an honest, current list of what Runway does **not** do, or does only partially, in the
|
> **What this is:** an honest, current list of what Runway does **not** do, or does only partially, in the
|
||||||
> code as it stands (release `1.0.0`; the exact version is in the [CHANGELOG](../CHANGELOG.md)). The plugin
|
> code as it stands (release `1.0.0`; the exact version is in the [CHANGELOG](../CHANGELOG.md)). The plugin
|
||||||
> contract is frozen at SPI `1.0.0` and enforced at load time ([SPI-STABILITY.md](SPI-STABILITY.md));
|
> contract was frozen at SPI `1.0.0`, changes only additively within `1.x`, and is enforced at load time ([SPI-STABILITY.md](SPI-STABILITY.md));
|
||||||
> configuration, the data folder and backups are governed by
|
> configuration, the data folder and backups are governed by
|
||||||
> [CONFIGURATION-AND-DATA-STABILITY.md](CONFIGURATION-AND-DATA-STABILITY.md), which binds from `1.0.0`. The data
|
> [CONFIGURATION-AND-DATA-STABILITY.md](CONFIGURATION-AND-DATA-STABILITY.md), which binds from `1.0.0`. The data
|
||||||
> folder and backup archives carry the version markers that promise is built on (`external/layout.yml`, a
|
> folder and backup archives carry the version markers that promise is built on (`external/layout.yml`, a
|
||||||
@@ -136,10 +136,6 @@ closes it. Items marked **after 1.0** are decided: they are not part of the `1.0
|
|||||||
and parses it itself, and takes its CSRF token in the `X-CSRF-TOKEN` header (no first-party plugin accepts
|
and parses it itself, and takes its CSRF token in the `X-CSRF-TOKEN` header (no first-party plugin accepts
|
||||||
uploads).
|
uploads).
|
||||||
- **Billboard and News plugins are not built** (**after 1.0**, as plugin releases).
|
- **Billboard and News plugins are not built** (**after 1.0**, as plugin releases).
|
||||||
- **No published plugin serves `/sitemap.xml`, `/robots.txt`, `/llms.txt` or schema.org structured data.** The
|
|
||||||
kernel provides the seams (`EndpointContributor`, `HeadContributor`) and the Site-manager guide (§10) describes
|
|
||||||
what such a plugin provides, but none of the published plugins (demo, search, search-lucene, lucene-provider)
|
|
||||||
does; without one a site serves no `/robots.txt` at all (crawlers read that as everything allowed) and no sitemap.
|
|
||||||
- **The search plugin's rate limit is a courtesy limiter, not a defence.** It keys on the client address after
|
- **The search plugin's rate limit is a courtesy limiter, not a defence.** It keys on the client address after
|
||||||
the kernel's trusted-proxy gate; the kernel's own edge guard is the abuse floor.
|
the kernel's trusted-proxy gate; the kernel's own edge guard is the abuse floor.
|
||||||
- **A search index rebuilds by rendering every page once per language.** A page is indexed as rendered in
|
- **A search index rebuilds by rendering every page once per language.** A page is indexed as rendered in
|
||||||
@@ -150,9 +146,16 @@ closes it. Items marked **after 1.0** are decided: they are not part of the `1.0
|
|||||||
|
|
||||||
## By design — not limitations
|
## By design — not limitations
|
||||||
|
|
||||||
- **No database.** The kernel is filesystem/YAML-backed on purpose; there is no SQL layer to
|
- **Runway's own data is on files.** The kernel is filesystem/YAML-backed on purpose; there is no SQL
|
||||||
configure. A deployment that genuinely needs one adds it as a **datasource-provider plugin** (the
|
layer to configure, and the first-run wizard provisions the app superadmin and first site, never a
|
||||||
first-run wizard therefore provisions the app superadmin + first site, never a DB).
|
database. Plugins that need one use PostgreSQL or MariaDB through the **database plugins**
|
||||||
|
(ADMINISTRATION §11.1), with these limits:
|
||||||
|
- a site's **transfer copy** carries no database data (the copy starts with an empty schema), so
|
||||||
|
plugins keep there only data a transfer may leave behind;
|
||||||
|
- the Runway-wide schema (`<ns>_app`) is in no site backup; back it up with the database's own tools;
|
||||||
|
- a site's database data in one backup is capped by `backupBudgetMiB` (default 128 MiB compressed);
|
||||||
|
- isolation between sites inside the database is enforced by the plugins' code (one account reaches
|
||||||
|
every schema), as everywhere else in Runway where plugins are trusted code.
|
||||||
- **Central seed changes do not back-propagate to existing tenants.** Each tenant owns its copy of the
|
- **Central seed changes do not back-propagate to existing tenants.** Each tenant owns its copy of the
|
||||||
seeded master/templates after creation (the self-containment law); improving the seed affects only
|
seeded master/templates after creation (the self-containment law); improving the seed affects only
|
||||||
*new* tenants. This is the deliberate price of complete tenant isolation and portable backups.
|
*new* tenants. This is the deliberate price of complete tenant isolation and portable backups.
|
||||||
|
|||||||
+3
-1
@@ -34,7 +34,8 @@ rolling back safely (**§9**).
|
|||||||
Runway runs as **one JVM**, filesystem/YAML-backed (there is no database to operate). Everything
|
Runway runs as **one JVM**, filesystem/YAML-backed (there is no database to operate). Everything
|
||||||
it writes lives under the version-independent data dir `/opt/runway-data/` (`external/`, `logs/`,
|
it writes lives under the version-independent data dir `/opt/runway-data/` (`external/`, `logs/`,
|
||||||
`backups/`). Keep that fact in mind — nearly every recovery step below is a file operation there,
|
`backups/`). Keep that fact in mind — nearly every recovery step below is a file operation there,
|
||||||
not a database operation.
|
not a database operation. The one exception is a plugin's data when the optional database plugins are
|
||||||
|
installed: that lives in your PostgreSQL or MariaDB server (ADMINISTRATION §11.1).
|
||||||
|
|
||||||
## 2. Health checks & readiness
|
## 2. Health checks & readiness
|
||||||
|
|
||||||
@@ -902,6 +903,7 @@ means the pin never got written (**§4.4**); a stuck plugin apply means a plugin
|
|||||||
installs and upgrades, and it is idempotent (Administration §15 has the full walk-through):
|
installs and upgrades, and it is idempotent (Administration §15 has the full walk-through):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
chmod +x runway-<newer-version>.bin # a download has no execute bit
|
||||||
sudo ./runway-<newer-version>.bin -y # or interactively — not with --port / --tls-keystore
|
sudo ./runway-<newer-version>.bin -y # or interactively — not with --port / --tls-keystore
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
> the contribution seams, settings, permissions, and the rules that keep plugins compatible.
|
> the contribution seams, settings, permissions, and the rules that keep plugins compatible.
|
||||||
|
|
||||||
> **Doc status.** The plugin contract is **SPI `1.0.0`, frozen** (Runway `1.0.0`): from here it changes only
|
> **Doc status.** The plugin contract is **SPI `1.0.0`, frozen** (Runway `1.0.0`): from here it changes only
|
||||||
> additively within `1.x` — the commitment and the full type list are in [SPI-STABILITY.md](SPI-STABILITY.md); the
|
> additively within `1.x` (SPI `1.1.0` added `PluginSettings.appSecret`) — the commitment and the full type list are in [SPI-STABILITY.md](SPI-STABILITY.md); the
|
||||||
> `plugin.yml` keys and their tolerance rules are covered by
|
> `plugin.yml` keys and their tolerance rules are covered by
|
||||||
> [CONFIGURATION-AND-DATA-STABILITY.md](CONFIGURATION-AND-DATA-STABILITY.md) §4. A plugin is built against
|
> [CONFIGURATION-AND-DATA-STABILITY.md](CONFIGURATION-AND-DATA-STABILITY.md) §4. A plugin is built against
|
||||||
> `runway-spi` **only**; the kernel refuses one that links its internal classes (§3, *The 1.0 contract at a
|
> `runway-spi` **only**; the kernel refuses one that links its internal classes (§3, *The 1.0 contract at a
|
||||||
@@ -104,7 +104,7 @@ boots.
|
|||||||
> **Which floor to declare.** The lowest SPI version whose additions you use — the evolution log on
|
> **Which floor to declare.** The lowest SPI version whose additions you use — the evolution log on
|
||||||
> `RunwaySpi.VERSION` lists them per version. `>=0.4.0`, `>=0.5.0` and `>=0.6.0` are all **1.x floors** (the service
|
> `RunwaySpi.VERSION` lists them per version. `>=0.4.0`, `>=0.5.0` and `>=0.6.0` are all **1.x floors** (the service
|
||||||
> tier those versions introduced is the 1.0 contract), so a plugin built against them loads on every `1.x` kernel;
|
> tier those versions introduced is the 1.0 contract), so a plugin built against them loads on every `1.x` kernel;
|
||||||
> declare `>=1.0.0` only if you use `HeadContext.origin()`. The floor is an **SPI level** — the value of
|
> declare `>=1.0.0` only if you use `HeadContext.origin()`, and `>=1.1.0` if you call `PluginSettings.appSecret`. The floor is an **SPI level** — the value of
|
||||||
> `RunwaySpi.VERSION` — not the version of the `runway-spi` artifact you compile against, which is the kernel's
|
> `RunwaySpi.VERSION` — not the version of the `runway-spi` artifact you compile against, which is the kernel's
|
||||||
> release version (kernel `1.0.0` carries SPI `1.0.0`; §3).
|
> release version (kernel `1.0.0` carries SPI `1.0.0`; §3).
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ Then depend on `mx.quest:runway-spi:<ver>` (`provided`) and `mx.quest:runway-spi
|
|||||||
|
|
||||||
| You need | Use | Never |
|
| You need | Use | Never |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| your per-site settings and secrets (app-level ones: `@ConfigurationProperties("runway.plugin.<id>")`) | `PluginSettings` (+ `SettingsView`) | `SitePluginConfigService`, `SecretCipher`, `@Value("${runway.plugin…}")` on a per-site key |
|
| your per-site settings and secrets (app-level ones: `@ConfigurationProperties("runway.plugin.<id>")`; an app-level secret in clear: `PluginSettings.appSecret`, SPI 1.1.0) | `PluginSettings` (+ `SettingsView`) | `SitePluginConfigService`, `SecretCipher`, `@Value("${runway.plugin…}")` on a per-site key |
|
||||||
| your per-site files | `PluginSiteFiles`; declare personal data in `siteData.personal` | `SiteFileStore`, `StorageLayout`, a path you build |
|
| your per-site files | `PluginSiteFiles`; declare personal data in `siteData.personal` | `SiteFileStore`, `StorageLayout`, a path you build |
|
||||||
| the site, the request's site, a permission check, a message | `Sites`, `RequestContext`, `AccessCheck` (`@authz`), `Messages` | `SiteResolver`, `AuthzExpressions`, `SiteAwareMessageSource` |
|
| the site, the request's site, a permission check, a message | `Sites`, `RequestContext`, `AccessCheck` (`@authz`), `Messages` | `SiteResolver`, `AuthzExpressions`, `SiteAwareMessageSource` |
|
||||||
| a starter page | `SitePages.install` → `InstallResult` | `PageWriteService`, writing templates |
|
| a starter page | `SitePages.install` → `InstallResult` | `PageWriteService`, writing templates |
|
||||||
@@ -332,7 +332,7 @@ if you use any `0.6.0` type, `">=0.5.0"` for a `0.5.0` service.
|
|||||||
|
|
||||||
| Service | What it gives you |
|
| Service | What it gives you |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `PluginSettings` | `site(siteId)` → a `SettingsView` of **your** per-site settings: the `siteSettings:` defaults overlaid by what the operator saved (`sites/<id>/plugins/<yourId>.yml`), unknown stored keys preserved, secret keys absent. `secret(siteId, key)` → a `type: secret` value in clear (an `ENC(...)` value decrypted; a hand-written plaintext returned as is; empty when unset, undeclared as secret, or undecryptable). |
|
| `PluginSettings` | `site(siteId)` → a `SettingsView` of **your** per-site settings: the `siteSettings:` defaults overlaid by what the operator saved (`sites/<id>/plugins/<yourId>.yml`), unknown stored keys preserved, secret keys absent. `secret(siteId, key)` → a `type: secret` value in clear (an `ENC(...)` value decrypted; a hand-written plaintext returned as is; empty when unset, undeclared as secret, or undecryptable). `appSecret(key)` (SPI 1.1.0) → the same for a secret declared in your app-level `settings:`, as the running application holds it. |
|
||||||
| `SettingsView` | lenient typed reads: `string(key, fallback)` (blank → fallback), `bool`, `integer` (and a clamped form), `decimal`, `list` (a YAML list or a comma/newline string). A value that does not parse yields the fallback, never an exception. Nested values are frozen; parse structures from `values()` yourself. |
|
| `SettingsView` | lenient typed reads: `string(key, fallback)` (blank → fallback), `bool`, `integer` (and a clamped form), `decimal`, `list` (a YAML list or a comma/newline string). A value that does not parse yields the fallback, never an exception. Nested values are frozen; parse structures from `values()` yourself. |
|
||||||
| `PluginInfo` | your `id`, `version` and install folder. Injectable; also handed to `PluginLifecycle.started`. |
|
| `PluginInfo` | your `id`, `version` and install folder. Injectable; also handed to `PluginLifecycle.started`. |
|
||||||
| `PluginLifecycle` | optional `started(PluginInfo)` after the platform is up (in plugin load order) and `stopping()` at shutdown (reverse order, only if started). Collected by type — no `id()` to keep in sync. |
|
| `PluginLifecycle` | optional `started(PluginInfo)` after the platform is up (in plugin load order) and `stopping()` at shutdown (reverse order, only if started). Collected by type — no `id()` to keep in sync. |
|
||||||
@@ -923,7 +923,10 @@ the raw stored map is blocked — it links a kernel class.)
|
|||||||
|
|
||||||
A `secret`-typed value is stored **encrypted** as `ENC(...)` and the file is `chmod 600` whenever it
|
A `secret`-typed value is stored **encrypted** as `ENC(...)` and the file is `chmod 600` whenever it
|
||||||
holds one. Read a per-site secret with `PluginSettings.secret(siteId, key)` — it decrypts for you, and never
|
holds one. Read a per-site secret with `PluginSettings.secret(siteId, key)` — it decrypts for you, and never
|
||||||
appears in `site(siteId)`. Encryption requires `runway.security.secret-key` to be set — until it is, a secret can't be
|
appears in `site(siteId)`. Read an **app-level** secret (declared `type: secret` under `settings:`) with
|
||||||
|
`PluginSettings.appSecret(key)` (SPI 1.1.0, so declare `requiresSpi: ">=1.1.0"`): your `@ConfigurationProperties`
|
||||||
|
bind it only in its `ENC(...)` form, which you cannot decrypt. It answers the value the running application started
|
||||||
|
with, so a saved change applies after the restart, like every app-level setting. Encryption requires `runway.security.secret-key` to be set — until it is, a secret can't be
|
||||||
saved and the form says so. A **blank secret on resubmit keeps** the stored value (you never retype
|
saved and the form says so. A **blank secret on resubmit keeps** the stored value (you never retype
|
||||||
it), and secrets are never echoed back into the form.
|
it), and secrets are never echoed back into the form.
|
||||||
|
|
||||||
@@ -1234,7 +1237,7 @@ id: protection
|
|||||||
name: Essential Protection
|
name: Essential Protection
|
||||||
version: 1.0.0 # the kernel's version line
|
version: 1.0.0 # the kernel's version line
|
||||||
essential: true
|
essential: true
|
||||||
requiresSpi: ">=1.0.0" # the kernel's own SPI: the mandatory floor can never block it
|
requiresSpi: ">=1.0.0" # the SPI major's floor, met by every 1.x kernel: the mandatory floor never blocks it
|
||||||
mainClass: mx.quest.protection.ProtectionConfig
|
mainClass: mx.quest.protection.ProtectionConfig
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ How large a request may be. Applies after a restart.
|
|||||||
| Setting | Key | What it does | Values |
|
| Setting | Key | What it does | Values |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| Largest request before sign-in (bytes) | `runway.endpoints.max-form-bytes` | The most a visitor who is not signed in may send in one request, on any path. Default 262144 (256 KiB). | whole number from 1024 to 104857600; default `262144` |
|
| Largest request before sign-in (bytes) | `runway.endpoints.max-form-bytes` | The most a visitor who is not signed in may send in one request, on any path. Default 262144 (256 KiB). | whole number from 1024 to 104857600; default `262144` |
|
||||||
|
| Slowest request body (bytes per second) *(Advanced)* | `runway.http.min-request-data-rate` | A request body arriving more slowly is answered 408 Request Timeout: login and other forms, uploads and raw bodies alike, so a client sending a byte now and then cannot keep a request thread. Only time spent waiting for the client counts, and a body that has arrived complete is never refused. Sending part of a body fast earns at most 30 seconds of waiting. Default 4096; 0 turns the check off. | whole number from 0 to 1048576; default `4096` |
|
||||||
| Largest request to a plugin (bytes) | `runway.endpoints.max-body-bytes` | The most a signed-in user may send to a plugin's route. Default 10485760 (10 MiB). | whole number from 1024 to 1073741824; default `10485760` |
|
| Largest request to a plugin (bytes) | `runway.endpoints.max-body-bytes` | The most a signed-in user may send to a plugin's route. Default 10485760 (10 MiB). | whole number from 1024 to 1073741824; default `10485760` |
|
||||||
| Largest uploaded file | `spring.servlet.multipart.max-file-size` | For uploads such as a backup to restore. A size like 256MB or 1GB. Default 256MB. | text; default `256MB` |
|
| Largest uploaded file | `spring.servlet.multipart.max-file-size` | For uploads such as a backup to restore. A size like 256MB or 1GB. Default 256MB. | text; default `256MB` |
|
||||||
| Largest upload request | `spring.servlet.multipart.max-request-size` | All the files of one upload together. A size like 256MB. Default 256MB. | text; default `256MB` |
|
| Largest upload request | `spring.servlet.multipart.max-request-size` | All the files of one upload together. A size like 256MB. Default 256MB. | text; default `256MB` |
|
||||||
@@ -132,7 +133,7 @@ Whether to trust X-Forwarded-* headers, and from which addresses. Only from your
|
|||||||
| Setting | Key | What it does | Values |
|
| Setting | Key | What it does | Values |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| Read X-Forwarded-* headers | `runway.proxy.forwarded-headers` | From the trusted addresses below only. | `true` or `false`; default `true` |
|
| Read X-Forwarded-* headers | `runway.proxy.forwarded-headers` | From the trusted addresses below only. | `true` or `false`; default `true` |
|
||||||
| Trusted proxy addresses | `runway.proxy.trusted-cidrs` | The exact address of your reverse proxy, e.g. 10.0.0.5/32. A /0 (0.0.0.0/0, ::/0), or ranges that add up to every address (0.0.0.0/1 with 128.0.0.0/1), would trust every client to fake its address, so it is refused. | comma-separated list; default `127.0.0.1/32,::1/128` |
|
| Trusted proxy addresses | `runway.proxy.trusted-cidrs` | The exact address of your reverse proxy, e.g. 10.0.0.5/32, and of every proxy in front of it (a CDN). Check the result under About Runway → This request. A /0 (0.0.0.0/0, ::/0), or ranges that add up to every address (0.0.0.0/1 with 128.0.0.0/1), would trust every client to fake its address, so it is refused. | comma-separated list; default `127.0.0.1/32,::1/128` |
|
||||||
|
|
||||||
#### Capacity
|
#### Capacity
|
||||||
|
|
||||||
|
|||||||
@@ -231,7 +231,8 @@ name or the default language. While no field is set and no manifest icon (192, 5
|
|||||||
|
|
||||||
The **Logs** screen (`/__admin/logs`) shows your site's own **access log** (public traffic — the most recent
|
The **Logs** screen (`/__admin/logs`) shows your site's own **access log** (public traffic — the most recent
|
||||||
lines) and its **audit journal**: who did what on your site, and when. The journal records sign-ins
|
lines) and its **audit journal**: who did what on your site, and when. The journal records sign-ins
|
||||||
(`login.success`, `login.failure`) and sign-outs (`logout`); password recovery through an emailed link
|
(`login.success`, `login.failure`) and sign-outs (`logout`), each with the address it came from (`ip=…`, in full:
|
||||||
|
the anonymizing setting below applies to the access log only); password recovery through an emailed link
|
||||||
(`recovery.requested`, `recovery.completed`); page changes (`page.saved`, `page.deleted`, `page.published`,
|
(`recovery.requested`, `recovery.completed`); page changes (`page.saved`, `page.deleted`, `page.published`,
|
||||||
`page.unpublished`); user changes (`user.created`, `user.password-reset`, `user.deleted`); role and permission
|
`page.unpublished`); user changes (`user.created`, `user.password-reset`, `user.deleted`); role and permission
|
||||||
changes on **Permissions** (`permissions.role-assigned`, `permissions.permission-granted`,
|
changes on **Permissions** (`permissions.role-assigned`, `permissions.permission-granted`,
|
||||||
@@ -1168,8 +1169,8 @@ they never touch your templates. Analytics and richer GEO markup are added by pl
|
|||||||
### Sitemaps, robots and AI crawlers
|
### Sitemaps, robots and AI crawlers
|
||||||
|
|
||||||
The core stops at the page's own `<head>`. The crawl surfaces themselves — `/sitemap.xml`, `/robots.txt`
|
The core stops at the page's own `<head>`. The crawl surfaces themselves — `/sitemap.xml`, `/robots.txt`
|
||||||
and `/llms.txt` — and the schema.org structured data that says what a page *is* come from a plugin,
|
and `/llms.txt` — and the schema.org structured data that says what a page *is* come from a plugin (the `discoverability` plugin
|
||||||
if your operator has installed one; it then appears in the **Settings** dropdown
|
does all four), if your operator has installed one; it then appears in the **Settings** dropdown
|
||||||
with its own per-site form (**§8**). Without one your site serves no `/robots.txt` at all, which crawlers read as
|
with its own per-site form (**§8**). Without one your site serves no `/robots.txt` at all, which crawlers read as
|
||||||
*everything allowed*.
|
*everything allowed*.
|
||||||
|
|
||||||
@@ -1318,13 +1319,15 @@ a copy of everyone's credentials.
|
|||||||
page, template, user and setting reverts to the moment the backup was taken. Because it is
|
page, template, user and setting reverts to the moment the backup was taken. Because it is
|
||||||
destructive, **only the site's administrators (the site superadmin, or the Administrator tier) may
|
destructive, **only the site's administrators (the site superadmin, or the Administrator tier) may
|
||||||
restore**; the restore controls are hidden for everyone else. You can restore either from a **saved backup** (pick it from the list) or by
|
restore**; the restore controls are hidden for everyone else. You can restore either from a **saved backup** (pick it from the list) or by
|
||||||
**uploading a `.zip`** you downloaded earlier.
|
**uploading a `.zip`** you downloaded earlier. One thing does not revert: the site's **host names and base URL**
|
||||||
|
(how visitors reach it) stay as the platform operator has set them now, whatever the backup says.
|
||||||
|
|
||||||
Restore is safe by design: the platform first checks the file is a genuine, complete site
|
Restore is safe by design: the platform first checks the file is a genuine, complete site
|
||||||
backup and only then swaps it in, in one step. **A corrupt, empty, or wrong file is rejected
|
backup and only then swaps it in, in one step. **A corrupt, empty, or wrong file is rejected
|
||||||
and your live site is left exactly as it was** — a failed or interrupted restore never leaves
|
and your live site is left exactly as it was** — a failed or interrupted restore never leaves
|
||||||
you with a half-restored or missing site. After a successful restore the site reflects the
|
you with a half-restored or missing site. After a successful restore the site reflects the
|
||||||
backup immediately (no restart).
|
backup immediately (no restart), and the Backups screen shows the site's host names and base URL for you to check: a restore made here keeps them as
|
||||||
|
they were (how the site is reached is set by the platform operator), so if they look wrong, ask the operator.
|
||||||
|
|
||||||
A backup made on a **newer** version of the platform than the one your site runs on is refused
|
A backup made on a **newer** version of the platform than the one your site runs on is refused
|
||||||
the same way, with the message *"This backup was made by a newer version of Runway … Ask the
|
the same way, with the message *"This backup was made by a newer version of Runway … Ask the
|
||||||
|
|||||||
+10
-1
@@ -50,7 +50,7 @@ contribution, a host-coupled seam that is not part of the 1.0 contract (see "Wha
|
|||||||
|
|
||||||
| Type | Since | Scope | What it gives a plugin |
|
| Type | Since | Scope | What it gives a plugin |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| `service.PluginSettings` (+ `model.SettingsView`) | 0.4.0 | plugin-scoped | its per-site settings, defaults applied, and its declared secrets decrypted (app-level settings bind through `@ConfigurationProperties("runway.plugin.<id>")`, not this service) |
|
| `service.PluginSettings` (+ `model.SettingsView`) | 0.4.0 | plugin-scoped | its per-site settings, defaults applied, and its declared secrets decrypted (app-level settings bind through `@ConfigurationProperties("runway.plugin.<id>")`; an app-level `secret` setting in clear through `appSecret(key)`, since 1.1.0) |
|
||||||
| `model.PluginInfo` | 0.4.0 | plugin-scoped | its own id, version and install facts |
|
| `model.PluginInfo` | 0.4.0 | plugin-scoped | its own id, version and install facts |
|
||||||
| `service.PluginLifecycle` | 0.4.0 | callback | `started(PluginInfo)` / `stopping()`, in load order and reverse |
|
| `service.PluginLifecycle` | 0.4.0 | callback | `started(PluginInfo)` / `stopping()`, in load order and reverse |
|
||||||
| `service.PluginSiteFiles` (+ `model.FileEntry`) | 0.5.0 | plugin-scoped | its own per-site subtree `sites/<id>/plugins/<pluginId>/`: atomic text writes, capped reads, listing, deletes; confined against crafted paths **and** symbolic links |
|
| `service.PluginSiteFiles` (+ `model.FileEntry`) | 0.5.0 | plugin-scoped | its own per-site subtree `sites/<id>/plugins/<pluginId>/`: atomic text writes, capped reads, listing, deletes; confined against crafted paths **and** symbolic links |
|
||||||
@@ -92,6 +92,15 @@ additive rules below apply to them unchanged.
|
|||||||
not serve an item's primary locale, x-default is the item's first **available** locale (it used to be the site
|
not serve an item's primary locale, x-default is the item's first **available** locale (it used to be the site
|
||||||
default, an unprefixed path the item may not exist at — which llms.txt then linked).
|
default, an unprefixed path the item may not exist at — which llms.txt then linked).
|
||||||
|
|
||||||
|
### What `1.1.0` added
|
||||||
|
|
||||||
|
- **`PluginSettings.appSecret(key)`**: the calling plugin's own `secret`-typed **app-level** setting (`settings:` in
|
||||||
|
`plugin.yml`), in clear. App-level settings bind through `@ConfigurationProperties`, where a secret arrives only in
|
||||||
|
its stored `ENC(...)` form, and a plugin has no way to decrypt that. The answer is the value the running application
|
||||||
|
was started with, so a change saved on the console applies after the restart, as every app-level setting does.
|
||||||
|
It is a `default` method answering empty, so an implementation written against `1.0.0` still compiles. A plugin
|
||||||
|
that calls it declares `requiresSpi: ">=1.1.0"`.
|
||||||
|
|
||||||
## The compatibility rules (in force from `1.0.0`)
|
## The compatibility rules (in force from `1.0.0`)
|
||||||
|
|
||||||
The SPI is **binary API**. A plugin compiled against a released `runway-spi` keeps loading on any later version of
|
The SPI is **binary API**. A plugin compiled against a released `runway-spi` keeps loading on any later version of
|
||||||
|
|||||||
+23
-6
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This folder holds **Runway plugin projects**. Each plugin is a **standalone project** (its own build) that
|
This folder holds **Runway plugin projects**. Each plugin is a **standalone project** (its own build) that
|
||||||
compiles against the Runway SPI only (`mx.quest:runway-spi`, plus `runway-spi-testkit` for its tests) from the local Maven repository and deploys as a
|
compiles against the Runway SPI only (`mx.quest:runway-spi`, plus `runway-spi-testkit` for its tests) from the local Maven repository and deploys as a
|
||||||
folder under a Runway install's `external/plugins/<id>/`. The contract is **SPI `1.0.0`** (Runway `1.0.0`): the
|
folder under a Runway install's `external/plugins/<id>/`. The contract is **SPI `1.1.0`** (Runway `1.1.0`; every `1.0.0`
|
||||||
kernel blocks a plugin that links its internal classes. The SPI jars are not yet published to a Maven repository — see the authoring
|
plugin still loads): the kernel blocks a plugin that links its internal classes. The SPI jars are not yet published to a Maven repository — see the authoring
|
||||||
guide, §2.
|
guide, §2.
|
||||||
|
|
||||||
Each Runway release on the releases page (<https://g.quest.mx/quest/runway/releases>) carries the zips of these
|
Each Runway release on the releases page (<https://g.quest.mx/quest/runway/releases>) carries the zips of these
|
||||||
@@ -15,9 +15,17 @@ plugins built for it, beside the kernel's own files and listed in the same `SHA2
|
|||||||
plugins/
|
plugins/
|
||||||
├── docs/PLUGIN-AUTHORING-GUIDE.md # THE canonical guide: build any Runway plugin from scratch
|
├── docs/PLUGIN-AUTHORING-GUIDE.md # THE canonical guide: build any Runway plugin from scratch
|
||||||
├── demo/ # the reference "kitchen-sink" plugin — exercises EVERY seam
|
├── demo/ # the reference "kitchen-sink" plugin — exercises EVERY seam
|
||||||
|
├── blog/ # a blog: entries as virtual pages via ContentSource, in the site's own chrome
|
||||||
|
├── carousel-manager/ # an image/slide carousel content widget, slides configured per site
|
||||||
|
├── contact/ # a contact form widget: emails each submission and stores it for the console
|
||||||
|
├── discoverability/ # SEO+ & GEO: sitemap.xml, robots.txt, llms.txt and schema.org JSON-LD
|
||||||
├── search/ # on-site search: box widget + /search + /search/api + a published SiteSearchEngine SPI
|
├── search/ # on-site search: box widget + /search + /search/api + a published SiteSearchEngine SPI
|
||||||
├── search-lucene/ # a Lucene engine for `search` (requires: search + lucene-provider; per-locale analyzers, heap or disk)
|
├── search-lucene/ # a Lucene engine for `search` (requires: search + lucene-provider; per-locale analyzers, heap or disk)
|
||||||
└── lucene-provider/ # CODE-LESS library provider: bundles Apache Lucene under lib/ (no mainClass)
|
├── lucene-provider/ # CODE-LESS library provider: bundles Apache Lucene under lib/ (no mainClass)
|
||||||
|
├── database/ # plugins' own data in PostgreSQL or MariaDB: schema per site, migrations, backups
|
||||||
|
├── database-postgresql/ # the PostgreSQL provider for `database` (bundles pgjdbc)
|
||||||
|
├── database-mariadb/ # the MariaDB provider for `database` (bundles MariaDB Connector/J)
|
||||||
|
└── runway-demo-database/ # the worked example of a database consumer: a per-site guestbook
|
||||||
```
|
```
|
||||||
|
|
||||||
The essential **protection** plugin is not here: it is `runway-plugin-protection` at the root of the repository,
|
The essential **protection** plugin is not here: it is `runway-plugin-protection` at the root of the repository,
|
||||||
@@ -25,9 +33,10 @@ and ships inside the Runway installer.
|
|||||||
|
|
||||||
Each plugin carries a `README.md` and a `plugin.yml` (and, when it has code, its unit tests), and versions independently (its
|
Each plugin carries a `README.md` and a `plugin.yml` (and, when it has code, its unit tests), and versions independently (its
|
||||||
version is in its `plugin.yml`). Each also carries a `docs/<NAME>-PLUGIN.md`, and most a
|
version is in its `plugin.yml`). Each also carries a `docs/<NAME>-PLUGIN.md`, and most a
|
||||||
`scripts/verify-against-host.sh` that checks it against the packaged host. One does not have the verify script:
|
`scripts/verify-against-host.sh` that checks it against the packaged host. Three do not have their own verify script:
|
||||||
**`lucene-provider`** has `docs/LUCENE-PROVIDER-PLUGIN.md` but no verify script — it is a code-less library bundle
|
**`lucene-provider`** is a code-less library bundle with no code of its own to verify, and the two database
|
||||||
with no code of its own to verify.
|
providers (**`database-postgresql`**, **`database-mariadb`**) are verified by `database/scripts/verify-against-host.sh`,
|
||||||
|
which installs both.
|
||||||
|
|
||||||
## Start here
|
## Start here
|
||||||
|
|
||||||
@@ -41,6 +50,14 @@ with no code of its own to verify.
|
|||||||
- Implementing another plugin's SPI (`requires:`) + **consuming a library-provider** (Lucene) → [`search-lucene/`](search-lucene/).
|
- Implementing another plugin's SPI (`requires:`) + **consuming a library-provider** (Lucene) → [`search-lucene/`](search-lucene/).
|
||||||
- A **code-less library-provider** plugin (bundle a shared library under `lib/`, no `mainClass`) →
|
- A **code-less library-provider** plugin (bundle a shared library under `lib/`, no `mainClass`) →
|
||||||
[`lucene-provider/`](lucene-provider/) (Apache Lucene) — consumed by a `requires:` plugin (`search-lucene`).
|
[`lucene-provider/`](lucene-provider/) (Apache Lucene) — consumed by a `requires:` plugin (`search-lucene`).
|
||||||
|
- Routable content of your own (virtual pages in the site's chrome, sitemap and search included) →
|
||||||
|
[`blog/`](blog/) (`ContentSource`).
|
||||||
|
- A public form that posts, mails and stores tenant data → [`contact/`](contact/).
|
||||||
|
- Server routes and `<head>` markup for a whole site (`EndpointContributor`, `HeadContributor`) →
|
||||||
|
[`discoverability/`](discoverability/).
|
||||||
|
- A self-contained content widget with its own static assets → [`carousel-manager/`](carousel-manager/).
|
||||||
|
- Keeping your data in a database (PostgreSQL or MariaDB) → [`runway-demo-database/`](runway-demo-database/), on
|
||||||
|
[`database/`](database/) (authoring guide §7.14).
|
||||||
|
|
||||||
## Conventions
|
## Conventions
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes are recorded here. Versions follow [Semantic Versioning](https://semver.org/).
|
||||||
|
|
||||||
|
## [2.1.0] — 2026-10-21
|
||||||
|
|
||||||
|
First public release of `blog`: blog entries as first-class virtual pages through the kernel's `ContentSource`
|
||||||
|
seam — each with its own URL (under a configurable prefix, or a custom path), rendered in the site's own chrome, in
|
||||||
|
every language the site serves, and listed in the sitemap and `llms.txt`. Requires SPI `1.0.0` (Runway `1.0.0` or later). Licensed under the GNU AGPL v3.0 with an additional permission for
|
||||||
|
plugins (`LICENSE`, `LICENSE-EXCEPTION`).
|
||||||
@@ -0,0 +1,661 @@
|
|||||||
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights
|
||||||
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified source code becomes available
|
||||||
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and
|
||||||
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
|
this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer
|
||||||
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for the
|
||||||
|
specific requirements.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
Runway — additional permission for plugins
|
||||||
|
(an additional permission under section 7 of the GNU Affero General Public License, version 3)
|
||||||
|
|
||||||
|
Copyright (C) 2026 Quest ICT SAS de CV
|
||||||
|
|
||||||
|
Runway is free software: you can redistribute it and/or modify it under the terms of the
|
||||||
|
GNU Affero General Public License as published by the Free Software Foundation, version 3
|
||||||
|
(the file LICENSE), with the additional permission below. Runway is distributed in the hope
|
||||||
|
that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||||
|
License for more details.
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
|
||||||
|
"Runway" means the Runway kernel and every Runway plugin whose source carries this file.
|
||||||
|
|
||||||
|
"Published SPI" means the public classes and interfaces of the runway-spi artifact
|
||||||
|
(the package mx.quest.runway.spi and its subpackages), together with the public classes
|
||||||
|
and interfaces of any package named "spi" that a part of Runway publishes for other
|
||||||
|
plugins to use (for example mx.quest.search.spi).
|
||||||
|
|
||||||
|
"Plugin" means an independent module that Runway loads as a plugin, that interacts with
|
||||||
|
Runway only through the Published SPI, and that is not based on any part of Runway other
|
||||||
|
than the Published SPI.
|
||||||
|
|
||||||
|
2. Permission
|
||||||
|
|
||||||
|
As an additional permission, the copyright holder gives you permission to combine Runway
|
||||||
|
with Plugins, and to convey and run the resulting combination, without the terms of the
|
||||||
|
GNU Affero General Public License applying to those Plugins. You may license, convey and
|
||||||
|
run your Plugins under terms of your choice, provided that you continue to meet the terms
|
||||||
|
of the GNU Affero General Public License for Runway itself, including offering the
|
||||||
|
Corresponding Source of Runway, and of any modification you make to it, as that license
|
||||||
|
requires.
|
||||||
|
|
||||||
|
3. Testing
|
||||||
|
|
||||||
|
Compiling a Plugin's tests against the runway-spi-testkit artifact, and running them, does
|
||||||
|
not by itself make the Plugin subject to the GNU Affero General Public License.
|
||||||
|
|
||||||
|
4. Modified versions
|
||||||
|
|
||||||
|
If you modify Runway, you may extend this additional permission to your version, but you
|
||||||
|
are not obliged to do so. If you do not wish to, delete this file from your version.
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
# blog — a blog for Runway sites
|
||||||
|
|
||||||
|
Blog entries as **first-class virtual pages**, built on the host's `ContentSource` seam: each entry has its own URL under a configurable prefix (default `/blog`) — or a per-entry
|
||||||
|
**custom absolute path** — renders inside the **tenant's own master chrome** through this plugin's shipped
|
||||||
|
entry templates, follows the site's full language dispatch (per-language slugs, `?lang=` switcher, canonical
|
||||||
|
redirects), appears in **sitemap.xml / llms.txt** with `hreflang` + `<lastmod>`, and is linkable from any
|
||||||
|
tenant page as `${urls['blog:<id>']}`. All of that is host-provided; this plugin only stores entries and
|
||||||
|
answers the source contract.
|
||||||
|
|
||||||
|
**The plugin links only the Runway SPI** (service tier, SPI `1.0.0`) — no kernel-internal class. The full design
|
||||||
|
and reference is [`docs/BLOG-PLUGIN.md`](docs/BLOG-PLUGIN.md); the release notes are in
|
||||||
|
[`CHANGELOG.md`](CHANGELOG.md); `scripts/verify-against-host.sh` checks it end to end against a packaged kernel.
|
||||||
|
|
||||||
|
- **Storage** — entries live in the *tenant's* folder: `sites/<siteId>/plugins/blog/entries/<id>/entry.yml`
|
||||||
|
(metadata) + `body-<lang>.md` (one Markdown body per language), through the kernel's `PluginSiteFiles` (confined
|
||||||
|
to the plugin's subtree). Tenant backups carry the whole blog
|
||||||
|
automatically; the metadata/body file split keeps enumeration body-free (the source contract).
|
||||||
|
- **Authoring** — the tenant console gains a **Blog** screen (`/__admin/blog`, gated by the grantable
|
||||||
|
`blog|manage` control point): list, create, edit (per-language title/description/slug/body), publish/
|
||||||
|
unpublish, delete — each a CSRF-checked `POST`. Every mutation is announced with `ContentChanges`, so routing,
|
||||||
|
sitemap and search follow on the next request; the editor warns when a published **page owns an entry's
|
||||||
|
address** (the page wins — the platform's precedence rule), and refuses a custom path the kernel would not serve.
|
||||||
|
- **Settings** (per tenant, applied immediately): `enabled`, `prefix`, `template`
|
||||||
|
(`entry-classic` — title, date line, back link — or `entry-minimal` — title + body only).
|
||||||
|
- **Search** — entries declare the kernel's `content.indexable-text` capability and serve their
|
||||||
|
body through it (rendered Markdown→HTML, the same transform the page render uses, so the engines' HTML
|
||||||
|
stripper yields clean prose — raw Markdown syntax would leak into index terms and snippets). A search engine
|
||||||
|
that indexes the content catalog (the `search` and `search-lucene` plugins) finds entries by body text,
|
||||||
|
title and description — first-class search citizens, no blog-specific code in any engine.
|
||||||
|
- **Markdown** — rendered with [commonmark-java] (bundled in this plugin's `lib/`, private to this plugin).
|
||||||
|
Entry Markdown is operator-authored trusted content: raw HTML passes through, exactly as a page author may
|
||||||
|
write markup.
|
||||||
|
|
||||||
|
## Bylines and publication dates
|
||||||
|
|
||||||
|
Each entry carries its own **author** and **publication date**, and both travel across the SPI as that
|
||||||
|
entry's own values — so the discoverability plugin emits a truthful per-post `author` and `datePublished` in
|
||||||
|
`Article`/`BlogPosting` structured data, and the entry template renders a byline.
|
||||||
|
|
||||||
|
Without them, authorship and dates could only come from the per-site `content.schema` block, which matches by
|
||||||
|
path prefix — one `/blog/*` entry covering *every* post. The only honest options would be to emit nothing, or to
|
||||||
|
assert a single author and date identically across all posts: false of nearly every page carrying it, and
|
||||||
|
exactly the kind of untrue markup structured-data policy prohibits.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
- Both fields are **optional**. An unattributed entry renders no byline and asserts no author — absence is a
|
||||||
|
normal state, never a placeholder.
|
||||||
|
- The byline element appears when the entry has an author **or** a date, and each part renders independently,
|
||||||
|
so an entry with one but not the other is handled correctly.
|
||||||
|
- `author` is a free-text display name, matching the kernel's page-level author. A real identity model is a
|
||||||
|
larger design; blocking bylines on it would leave content unattributable meanwhile.
|
||||||
|
|
||||||
|
## Publication dates
|
||||||
|
|
||||||
|
Each entry's `publishedOn` date is carried across the SPI as that entry's own `publishedAt`, so the
|
||||||
|
discoverability plugin can emit a **truthful per-post `datePublished`** in `Article`/`BlogPosting`
|
||||||
|
structured data.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
- `publishedOn` is free-form display text. A value that is not an ISO `yyyy-MM-dd` date yields **no**
|
||||||
|
`datePublished` rather than a guess — asserting a wrong date is worse than asserting none, because a
|
||||||
|
consumer is told to trust it.
|
||||||
|
- Dates are interpreted at **midnight UTC**, matching how the kernel's page editor parses its own date
|
||||||
|
field, so a blog entry and a page dated the same day produce the same instant.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
**Needs Runway 1.0.0 or later** (SPI `1.0.0`). The descriptor declares `requiresSpi: ">=1.0.0"`, so an older
|
||||||
|
kernel blocks this plugin at startup with a reason and still boots its other plugins. Upgrade the kernel first, then
|
||||||
|
the plugin.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mvn package
|
||||||
|
```
|
||||||
|
|
||||||
|
`target/blog/` (the install-ready folder) and `target/runway-plugin-blog-<version>.zip` (the UI-upload
|
||||||
|
archive), where `<version>` is the `version:` in `plugin.yml`.
|
||||||
|
|
||||||
|
The first build downloads its Maven dependencies, and needs the `runway-spi` jars installed in `~/.m2` as the
|
||||||
|
[authoring guide §2](../docs/PLUGIN-AUTHORING-GUIDE.md#2-prerequisites) describes.
|
||||||
|
|
||||||
|
## Install (either path, then restart the host)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. cp -r target/blog <external>/plugins/
|
||||||
|
# 2. app console → /__app/plugins → install → upload runway-plugin-blog-<version>.zip
|
||||||
|
```
|
||||||
|
|
||||||
|
## Verify
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mvn verify # 67 unit tests, incl. the no-host-linkage bytecode scan
|
||||||
|
JAVA_HOME=… HOST_JAR=…/runway-app-<ver>-exec.jar VERIFY_TMPDIR=… scripts/verify-against-host.sh # 56 end-to-end checks
|
||||||
|
```
|
||||||
|
|
||||||
|
## Try it
|
||||||
|
|
||||||
|
1. Console → **Blog** → **New entry**: id `hello-world`, tick a language, type a title and a Markdown body,
|
||||||
|
tick **Published**, Save.
|
||||||
|
2. Visit `https://<site>/blog/hello-world` — the entry wears the site's chrome.
|
||||||
|
3. `GET /sitemap.xml` — the entry is listed with `hreflang` alternates and `<lastmod>`.
|
||||||
|
4. Give a **page** the same path — the page serves, the blog editor and the Pages screen both warn.
|
||||||
|
|
||||||
|
_Java package `mx.quest.blog` · plugin id `blog` · built against `runway-spi` 1.0.0 · declared SPI floor
|
||||||
|
`>=1.0.0`._
|
||||||
|
|
||||||
|
[commonmark-java]: https://github.com/commonmark/commonmark-java
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
GNU Affero General Public License v3.0 with an additional permission for plugins (`LICENSE`, `LICENSE-EXCEPTION`),
|
||||||
|
copyright Quest ICT SAS de CV. The permission means that a plugin which uses only the published SPI may carry any
|
||||||
|
license.
|
||||||
@@ -0,0 +1,202 @@
|
|||||||
|
# Runway Blog plugin — design & reference
|
||||||
|
|
||||||
|
> The plugins' reference for **routable content that is not a kernel page**: a plugin `ContentSource` whose
|
||||||
|
> items the kernel routes, renders in the tenant's own master chrome, lists in sitemap.xml / llms.txt and hands to
|
||||||
|
> search — using **only the Runway SPI** (SPI 1.0.0). Grounded in the Runway kernel as built.
|
||||||
|
|
||||||
|
## 1. What it does
|
||||||
|
|
||||||
|
- **Entries as virtual pages.** Each entry is served by the kernel at `<prefix>/<slug>` (default prefix `/blog`),
|
||||||
|
or at a per-entry **custom absolute path** (`/announcing-v2`) for the default language, with **per-language
|
||||||
|
slugs** (`/es/blog/hola-mundo`). The kernel does the routing (real pages always win first), the locale ladder
|
||||||
|
(`?lang=`, cookie, `Accept-Language`, canonical redirects), the `<head>` (title, description, `hreflang`
|
||||||
|
alternates, canonical), the `ETag`/`304`, and wraps the body in the **site's own master** (`_master`).
|
||||||
|
- **Body templates** shipped by the plugin: `entry-classic` (title, a meta line with the date and the byline, the
|
||||||
|
body, a back link) and `entry-minimal` (title and body). The operator picks one per site.
|
||||||
|
- **Discoverability and search, through the kernel catalog.** Published entries are part of the site's content
|
||||||
|
catalog, so sitemap.xml (with `hreflang` and `<lastmod>`), llms.txt and the URL map (`${urls['blog:<id>']}`, usable
|
||||||
|
in any page) list them, and a search engine that indexes the catalog finds an entry by the words of its body
|
||||||
|
(`content.indexable-text`: the body rendered to HTML, the same transform the page uses). The blog has no
|
||||||
|
blog-specific code in any of those plugins.
|
||||||
|
- **Bylines and dates.** Each entry carries its own `author` and `publishedOn`; both cross the SPI as that entry's
|
||||||
|
own values (`ContentRef.author`, `ContentRef.publishedAt`, midnight UTC; a non-ISO date yields no date), so
|
||||||
|
structured data can attribute and date every post truthfully. Both are optional and render independently.
|
||||||
|
- **Console** (`/__admin/blog`, tenant console, gated by `blog|manage`): list, create, edit (per-language title,
|
||||||
|
description, slug, Markdown body; date, author, custom path, published), publish/unpublish, delete. The editor
|
||||||
|
warns when a **published page owns an entry's URL** in some language (the page wins, so the entry is unreachable
|
||||||
|
there). Per-site settings (`enabled`, `prefix`, `template`) are edited on the kernel's generic settings form,
|
||||||
|
gated by `blog|settings`.
|
||||||
|
- **Markdown** is rendered with [commonmark-java], bundled in this plugin's `lib/` and private to it. Entry
|
||||||
|
Markdown is operator-authored, trusted content: raw HTML passes through, exactly as a page author may write
|
||||||
|
markup.
|
||||||
|
|
||||||
|
## 2. Storage (the site's folder)
|
||||||
|
|
||||||
|
```
|
||||||
|
sites/<siteId>/plugins/blog/
|
||||||
|
└── entries/<entryId>/
|
||||||
|
├── entry.yml # metadata (no id: the folder name is the id)
|
||||||
|
├── body-en.md # one Markdown body per language
|
||||||
|
└── body-es.md
|
||||||
|
sites/<siteId>/plugins/blog.yml # the per-site settings (the kernel's settings store)
|
||||||
|
```
|
||||||
|
|
||||||
|
- Read and written through **`PluginSiteFiles`**, which confines every path to `plugins/blog/` (symbolic links
|
||||||
|
included) and writes atomically (temporary file + rename), so a public reader never sees a torn `entry.yml`.
|
||||||
|
- `entry.yml` goes through the plugin's own **lenient** Jackson 3 `YAMLMapper`, so **an entry written by an earlier
|
||||||
|
release or by hand loads unchanged** (a missing `published:` defaults, an unknown key is ignored) and is **written
|
||||||
|
back byte for byte** (`BlogStoreTest` proves both with the fixture entries under `src/test/resources/fixtures`,
|
||||||
|
written by blog 1.3.1 and including an entry with no `author`).
|
||||||
|
- **`updatedAt`** is the newest modification time of the entry's files (`FileEntry.lastModified`), so a console
|
||||||
|
edit of only a body moves the `ETag` and `<lastmod>` with no explicit bump. It is read when the source lists the
|
||||||
|
entries, and that list is cached until a change is announced (§3) — so a file edited **on disk** does not move
|
||||||
|
them until then.
|
||||||
|
- **Metadata/body split**: listing reads only `entry.yml` files; a body is read only to render or index it — the
|
||||||
|
`ContentSource` rule that keeps `/sitemap.xml` from reading the whole corpus.
|
||||||
|
- Ids (`[a-z0-9-]`, ≤ 100) and language codes (`[a-z]{2,8}`) are validated before any path is formed. One
|
||||||
|
unreadable `entry.yml` is skipped with a WARN; it never blanks the blog.
|
||||||
|
- **Backups**: the entries live in the site's folder, so full backups carry them with no `BackupParticipant`.
|
||||||
|
They are **published content, not personal data**, so nothing is declared under `siteData.personal` and a
|
||||||
|
transfer copy carries them too.
|
||||||
|
|
||||||
|
## 3. Freshness: who drops what, and when
|
||||||
|
|
||||||
|
| Change | Announced by | What the kernel does | What the blog does |
|
||||||
|
|---|---|---|---|
|
||||||
|
| An entry is created, edited, (un)published or deleted | the console: `ContentChanges.changed(site, "blog", id)` after the write | evicts routing, the URL map and the catalog; relays to cluster peers; delivers a `CONTENT` `CatalogChange` | `BlogContentSource.onCatalogChanged` (SOURCE phase) drops the site's URL index and enumerated refs |
|
||||||
|
| The blog's settings are saved | the kernel's settings form | evicts the settings cache; delivers `SettingsChange` | `onSettingsChanged` drops the index (a prefix change re-keys every URL) |
|
||||||
|
| A site lifecycle event (incl. a backup **restore**) | the kernel | evicts its caches | `onSiteLifecycle` drops the index (the files were replaced wholesale) |
|
||||||
|
|
||||||
|
The source listens in the **`SOURCE` phase**: the kernel delivers every SOURCE listener first, evicts the catalog
|
||||||
|
once more, and only then lets consumers (sitemap, search) re-read — so none of them rebuilds from the blog's stale
|
||||||
|
index. A change replayed from a cluster peer arrives with `local = false` and drops this node's index the same way.
|
||||||
|
A file edited by hand **on disk** announces nothing, and the blog's index and listing have **no** time-to-live:
|
||||||
|
|
||||||
|
- a **new** entry folder, an `entry.yml` change (title, slug, path, published) or a deleted entry takes effect only
|
||||||
|
after the next console save of any entry, a save of the blog's settings, or a site lifecycle event — a **site
|
||||||
|
reload** (`POST /__reload/site/<id>`, Runway Administration §12.2) is the deliberate one;
|
||||||
|
- an edited **`body-<lang>.md`** is served at once (the body is read on every full render), but **under the old
|
||||||
|
`ETag`** and with the old `<lastmod>`, and search keeps the old text: a browser or CDN holding the page
|
||||||
|
revalidates to `304` and keeps the old body, until one of the events above. **After editing entry files on
|
||||||
|
disk, reload the site.** (Measured against a packaged kernel: body changed on disk → `200` with the new body and the
|
||||||
|
same `ETag`, conditional request → `304`; after the reload → a new `ETag`.)
|
||||||
|
|
||||||
|
**Result, for site managers:** an entry saved in the console serves at once, and is in sitemap.xml and search on
|
||||||
|
the next request; an unpublished entry is a 404 at once and leaves both (the verify script checks each of these).
|
||||||
|
|
||||||
|
## 4. The body-template contract
|
||||||
|
|
||||||
|
The templates read `${master}` and `${content.*}`. The SPI documents that render model on `ContentSource` /
|
||||||
|
`ContentRef.bodyTemplate` as a **contract**: a body template renders with
|
||||||
|
exactly
|
||||||
|
|
||||||
|
- `master` — the site master to wrap (`th:replace="~{${master} :: …}"`);
|
||||||
|
- `content` — `id`, `sourceKey`, `title`, `description` (in the rendered locale), `bodyHtml`, `attributes` (from
|
||||||
|
`body()`), `updatedAt`;
|
||||||
|
- `locale`; and `urls` (link targets: `${urls['index']}`, `${urls['blog:<id>']}`).
|
||||||
|
|
||||||
|
Nothing else is promised. The shipped templates use only these;
|
||||||
|
**`BlogEntryTemplateContractTest` holds them to it**: statically (every `${…}` starts from one of the four
|
||||||
|
variables, every `content.` key is a listed one, no bean is reached, every `#{…}` key is in the plugin's bundle) and
|
||||||
|
by rendering them with Thymeleaf over a model built exactly to the contract, with no kernel class. The attributes
|
||||||
|
the blog puts in `body()` are its own: `publishedOn` and `author`, each present only when set.
|
||||||
|
|
||||||
|
## 5. The console screen
|
||||||
|
|
||||||
|
`BlogAdminController` carries **`@ConsoleScreen`**: the kernel's own advice fills the operator shell's model
|
||||||
|
(topbar, menus incl. this plugin's entry, language switcher, footer). Handlers return `ConsoleScreen.LAYOUT_VIEW` with
|
||||||
|
`CONTENT_TEMPLATE` set to `__plugin__/blog/admin-list|admin-edit` and `PAGE_TITLE_KEY`.
|
||||||
|
|
||||||
|
- **Tenancy** is always the bound one: `RequestContext.site()`; empty (the application console) → `400`.
|
||||||
|
- **Every handler** is `@PreAuthorize("@authz.may('blog|manage')")` (`AccessCheck`, bean `authz`).
|
||||||
|
- **Every state change is a `POST`** (create, update, publish toggle, delete) checked by the console chain's CSRF
|
||||||
|
filter; each form carries `${_csrf}`. The three `GET`s only render. A test asserts this shape.
|
||||||
|
- **Validation before writing** — what the kernel's fail-closed re-filter would otherwise drop silently: a slug
|
||||||
|
must match the slug grammar; a custom path must be absolute, free of `|` and `:`, and
|
||||||
|
**`ContentCatalogView.servablePath`** (safe, not reserved, not an endpoint route such as `/sitemap.xml`).
|
||||||
|
- **The reverse advisory** asks `ContentCatalogView.pageAt(site, path, locale)` for each language's real URL.
|
||||||
|
- Console words come from `Messages.console` (the operator's UI language) and the plugin's bundle. The templates
|
||||||
|
read only the controller's model plus `_csrf`, and only this plugin's message keys (the pretitle uses
|
||||||
|
`blog.admin.pretitle`, not a kernel key) — `BlogAdminTemplatesRenderTest` checks both.
|
||||||
|
|
||||||
|
## 6. Settings
|
||||||
|
|
||||||
|
| Key | Type | Default | Notes |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `enabled` | boolean | `true` | Off: nothing serves or lists; entries are kept. |
|
||||||
|
| `prefix` | string | `/blog` | Normalized (leading `/`, no trailing `/`); `/` puts entries at the top level. A prefix under which the kernel would not serve an entry (`/app`, `/__x`, `/actuator`, `|`, `..` — checked with `servablePath` on a child path) falls back to `/blog`. |
|
||||||
|
| `template` | enum | `entry-classic` | `entry-classic` or `entry-minimal`; anything else reads as classic. |
|
||||||
|
|
||||||
|
Read through **`PluginSettings.site(siteId)`** (stored value > descriptor default > code fallback; the code
|
||||||
|
fallbacks equal the descriptor defaults, which a test asserts).
|
||||||
|
|
||||||
|
## 7. Inventory
|
||||||
|
|
||||||
|
| Piece | Type | Role |
|
||||||
|
|---|---|---|
|
||||||
|
| `BlogConfig` | `mainClass` `@Configuration` | wires the three beans from SPI services; bean names `blogStore`, `blogContentSource`, `blogAdminController` |
|
||||||
|
| `BlogStore` | over `PluginSiteFiles` | `entries/<id>/entry.yml` + `body-<lang>.md` |
|
||||||
|
| `BlogEntry` | record | one entry's metadata (the `entry.yml` document) |
|
||||||
|
| `BlogSettings` | record | the effective per-site settings (`PluginSettings` + `servablePath`) |
|
||||||
|
| `BlogContentSource` | `ContentSource` (`blog`) + `SiteEventListener` (SOURCE) | enumerate / resolve (O(1) index) / body / indexableText; index invalidation |
|
||||||
|
| `BlogAdminController` | `@Controller` `@ConsoleScreen` | the authoring screens |
|
||||||
|
| `templates/` | decoupled Thymeleaf | `entry-classic`, `entry-minimal`, `admin-list`, `admin-edit` |
|
||||||
|
| `i18n/` | EN / ES | public labels + console |
|
||||||
|
| `lib/commonmark-*.jar` | bundled | Markdown |
|
||||||
|
|
||||||
|
## 8. What it links (SPI 1.0.0)
|
||||||
|
|
||||||
|
`pom.xml` depends on `runway-spi` only (`runway-spi-testkit` and Thymeleaf for tests; Spring, Spring Security and
|
||||||
|
Jackson 3 YAML as **provided** platform libraries); **`runway-app` is not a dependency in any scope**, and
|
||||||
|
`BlogConfigTest` scans the compiled classes' constant pools for any `mx.quest.runway` reference outside
|
||||||
|
`mx.quest.runway.spi`.
|
||||||
|
|
||||||
|
The SPI services it uses: `PluginSiteFiles` (with the plugin's own `YAMLMapper`), `PluginSettings`,
|
||||||
|
`ContentCatalogView` (`servablePath`, `pageAt`), `ContentChanges`, `SiteEventListener` (SOURCE phase),
|
||||||
|
`RequestContext` (`SiteView`), `Messages.console` and `@ConsoleScreen`.
|
||||||
|
|
||||||
|
`requiresSpi: ">=1.0.0"`: a kernel with an older SPI blocks the plugin before wiring, with a reason.
|
||||||
|
|
||||||
|
## 9. Verify
|
||||||
|
|
||||||
|
`scripts/verify-against-host.sh` (honours `JAVA_HOME` (required), `MVN`, `HOST_TARGET`, `HOST_JAR`, `VERIFY_TMPDIR`,
|
||||||
|
`VERIFY_LOG_DIR`, `COMPANIONS`; never runs
|
||||||
|
`mvn install`, never needs `--keep`) boots the **packaged** host in ACTIVE mode with the wizard's default site made
|
||||||
|
bilingual (EN default, ES), the **1.3.1 fixture entries** copied into it, and — built offline from copies of the
|
||||||
|
sibling folders, skipped if they cannot be built — the `discoverability` and `search` plugins. It checks:
|
||||||
|
|
||||||
|
- the plugin loads (registered, 0 blocked) with **zero** host-linkage and bean-name/surface findings (the kernel
|
||||||
|
logs "linkage scan: …" and blocks a plugin that links host internals; a surface problem names the bean) and no
|
||||||
|
WARN or ERROR about it, and the application console's plugins screen shows it Loaded with no health note (this check
|
||||||
|
has no positive control since every companion became SPI-only; one needs a deliberately host-linked fixture jar);
|
||||||
|
- the 1.3.1 entries serve unchanged: default URL, localized slug in Spanish, custom path, the byline and date, the
|
||||||
|
entry without an author (date, no byline), the draft a 404, an `ETag` that revalidates `304`, and a page's
|
||||||
|
`${urls['blog:hello-world']}`;
|
||||||
|
- sitemap.xml and llms.txt list the published entries and not the draft; search finds an entry by a body word;
|
||||||
|
- the console renders inside the shell, is gated for anonymous visitors, and every mutation is a CSRF-checked POST
|
||||||
|
(no token → `403`, nothing written; a `GET` on a mutation path changes nothing);
|
||||||
|
- create → serves at once, in sitemap.xml and search on the next request; edit the body → search follows;
|
||||||
|
unpublish → `404` and gone from both; a reserved custom path is refused at save; a prefix change through the
|
||||||
|
settings form re-keys the URLs at once (and a reserved prefix falls back to `/blog`); delete removes the folder;
|
||||||
|
- a full backup and a transfer copy both carry the entries.
|
||||||
|
|
||||||
|
Unit tests (67) run on the testkit's fakes with no kernel class: the store (`BlogStoreTest`, incl. the 1.3.1
|
||||||
|
fixture read in place and written back byte for byte, confinement through a planted symbolic link), the source and
|
||||||
|
its listener (`BlogContentSourceTest`, driven by `EventDispatch` in the kernel's order), the controller
|
||||||
|
(`BlogAdminControllerTest`: parsing, validation, announcements, advisory, tenancy, the screen's POST-only shape),
|
||||||
|
the console templates (`BlogAdminTemplatesRenderTest`), the body-template contract
|
||||||
|
(`BlogEntryTemplateContractTest`), and the plugin's contract with the host (`BlogConfigTest`: wiring, bean names,
|
||||||
|
descriptor, EN/ES parity, the constant-pool scan).
|
||||||
|
|
||||||
|
## 10. Not covered (honest gaps)
|
||||||
|
|
||||||
|
- **No listing page.** There is no `/blog` index of entries; link entries from a site page with
|
||||||
|
`${urls['blog:<id>']}`. A listing would be a widget or a virtual page — a feature for a later release.
|
||||||
|
- **No per-entry `noindex` or canonical override**, no categories or tags, no RSS/Atom feed.
|
||||||
|
- **`author` is free text** (a display name), not an account.
|
||||||
|
- **Concurrent edits of one entry**: the last save wins (each file write is atomic; there is no merge).
|
||||||
|
- **A file edited on disk** is not picked up until something announces a change (any console save, a settings
|
||||||
|
save, a site reload); an edited body is served at once but under the old `ETag` until then (§3). Reload the site
|
||||||
|
after editing entry files by hand.
|
||||||
|
|
||||||
|
[commonmark-java]: https://github.com/commonmark/commonmark-java
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
# Blog plugin — appended LAST to each site's bundle (add-only: a site defining the same key wins) and to the
|
||||||
|
# operator console bundle. Public-side keys (the entry templates) + the console screens.
|
||||||
|
|
||||||
|
# Public entry templates
|
||||||
|
blog.publishedOn=Published on
|
||||||
|
blog.by=By
|
||||||
|
blog.back=Back to the site
|
||||||
|
|
||||||
|
# Console — permissions / settings / menu labels (referenced from plugin.yml)
|
||||||
|
blog.perm.settings=Configure the blog
|
||||||
|
blog.perm.manage=Manage blog entries
|
||||||
|
blog.settings.enabled=Blog enabled
|
||||||
|
blog.settings.prefix=URL prefix
|
||||||
|
blog.settings.template=Entry template
|
||||||
|
blog.menu=Blog
|
||||||
|
|
||||||
|
# Console — list screen
|
||||||
|
blog.admin.pretitle=Site
|
||||||
|
blog.admin.title=Blog
|
||||||
|
blog.admin.heading=Blog
|
||||||
|
blog.admin.new=New entry
|
||||||
|
blog.admin.new.tip=Create a new blog entry (it starts unpublished).
|
||||||
|
blog.admin.disabled=The blog is disabled for this site (see the plugin's settings) — entries are kept but none serves.
|
||||||
|
blog.admin.col.entry=Entry
|
||||||
|
blog.admin.col.path=Path
|
||||||
|
blog.admin.col.langs=Languages
|
||||||
|
blog.admin.col.date=Date
|
||||||
|
blog.admin.col.status=Status
|
||||||
|
blog.admin.col.actions=Actions
|
||||||
|
blog.admin.empty=No entries yet.
|
||||||
|
blog.admin.published=Published
|
||||||
|
blog.admin.draft=Draft
|
||||||
|
blog.admin.edit=Edit
|
||||||
|
blog.admin.publish=Publish
|
||||||
|
blog.admin.unpublish=Unpublish
|
||||||
|
blog.admin.delete=Delete
|
||||||
|
blog.admin.delete.confirm=Delete this entry and all its languages?
|
||||||
|
|
||||||
|
# Console — editor
|
||||||
|
blog.edit.heading=Edit entry
|
||||||
|
blog.edit.headingNew=New entry
|
||||||
|
blog.edit.back=Back to blog
|
||||||
|
blog.edit.shadowed=A page owns this entry's address — the page wins, so the entry is unreachable there:
|
||||||
|
blog.edit.entry=Entry
|
||||||
|
blog.edit.id=Id
|
||||||
|
blog.edit.id.tip=The entry's stable identity (lowercase letters, digits, hyphens). It names the entry's folder and its default slug; it cannot be changed later.
|
||||||
|
blog.edit.date=Publication date
|
||||||
|
blog.edit.author=Author
|
||||||
|
blog.edit.author.tip=Who is credited for this post. Shown as a byline and used for structured data. Leave blank for an unattributed entry.
|
||||||
|
blog.edit.customPath=Custom path
|
||||||
|
blog.edit.customPath.tip=Optional absolute address (e.g. /announcing-v2) replacing the prefixed one for the default language. Leave empty for the normal <prefix>/<slug> address.
|
||||||
|
blog.edit.published=Published
|
||||||
|
blog.edit.defaultLang=default
|
||||||
|
blog.edit.langOn=Published in this language
|
||||||
|
blog.edit.title=Title
|
||||||
|
blog.edit.slug=Slug
|
||||||
|
blog.edit.slug.tip=The address segment under the blog prefix for this language. The default language's slug is the entry's base slug.
|
||||||
|
blog.edit.description=Description
|
||||||
|
blog.edit.body=Body (Markdown)
|
||||||
|
blog.edit.save=Save
|
||||||
|
|
||||||
|
# Console — flash/error feedback
|
||||||
|
blog.flash.created=Entry created.
|
||||||
|
blog.flash.saved=Saved.
|
||||||
|
blog.flash.published=Entry published.
|
||||||
|
blog.flash.unpublished=Entry unpublished.
|
||||||
|
blog.flash.deleted=Entry deleted.
|
||||||
|
blog.error.duplicate=An entry with that id already exists.
|
||||||
|
blog.error.reservedId=That id is reserved — pick another.
|
||||||
|
blog.error.invalid=Some fields are invalid:
|
||||||
|
blog.error.ioError=The entry could not be written.
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
# Blog plugin — español.
|
||||||
|
|
||||||
|
blog.publishedOn=Publicado el
|
||||||
|
blog.by=Por
|
||||||
|
blog.back=Volver al sitio
|
||||||
|
|
||||||
|
blog.perm.settings=Configurar el blog
|
||||||
|
blog.perm.manage=Gestionar entradas del blog
|
||||||
|
blog.settings.enabled=Blog activo
|
||||||
|
blog.settings.prefix=Prefijo de URL
|
||||||
|
blog.settings.template=Plantilla de entrada
|
||||||
|
blog.menu=Blog
|
||||||
|
|
||||||
|
blog.admin.pretitle=Sitio
|
||||||
|
blog.admin.title=Blog
|
||||||
|
blog.admin.heading=Blog
|
||||||
|
blog.admin.new=Nueva entrada
|
||||||
|
blog.admin.new.tip=Crea una nueva entrada (empieza sin publicar).
|
||||||
|
blog.admin.disabled=El blog está desactivado para este sitio (ver la configuración del plugin) — las entradas se conservan pero ninguna se sirve.
|
||||||
|
blog.admin.col.entry=Entrada
|
||||||
|
blog.admin.col.path=Ruta
|
||||||
|
blog.admin.col.langs=Idiomas
|
||||||
|
blog.admin.col.date=Fecha
|
||||||
|
blog.admin.col.status=Estado
|
||||||
|
blog.admin.col.actions=Acciones
|
||||||
|
blog.admin.empty=Aún no hay entradas.
|
||||||
|
blog.admin.published=Publicada
|
||||||
|
blog.admin.draft=Borrador
|
||||||
|
blog.admin.edit=Editar
|
||||||
|
blog.admin.publish=Publicar
|
||||||
|
blog.admin.unpublish=Despublicar
|
||||||
|
blog.admin.delete=Eliminar
|
||||||
|
blog.admin.delete.confirm=¿Eliminar esta entrada y todos sus idiomas?
|
||||||
|
|
||||||
|
blog.edit.heading=Editar entrada
|
||||||
|
blog.edit.headingNew=Nueva entrada
|
||||||
|
blog.edit.back=Volver al blog
|
||||||
|
blog.edit.shadowed=Una página posee la dirección de esta entrada — la página gana, así que la entrada es inaccesible ahí:
|
||||||
|
blog.edit.entry=Entrada
|
||||||
|
blog.edit.id=Id
|
||||||
|
blog.edit.id.tip=La identidad estable de la entrada (minúsculas, dígitos, guiones). Nombra su carpeta y su slug por defecto; no puede cambiarse después.
|
||||||
|
blog.edit.date=Fecha de publicación
|
||||||
|
blog.edit.author=Autor
|
||||||
|
blog.edit.author.tip=A quién se atribuye esta entrada. Se muestra como firma y se usa en los datos estructurados. Déjelo en blanco si no lleva autor.
|
||||||
|
blog.edit.customPath=Ruta personalizada
|
||||||
|
blog.edit.customPath.tip=Dirección absoluta opcional (p. ej. /anunciando-v2) que sustituye a la prefijada para el idioma por defecto. Vacío = la dirección normal <prefijo>/<slug>.
|
||||||
|
blog.edit.published=Publicada
|
||||||
|
blog.edit.defaultLang=por defecto
|
||||||
|
blog.edit.langOn=Publicada en este idioma
|
||||||
|
blog.edit.title=Título
|
||||||
|
blog.edit.slug=Slug
|
||||||
|
blog.edit.slug.tip=El segmento de la dirección bajo el prefijo del blog para este idioma. El slug del idioma por defecto es el slug base de la entrada.
|
||||||
|
blog.edit.description=Descripción
|
||||||
|
blog.edit.body=Cuerpo (Markdown)
|
||||||
|
blog.edit.save=Guardar
|
||||||
|
|
||||||
|
# Consola — mensajes de estado/error
|
||||||
|
blog.flash.created=Entrada creada.
|
||||||
|
blog.flash.saved=Guardado.
|
||||||
|
blog.flash.published=Entrada publicada.
|
||||||
|
blog.flash.unpublished=Entrada despublicada.
|
||||||
|
blog.flash.deleted=Entrada eliminada.
|
||||||
|
blog.error.duplicate=Ya existe una entrada con ese id.
|
||||||
|
blog.error.reservedId=Ese id está reservado — elige otro.
|
||||||
|
blog.error.invalid=Algunos campos no son válidos:
|
||||||
|
blog.error.ioError=No se pudo escribir la entrada.
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# Runway Blog Plugin — descriptor
|
||||||
|
# Blog entries as first-class virtual pages via the kernel's ContentSource seam.
|
||||||
|
# Links ONLY the Runway SPI (service tier, SPI 1.0.0).
|
||||||
|
# The install folder name MUST equal this `id`: external/plugins/blog/.
|
||||||
|
# =============================================================================
|
||||||
|
id: blog
|
||||||
|
name: Blog
|
||||||
|
version: 2.1.0
|
||||||
|
|
||||||
|
# Built against the SPI service tier (ContentChanges, SiteEventListener, ContentCatalogView, PluginSettings,
|
||||||
|
# PluginSiteFiles, RequestContext, Messages and @ConsoleScreen) as frozen in SPI 1.0.0. A kernel below it BLOCKS this
|
||||||
|
# plugin at startup with a reason.
|
||||||
|
requiresSpi: ">=1.0.0"
|
||||||
|
|
||||||
|
# The @Configuration registered into the host context before refresh. Its package (mx.quest.blog) lives
|
||||||
|
# OUTSIDE mx.quest.runway so the host never double-scans it. Beans are wired EXPLICITLY (no @ComponentScan), and every
|
||||||
|
# bean name starts with the plugin id (blog…).
|
||||||
|
mainClass: mx.quest.blog.BlogConfig
|
||||||
|
|
||||||
|
# --- Per-site data -----------------------------------------------------------------------------------------
|
||||||
|
# Entries live in sites/<id>/plugins/blog/entries/<entryId>/ (entry.yml + body-<lang>.md). They are PUBLISHED
|
||||||
|
# CONTENT the site's own operators author, not visitor or user input, so nothing is
|
||||||
|
# declared under siteData.personal: a transfer copy of the site carries the blog, like its pages.
|
||||||
|
|
||||||
|
# --- Grantable control-point permissions -----------------------------------------------------------------
|
||||||
|
# `settings` (reserved id) gates the per-site config editor; `manage` gates the authoring screen.
|
||||||
|
permissions:
|
||||||
|
- { id: settings, realm: tenant, label: blog.perm.settings, defaultRoles: [] }
|
||||||
|
- { id: manage, realm: tenant, label: blog.perm.manage, defaultRoles: [] }
|
||||||
|
|
||||||
|
# --- Per-site settings (tenant-owned BEHAVIOUR; over sites/<id>/plugins/blog.yml; applied IMMEDIATELY — a save
|
||||||
|
# reaches the blog's SiteEventListener, which drops its per-site URL index before anything re-reads it) -------
|
||||||
|
siteSettings:
|
||||||
|
- { key: enabled, type: boolean, default: true, label: blog.settings.enabled }
|
||||||
|
- { key: prefix, type: string, default: "/blog", label: blog.settings.prefix }
|
||||||
|
- { key: template, type: enum, default: entry-classic, range: "entry-classic,entry-minimal",
|
||||||
|
label: blog.settings.template }
|
||||||
|
|
||||||
|
# --- Tenant-console menu entry (gated by the FULL namespaced permission key; visibility is UX only) --------
|
||||||
|
menu:
|
||||||
|
- { realm: tenant, region: menu, order: 55, label: blog.menu, path: "/__admin/blog",
|
||||||
|
permission: "blog|manage", icon: "fa-solid fa-feather-pointed" }
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<!-- Inherit the SAME managed versions the kernel uses (Spring Boot 4.0.6). NOT a Boot app — no repackage;
|
||||||
|
`mvn package` produces a THIN jar of only this plugin's classes plus a lib/ with commonmark. -->
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>4.0.6</version>
|
||||||
|
<relativePath/>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>mx.quest</groupId>
|
||||||
|
<artifactId>runway-plugin-blog</artifactId>
|
||||||
|
<version>2.1.0</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>Runway Blog Plugin</name>
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>GNU Affero General Public License v3.0, with the Runway additional permission for plugins</name>
|
||||||
|
<url>https://www.gnu.org/licenses/agpl-3.0.txt</url>
|
||||||
|
<distribution>repo</distribution>
|
||||||
|
<comments>See LICENSE and LICENSE-EXCEPTION.</comments>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
<description>
|
||||||
|
A blog for Runway sites, built on the kernel's ContentSource seam: entries are plugin-owned files in
|
||||||
|
the tenant's folder (metadata + per-language Markdown bodies), served as first-class virtual pages —
|
||||||
|
own URLs under a configurable prefix (or per-entry custom paths), the site's master chrome, full
|
||||||
|
locale dispatch, sitemap/llms.txt listing, search indexing, and by-id links. Authored in a console
|
||||||
|
screen. Links only the Runway SPI (service tier, SPI 1.0.0).
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>25</java.version>
|
||||||
|
<maven.compiler.release>25</maven.compiler.release>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<!-- Reproducible builds: pins every archive entry's timestamp so two builds of the same source
|
||||||
|
produce byte-identical artifacts. Without it a jar embeds the build time, so a rebuild can
|
||||||
|
never match what was published. Bump at each release. -->
|
||||||
|
<project.build.outputTimestamp>2026-10-21T18:56:00Z</project.build.outputTimestamp>
|
||||||
|
<runway.version>1.0.0</runway.version>
|
||||||
|
<!-- BUNDLED (goes into this plugin's lib/): the Markdown renderer for entry bodies. PRIVATE to this
|
||||||
|
plugin until a second consumer exists — then it graduates to a code-less provider plugin (the
|
||||||
|
library-provider convention). One version deployment-wide (shared classloader). -->
|
||||||
|
<commonmark.version>0.25.1</commonmark.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mx.quest</groupId>
|
||||||
|
<artifactId>runway-spi</artifactId>
|
||||||
|
<version>${runway.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- NO runway-app dependency, in any scope: the plugin links only the SPI, so a host
|
||||||
|
import no longer compiles and the kernel's host-linkage scanner finds nothing to report. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mx.quest</groupId>
|
||||||
|
<artifactId>runway-spi-testkit</artifactId>
|
||||||
|
<version>${runway.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- PLATFORM LIBRARIES — provided by the host at runtime (the kernel's MAJOR line pins their MAJOR lines);
|
||||||
|
compile-only here and never bundled into lib/. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- The console controller: @Controller, @GetMapping/@PostMapping, RedirectAttributes. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-webmvc</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- @PreAuthorize on the console handlers. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security</groupId>
|
||||||
|
<artifactId>spring-security-core</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- entry.yml is read and written with this plugin's own (lenient) YAMLMapper over Jackson 3. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>tools.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- The bundled Markdown engine (compile scope → copied into lib/ by the packaging step below). -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.commonmark</groupId>
|
||||||
|
<artifactId>commonmark</artifactId>
|
||||||
|
<version>${commonmark.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- The template tests render the shipped templates with Thymeleaf's own engine (decoupled logic), over the
|
||||||
|
model the SPI documents — no kernel class involved. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.thymeleaf</groupId>
|
||||||
|
<artifactId>thymeleaf-spring6</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>runway-plugin-blog</finalName>
|
||||||
|
<plugins>
|
||||||
|
<!-- Stage the bundled third-party jars for lib/ (compile-scope, non-provided = just commonmark). -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>stage-lib</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}/staged-lib</outputDirectory>
|
||||||
|
<includeScope>runtime</includeScope>
|
||||||
|
<!-- NEVER bundle the host's own artifacts: the SPI ships with the kernel; a second
|
||||||
|
copy in lib/ would sit on the shared classloader beside the kernel's. -->
|
||||||
|
<excludeGroupIds>mx.quest</excludeGroupIds>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>assemble-plugin-folder</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<property name="stage" value="${project.build.directory}/blog"/>
|
||||||
|
<delete dir="${stage}"/>
|
||||||
|
<mkdir dir="${stage}"/>
|
||||||
|
<copy file="${project.basedir}/plugin.yml" todir="${stage}"/>
|
||||||
|
<copy file="${project.basedir}/LICENSE" todir="${stage}"/>
|
||||||
|
<copy file="${project.basedir}/LICENSE-EXCEPTION" todir="${stage}"/>
|
||||||
|
<copy file="${project.build.directory}/runway-plugin-blog.jar" todir="${stage}"/>
|
||||||
|
<copy todir="${stage}/lib">
|
||||||
|
<fileset dir="${project.build.directory}/staged-lib"/>
|
||||||
|
</copy>
|
||||||
|
<!-- Never a plugin zip without its libraries (it would load and fail at its first use). -->
|
||||||
|
<fail message="no library in ${stage}/lib">
|
||||||
|
<condition><resourcecount when="equal" count="0">
|
||||||
|
<fileset dir="${stage}" includes="lib/*.jar"/></resourcecount></condition>
|
||||||
|
</fail>
|
||||||
|
<copy todir="${stage}/templates">
|
||||||
|
<fileset dir="${project.basedir}/templates"/>
|
||||||
|
</copy>
|
||||||
|
<copy todir="${stage}/i18n">
|
||||||
|
<fileset dir="${project.basedir}/i18n"/>
|
||||||
|
</copy>
|
||||||
|
<touch datetime="${project.build.outputTimestamp}"
|
||||||
|
pattern="yyyy-MM-dd'T'HH:mm:ss'Z'">
|
||||||
|
<fileset dir="${stage}"/>
|
||||||
|
<dirset dir="${stage}"/>
|
||||||
|
<dirset dir="${project.build.directory}" includes="blog"/>
|
||||||
|
</touch>
|
||||||
|
<!-- The stamped files predate any earlier zip, so <zip> would skip the rebuild. -->
|
||||||
|
<delete file="${project.build.directory}/runway-plugin-blog-${project.version}.zip"/>
|
||||||
|
<zip destfile="${project.build.directory}/runway-plugin-blog-${project.version}.zip">
|
||||||
|
<zipfileset dir="${project.build.directory}" includes="blog/**"/>
|
||||||
|
</zip>
|
||||||
|
<echo message="Staged install folder: ${stage}"/>
|
||||||
|
<echo message="UI-uploadable archive: ${project.build.directory}/runway-plugin-blog-${project.version}.zip"/>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
Executable
+331
@@ -0,0 +1,331 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build this plugin, drop it into a throwaway Runway deployment, boot the PACKAGED host in ACTIVE mode, and prove
|
||||||
|
# the blog's contract end to end against a Runway 1.0.0 kernel (SPI 1.0.0):
|
||||||
|
# - it loads with ZERO host-linkage and bean-name/surface findings, and nothing blocks or quarantines it;
|
||||||
|
# - entries WRITTEN BY blog 1.3.1 (the test fixture, placed in the site's plugins/blog/entries/ before the boot —
|
||||||
|
# one of them without an author) load unchanged: they serve at their URLs (default prefix, localized slug,
|
||||||
|
# custom path) inside the tenant's own master chrome, with the byline where there is one and none where there
|
||||||
|
# is not; the draft does not serve;
|
||||||
|
# - a page linking ${urls['blog:<id>']} gets the entry's URL from the kernel catalog;
|
||||||
|
# - with discoverability and search installed (built from this repository's sibling folders into the scratch
|
||||||
|
# folder; SKIPPED when they cannot be built): sitemap.xml and llms.txt list the published entries and not the
|
||||||
|
# draft, and search finds an entry by a word that is only in its Markdown body (indexableText);
|
||||||
|
# - the console screen (@ConsoleScreen) renders inside the operator shell, gated (anonymous → login), and every
|
||||||
|
# mutation is a CSRF-checked POST: without the token → 403 and nothing written; a GET on a mutation path
|
||||||
|
# changes nothing;
|
||||||
|
# - signed in as the site owner: create → the entry serves AT ONCE and is in sitemap and search on the next
|
||||||
|
# request (ContentChanges evicts routing, the catalog and search); edit the body → search follows; unpublish →
|
||||||
|
# 404 and gone from sitemap and search; a reserved custom path is refused at save; a prefix change through the
|
||||||
|
# settings form re-keys the URLs at once (onSettingsChanged); delete → the folder is gone;
|
||||||
|
# - a FULL backup and a TRANSFER copy both carry the entries (published content, not personal data).
|
||||||
|
# Verify ONLY against the packaged jar — never spring-boot:run (its restart classloader loads ZERO plugins).
|
||||||
|
#
|
||||||
|
# Usage: scripts/verify-against-host.sh [--keep] [--port N]
|
||||||
|
# JAVA_HOME=/path/to/jdk-25 required: the JDK that builds the plugin and runs the host
|
||||||
|
# MVN=/path/to/mvn Maven (default: mvn on the PATH)
|
||||||
|
# HOST_TARGET=/path/to/runway/runway-app/target the host build (default: the kernel this plugin sits in, else ../runway)
|
||||||
|
# HOST_JAR=/path/to/runway-app-<ver>-exec.jar the kernel to verify against (default: the host checkout's
|
||||||
|
# runway-app/target jar MATCHING its pom version)
|
||||||
|
# COMPANIONS="discoverability search" sibling plugins to install for the sitemap/llms.txt/search checks
|
||||||
|
# (built offline from a COPY in the scratch folder; their own folders
|
||||||
|
# are never written). Set it to "" to skip those checks.
|
||||||
|
# VERIFY_TMPDIR=/dir where the throwaway deployment goes (default: $TMPDIR or /tmp)
|
||||||
|
# VERIFY_LOG_DIR=/dir keep copies of the host logs and the backup manifests there
|
||||||
|
# The script never runs `mvn install` (nothing is written to ~/.m2): it packages offline against whatever is already
|
||||||
|
# in the local repository.
|
||||||
|
set -uo pipefail
|
||||||
|
|
||||||
|
HERE="$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)"
|
||||||
|
# JAVA_HOME must name a JDK 25. MVN (default: `mvn` on the PATH) and HOST_TARGET (default: see above) can be set in the environment.
|
||||||
|
if [ -z "${JAVA_HOME:-}" ] || [ ! -x "$JAVA_HOME/bin/java" ]; then echo "set JAVA_HOME to a JDK 25"; exit 2; fi
|
||||||
|
export JAVA_HOME
|
||||||
|
JAVA="$JAVA_HOME/bin/java"
|
||||||
|
MVN="${MVN:-mvn}"
|
||||||
|
# Default host: the kernel at the root of the repository this plugin sits in (plugins/<name>/), else a kernel
|
||||||
|
# checkout named `runway` beside the plugins checkout.
|
||||||
|
if [ -z "${HOST_TARGET:-}" ]; then
|
||||||
|
if [ -f "$HERE/../../runway-app/pom.xml" ]; then HOST_TARGET="$HERE/../../runway-app/target"
|
||||||
|
else HOST_TARGET="$HERE/../../runway/runway-app/target"; fi
|
||||||
|
fi
|
||||||
|
COMPANIONS="${COMPANIONS-discoverability search}"
|
||||||
|
|
||||||
|
KEEP="no"; PORT=""
|
||||||
|
while [ $# -gt 0 ]; do case "$1" in
|
||||||
|
--keep) KEEP="yes"; shift ;;
|
||||||
|
--port) PORT="${2:?}"; shift 2 ;;
|
||||||
|
*) echo "unknown arg: $1"; exit 2 ;;
|
||||||
|
esac; done
|
||||||
|
|
||||||
|
APP_USER=root; APP_PW=Blog-Admin-2026; SITE_USER=owner; SITE_PW=Blog-Site-2026
|
||||||
|
SECRET_KEY=blog-verify-master-key-2026
|
||||||
|
free_port() { python3 -I -c 'import socket;s=socket.socket();s.bind(("127.0.0.1",0));print(s.getsockname()[1]);s.close()'; }
|
||||||
|
[ -n "$PORT" ] || PORT="$(free_port)"
|
||||||
|
BASE="http://localhost:$PORT"
|
||||||
|
|
||||||
|
echo "[verify] building the plugin ..."
|
||||||
|
( cd "$HERE" && "$MVN" -o -q -DskipTests package ) || { echo "plugin build failed"; exit 1; }
|
||||||
|
|
||||||
|
# The host jar MATCHING the host pom's version — never "the newest file": every reproducible jar carries the same
|
||||||
|
# fixed timestamp, so `ls -t` cannot tell a leftover release jar from the SNAPSHOT under test.
|
||||||
|
if [ -n "${HOST_JAR:-}" ]; then
|
||||||
|
JAR="$HOST_JAR"
|
||||||
|
else
|
||||||
|
HOST_VERSION="$(sed -n 's:.*<version>\(.*\)</version>.*:\1:p' "$HOST_TARGET/../pom.xml" | head -1)"
|
||||||
|
JAR="$HOST_TARGET/runway-app-$HOST_VERSION-exec.jar"
|
||||||
|
fi
|
||||||
|
[ -f "$JAR" ] || { echo "no host exec jar $JAR — build the host (mvn -pl runway-app package) or set HOST_JAR"; exit 1; }
|
||||||
|
echo "[verify] host jar: $JAR"
|
||||||
|
|
||||||
|
SCRATCH="$(mktemp -d "${VERIFY_TMPDIR:-${TMPDIR:-/tmp}}/blog-verify.XXXXXX")"
|
||||||
|
cleanup() {
|
||||||
|
[ -z "${VERIFY_LOG_DIR:-}" ] || { mkdir -p "$VERIFY_LOG_DIR" \
|
||||||
|
&& cp "$SCRATCH"/*.log "$SCRATCH"/*-manifest.yml "$VERIFY_LOG_DIR"/ 2>/dev/null; }
|
||||||
|
# Wait for the host to exit before deleting: a JVM still shutting down rewrites files under external/ and
|
||||||
|
# makes `rm -rf` leave the scratch folder behind.
|
||||||
|
[ "$KEEP" = "yes" ] || { kill "${PID:-0}" 2>/dev/null; wait "${PID:-0}" 2>/dev/null; rm -rf "$SCRATCH"; }
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
EXT="$SCRATCH/external"
|
||||||
|
mkdir -p "$EXT/plugins"
|
||||||
|
cp -r "$HERE/target/blog" "$EXT/plugins/blog"
|
||||||
|
|
||||||
|
# --- Companion plugins, built from a COPY (their own folders stay untouched) ---------------------------------------
|
||||||
|
INSTALLED=""
|
||||||
|
for id in $COMPANIONS; do
|
||||||
|
src="$HERE/../$id"
|
||||||
|
[ -f "$src/pom.xml" ] || { echo "[verify] companion $id: no source at $src"; continue; }
|
||||||
|
mkdir -p "$SCRATCH/build"
|
||||||
|
( cd "$src" && tar --exclude=./target -cf - . ) | ( mkdir -p "$SCRATCH/build/$id" && cd "$SCRATCH/build/$id" && tar -xf - )
|
||||||
|
if ( cd "$SCRATCH/build/$id" && "$MVN" -o -q -DskipTests package >"$SCRATCH/build-$id.txt" 2>&1 ) \
|
||||||
|
&& [ -d "$SCRATCH/build/$id/target/$id" ]; then
|
||||||
|
cp -r "$SCRATCH/build/$id/target/$id" "$EXT/plugins/$id"
|
||||||
|
INSTALLED="$INSTALLED $id"
|
||||||
|
echo "[verify] companion $id $(sed -n 's/^version: *//p' "$EXT/plugins/$id/plugin.yml") installed"
|
||||||
|
else
|
||||||
|
echo "[verify] companion $id could not be built (see build-$id.txt) — its checks are skipped"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
has() { case " $INSTALLED " in *" $1 "*) return 0 ;; esac; return 1; }
|
||||||
|
|
||||||
|
wait_for() { for _ in $(seq 1 "$3"); do grep -q "$2" "$1" 2>/dev/null && return 0; sleep 1; done; return 1; }
|
||||||
|
PASS=0; FAIL=0; SKIP=0
|
||||||
|
ck() { if eval "$2" >/dev/null 2>&1; then echo " PASS $1"; PASS=$((PASS+1)); else echo " FAIL $1"; FAIL=$((FAIL+1)); fi; }
|
||||||
|
skip() { echo " SKIP $1"; SKIP=$((SKIP+1)); }
|
||||||
|
boot() { ( cd "$SCRATCH" && exec "$JAVA" -jar "$JAR" --server.port="$PORT" --runway.storage.external="$EXT" \
|
||||||
|
--runway.security.secret-key="$SECRET_KEY" ) >"$1" 2>&1 & PID=$!; }
|
||||||
|
|
||||||
|
echo "[verify] booting host (wizard) on :$PORT ..."
|
||||||
|
boot "$SCRATCH/wizard.log"
|
||||||
|
wait_for "$SCRATCH/wizard.log" "Started RunwayApplication" 90 || { echo "wizard did not start"; tail -20 "$SCRATCH/wizard.log"; exit 1; }
|
||||||
|
curl -s -o /dev/null -X POST "$BASE/setup" --data-urlencode "username=$APP_USER" --data-urlencode "password=$APP_PW" \
|
||||||
|
--data-urlencode "displayName=Root" --data-urlencode "siteAdminUsername=$SITE_USER" --data-urlencode "siteAdminPassword=$SITE_PW"
|
||||||
|
for _ in $(seq 1 30); do kill -0 "$PID" 2>/dev/null || break; sleep 1; done
|
||||||
|
|
||||||
|
# --- The default site, prepared on disk before the ACTIVE boot reads it ---------------------------------------------
|
||||||
|
SITE="$EXT/sites/default"
|
||||||
|
[ -f "$SITE/site.yml" ] || { echo "the wizard did not seed $SITE"; exit 1; }
|
||||||
|
# Two languages (English default, Spanish), so the localized slug and the locale ladder are exercised.
|
||||||
|
python3 -I - "$SITE/site.yml" <<'PY'
|
||||||
|
import re, sys
|
||||||
|
p = sys.argv[1]; s = open(p, encoding="utf-8").read()
|
||||||
|
s = re.sub(r'(?m)^locales:\n(?:- .*\n)*', 'locales:\n- "en"\n- "es"\n', s)
|
||||||
|
open(p, "w", encoding="utf-8").write(s)
|
||||||
|
PY
|
||||||
|
grep -q '^- "es"' "$SITE/site.yml" || { echo "could not add Spanish to the site:"; cat "$SITE/site.yml"; exit 1; }
|
||||||
|
# Entries exactly as blog 1.3.1 wrote them (the unit tests' fixture, produced by the 1.3.1 store).
|
||||||
|
mkdir -p "$SITE/plugins/blog"
|
||||||
|
cp -r "$HERE/src/test/resources/fixtures/blog-1.3.1/entries" "$SITE/plugins/blog/entries"
|
||||||
|
# A page whose body links an entry through the kernel's URL map: the seeded About page, edited on disk.
|
||||||
|
sed -i 's|<main id="content">|<main id="content"><a id="to-blog" href="#">blog</a>|' "$SITE/templates/about.html"
|
||||||
|
sed -i 's|</thlogic>|<attr sel="#to-blog" th:href="${urls['"'"'blog:hello-world'"'"']}"/></thlogic>|' \
|
||||||
|
"$SITE/templates/about.th.xml"
|
||||||
|
# llms.txt is part of discoverability's opt-in GEO area (off by default): switch it on for this site.
|
||||||
|
has discoverability && printf '"geo.enabled": true\n' > "$SITE/plugins/discoverability.yml"
|
||||||
|
|
||||||
|
echo "[verify] booting host (ACTIVE) ..."
|
||||||
|
boot "$SCRATCH/active.log"
|
||||||
|
wait_for "$SCRATCH/active.log" "Started RunwayApplication" 90 || { echo "ACTIVE did not start"; tail -20 "$SCRATCH/active.log"; exit 1; }
|
||||||
|
LOG="$SCRATCH/active.log"
|
||||||
|
ENTRIES="$SITE/plugins/blog/entries"
|
||||||
|
code() { curl -s -o /dev/null -w '%{http_code}' -H 'Accept-Language: en' "$@"; }
|
||||||
|
get() { curl -s -H 'Accept-Language: en' "$@"; }
|
||||||
|
|
||||||
|
echo "== plugin load (SPI 1.0.0 contract) =="
|
||||||
|
EXPECTED=$((1 + $(echo $INSTALLED | wc -w)))
|
||||||
|
ck "plugins registered ($EXPECTED), 0 blocked" "grep -qE 'plugins: $EXPECTED registered, 0 blocked' '$LOG'"
|
||||||
|
ck "blog not blocked / quarantined" "! grep -qE \"plugin 'blog' is blocked|plugin-quarantine/blog\" '$LOG'"
|
||||||
|
# Host linkage and the surface rules: the kernel logs "plugin 'blog' linkage scan: <reason>" before "is blocked" (the
|
||||||
|
# check above), and a surface problem names the offending bean ("bean name …", "… may not contribute"). The badge
|
||||||
|
# wording of the plugins screen ("uses host internals") is matched too.
|
||||||
|
ck "ZERO host-linkage findings for blog" "! grep -qE \"plugin 'blog' (uses host internals|linkage scan)\" '$LOG'"
|
||||||
|
ck "ZERO bean-name/surface findings for blog" "! grep -qE \"plugin 'blog'.*(bean name|may not contribute)\" '$LOG'"
|
||||||
|
ck "no WARN/ERROR from or about the blog" "! grep -E ' (WARN|ERROR) ' '$LOG' | grep -qiE \"mx\\.quest\\.blog|'blog'|blog entr\""
|
||||||
|
ck "no key collision / degraded" "! grep -qiE 'collision|duplicate key|degraded' '$LOG'"
|
||||||
|
|
||||||
|
# The application console's plugins screen: blog's row shows the version, LOADED, and no health note at all — no
|
||||||
|
# host-linkage badge, no contained failure, no warning.
|
||||||
|
APP_JAR_C="$SCRATCH/cookies-app.txt"
|
||||||
|
ac() { curl -s -H 'Accept-Language: en' -c "$APP_JAR_C" -b "$APP_JAR_C" "$@"; }
|
||||||
|
ac -o /dev/null -X POST "$BASE/app/login" --data-urlencode "username=$APP_USER" --data-urlencode "password=$APP_PW" \
|
||||||
|
--data-urlencode "_csrf=$(ac "$BASE/app/login" | grep -o 'name="_csrf" value="[^"]*"' | head -1 | sed 's/.*value="//; s/"$//')"
|
||||||
|
ac "$BASE/__app/plugins" > "$SCRATCH/plugins-screen.html"
|
||||||
|
row() { # plugin-id -> its <tr> on the plugins screen
|
||||||
|
python3 -I - "$SCRATCH/plugins-screen.html" "$1" <<'PY2'
|
||||||
|
import re, sys
|
||||||
|
html = open(sys.argv[1], encoding="utf-8").read()
|
||||||
|
for tr in re.findall(r"(?s)<tr\b.*?</tr>", html):
|
||||||
|
if re.search(r'class="c-id">%s<' % re.escape(sys.argv[2]), tr):
|
||||||
|
print(tr); break
|
||||||
|
PY2
|
||||||
|
}
|
||||||
|
row blog > "$SCRATCH/plugins-row-blog.html"
|
||||||
|
BLOG_VERSION="$(sed -n 's/^version: *//p' "$HERE/plugin.yml")"
|
||||||
|
ck "plugins screen: blog $BLOG_VERSION, Loaded" \
|
||||||
|
"grep -q 'class=\"c-version\">$BLOG_VERSION<' '$SCRATCH/plugins-row-blog.html' && grep -q 'bg-green-lt' '$SCRATCH/plugins-row-blog.html'"
|
||||||
|
ck "…with no host-linkage badge, no failure count and no health notes" \
|
||||||
|
"[ -s '$SCRATCH/plugins-row-blog.html' ] && ! grep -qE 'c-host|c-failures|c-notes|c-warning|c-refused' '$SCRATCH/plugins-row-blog.html'"
|
||||||
|
# There used to be a positive control here: "an unmigrated companion (discoverability) does show the badge". Every
|
||||||
|
# companion is SPI-only now, so it failed for the wrong reason and was dropped. A real control
|
||||||
|
# needs a deliberately host-linked fixture jar; until then the badge check above has none.
|
||||||
|
|
||||||
|
echo "== entries written by blog 1.3.1 serve unchanged =="
|
||||||
|
get "$BASE/blog/hello-world" > "$SCRATCH/hello.html"
|
||||||
|
ck "/blog/hello-world -> 200" "[ \"\$(code '$BASE/blog/hello-world')\" = 200 ]"
|
||||||
|
ck "…inside the tenant's master chrome (site header + footer)" \
|
||||||
|
"grep -q 'id=\"site-header\"' '$SCRATCH/hello.html' && grep -q 'id=\"site-footer\"' '$SCRATCH/hello.html' && ! grep -q 'from the master at render' '$SCRATCH/hello.html'"
|
||||||
|
ck "…with its title, its rendered Markdown and its byline" \
|
||||||
|
"grep -q 'Hello world' '$SCRATCH/hello.html' && grep -q '<strong>bold</strong>' '$SCRATCH/hello.html' && grep -q 'By Jane Doe' '$SCRATCH/hello.html' && grep -q 'Published on 2026-07-17' '$SCRATCH/hello.html'"
|
||||||
|
get "$BASE/es/blog/hola-mundo" > "$SCRATCH/hola.html"
|
||||||
|
ck "/es/blog/hola-mundo (the localized slug) -> 200 in Spanish" \
|
||||||
|
"[ \"\$(code '$BASE/es/blog/hola-mundo')\" = 200 ] && grep -q 'Hola mundo' '$SCRATCH/hola.html' && grep -q 'Publicado el' '$SCRATCH/hola.html'"
|
||||||
|
get "$BASE/blog/no-author" > "$SCRATCH/no-author.html"
|
||||||
|
ck "the entry 1.3.1 wrote WITHOUT an author serves, with a date and no byline" \
|
||||||
|
"[ \"\$(code '$BASE/blog/no-author')\" = 200 ] && grep -q 'Unattributed' '$SCRATCH/no-author.html' && grep -q 'Published on 2026-08-01' '$SCRATCH/no-author.html' && ! grep -q 'id=\"entry-author\"' '$SCRATCH/no-author.html'"
|
||||||
|
ck "the custom path /announcing-v2 serves the launch entry" \
|
||||||
|
"[ \"\$(code '$BASE/announcing-v2')\" = 200 ] && get '$BASE/announcing-v2' | grep -q 'By Richard Roe'"
|
||||||
|
ck "the draft does not serve (404)" "[ \"\$(code '$BASE/blog/draft-post')\" = 404 ]"
|
||||||
|
ck "a page's \${urls['blog:hello-world']} is the entry's URL (kernel catalog)" \
|
||||||
|
"get '$BASE/about' | grep -q 'id=\"to-blog\" href=\"/blog/hello-world\"'"
|
||||||
|
ck "an entry carries an ETag (its updatedAt) and revalidates 304" \
|
||||||
|
"E=\$(curl -s -D - -o /dev/null '$BASE/blog/hello-world' | sed -n 's/^[Ee][Tt]ag: *//p' | tr -d '\r'); [ -n \"\$E\" ] && [ \"\$(code -H \"If-None-Match: \$E\" '$BASE/blog/hello-world')\" = 304 ]"
|
||||||
|
|
||||||
|
sitemap() { get "$BASE/sitemap.xml"; }
|
||||||
|
search() { get "$BASE/search/api?q=$1"; }
|
||||||
|
echo "== sitemap.xml / llms.txt / search through the kernel catalog =="
|
||||||
|
if has discoverability; then
|
||||||
|
sitemap > "$SCRATCH/sitemap-0.xml"
|
||||||
|
ck "sitemap.xml lists the published entries (default + localized URLs, custom path)" \
|
||||||
|
"grep -q '/blog/hello-world</loc>' '$SCRATCH/sitemap-0.xml' && grep -q '/es/blog/hola-mundo' '$SCRATCH/sitemap-0.xml' && grep -q '/announcing-v2</loc>' '$SCRATCH/sitemap-0.xml' && grep -q '/blog/no-author</loc>' '$SCRATCH/sitemap-0.xml'"
|
||||||
|
ck "…and not the draft" "! grep -q 'draft-post' '$SCRATCH/sitemap-0.xml'"
|
||||||
|
ck "llms.txt lists an entry" "get '$BASE/llms.txt' | grep -q '/blog/hello-world'"
|
||||||
|
else
|
||||||
|
skip "sitemap.xml / llms.txt (discoverability not installed)"
|
||||||
|
fi
|
||||||
|
if has search; then
|
||||||
|
ck "search finds an entry by a word only in its Markdown body (indexableText)" \
|
||||||
|
"search words | grep -q '/blog/hello-world'"
|
||||||
|
ck "…and not the draft's body" "! search 'Not+yet' | grep -q 'draft-post'"
|
||||||
|
else
|
||||||
|
skip "search (search not installed)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "== the console screen: @ConsoleScreen, gated, CSRF-checked POSTs =="
|
||||||
|
token() { grep -o 'name="_csrf" value="[^"]*"' | head -1 | sed 's/.*value="//; s/"$//'; }
|
||||||
|
JAR_C="$SCRATCH/cookies.txt"
|
||||||
|
sc() { curl -s -H 'Accept-Language: en' -c "$JAR_C" -b "$JAR_C" "$@"; }
|
||||||
|
ck "anonymous GET /__admin/blog does not render the screen (sign-in first)" \
|
||||||
|
"R=\$(curl -s -o /dev/null -w '%{http_code} %{redirect_url}' '$BASE/__admin/blog'); echo \"\$R\" | grep -qE '^(302|303) .*/login|^40[13]'"
|
||||||
|
ck "anonymous POST create without a token -> 403, nothing written" \
|
||||||
|
"[ \"\$(code -X POST '$BASE/__admin/blog/create' -d 'id=anon-post&title_en=x&published=on')\" = 403 ] && [ ! -e '$ENTRIES/anon-post' ]"
|
||||||
|
sc -o /dev/null -X POST "$BASE/login" --data-urlencode "username=$SITE_USER" --data-urlencode "password=$SITE_PW" \
|
||||||
|
--data-urlencode "_csrf=$(sc "$BASE/login" | token)"
|
||||||
|
sc "$BASE/__admin/blog" > "$SCRATCH/console-list.html"
|
||||||
|
ck "signed in: the list renders INSIDE the operator shell" \
|
||||||
|
"grep -q 'id=\"topbar\"' '$SCRATCH/console-list.html' && grep -q 'id=\"op-main\"' '$SCRATCH/console-list.html' && grep -q 'id=\"bl-heading\"' '$SCRATCH/console-list.html'"
|
||||||
|
ck "…with the 1.3.1 entries, the draft badge and the plugin's pretitle" \
|
||||||
|
"grep -q '>hello-world<' '$SCRATCH/console-list.html' && grep -q '>draft-post<' '$SCRATCH/console-list.html' && grep -q '>Draft<' '$SCRATCH/console-list.html' && grep -q 'id=\"bl-pretitle\">Site<' '$SCRATCH/console-list.html'"
|
||||||
|
ck "…and the shell's menu carries the Blog entry" "grep -q 'href=\"/__admin/blog\"' '$SCRATCH/console-list.html'"
|
||||||
|
ck "every mutating form is a POST carrying the console's CSRF token" \
|
||||||
|
"! grep -qE 'href=\"/__admin/blog/[^\"]*/(publish|delete)\"' '$SCRATCH/console-list.html' && grep -qE 'method=\"post\" action=\"/__admin/blog/hello-world/publish\"' '$SCRATCH/console-list.html' && grep -qE 'name=\"_csrf\" value=\"[^\"]+\"' '$SCRATCH/console-list.html'"
|
||||||
|
TOKEN="$(token < "$SCRATCH/console-list.html")"
|
||||||
|
ck "signed in, POST without the token -> 403 and the entry stays published" \
|
||||||
|
"[ \"\$(sc -o /dev/null -w '%{http_code}' -X POST '$BASE/__admin/blog/hello-world/publish')\" = 403 ] && grep -q 'published: true' '$ENTRIES/hello-world/entry.yml'"
|
||||||
|
ck "signed in, GET on the publish path changes nothing" \
|
||||||
|
"sc -o /dev/null '$BASE/__admin/blog/hello-world/publish'; grep -q 'published: true' '$ENTRIES/hello-world/entry.yml'"
|
||||||
|
ck "the editor of an entry 1.3.1 wrote shows its fields" \
|
||||||
|
"sc '$BASE/__admin/blog/no-author/edit' | grep -q 'value=\"Unattributed\"'"
|
||||||
|
|
||||||
|
echo "== create / edit / unpublish / delete: every change is visible on the next request =="
|
||||||
|
[ -n "$(has discoverability && echo y)" ] && sitemap > /dev/null # warm the catalog cache before the change
|
||||||
|
[ -n "$(has search && echo y)" ] && search warmup > /dev/null # …and the search index
|
||||||
|
R="$(sc -o /dev/null -w '%{http_code} %{redirect_url}' -X POST "$BASE/__admin/blog/create" \
|
||||||
|
--data-urlencode "_csrf=$TOKEN" --data-urlencode 'id=fresh-post' --data-urlencode 'title_en=Fresh post' \
|
||||||
|
--data-urlencode 'title_es=Entrada nueva' --data-urlencode 'slug_es=entrada-nueva' \
|
||||||
|
--data-urlencode 'body_en=Zanzibar is the first word of this body.' --data-urlencode 'locales_en=on' \
|
||||||
|
--data-urlencode 'locales_es=on' --data-urlencode 'published=on' --data-urlencode 'publishedOn=2026-10-18')"
|
||||||
|
ck "create -> redirect to the editor" "echo '$R' | grep -qE '^302 .*/__admin/blog/fresh-post/edit'"
|
||||||
|
ck "…written into the entries folder" "[ -f '$ENTRIES/fresh-post/entry.yml' ] && [ -f '$ENTRIES/fresh-post/body-en.md' ]"
|
||||||
|
ck "…and it serves AT ONCE (routing evicted)" "get '$BASE/blog/fresh-post' | grep -q 'Zanzibar'"
|
||||||
|
ck "…in Spanish at its localized slug" "[ \"\$(code '$BASE/es/blog/entrada-nueva')\" = 200 ]"
|
||||||
|
if has discoverability; then ck "…and is in sitemap.xml on the next request" "sitemap | grep -q '/blog/fresh-post</loc>'"; fi
|
||||||
|
if has search; then ck "…and search finds it on the next request" "search zanzibar | grep -q '/blog/fresh-post'"; fi
|
||||||
|
sc -o /dev/null -X POST "$BASE/__admin/blog/fresh-post" --data-urlencode "_csrf=$TOKEN" \
|
||||||
|
--data-urlencode 'title_en=Fresh post' --data-urlencode 'body_en=Quokka replaced the old word.' \
|
||||||
|
--data-urlencode 'locales_en=on' --data-urlencode 'published=on' --data-urlencode 'publishedOn=2026-10-18'
|
||||||
|
ck "edit the body -> the page shows the new body" "get '$BASE/blog/fresh-post' | grep -q 'Quokka'"
|
||||||
|
if has search; then
|
||||||
|
ck "…search finds the new word" "search quokka | grep -q '/blog/fresh-post'"
|
||||||
|
ck "…and no longer the old one" "! search zanzibar | grep -q '/blog/fresh-post'"
|
||||||
|
fi
|
||||||
|
ck "a reserved custom path is refused at save, nothing written" \
|
||||||
|
"sc -X POST '$BASE/__admin/blog/create' --data-urlencode '_csrf=$TOKEN' -d 'id=bad-path&title_en=x&customPath=/app/x&published=on' | grep -q 'customPath' && [ ! -e '$ENTRIES/bad-path' ]"
|
||||||
|
sc -o /dev/null -X POST "$BASE/__admin/blog/fresh-post/publish" --data-urlencode "_csrf=$TOKEN"
|
||||||
|
ck "unpublish -> 404 at once" "[ \"\$(code '$BASE/blog/fresh-post')\" = 404 ]"
|
||||||
|
if has discoverability; then ck "…and gone from sitemap.xml" "! sitemap | grep -q 'fresh-post'"; fi
|
||||||
|
if has search; then ck "…and from search" "! search quokka | grep -q 'fresh-post'"; fi
|
||||||
|
|
||||||
|
echo "== a prefix change through the settings form re-keys every URL at once =="
|
||||||
|
SETTINGS="$BASE/__admin/plugins/blog/settings"
|
||||||
|
sc -o /dev/null -X POST "$SETTINGS" --data-urlencode "_csrf=$(sc "$SETTINGS" | token)" \
|
||||||
|
--data-urlencode 'enabled=true' --data-urlencode 'prefix=/news' --data-urlencode 'template=entry-minimal'
|
||||||
|
ck "the settings were stored" "grep -q 'prefix: \"/news\"' '$SITE/plugins/blog.yml'"
|
||||||
|
ck "/news/hello-world -> 200 with the minimal template (no byline)" \
|
||||||
|
"[ \"\$(code '$BASE/news/hello-world')\" = 200 ] && ! get '$BASE/news/hello-world' | grep -q 'By Jane Doe'"
|
||||||
|
ck "/blog/hello-world -> 404 (the old URL is gone)" "[ \"\$(code '$BASE/blog/hello-world')\" = 404 ]"
|
||||||
|
ck "the custom path is unaffected" "[ \"\$(code '$BASE/announcing-v2')\" = 200 ]"
|
||||||
|
if has discoverability; then ck "sitemap.xml follows the new prefix" "sitemap | grep -q '/news/hello-world</loc>'"; fi
|
||||||
|
sc -o /dev/null -X POST "$SETTINGS" --data-urlencode "_csrf=$(sc "$SETTINGS" | token)" \
|
||||||
|
--data-urlencode 'enabled=true' --data-urlencode 'prefix=/app' --data-urlencode 'template=entry-classic'
|
||||||
|
ck "a reserved prefix (/app) falls back to /blog instead of hiding every entry" \
|
||||||
|
"[ \"\$(code '$BASE/blog/hello-world')\" = 200 ]"
|
||||||
|
|
||||||
|
echo "== backups carry the blog (published content, not personal data) =="
|
||||||
|
sc -o "$SCRATCH/full.zip" "$BASE/__admin/backups/download"
|
||||||
|
sc -o "$SCRATCH/transfer.zip" "$BASE/__admin/backups/download-transfer"
|
||||||
|
zipq() { # zip mode -> prints what was asked
|
||||||
|
python3 -I - "$@" <<'PY'
|
||||||
|
import sys, zipfile
|
||||||
|
z = zipfile.ZipFile(sys.argv[1]); mode = sys.argv[2]
|
||||||
|
names = z.namelist()
|
||||||
|
if mode == "has":
|
||||||
|
sys.exit(0 if any(n.endswith(sys.argv[3]) for n in names) else 1)
|
||||||
|
if mode == "read":
|
||||||
|
n = next(n for n in names if n.endswith(sys.argv[3])); sys.stdout.write(z.read(n).decode("utf-8"))
|
||||||
|
PY
|
||||||
|
}
|
||||||
|
zipq "$SCRATCH/full.zip" read manifest.yml > "$SCRATCH/full-manifest.yml" 2>/dev/null
|
||||||
|
zipq "$SCRATCH/transfer.zip" read manifest.yml > "$SCRATCH/transfer-manifest.yml" 2>/dev/null
|
||||||
|
ck "the full backup carries the entries" "zipq '$SCRATCH/full.zip' has plugins/blog/entries/hello-world/entry.yml"
|
||||||
|
ck "the transfer copy carries them too" "zipq '$SCRATCH/transfer.zip' has plugins/blog/entries/no-author/body-en.md"
|
||||||
|
ck "…and its manifest omits nothing of the blog" "! grep -q 'plugins/blog' '$SCRATCH/transfer-manifest.yml'"
|
||||||
|
|
||||||
|
echo "== delete =="
|
||||||
|
sc -o /dev/null -X POST "$BASE/__admin/blog/fresh-post/delete" --data-urlencode "_csrf=$TOKEN"
|
||||||
|
ck "delete removes the entry's folder" "[ ! -e '$ENTRIES/fresh-post' ]"
|
||||||
|
ck "…and the other entries are intact" "[ -f '$ENTRIES/hello-world/entry.yml' ] && [ -f '$ENTRIES/no-author/entry.yml' ]"
|
||||||
|
|
||||||
|
ck "no ERROR in the host log after all of it" "! grep -q ' ERROR ' '$LOG'"
|
||||||
|
|
||||||
|
echo; echo "RESULT: $PASS passed, $FAIL failed, $SKIP skipped"
|
||||||
|
if [ "$KEEP" = "yes" ]; then echo "[verify] kept at $BASE (scratch $SCRATCH; kill $PID to stop)"; wait "$PID"; fi
|
||||||
|
exit "$FAIL"
|
||||||
@@ -0,0 +1,332 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import mx.quest.runway.spi.model.SiteView;
|
||||||
|
import mx.quest.runway.spi.service.ConsoleScreen;
|
||||||
|
import mx.quest.runway.spi.service.ContentCatalogView;
|
||||||
|
import mx.quest.runway.spi.service.ContentChanges;
|
||||||
|
import mx.quest.runway.spi.service.Messages;
|
||||||
|
import mx.quest.runway.spi.service.RequestContext;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The blog's tenant-console authoring screens ({@code /__admin/blog}): list, create, edit, publish/unpublish
|
||||||
|
* and delete entries — a plugin-owned console surface rendered inside the operator shell through
|
||||||
|
* {@link ConsoleScreen} (the kernel fills the shell's model; the {@code contentTemplate} resolves through this
|
||||||
|
* plugin's own {@code __plugin__/blog/…} namespace).
|
||||||
|
*
|
||||||
|
* <p>Four platform disciplines enforced here:
|
||||||
|
* <ul>
|
||||||
|
* <li><b>tenancy is always the bound one</b> ({@link RequestContext#site()}), never a path/param id;</li>
|
||||||
|
* <li><b>every mutation is announced</b> through {@link ContentChanges#changed} — the single freshness trigger
|
||||||
|
* for the plugin's own URL index (delivered back to {@link BlogContentSource} as a SOURCE listener) and for
|
||||||
|
* every kernel consumer (routing, sitemap, llms.txt, search), relayed cluster-wide by the host;</li>
|
||||||
|
* <li><b>every state change is a CSRF-checked {@code POST}</b> (the console chain checks the token; the
|
||||||
|
* templates put it in every form) — the {@code GET}s only render;</li>
|
||||||
|
* <li><b>the reverse advisory</b>: the edit screen asks the kernel's
|
||||||
|
* {@link ContentCatalogView#pageAt} whether a published page owns any of the entry's URLs — the page would
|
||||||
|
* win, so the author is warned exactly where they type the slug.</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* <p>Gated by this plugin's own grantable control point ({@code blog|manage}, checked by the kernel's
|
||||||
|
* {@code AccessCheck}, bean {@code authz}); the per-site settings editor is gated separately by the reserved
|
||||||
|
* {@code settings} point (host-rendered from the descriptor schema).
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@ConsoleScreen
|
||||||
|
public class BlogAdminController {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(BlogAdminController.class);
|
||||||
|
|
||||||
|
private static final String PERMISSION = "@authz.may('blog|manage')";
|
||||||
|
|
||||||
|
/** Ids the routing table owns — an entry named like an action verb would be uneditable/unreachable. */
|
||||||
|
private static final Set<String> RESERVED_IDS = Set.of("create", "new");
|
||||||
|
private static final Pattern SAFE_SLUG = Pattern.compile("[a-z0-9][a-z0-9-]{0,98}[a-z0-9]|[a-z0-9]");
|
||||||
|
|
||||||
|
private final RequestContext request;
|
||||||
|
private final BlogStore store;
|
||||||
|
private final BlogContentSource source;
|
||||||
|
private final ContentCatalogView catalog;
|
||||||
|
private final ContentChanges changes;
|
||||||
|
private final Messages messages;
|
||||||
|
|
||||||
|
public BlogAdminController(RequestContext request, BlogStore store, BlogContentSource source,
|
||||||
|
ContentCatalogView catalog, ContentChanges changes, Messages messages) {
|
||||||
|
this.request = request;
|
||||||
|
this.store = store;
|
||||||
|
this.source = source;
|
||||||
|
this.catalog = catalog;
|
||||||
|
this.changes = changes;
|
||||||
|
this.messages = messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String message(String key, String fallback) {
|
||||||
|
return messages.console(key, fallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One list row: the entry plus its resolved public path (under the current prefix settings). */
|
||||||
|
public record EntryRow(BlogEntry entry, String publicPath) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/__admin/blog")
|
||||||
|
@PreAuthorize(PERMISSION)
|
||||||
|
public String list(Model model) {
|
||||||
|
SiteView site = boundTenancy();
|
||||||
|
List<EntryRow> rows = new ArrayList<>();
|
||||||
|
for (BlogEntry entry : store.list(site.id())) {
|
||||||
|
rows.add(new EntryRow(entry, source.publicPath(site.id(), entry)));
|
||||||
|
}
|
||||||
|
model.addAttribute("rows", rows);
|
||||||
|
model.addAttribute("blogEnabled", source.settings(site.id()).enabled());
|
||||||
|
model.addAttribute(ConsoleScreen.PAGE_TITLE_KEY, "blog.admin.title");
|
||||||
|
model.addAttribute(ConsoleScreen.CONTENT_TEMPLATE, "__plugin__/blog/admin-list");
|
||||||
|
return ConsoleScreen.LAYOUT_VIEW;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/__admin/blog/new")
|
||||||
|
@PreAuthorize(PERMISSION)
|
||||||
|
public String createForm(Model model) {
|
||||||
|
SiteView site = boundTenancy();
|
||||||
|
editorModel(model, site, new BlogEntry("new-entry", Map.of(), Map.of(), List.of(), null, Map.of(),
|
||||||
|
null, false, null, null, null), Map.of(), true);
|
||||||
|
return ConsoleScreen.LAYOUT_VIEW;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/__admin/blog/create")
|
||||||
|
@PreAuthorize(PERMISSION)
|
||||||
|
public String create(@RequestParam("id") String id, @RequestParam MultiValueMap<String, String> params,
|
||||||
|
Model model, RedirectAttributes redirect) {
|
||||||
|
SiteView site = boundTenancy();
|
||||||
|
String entryId = id == null ? "" : id.trim().toLowerCase(Locale.ROOT);
|
||||||
|
String error = null;
|
||||||
|
try {
|
||||||
|
BlogStore.requireSafeId(entryId);
|
||||||
|
if (RESERVED_IDS.contains(entryId)) {
|
||||||
|
error = message("blog.error.reservedId", "That id is reserved — pick another.");
|
||||||
|
} else if (store.read(site.id(), entryId).isPresent()) {
|
||||||
|
error = message("blog.error.duplicate", "An entry with that id already exists.");
|
||||||
|
} else {
|
||||||
|
validateForm(site, params);
|
||||||
|
save(site, entryId, params);
|
||||||
|
redirect.addFlashAttribute("flash",
|
||||||
|
message("blog.flash.created", "Entry created."));
|
||||||
|
return "redirect:/__admin/blog/" + entryId + "/edit";
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException invalid) {
|
||||||
|
error = message("blog.error.invalid", "Some fields are invalid: ") + invalid.getMessage();
|
||||||
|
} catch (IOException io) {
|
||||||
|
log.warn("creating blog entry {}/{} failed", site.id(), entryId, io);
|
||||||
|
error = message("blog.error.ioError", "The entry could not be written.");
|
||||||
|
}
|
||||||
|
// NEVER blank the form on failure: re-render the editor with exactly what the author typed.
|
||||||
|
editorModel(model, site, parseEntry(site, entryId.isEmpty() ? "new-entry" : entryId, params),
|
||||||
|
parseBodies(site, params), true);
|
||||||
|
model.addAttribute("error", error);
|
||||||
|
return ConsoleScreen.LAYOUT_VIEW;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/__admin/blog/{id}/edit")
|
||||||
|
@PreAuthorize(PERMISSION)
|
||||||
|
public String editForm(@PathVariable("id") String id, Model model) {
|
||||||
|
SiteView site = boundTenancy();
|
||||||
|
BlogEntry entry = store.read(site.id(), id)
|
||||||
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "no such entry"));
|
||||||
|
Map<String, String> bodies = new LinkedHashMap<>();
|
||||||
|
for (Locale locale : site.locales()) {
|
||||||
|
bodies.put(locale.getLanguage(), store.readBody(site.id(), id, locale.getLanguage()));
|
||||||
|
}
|
||||||
|
editorModel(model, site, entry, bodies, false);
|
||||||
|
return ConsoleScreen.LAYOUT_VIEW;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/__admin/blog/{id}")
|
||||||
|
@PreAuthorize(PERMISSION)
|
||||||
|
public String update(@PathVariable("id") String id, @RequestParam MultiValueMap<String, String> params,
|
||||||
|
RedirectAttributes redirect) {
|
||||||
|
SiteView site = boundTenancy();
|
||||||
|
store.read(site.id(), id)
|
||||||
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "no such entry"));
|
||||||
|
try {
|
||||||
|
validateForm(site, params);
|
||||||
|
save(site, id, params);
|
||||||
|
redirect.addFlashAttribute("flash", message("blog.flash.saved", "Saved."));
|
||||||
|
} catch (IllegalArgumentException invalid) {
|
||||||
|
redirect.addFlashAttribute("error",
|
||||||
|
message("blog.error.invalid", "Some fields are invalid: ") + invalid.getMessage());
|
||||||
|
} catch (IOException io) {
|
||||||
|
log.warn("saving blog entry {}/{} failed", site.id(), id, io);
|
||||||
|
redirect.addFlashAttribute("error", message("blog.error.ioError", "The entry could not be written."));
|
||||||
|
}
|
||||||
|
return "redirect:/__admin/blog/" + id + "/edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/__admin/blog/{id}/publish")
|
||||||
|
@PreAuthorize(PERMISSION)
|
||||||
|
public String togglePublished(@PathVariable("id") String id, RedirectAttributes redirect) {
|
||||||
|
SiteView site = boundTenancy();
|
||||||
|
BlogEntry entry = store.read(site.id(), id)
|
||||||
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "no such entry"));
|
||||||
|
try {
|
||||||
|
// Carry author and publishedOn through: toggling visibility is not an editorial change, and this
|
||||||
|
// rebuild lists every field explicitly, so anything forgotten here is silently erased on publish.
|
||||||
|
store.save(site.id(), new BlogEntry(entry.id(), entry.title(), entry.description(),
|
||||||
|
entry.locales(), entry.slug(), entry.localizedSlugs(), entry.customPath(),
|
||||||
|
!entry.published(), entry.publishedOn(), entry.author(), null), null);
|
||||||
|
changes.changed(site.id(), BlogContentSource.KEY, id);
|
||||||
|
redirect.addFlashAttribute("flash", entry.published()
|
||||||
|
? message("blog.flash.unpublished", "Entry unpublished.")
|
||||||
|
: message("blog.flash.published", "Entry published."));
|
||||||
|
} catch (IOException io) {
|
||||||
|
log.warn("toggling blog entry {}/{} failed", site.id(), id, io);
|
||||||
|
redirect.addFlashAttribute("error", message("blog.error.ioError", "The entry could not be written."));
|
||||||
|
}
|
||||||
|
return "redirect:/__admin/blog";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/__admin/blog/{id}/delete")
|
||||||
|
@PreAuthorize(PERMISSION)
|
||||||
|
public String delete(@PathVariable("id") String id, RedirectAttributes redirect) {
|
||||||
|
SiteView site = boundTenancy();
|
||||||
|
try {
|
||||||
|
store.delete(site.id(), id);
|
||||||
|
changes.changed(site.id(), BlogContentSource.KEY, id);
|
||||||
|
redirect.addFlashAttribute("flash", message("blog.flash.deleted", "Entry deleted."));
|
||||||
|
} catch (IOException io) {
|
||||||
|
log.warn("deleting blog entry {}/{} failed", site.id(), id, io);
|
||||||
|
redirect.addFlashAttribute("error", message("blog.error.ioError", "The entry could not be deleted."));
|
||||||
|
}
|
||||||
|
return "redirect:/__admin/blog";
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- shared ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/** Reads the editor form into the entry + bodies, persists, and announces the change. */
|
||||||
|
private void save(SiteView site, String entryId, MultiValueMap<String, String> params) throws IOException {
|
||||||
|
store.save(site.id(), parseEntry(site, entryId, params), parseBodies(site, params));
|
||||||
|
changes.changed(site.id(), BlogContentSource.KEY, entryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The editor form → an entry (the default language's slug field doubles as the base slug). */
|
||||||
|
private static BlogEntry parseEntry(SiteView site, String entryId, MultiValueMap<String, String> params) {
|
||||||
|
Map<String, String> title = perLang(site, params, "title_");
|
||||||
|
Map<String, String> description = perLang(site, params, "description_");
|
||||||
|
Map<String, String> localizedSlugs = perLang(site, params, "slug_");
|
||||||
|
List<String> locales = new ArrayList<>();
|
||||||
|
for (Locale locale : site.locales()) {
|
||||||
|
if (params.containsKey("locales_" + locale.getLanguage())) {
|
||||||
|
locales.add(locale.getLanguage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String defaultLang = site.defaultLocale().getLanguage();
|
||||||
|
String slug = localizedSlugs.remove(defaultLang);
|
||||||
|
return new BlogEntry(entryId, title, description, locales, slug, localizedSlugs,
|
||||||
|
first(params, "customPath"), params.containsKey("published"), first(params, "publishedOn"),
|
||||||
|
first(params, "author"), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, String> parseBodies(SiteView site, MultiValueMap<String, String> params) {
|
||||||
|
Map<String, String> bodies = new LinkedHashMap<>();
|
||||||
|
for (Locale locale : site.locales()) {
|
||||||
|
String lang = locale.getLanguage();
|
||||||
|
bodies.put(lang, first(params, "body_" + lang));
|
||||||
|
}
|
||||||
|
return bodies;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rejects URL inputs the kernel's fail-closed backstop would otherwise DISCARD SILENTLY (the console
|
||||||
|
* would flash "saved" while the entry quietly vanished from routing and listings): slugs must match the
|
||||||
|
* slug grammar; a custom path must be absolute, free of the index separator, and a path the kernel would
|
||||||
|
* serve content at ({@link ContentCatalogView#servablePath}: safe, not reserved, not an endpoint route).
|
||||||
|
*/
|
||||||
|
private void validateForm(SiteView site, MultiValueMap<String, String> params) {
|
||||||
|
for (Locale locale : site.locales()) {
|
||||||
|
String slug = first(params, "slug_" + locale.getLanguage());
|
||||||
|
if (slug != null && !slug.isBlank() && !SAFE_SLUG.matcher(slug.trim()).matches()) {
|
||||||
|
throw new IllegalArgumentException("slug (" + locale.getLanguage() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String customPath = first(params, "customPath");
|
||||||
|
if (customPath != null && !customPath.isBlank()) {
|
||||||
|
String p = customPath.trim();
|
||||||
|
if (!p.startsWith("/") || p.contains("|") || p.contains(":")
|
||||||
|
|| !catalog.servablePath(site.id(), p)) {
|
||||||
|
throw new IllegalArgumentException("customPath");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Populates the editor model, including the reverse advisory (which pages own this entry's URLs). */
|
||||||
|
private void editorModel(Model model, SiteView site, BlogEntry entry, Map<String, String> bodies,
|
||||||
|
boolean creating) {
|
||||||
|
List<String> shadowedBy = new ArrayList<>();
|
||||||
|
if (!creating) {
|
||||||
|
for (Locale locale : site.locales()) {
|
||||||
|
String lang = locale.getLanguage();
|
||||||
|
// The REAL per-language URL (localized slug when set) — mirrors routing's own semantics.
|
||||||
|
String path = source.publicPath(site.id(), entry, lang);
|
||||||
|
catalog.pageAt(site.id(), path, locale)
|
||||||
|
.ifPresent(slug -> shadowedBy.add(slug + " (" + lang + ")"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Thymeleaf trap: a literal containing TWO '__' sequences inside a th.xml expression trips Thymeleaf's
|
||||||
|
// __…__ preprocessing — so the form action (two '/__admin' literals in a ternary) is computed HERE and
|
||||||
|
// passed as a plain model value the template reads with one ${formAction}.
|
||||||
|
model.addAttribute("formAction", creating ? "/__admin/blog/create" : "/__admin/blog/" + entry.id());
|
||||||
|
model.addAttribute("entry", entry);
|
||||||
|
model.addAttribute("bodies", bodies);
|
||||||
|
model.addAttribute("creating", creating);
|
||||||
|
model.addAttribute("shadowedBy", shadowedBy);
|
||||||
|
model.addAttribute("siteLocaleTags",
|
||||||
|
site.locales().stream().map(Locale::getLanguage).toList());
|
||||||
|
model.addAttribute("defaultLocaleTag", site.defaultLocale().getLanguage());
|
||||||
|
model.addAttribute(ConsoleScreen.PAGE_TITLE_KEY, "blog.admin.title");
|
||||||
|
model.addAttribute(ConsoleScreen.CONTENT_TEMPLATE, "__plugin__/blog/admin-edit");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, String> perLang(SiteView site, MultiValueMap<String, String> params, String prefix) {
|
||||||
|
Map<String, String> values = new LinkedHashMap<>();
|
||||||
|
for (Locale locale : site.locales()) {
|
||||||
|
String lang = locale.getLanguage();
|
||||||
|
String value = first(params, prefix + lang);
|
||||||
|
if (value != null && !value.isBlank()) {
|
||||||
|
values.put(lang, value.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String first(MultiValueMap<String, String> params, String name) {
|
||||||
|
List<String> values = params.get(name);
|
||||||
|
return (values == null || values.isEmpty()) ? null : values.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The site this console request is bound to. Empty on the application console (there is no tenancy there) —
|
||||||
|
* a {@code 400}.
|
||||||
|
*/
|
||||||
|
private SiteView boundTenancy() {
|
||||||
|
return request.site()
|
||||||
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "no bound tenancy"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import mx.quest.runway.spi.ContentSource;
|
||||||
|
import mx.quest.runway.spi.service.ContentCatalogView;
|
||||||
|
import mx.quest.runway.spi.service.ContentChanges;
|
||||||
|
import mx.quest.runway.spi.service.Messages;
|
||||||
|
import mx.quest.runway.spi.service.PluginSettings;
|
||||||
|
import mx.quest.runway.spi.service.PluginSiteFiles;
|
||||||
|
import mx.quest.runway.spi.service.RequestContext;
|
||||||
|
import mx.quest.runway.spi.service.SiteEventListener;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The blog plugin's Spring wiring — the {@code mainClass} the host registers before context refresh. Beans are wired
|
||||||
|
* EXPLICITLY (never {@code @ComponentScan}), and every collaborator is a Runway SPI service the kernel provides:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link PluginSettings}, {@link PluginSiteFiles} and {@link ContentChanges} are <b>plugin-scoped</b> — the
|
||||||
|
* kernel binds each to this plugin because the injecting class ({@code BlogConfig}) comes from this plugin's
|
||||||
|
* jar, so they reach only {@code sites/<id>/plugins/blog.yml}, {@code sites/<id>/plugins/blog/} and this
|
||||||
|
* plugin's own content source;</li>
|
||||||
|
* <li>{@link ContentCatalogView}, {@link RequestContext} and {@link Messages} are kernel singletons.</li>
|
||||||
|
* </ul>
|
||||||
|
* The {@link BlogContentSource} bean is collected twice by type: as a {@link ContentSource} (routing, sitemap and
|
||||||
|
* llms.txt, URL maps and search light up with zero further wiring) and as a {@link SiteEventListener} (its index
|
||||||
|
* invalidation). The controller carries {@code @ConsoleScreen}, so the kernel renders it inside the operator shell.
|
||||||
|
* Every bean name starts with the plugin id ({@code blog…}) — the kernel's bean-name rule.
|
||||||
|
*/
|
||||||
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
public class BlogConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public BlogStore blogStore(PluginSiteFiles files) {
|
||||||
|
return new BlogStore(files);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public BlogContentSource blogContentSource(BlogStore blogStore, PluginSettings settings,
|
||||||
|
ContentCatalogView catalog) {
|
||||||
|
return new BlogContentSource(blogStore, settings, catalog);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public BlogAdminController blogAdminController(RequestContext request, BlogStore blogStore,
|
||||||
|
BlogContentSource blogContentSource,
|
||||||
|
ContentCatalogView catalog, ContentChanges changes,
|
||||||
|
Messages messages) {
|
||||||
|
return new BlogAdminController(request, blogStore, blogContentSource, catalog, changes, messages);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,309 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
import mx.quest.runway.spi.ContentSource;
|
||||||
|
import mx.quest.runway.spi.model.Capabilities;
|
||||||
|
import mx.quest.runway.spi.model.CatalogChange;
|
||||||
|
import mx.quest.runway.spi.model.ContentBody;
|
||||||
|
import mx.quest.runway.spi.model.ContentRef;
|
||||||
|
import mx.quest.runway.spi.model.SettingsChange;
|
||||||
|
import mx.quest.runway.spi.model.SiteLifecycleEvent;
|
||||||
|
import mx.quest.runway.spi.model.SiteView;
|
||||||
|
import mx.quest.runway.spi.service.ContentCatalogView;
|
||||||
|
import mx.quest.runway.spi.service.PluginSettings;
|
||||||
|
import mx.quest.runway.spi.service.SiteEventListener;
|
||||||
|
import org.commonmark.parser.Parser;
|
||||||
|
import org.commonmark.renderer.html.HtmlRenderer;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The blog as a kernel {@link ContentSource}: entries become first-class virtual pages — routed through the
|
||||||
|
* full locale-dispatch ladder, rendered in the tenant's master chrome around this plugin's own body template,
|
||||||
|
* listed in sitemap.xml/llms.txt with {@code hreflang} + {@code <lastmod>}, indexed by search, and linkable as
|
||||||
|
* {@code ${urls['blog:<id>']}} — all host-provided; this class only answers the contract questions.
|
||||||
|
*
|
||||||
|
* <h2>The contract, honored</h2>
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link #enumerate}: published entries only, metadata-only ({@link BlogStore#list} reads
|
||||||
|
* {@code entry.yml} files, never a body), each with {@code updatedAt} from file times, cached until an
|
||||||
|
* announced change: a console save moves the render ETag with no explicit bump; a body edited on disk
|
||||||
|
* is served at once but under the OLD ETag until a site reload (docs/BLOG-PLUGIN.md §3).</li>
|
||||||
|
* <li>{@link #resolve}: an O(1) probe of a per-site {@code path|lang → id} index (printable {@code |}),
|
||||||
|
* rebuilt lazily after any invalidation — required because {@code content.arbitrary-paths} makes this
|
||||||
|
* source run on <b>every</b> routing miss of an enabled site.</li>
|
||||||
|
* <li>{@link #body}: Markdown → HTML via the bundled commonmark, fetched only for an actual 200 render.
|
||||||
|
* Entry Markdown is operator-authored, first-party trusted content (raw HTML passes through, exactly as
|
||||||
|
* a page author may write markup).</li>
|
||||||
|
* <li>{@link #indexableText}: the same rendered HTML, for search.</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* <h2>Index invalidation: a SOURCE-phase {@link SiteEventListener}</h2>
|
||||||
|
* The console announces every mutation through {@code ContentChanges.changed}; the kernel delivers it back here as
|
||||||
|
* a {@code CONTENT} {@link CatalogChange} for this source's key, and this class drops the site's index. A site
|
||||||
|
* lifecycle event drops it too (a <b>backup restore</b> replaces the entry files wholesale), and so does a save of
|
||||||
|
* this plugin's own settings (a prefix change re-keys every URL). Running in the {@link Phase#SOURCE SOURCE} phase
|
||||||
|
* is what keeps consumers honest: the kernel delivers every SOURCE listener first, evicts its content listing once
|
||||||
|
* more, and only then lets sitemap and search consumers re-read — so none of them can rebuild from this source's
|
||||||
|
* stale index. With clustering ON, the kernel relays the change to every node and delivers it there too
|
||||||
|
* ({@code local == false}), so every node's index converges.
|
||||||
|
*/
|
||||||
|
public class BlogContentSource implements ContentSource, SiteEventListener {
|
||||||
|
|
||||||
|
public static final String KEY = "blog";
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(BlogContentSource.class);
|
||||||
|
|
||||||
|
private final BlogStore store;
|
||||||
|
private final PluginSettings settings;
|
||||||
|
private final ContentCatalogView catalog;
|
||||||
|
private final Parser markdown = Parser.builder().build();
|
||||||
|
private final HtmlRenderer html = HtmlRenderer.builder().build();
|
||||||
|
|
||||||
|
/** Per-site URL index: {@code path|lang → entryId}; dropped on any content/config/site change. */
|
||||||
|
private final ConcurrentMap<String, Map<String, String>> index = new ConcurrentHashMap<>();
|
||||||
|
/** Per-site enumerated refs — the metadata cache behind {@link #enumerate}, dropped by the SAME events, so
|
||||||
|
* the per-render urlMap and per-request sitemap don't re-read the entries tree every time. */
|
||||||
|
private final ConcurrentMap<String, List<ContentRef>> refs = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public BlogContentSource(BlogStore store, PluginSettings settings, ContentCatalogView catalog) {
|
||||||
|
this.store = store;
|
||||||
|
this.settings = settings;
|
||||||
|
this.catalog = catalog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String key() {
|
||||||
|
return KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Capabilities capabilities() {
|
||||||
|
// Custom paths escape the prefix; indexable-text opts this source into the search integration.
|
||||||
|
return Capabilities.of(CAP_ARBITRARY_PATHS, CAP_INDEXABLE_TEXT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The site's effective settings — the one place the source and the console read them. */
|
||||||
|
public BlogSettings settings(String siteId) {
|
||||||
|
return BlogSettings.of(settings, catalog, siteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The entry's indexable material for {@code locale}: the Markdown body rendered to HTML — the SAME
|
||||||
|
* transform the {@link #body} render uses. Engines strip <em>HTML</em> markup (they were built for page
|
||||||
|
* HTML bodies), so handing them the rendered HTML yields clean prose in the index and in result snippets;
|
||||||
|
* handing them the raw Markdown would leak {@code ## heading}, {@code **bold**} and {@code [text](url)}
|
||||||
|
* link syntax straight into the terms and the visible snippet. Empty when the entry has no body for this
|
||||||
|
* locale.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String indexableText(SiteView site, String id, Locale locale) {
|
||||||
|
String source = store.readBody(site.id(), id, locale.getLanguage());
|
||||||
|
return source.isEmpty() ? "" : html.render(markdown.parse(source));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ContentRef> enumerate(SiteView site) {
|
||||||
|
BlogSettings current = settings(site.id());
|
||||||
|
if (!current.enabled()) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
return refs.computeIfAbsent(site.id(), siteId -> {
|
||||||
|
List<ContentRef> out = new ArrayList<>();
|
||||||
|
for (BlogEntry entry : store.list(siteId)) {
|
||||||
|
if (entry.published()) {
|
||||||
|
out.add(toRef(entry, current));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return List.copyOf(out);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<ContentRef> resolve(SiteView site, String path, Locale locale) {
|
||||||
|
String id = index.computeIfAbsent(site.id(), sid -> buildIndex(site))
|
||||||
|
.get(path + '|' + locale.getLanguage());
|
||||||
|
if (id == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
// Answer from the SAME cached refs the index was built from (one settings read, no torn view).
|
||||||
|
for (ContentRef ref : enumerate(site)) {
|
||||||
|
if (ref.id().equals(id)) {
|
||||||
|
return Optional.of(ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ContentBody body(SiteView site, String id, Locale locale) {
|
||||||
|
String source = store.readBody(site.id(), id, locale.getLanguage());
|
||||||
|
if (source.isBlank()) {
|
||||||
|
return ContentBody.empty();
|
||||||
|
}
|
||||||
|
// Editorial metadata the body template may render. Absent keys are simply not put, so a template can
|
||||||
|
// test for presence — an entry with no byline must render no byline, not an empty one.
|
||||||
|
Map<String, String> attributes = new LinkedHashMap<>();
|
||||||
|
store.read(site.id(), id).ifPresent(entry -> {
|
||||||
|
if (entry.publishedOn() != null) {
|
||||||
|
attributes.put("publishedOn", entry.publishedOn());
|
||||||
|
}
|
||||||
|
if (entry.author() != null) {
|
||||||
|
attributes.put("author", entry.author());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ContentBody(html.render(markdown.parse(source)), attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- invalidation (SiteEventListener, SOURCE phase) --------------------------------------------------------
|
||||||
|
|
||||||
|
/** {@link Phase#SOURCE}: this source's own index must be dropped before any consumer re-reads the listing. */
|
||||||
|
@Override
|
||||||
|
public Phase phase() {
|
||||||
|
return Phase.SOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Any lifecycle event — including a backup restore, which replaced the entry files wholesale. */
|
||||||
|
@Override
|
||||||
|
public void onSiteLifecycle(SiteLifecycleEvent event) {
|
||||||
|
drop(event.siteId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This plugin's own settings were saved: a prefix or template change re-keys every URL and every ref. */
|
||||||
|
@Override
|
||||||
|
public void onSettingsChanged(SettingsChange change) {
|
||||||
|
drop(change.siteId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This source's own content changed (announced by the console, on this node or a peer). */
|
||||||
|
@Override
|
||||||
|
public void onCatalogChanged(CatalogChange change) {
|
||||||
|
if (change.cause() == CatalogChange.Cause.CONTENT && KEY.equals(change.sourceKey())) {
|
||||||
|
drop(change.siteId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drop(String siteId) {
|
||||||
|
index.remove(siteId);
|
||||||
|
refs.remove(siteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- mapping -----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/** Projects an entry onto the content noun under the site's current prefix settings. */
|
||||||
|
private ContentRef toRef(BlogEntry entry, BlogSettings current) {
|
||||||
|
String defaultPath = entry.customPath() != null ? entry.customPath()
|
||||||
|
: current.pathFor(entry.effectiveSlug());
|
||||||
|
Map<String, String> localizedPaths = new LinkedHashMap<>();
|
||||||
|
entry.localizedSlugs().forEach((lang, slug) ->
|
||||||
|
localizedPaths.put(lang, current.pathFor(slug)));
|
||||||
|
List<Locale> locales = entry.locales().stream().map(Locale::forLanguageTag).toList();
|
||||||
|
return new ContentRef(entry.id(), defaultPath, localizedPaths, locales, entry.title(),
|
||||||
|
entry.description(), null, current.bodyTemplate(), entry.published(), entry.updatedAt(),
|
||||||
|
false, null, null, Map.of(), entry.author(), publishedAt(entry));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The entry's own {@code publishedOn} as an instant, for {@link ContentRef#publishedAt()} — so each post
|
||||||
|
* carries ITS OWN publication date across the SPI boundary.
|
||||||
|
*
|
||||||
|
* <p>This is what makes per-post dates truthful. Without it, the discoverability plugin would have to take
|
||||||
|
* {@code datePublished} from the per-site {@code content.schema} block, which matches by path prefix — so ONE
|
||||||
|
* {@code /blog/*} entry would cover every post. A site's only honest options would be to emit no dates at all,
|
||||||
|
* or to assert a single date identically on every post: a statement false of nearly every page carrying it,
|
||||||
|
* and exactly the kind of untrue markup structured-data policy prohibits.
|
||||||
|
*
|
||||||
|
* <p>Interpreted at <b>midnight UTC</b> on the stated day, matching how the kernel's page editor parses its
|
||||||
|
* own date field, so a blog entry and a page dated the same day produce the same instant.
|
||||||
|
*
|
||||||
|
* <p>The entry's {@code author} travels the same way, so a post is attributed to whoever
|
||||||
|
* actually wrote it rather than to one name shared by every post on the site.
|
||||||
|
*
|
||||||
|
* <p>An unparseable value yields {@code null} — no date. {@code publishedOn} is free-form display text on
|
||||||
|
* the entry, so it can legitimately hold something that is not a date; asserting a wrong
|
||||||
|
* {@code datePublished} would be worse than asserting none, because a consumer is told to trust it.
|
||||||
|
*/
|
||||||
|
private static Instant publishedAt(BlogEntry entry) {
|
||||||
|
String raw = entry.publishedOn();
|
||||||
|
if (raw == null || raw.isBlank()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return LocalDate.parse(raw.trim()).atStartOfDay(ZoneOffset.UTC).toInstant();
|
||||||
|
} catch (DateTimeParseException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One pass over the published refs → {@code path|lang → id} for O(1) miss-time resolution. Keys the FULL
|
||||||
|
* union of the site's locales plus the default (parity with the SPI's default {@code resolve}, which
|
||||||
|
* matches {@code pathFor(L)} for any lookup locale), with a locale's OWN localized slug taking precedence
|
||||||
|
* over another entry's fallback claim. Two entries claiming one (path, lang) is a same-source collision
|
||||||
|
* the kernel cannot see — logged loudly here; the deterministic winner is the explicit/localized claim,
|
||||||
|
* else first-listed.
|
||||||
|
*/
|
||||||
|
private Map<String, String> buildIndex(SiteView site) {
|
||||||
|
Map<String, String> paths = new HashMap<>();
|
||||||
|
Locale siteDefault = site.defaultLocale();
|
||||||
|
LinkedHashSet<Locale> lookupLocales = new LinkedHashSet<>();
|
||||||
|
lookupLocales.add(siteDefault);
|
||||||
|
lookupLocales.addAll(site.locales());
|
||||||
|
for (ContentRef ref : enumerate(site)) {
|
||||||
|
for (Locale locale : lookupLocales) {
|
||||||
|
String key = ref.pathFor(locale) + '|' + locale.getLanguage();
|
||||||
|
boolean explicit = ref.localizedPaths().containsKey(locale.getLanguage())
|
||||||
|
|| ref.hasLocale(locale, siteDefault);
|
||||||
|
String prior = explicit ? paths.put(key, ref.id()) : paths.putIfAbsent(key, ref.id());
|
||||||
|
if (prior != null && !prior.equals(ref.id())) {
|
||||||
|
log.warn("blog entries '{}' and '{}' (site '{}') both claim '{}' — '{}' wins; give one a "
|
||||||
|
+ "different slug", prior, ref.id(), site.id(), key,
|
||||||
|
explicit ? ref.id() : prior);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Map.copyOf(paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** For the console: the entry's public path in the site's default URL space (list-screen links). */
|
||||||
|
public String publicPath(String siteId, BlogEntry entry) {
|
||||||
|
return publicPath(siteId, entry, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The entry's public path for one language ({@code null} = the default URL space): the localized slug when
|
||||||
|
* that language has one, else the default path — the exact semantics {@code toRef}/routing use, so the
|
||||||
|
* console's reverse advisory checks the REAL per-language URLs.
|
||||||
|
*/
|
||||||
|
public String publicPath(String siteId, BlogEntry entry, String lang) {
|
||||||
|
BlogSettings current = settings(siteId);
|
||||||
|
if (lang != null && entry.localizedSlugs().containsKey(lang)) {
|
||||||
|
return current.pathFor(entry.localizedSlugs().get(lang));
|
||||||
|
}
|
||||||
|
return entry.customPath() != null ? entry.customPath()
|
||||||
|
: current.pathFor(entry.effectiveSlug());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test hook: the index currently cached for a site (null = not built). */
|
||||||
|
Map<String, String> cachedIndex(String siteId) {
|
||||||
|
return index.get(siteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test hook: the refs currently cached for a site (null = not built). */
|
||||||
|
List<ContentRef> cachedRefs(String siteId) {
|
||||||
|
return refs.get(siteId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One blog entry's <b>metadata</b> — the {@code entry.yml} document under
|
||||||
|
* {@code sites/<siteId>/plugins/blog/entries/<id>/}. Bodies live beside it as {@code body-<lang>.md} files
|
||||||
|
* (one per language), so enumerating entries never reads a body — the ContentSource contract's
|
||||||
|
* metadata/body split, made trivially honest by the file layout.
|
||||||
|
*
|
||||||
|
* <p>URLs: the entry serves at {@code <prefix>/<slug>} (the per-tenant {@code prefix} setting), with optional
|
||||||
|
* per-language slug overrides ({@code localizedSlugs}) and an optional <b>custom absolute path</b>
|
||||||
|
* ({@code customPath}, e.g. {@code /announcing-v2}) that replaces the prefixed default-locale URL entirely
|
||||||
|
* (the reason this plugin declares {@code content.arbitrary-paths}).
|
||||||
|
*
|
||||||
|
* @param id the entry's stable identity — its folder name (never part of the YAML; re-applied
|
||||||
|
* from the folder on read, like a page's slug)
|
||||||
|
* @param title per-language titles ({@code lang → text})
|
||||||
|
* @param description per-language descriptions
|
||||||
|
* @param locales the language codes this entry is published in (empty ⇒ site default only)
|
||||||
|
* @param slug the URL slug under the blog prefix ({@code null} ⇒ the id)
|
||||||
|
* @param localizedSlugs per-language slug overrides ({@code lang → slug})
|
||||||
|
* @param customPath an absolute path override for the default locale ({@code /…}), or {@code null}
|
||||||
|
* @param published whether the entry is publicly visible
|
||||||
|
* @param publishedOn the display publication date (ISO {@code yyyy-MM-dd}), or {@code null}
|
||||||
|
* @param author display name credited for this entry, or {@code null} when unattributed. Free text
|
||||||
|
* on purpose — a real identity model (accounts, profiles, affiliations) is a much
|
||||||
|
* larger design, and blocking bylines on it would leave every entry unattributable
|
||||||
|
* meanwhile. Matches the kernel's page-level author so the two cannot drift
|
||||||
|
* @param updatedAt newest mtime of the entry's files — derived on read, never serialized; drives the
|
||||||
|
* sitemap {@code <lastmod>} AND the render ETag (re-read only after an announced change)
|
||||||
|
*/
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public record BlogEntry(String id, Map<String, String> title, Map<String, String> description,
|
||||||
|
List<String> locales, String slug, Map<String, String> localizedSlugs,
|
||||||
|
String customPath, boolean published, String publishedOn, String author,
|
||||||
|
@JsonIgnore Instant updatedAt) {
|
||||||
|
|
||||||
|
public BlogEntry {
|
||||||
|
title = normalize(title);
|
||||||
|
description = normalize(description);
|
||||||
|
locales = (locales == null) ? List.of() : List.copyOf(locales);
|
||||||
|
localizedSlugs = normalize(localizedSlugs);
|
||||||
|
slug = blankToNull(slug);
|
||||||
|
customPath = blankToNull(customPath);
|
||||||
|
publishedOn = blankToNull(publishedOn);
|
||||||
|
// Blank == unattributed: the editor posts "" for an untouched field, and an empty byline must not
|
||||||
|
// serialize into entry.yml or render as an empty author element.
|
||||||
|
author = blankToNull(author);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This entry with its stable id applied (the folder name — never stored inside the YAML). */
|
||||||
|
public BlogEntry withId(String id) {
|
||||||
|
return new BlogEntry(id, title, description, locales, slug, localizedSlugs, customPath, published,
|
||||||
|
publishedOn, author, updatedAt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This entry with the derived {@code updatedAt} applied (from the entry files' mtimes). */
|
||||||
|
public BlogEntry withUpdatedAt(Instant updatedAt) {
|
||||||
|
return new BlogEntry(id, title, description, locales, slug, localizedSlugs, customPath, published,
|
||||||
|
publishedOn, author, updatedAt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The form serialized to {@code entry.yml}: no id (the folder carries it), no derived fields. */
|
||||||
|
public BlogEntry forStorage() {
|
||||||
|
return new BlogEntry(null, title, description, locales, slug, localizedSlugs, customPath, published,
|
||||||
|
publishedOn, author, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The effective URL slug under the blog prefix: the explicit {@link #slug}, else the id. */
|
||||||
|
@JsonIgnore
|
||||||
|
public String effectiveSlug() {
|
||||||
|
return slug != null ? slug : id;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, String> normalize(Map<String, String> raw) {
|
||||||
|
if (raw == null || raw.isEmpty()) {
|
||||||
|
return Map.of();
|
||||||
|
}
|
||||||
|
Map<String, String> clean = new LinkedHashMap<>();
|
||||||
|
raw.forEach((k, v) -> {
|
||||||
|
if (k != null && !k.isBlank() && v != null && !v.isBlank()) {
|
||||||
|
clean.put(k.trim(), v.trim());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return java.util.Collections.unmodifiableMap(clean);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String blankToNull(String value) {
|
||||||
|
return (value == null || value.isBlank()) ? null : value.trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import mx.quest.runway.spi.model.SettingsView;
|
||||||
|
import mx.quest.runway.spi.service.ContentCatalogView;
|
||||||
|
import mx.quest.runway.spi.service.PluginSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The blog's effective per-site settings — typed reads over {@link PluginSettings} (live: a console save is visible
|
||||||
|
* on the next read; an absent settings file means the descriptor's defaults). Kept as one value object so the
|
||||||
|
* source, the console and the templates agree on defaults in exactly one place.
|
||||||
|
*
|
||||||
|
* @param enabled whether the blog serves at all on this site
|
||||||
|
* @param prefix the URL prefix entries serve under (normalized: leading {@code /}, no trailing {@code /})
|
||||||
|
* @param template the entry body template name within this plugin's own namespace (the operator's pick)
|
||||||
|
*/
|
||||||
|
public record BlogSettings(boolean enabled, String prefix, String template) {
|
||||||
|
|
||||||
|
public static final String PLUGIN_ID = "blog";
|
||||||
|
|
||||||
|
static final String DEFAULT_PREFIX = "/blog";
|
||||||
|
static final String DEFAULT_TEMPLATE = "entry-classic";
|
||||||
|
static final String MINIMAL_TEMPLATE = "entry-minimal";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The site's effective settings (descriptor defaults: enabled, {@code /blog}, {@code entry-classic}).
|
||||||
|
*
|
||||||
|
* <p>The prefix is checked with {@link ContentCatalogView#servablePath}: an unsafe or reserved prefix
|
||||||
|
* ({@code /__x}, {@code /app}, {@code /actuator}, a path with {@code |} or {@code ..}) would make every entry
|
||||||
|
* path fail the kernel's fail-closed re-filter and silently vanish from routing and listings, so it falls back
|
||||||
|
* to {@code /blog} instead. The question asked is "would the kernel serve an entry under this prefix?", so the
|
||||||
|
* probe is a child path of the prefix — that is where entries live.
|
||||||
|
*
|
||||||
|
* @param settings this plugin's per-site settings
|
||||||
|
* @param catalog the kernel's content surface (for its path rule; no content source is consulted)
|
||||||
|
* @param siteId the site
|
||||||
|
* @return the effective settings (never {@code null})
|
||||||
|
*/
|
||||||
|
public static BlogSettings of(PluginSettings settings, ContentCatalogView catalog, String siteId) {
|
||||||
|
SettingsView view = settings.site(siteId);
|
||||||
|
boolean enabled = view.bool("enabled", true);
|
||||||
|
String prefix = normalizePrefix(view.string("prefix", DEFAULT_PREFIX));
|
||||||
|
// Fail closed on the template name: it becomes part of a __plugin__/blog/<name> template lookup.
|
||||||
|
String template = MINIMAL_TEMPLATE.equals(view.string("template", DEFAULT_TEMPLATE))
|
||||||
|
? MINIMAL_TEMPLATE : DEFAULT_TEMPLATE;
|
||||||
|
if (!catalog.servablePath(siteId, join(prefix, "x"))) {
|
||||||
|
prefix = DEFAULT_PREFIX;
|
||||||
|
}
|
||||||
|
return new BlogSettings(enabled, prefix, template);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The full logical body-template name the kernel resolves and namespace-validates. */
|
||||||
|
public String bodyTemplate() {
|
||||||
|
return "__plugin__/" + PLUGIN_ID + "/" + template;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** An entry's public path under this prefix — joined without doubling when the prefix is the root. */
|
||||||
|
public String pathFor(String slug) {
|
||||||
|
return join(prefix, slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String join(String prefix, String slug) {
|
||||||
|
return "/".equals(prefix) ? "/" + slug : prefix + "/" + slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String normalizePrefix(String raw) {
|
||||||
|
String p = raw.trim();
|
||||||
|
if (!p.startsWith("/")) {
|
||||||
|
p = "/" + p;
|
||||||
|
}
|
||||||
|
while (p.endsWith("/") && p.length() > 1) {
|
||||||
|
p = p.substring(0, p.length() - 1);
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,261 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UncheckedIOException;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import mx.quest.runway.spi.model.FileEntry;
|
||||||
|
import mx.quest.runway.spi.service.PluginSiteFiles;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import tools.jackson.core.StreamReadFeature;
|
||||||
|
import tools.jackson.core.StreamWriteFeature;
|
||||||
|
import tools.jackson.databind.DeserializationFeature;
|
||||||
|
import tools.jackson.databind.ObjectMapper;
|
||||||
|
import tools.jackson.dataformat.yaml.YAMLMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The blog's per-site file store, over the kernel's {@link PluginSiteFiles} (this plugin's own subtree,
|
||||||
|
* {@code sites/<siteId>/plugins/blog/}): {@code entries/<entryId>/entry.yml} (metadata) +
|
||||||
|
* {@code entries/<entryId>/body-<lang>.md} (one Markdown body per language). The layout has not changed across releases,
|
||||||
|
* so existing entries load unchanged. Everything lives in the site's own folder, so a full backup carries the whole
|
||||||
|
* blog with no {@code BackupParticipant}, and the kernel confines every path to the subtree (symbolic links
|
||||||
|
* included) — the store cannot reach another plugin's data or another site.
|
||||||
|
*
|
||||||
|
* <p><b>Metadata/body split on disk</b> is what makes the ContentSource contract trivially honest: {@link #list}
|
||||||
|
* reads only {@code entry.yml} files (plus file times for {@code updatedAt}); {@link #readBody} is called only when a
|
||||||
|
* body is actually rendered or indexed.
|
||||||
|
*
|
||||||
|
* <p>Ids and language codes are validated against a strict grammar before ever forming a path — an id is a folder
|
||||||
|
* name, a language code a file-name fragment; neither may traverse (the kernel would refuse it anyway).
|
||||||
|
*
|
||||||
|
* <p><b>Concurrency.</b> Each file write is atomic (the kernel writes a temporary file and renames it), so a public
|
||||||
|
* reader — the sitemap, a routing miss — never observes a half-written {@code entry.yml}. Two operators saving the
|
||||||
|
* same entry at once: the last save wins.
|
||||||
|
*
|
||||||
|
* <p><b>Freshness.</b> The store announces nothing; the console calls {@code ContentChanges.changed} after every
|
||||||
|
* mutation.
|
||||||
|
*/
|
||||||
|
public class BlogStore {
|
||||||
|
|
||||||
|
private static final Pattern SAFE_ID = Pattern.compile("[a-z0-9][a-z0-9-]{0,98}[a-z0-9]|[a-z0-9]");
|
||||||
|
private static final Pattern SAFE_LANG = Pattern.compile("[a-z]{2,8}");
|
||||||
|
/** The entries folder, relative to this plugin's per-site subtree. */
|
||||||
|
static final String ENTRIES = "entries";
|
||||||
|
static final String METADATA = "entry.yml";
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(BlogStore.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The YAML codec: <b>lenient</b> on read, so a hand-written {@code entry.yml} that omits {@code published:} or
|
||||||
|
* carries a key this version does not know still loads (it defaults instead of failing) — and writes an entry back
|
||||||
|
* byte for byte ({@code BlogStoreTest} proves it on the fixture entries). Streams are never auto-closed: the
|
||||||
|
* caller owns them.
|
||||||
|
*/
|
||||||
|
private static final ObjectMapper YAML = YAMLMapper.builder()
|
||||||
|
.disable(StreamWriteFeature.AUTO_CLOSE_TARGET)
|
||||||
|
.disable(StreamReadFeature.AUTO_CLOSE_SOURCE)
|
||||||
|
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
|
||||||
|
.disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
private final PluginSiteFiles files;
|
||||||
|
|
||||||
|
public BlogStore(PluginSiteFiles files) {
|
||||||
|
this.files = files;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Every entry of the site (published and not), newest publication date first, with {@code updatedAt} derived
|
||||||
|
* from file times. One unreadable entry is skipped with a WARN and never blanks the others.
|
||||||
|
*
|
||||||
|
* @throws UncheckedIOException if the entries folder itself cannot be listed
|
||||||
|
*/
|
||||||
|
public List<BlogEntry> list(String siteId) {
|
||||||
|
List<FileEntry> dirs;
|
||||||
|
try {
|
||||||
|
dirs = files.list(siteId, ENTRIES);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new UncheckedIOException("listing blog entries of " + siteId, ex);
|
||||||
|
}
|
||||||
|
List<BlogEntry> out = new ArrayList<>();
|
||||||
|
for (FileEntry dir : dirs) {
|
||||||
|
String id = dir.name();
|
||||||
|
if (!dir.directory() || !SAFE_ID.matcher(id).matches()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Per-ENTRY containment: one corrupt/hand-mangled entry.yml must never blank the whole blog
|
||||||
|
// (the corpus-level backstop upstream would otherwise drop the entire source).
|
||||||
|
try {
|
||||||
|
read(siteId, id).ifPresent(out::add);
|
||||||
|
} catch (RuntimeException ex) {
|
||||||
|
log.warn("skipping unreadable blog entry {}/{}: {}", siteId, id, ex.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.sort((a, b) -> {
|
||||||
|
// Newest first for the console: by publishedOn (desc, nulls last), then id for stability.
|
||||||
|
String pa = a.publishedOn() == null ? "" : a.publishedOn();
|
||||||
|
String pb = b.publishedOn() == null ? "" : b.publishedOn();
|
||||||
|
int byDate = pb.compareTo(pa);
|
||||||
|
return byDate != 0 ? byDate : a.id().compareTo(b.id());
|
||||||
|
});
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One entry by id, or empty (also empty for an unsafe id — never a path probe — and for a malformed
|
||||||
|
* {@code entry.yml}, which is logged).
|
||||||
|
*
|
||||||
|
* @throws UncheckedIOException if the file exists but cannot be read
|
||||||
|
*/
|
||||||
|
public Optional<BlogEntry> read(String siteId, String entryId) {
|
||||||
|
if (!SAFE_ID.matcher(entryId).matches()) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
String path = metadataPath(entryId);
|
||||||
|
Optional<String> text;
|
||||||
|
try {
|
||||||
|
text = files.readText(siteId, path);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new UncheckedIOException("reading blog entry " + siteId + "/" + entryId, ex);
|
||||||
|
}
|
||||||
|
if (text.isEmpty()) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
BlogEntry parsed;
|
||||||
|
try {
|
||||||
|
parsed = YAML.readValue(text.get(), BlogEntry.class);
|
||||||
|
} catch (RuntimeException parseFailure) {
|
||||||
|
// A malformed file is THIS entry's problem, never the corpus's: absent + a WARN naming the file.
|
||||||
|
log.warn("unparseable blog entry {}/{} — treated as absent: {}", siteId, path, parseFailure.toString());
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
if (parsed == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return Optional.of(parsed.withId(entryId).withUpdatedAt(newestModification(siteId, entryId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates or replaces an entry's metadata, and any bodies given ({@code lang → markdown}; a {@code null} body
|
||||||
|
* map leaves bodies untouched, a blank body deletes that language's file). The caller announces the change
|
||||||
|
* afterwards — the store never does.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException for an unsafe id or language code (nothing is written), or a body over the
|
||||||
|
* kernel's write cap
|
||||||
|
* @throws IOException when a write fails (for example, the site folder does not exist)
|
||||||
|
*/
|
||||||
|
public void save(String siteId, BlogEntry entry, Map<String, String> bodies) throws IOException {
|
||||||
|
requireSafeId(entry.id());
|
||||||
|
if (bodies != null) {
|
||||||
|
bodies.keySet().forEach(BlogStore::requireSafeLang); // validate ALL before writing ANY
|
||||||
|
}
|
||||||
|
files.writeText(siteId, metadataPath(entry.id()), YAML.writeValueAsString(entry.forStorage()));
|
||||||
|
if (bodies != null) {
|
||||||
|
for (Map.Entry<String, String> body : bodies.entrySet()) {
|
||||||
|
String path = bodyPath(entry.id(), body.getKey());
|
||||||
|
if (body.getValue() == null || body.getValue().isBlank()) {
|
||||||
|
files.delete(siteId, path);
|
||||||
|
} else {
|
||||||
|
files.writeText(siteId, path, body.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes an entry (its folder and every file in it; symbolic links are removed, never followed). Unknown and
|
||||||
|
* unsafe ids are a no-op.
|
||||||
|
*/
|
||||||
|
public void delete(String siteId, String entryId) throws IOException {
|
||||||
|
if (!SAFE_ID.matcher(entryId).matches()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
files.deleteTree(siteId, ENTRIES + "/" + entryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The entry's Markdown body for {@code lang}, or {@code ""} when that language has none (or the id or language
|
||||||
|
* is unsafe).
|
||||||
|
*
|
||||||
|
* @throws UncheckedIOException if the body exists but cannot be read (including one over the kernel's cap)
|
||||||
|
*/
|
||||||
|
public String readBody(String siteId, String entryId, String lang) {
|
||||||
|
if (!SAFE_ID.matcher(entryId).matches() || !SAFE_LANG.matcher(lang).matches()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return files.readText(siteId, bodyPath(entryId, lang)).orElse("");
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new UncheckedIOException("reading blog body " + siteId + "/" + entryId + "/" + lang, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The languages that have a body file for {@code entryId}, sorted. */
|
||||||
|
public List<String> bodyLangs(String siteId, String entryId) {
|
||||||
|
if (!SAFE_ID.matcher(entryId).matches()) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
List<String> langs = new ArrayList<>();
|
||||||
|
for (FileEntry file : entryFiles(siteId, entryId)) {
|
||||||
|
String name = file.name();
|
||||||
|
if (!file.directory() && name.startsWith("body-") && name.endsWith(".md")) {
|
||||||
|
langs.add(name.substring("body-".length(), name.length() - ".md".length()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
langs.sort(String::compareTo);
|
||||||
|
return langs;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void requireSafeId(String id) {
|
||||||
|
if (id == null || !SAFE_ID.matcher(id).matches()) {
|
||||||
|
throw new IllegalArgumentException("invalid blog entry id: '" + id + "' (lowercase letters, "
|
||||||
|
+ "digits and hyphens; no ':' — the composite blog:<id> identity must stay unambiguous)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String requireSafeLang(String lang) {
|
||||||
|
if (lang == null || !SAFE_LANG.matcher(lang).matches()) {
|
||||||
|
throw new IllegalArgumentException("invalid language code: '" + lang + "'");
|
||||||
|
}
|
||||||
|
return lang;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The newest modification time of the entry's files — {@code updatedAt}, which drives the sitemap
|
||||||
|
* {@code <lastmod>} and the render {@code ETag} once the source re-lists (after an announced change).
|
||||||
|
* {@code null} when no time is known.
|
||||||
|
*/
|
||||||
|
private Instant newestModification(String siteId, String entryId) {
|
||||||
|
Instant newest = null;
|
||||||
|
for (FileEntry file : entryFiles(siteId, entryId)) {
|
||||||
|
Instant at = file.lastModified();
|
||||||
|
if (!file.directory() && !Instant.EPOCH.equals(at) && (newest == null || at.isAfter(newest))) {
|
||||||
|
newest = at;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newest;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FileEntry> entryFiles(String siteId, String entryId) {
|
||||||
|
try {
|
||||||
|
return files.list(siteId, ENTRIES + "/" + entryId);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
// An unreadable folder contributes no file times and no body languages; the entry still lists.
|
||||||
|
log.debug("listing blog entry {}/{} failed: {}", siteId, entryId, ex.toString());
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String metadataPath(String entryId) {
|
||||||
|
return ENTRIES + "/" + entryId + "/" + METADATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String bodyPath(String entryId, String lang) {
|
||||||
|
return ENTRIES + "/" + entryId + "/body-" + requireSafeLang(lang) + ".md";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,369 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import mx.quest.runway.spi.model.CatalogChange;
|
||||||
|
import mx.quest.runway.spi.model.SiteView;
|
||||||
|
import mx.quest.runway.spi.service.ConsoleScreen;
|
||||||
|
import mx.quest.runway.spi.testkit.EventDispatch;
|
||||||
|
import mx.quest.runway.spi.testkit.FakeContentCatalog;
|
||||||
|
import mx.quest.runway.spi.testkit.FakePluginSettings;
|
||||||
|
import mx.quest.runway.spi.testkit.FakeSiteServices;
|
||||||
|
import mx.quest.runway.spi.testkit.TempDirSiteFiles;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ExtendedModelMap;
|
||||||
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
|
import org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link BlogAdminController} over SPI fakes: the form → entry parse (per-language fields, the default-language slug
|
||||||
|
* as base slug, published checkbox), the {@code ContentChanges} announcement after every mutation (the platform's
|
||||||
|
* freshness rule — and, delivered back, the source's own index drop), the reverse advisory through
|
||||||
|
* {@code ContentCatalogView.pageAt}, the bound tenancy through {@code RequestContext}, console messages through
|
||||||
|
* {@code Messages}, and the console-screen contract (annotation, paths, POST-only mutations, the permission gate).
|
||||||
|
*/
|
||||||
|
class BlogAdminControllerTest {
|
||||||
|
|
||||||
|
private static final Locale EN = Locale.ENGLISH;
|
||||||
|
private static final Locale ES = Locale.of("es");
|
||||||
|
|
||||||
|
private record Fixture(BlogAdminController controller, BlogStore store, EventDispatch events,
|
||||||
|
FakeContentCatalog catalog, BlogContentSource source) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Fixture fixture(Path tmp, boolean bound) throws IOException {
|
||||||
|
Files.createDirectories(tmp.resolve("acme"));
|
||||||
|
BlogStore store = new BlogStore(new TempDirSiteFiles(tmp, "blog"));
|
||||||
|
FakeContentCatalog catalog = new FakeContentCatalog().site("acme").route("/sitemap.xml");
|
||||||
|
BlogContentSource source = new BlogContentSource(store, new FakePluginSettings(), catalog);
|
||||||
|
EventDispatch events = new EventDispatch("blog", Set.of(BlogContentSource.KEY)).listener(source);
|
||||||
|
FakeSiteServices kernel = new FakeSiteServices()
|
||||||
|
.site(new SiteView("acme", "Acme", EN, List.of(EN, ES), null))
|
||||||
|
.message("acme", "blog.flash.created", "Entrada creada.");
|
||||||
|
if (bound) {
|
||||||
|
kernel.current("acme");
|
||||||
|
}
|
||||||
|
BlogAdminController controller = new BlogAdminController(kernel, store, source, catalog, events, kernel);
|
||||||
|
return new Fixture(controller, store, events, catalog, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Fixture fixture(Path tmp) throws IOException {
|
||||||
|
return fixture(tmp, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MultiValueMap<String, String> form() {
|
||||||
|
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
||||||
|
params.add("title_en", "My first post");
|
||||||
|
params.add("title_es", "Mi primera entrada");
|
||||||
|
params.add("description_en", "The very first.");
|
||||||
|
params.add("slug_en", "first"); // the default language's slug = the base slug
|
||||||
|
params.add("slug_es", "primera");
|
||||||
|
params.add("body_en", "Hello **world**.");
|
||||||
|
params.add("body_es", "Hola **mundo**.");
|
||||||
|
params.add("locales_en", "on");
|
||||||
|
params.add("locales_es", "on");
|
||||||
|
params.add("published", "on");
|
||||||
|
params.add("publishedOn", "2026-07-17");
|
||||||
|
params.add("author", "Jane Doe");
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> announcedIds(Fixture f) {
|
||||||
|
List<String> ids = new ArrayList<>();
|
||||||
|
for (CatalogChange c : f.events().announced()) {
|
||||||
|
assertEquals(BlogContentSource.KEY, c.sourceKey(), "always this plugin's own source");
|
||||||
|
assertEquals("acme", c.siteId(), "always the bound site");
|
||||||
|
ids.add(c.id());
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void createParsesTheFormAndAnnouncesTheChange(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp);
|
||||||
|
RedirectAttributesModelMap redirect = new RedirectAttributesModelMap();
|
||||||
|
String view = f.controller().create("First-Post ", form(), new ExtendedModelMap(), redirect);
|
||||||
|
assertEquals("redirect:/__admin/blog/first-post/edit", view, "the id is trimmed and lower-cased");
|
||||||
|
|
||||||
|
BlogEntry saved = f.store().read("acme", "first-post").orElseThrow();
|
||||||
|
assertEquals("My first post", saved.title().get("en"));
|
||||||
|
assertEquals("The very first.", saved.description().get("en"));
|
||||||
|
assertEquals("first", saved.slug(), "the default language's slug field becomes the base slug");
|
||||||
|
assertEquals(Map.of("es", "primera"), saved.localizedSlugs());
|
||||||
|
assertEquals(List.of("en", "es"), saved.locales());
|
||||||
|
assertTrue(saved.published());
|
||||||
|
assertEquals("2026-07-17", saved.publishedOn());
|
||||||
|
assertEquals("Jane Doe", saved.author());
|
||||||
|
assertEquals("Hello **world**.", f.store().readBody("acme", "first-post", "en"));
|
||||||
|
assertEquals("Hola **mundo**.", f.store().readBody("acme", "first-post", "es"));
|
||||||
|
|
||||||
|
assertEquals(List.of("first-post"), announcedIds(f), "one announcement, after the write");
|
||||||
|
assertEquals("Entry created.", redirect.getFlashAttributes().get("flash"),
|
||||||
|
"console words come from Messages.console (its fallback here)");
|
||||||
|
assertTrue(f.events().failures().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theAnnouncementReachesTheSourceSoTheNewEntryRoutesAtOnce(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp);
|
||||||
|
SiteView site = new SiteView("acme", "Acme", EN, List.of(EN, ES), null);
|
||||||
|
assertTrue(f.source().resolve(site, "/blog/first", EN).isEmpty(), "builds (and caches) an empty index");
|
||||||
|
f.controller().create("first-post", form(), new ExtendedModelMap(), new RedirectAttributesModelMap());
|
||||||
|
assertEquals("first-post", f.source().resolve(site, "/blog/first", EN).orElseThrow().id(),
|
||||||
|
"the source's SOURCE-phase listener dropped its stale index");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void anInvalidIdReRendersTheEditorWithTheTypedStateNothingWritten(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp);
|
||||||
|
ExtendedModelMap model = new ExtendedModelMap();
|
||||||
|
String view = f.controller().create("Bad:Id", form(), model, new RedirectAttributesModelMap());
|
||||||
|
assertEquals(ConsoleScreen.LAYOUT_VIEW, view, "failure RE-RENDERS the editor — never a blank form");
|
||||||
|
assertNotNull(model.getAttribute("error"), "the error message is in the model");
|
||||||
|
BlogEntry typed = (BlogEntry) model.getAttribute("entry");
|
||||||
|
assertEquals("My first post", typed.title().get("en"), "everything the author typed is preserved");
|
||||||
|
assertEquals("__plugin__/blog/admin-edit", model.getAttribute(ConsoleScreen.CONTENT_TEMPLATE));
|
||||||
|
assertEquals(Boolean.TRUE, model.getAttribute("creating"));
|
||||||
|
assertTrue(f.store().list("acme").isEmpty(), "nothing was written");
|
||||||
|
assertTrue(f.events().announced().isEmpty(), "nothing was announced");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void reservedAndDuplicateIdsAreRejected(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp);
|
||||||
|
for (String reserved : List.of("create", "new")) {
|
||||||
|
ExtendedModelMap model = new ExtendedModelMap();
|
||||||
|
assertEquals(ConsoleScreen.LAYOUT_VIEW,
|
||||||
|
f.controller().create(reserved, form(), model, new RedirectAttributesModelMap()));
|
||||||
|
assertEquals("That id is reserved — pick another.", model.getAttribute("error"));
|
||||||
|
assertTrue(f.store().read("acme", reserved).isEmpty(), reserved + " would collide with the route table");
|
||||||
|
}
|
||||||
|
f.controller().create("post", form(), new ExtendedModelMap(), new RedirectAttributesModelMap());
|
||||||
|
var other = form();
|
||||||
|
other.set("title_en", "Another");
|
||||||
|
ExtendedModelMap model = new ExtendedModelMap();
|
||||||
|
assertEquals(ConsoleScreen.LAYOUT_VIEW,
|
||||||
|
f.controller().create("post", other, model, new RedirectAttributesModelMap()));
|
||||||
|
assertEquals("An entry with that id already exists.", model.getAttribute("error"));
|
||||||
|
assertEquals("My first post", f.store().read("acme", "post").orElseThrow().title().get("en"),
|
||||||
|
"the existing entry is untouched");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void anUnsafeSlugOrCustomPathIsRejectedNotSilentlyDiscarded(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp);
|
||||||
|
var bad = form();
|
||||||
|
bad.set("slug_es", "Bad Slug!");
|
||||||
|
ExtendedModelMap model = new ExtendedModelMap();
|
||||||
|
assertEquals(ConsoleScreen.LAYOUT_VIEW, f.controller().create("post", bad, model,
|
||||||
|
new RedirectAttributesModelMap()));
|
||||||
|
assertTrue(String.valueOf(model.getAttribute("error")).contains("slug (es)"));
|
||||||
|
assertTrue(f.store().read("acme", "post").isEmpty(), "an invalid slug never persists");
|
||||||
|
|
||||||
|
// Each of these would be dropped by the kernel's fail-closed re-filter (or is not even a path).
|
||||||
|
for (String path : List.of("no-leading-slash", "/a|b", "/a:b", "/__admin/x", "/app/x", "/sitemap.xml",
|
||||||
|
"/x/../y")) {
|
||||||
|
var badPath = form();
|
||||||
|
badPath.set("customPath", path);
|
||||||
|
ExtendedModelMap m = new ExtendedModelMap();
|
||||||
|
assertEquals(ConsoleScreen.LAYOUT_VIEW,
|
||||||
|
f.controller().create("post2", badPath, m, new RedirectAttributesModelMap()), path);
|
||||||
|
assertTrue(String.valueOf(m.getAttribute("error")).contains("customPath"), path);
|
||||||
|
assertTrue(f.store().read("acme", "post2").isEmpty(), path + ": an invalid custom path never persists");
|
||||||
|
}
|
||||||
|
var goodPath = form();
|
||||||
|
goodPath.set("customPath", " /announcing-v2 ");
|
||||||
|
f.controller().create("post3", goodPath, new ExtendedModelMap(), new RedirectAttributesModelMap());
|
||||||
|
assertEquals("/announcing-v2", f.store().read("acme", "post3").orElseThrow().customPath());
|
||||||
|
assertEquals(List.of("post3"), announcedIds(f), "only the valid save was announced");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theFullLifecycleRoundTripsAndAnnouncesEveryMutation(@TempDir Path tmp) throws IOException {
|
||||||
|
// create → update (slug change + published checkbox ABSENT = silent unpublish, the intended
|
||||||
|
// full-state-form UX) → publish-toggle twice (ONLY the flag flips) → delete (folder gone).
|
||||||
|
Fixture f = fixture(tmp);
|
||||||
|
f.controller().create("post", form(), new ExtendedModelMap(), new RedirectAttributesModelMap());
|
||||||
|
|
||||||
|
var update = form();
|
||||||
|
update.set("slug_en", "renamed");
|
||||||
|
update.remove("published");
|
||||||
|
RedirectAttributesModelMap saved = new RedirectAttributesModelMap();
|
||||||
|
assertEquals("redirect:/__admin/blog/post/edit", f.controller().update("post", update, saved));
|
||||||
|
assertEquals("Saved.", saved.getFlashAttributes().get("flash"));
|
||||||
|
BlogEntry updated = f.store().read("acme", "post").orElseThrow();
|
||||||
|
assertEquals("renamed", updated.slug(), "the slug change persisted");
|
||||||
|
assertFalse(updated.published(), "checkbox absent ⇒ unpublished (full-state form semantics)");
|
||||||
|
assertEquals("Mi primera entrada", updated.title().get("es"), "other fields intact");
|
||||||
|
|
||||||
|
RedirectAttributesModelMap toggled = new RedirectAttributesModelMap();
|
||||||
|
assertEquals("redirect:/__admin/blog", f.controller().togglePublished("post", toggled));
|
||||||
|
assertEquals("Entry published.", toggled.getFlashAttributes().get("flash"));
|
||||||
|
BlogEntry republished = f.store().read("acme", "post").orElseThrow();
|
||||||
|
assertTrue(republished.published(), "toggle flips ONLY the flag");
|
||||||
|
assertEquals("renamed", republished.slug(), "the positional rebuild kept every other field");
|
||||||
|
assertEquals("2026-07-17", republished.publishedOn());
|
||||||
|
RedirectAttributesModelMap untoggled = new RedirectAttributesModelMap();
|
||||||
|
f.controller().togglePublished("post", untoggled);
|
||||||
|
assertEquals("Entry unpublished.", untoggled.getFlashAttributes().get("flash"));
|
||||||
|
assertFalse(f.store().read("acme", "post").orElseThrow().published());
|
||||||
|
|
||||||
|
RedirectAttributesModelMap deleted = new RedirectAttributesModelMap();
|
||||||
|
assertEquals("redirect:/__admin/blog", f.controller().delete("post", deleted));
|
||||||
|
assertEquals("Entry deleted.", deleted.getFlashAttributes().get("flash"));
|
||||||
|
assertTrue(f.store().read("acme", "post").isEmpty(), "deleted");
|
||||||
|
assertEquals(List.of("post", "post", "post", "post", "post"), announcedIds(f),
|
||||||
|
"create, update, publish, unpublish, delete — each announced");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void anInvalidUpdateFlashesTheErrorAndWritesNothing(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp);
|
||||||
|
f.controller().create("post", form(), new ExtendedModelMap(), new RedirectAttributesModelMap());
|
||||||
|
var bad = form();
|
||||||
|
bad.set("customPath", "/__nope");
|
||||||
|
bad.set("title_en", "Changed");
|
||||||
|
RedirectAttributesModelMap redirect = new RedirectAttributesModelMap();
|
||||||
|
assertEquals("redirect:/__admin/blog/post/edit", f.controller().update("post", bad, redirect));
|
||||||
|
assertTrue(String.valueOf(redirect.getFlashAttributes().get("error")).contains("customPath"));
|
||||||
|
assertEquals("My first post", f.store().read("acme", "post").orElseThrow().title().get("en"));
|
||||||
|
assertEquals(1, f.events().announced().size(), "only the create");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void unknownEntriesAre404(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp);
|
||||||
|
assertEquals(404, assertThrows(ResponseStatusException.class,
|
||||||
|
() -> f.controller().editForm("ghost", new ExtendedModelMap())).getStatusCode().value());
|
||||||
|
assertEquals(404, assertThrows(ResponseStatusException.class,
|
||||||
|
() -> f.controller().update("ghost", form(), new RedirectAttributesModelMap())).getStatusCode().value());
|
||||||
|
assertEquals(404, assertThrows(ResponseStatusException.class,
|
||||||
|
() -> f.controller().togglePublished("ghost", new RedirectAttributesModelMap()))
|
||||||
|
.getStatusCode().value());
|
||||||
|
assertTrue(f.store().read("acme", "ghost").isEmpty(), "an update never creates");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void withoutABoundTenancyEveryScreenIs400(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, false);
|
||||||
|
assertEquals(400, assertThrows(ResponseStatusException.class,
|
||||||
|
() -> f.controller().list(new ExtendedModelMap())).getStatusCode().value(),
|
||||||
|
"the application console has no site: RequestContext.site() is empty there");
|
||||||
|
assertEquals(400, assertThrows(ResponseStatusException.class,
|
||||||
|
() -> f.controller().create("x", form(), new ExtendedModelMap(), new RedirectAttributesModelMap()))
|
||||||
|
.getStatusCode().value());
|
||||||
|
assertEquals(400, assertThrows(ResponseStatusException.class,
|
||||||
|
() -> f.controller().delete("x", new RedirectAttributesModelMap())).getStatusCode().value());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theListModelCarriesRowsPathsAndTheEnabledFlag(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp);
|
||||||
|
BlogStoreTest.install131(tmp, "acme");
|
||||||
|
ExtendedModelMap model = new ExtendedModelMap();
|
||||||
|
assertEquals(ConsoleScreen.LAYOUT_VIEW, f.controller().list(model));
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<BlogAdminController.EntryRow> rows = (List<BlogAdminController.EntryRow>) model.getAttribute("rows");
|
||||||
|
assertEquals(List.of("launch", "no-author", "hello-world", "draft-post"),
|
||||||
|
rows.stream().map(r -> r.entry().id()).toList(), "every entry, drafts included, newest first");
|
||||||
|
assertEquals("/announcing-v2", rows.get(0).publicPath());
|
||||||
|
assertEquals("/blog/hello-world", rows.get(2).publicPath());
|
||||||
|
assertEquals(Boolean.TRUE, model.getAttribute("blogEnabled"));
|
||||||
|
assertEquals("__plugin__/blog/admin-list", model.getAttribute(ConsoleScreen.CONTENT_TEMPLATE));
|
||||||
|
assertEquals("blog.admin.title", model.getAttribute(ConsoleScreen.PAGE_TITLE_KEY));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theEditorModelCarriesTheReverseAdvisoryWhenAPageOwnsThePath(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp);
|
||||||
|
f.controller().create("first-post", form(), new ExtendedModelMap(), new RedirectAttributesModelMap());
|
||||||
|
f.catalog().page("acme", "/blog/first", EN, "about");
|
||||||
|
f.catalog().page("acme", "/blog/first", ES, "wrong-locale-claim");
|
||||||
|
f.catalog().page("acme", "/blog/primera", ES, "acerca");
|
||||||
|
|
||||||
|
ExtendedModelMap model = new ExtendedModelMap();
|
||||||
|
assertEquals(ConsoleScreen.LAYOUT_VIEW, f.controller().editForm("first-post", model));
|
||||||
|
assertEquals(List.of("about (en)", "acerca (es)"), model.getAttribute("shadowedBy"),
|
||||||
|
"each language's REAL URL is checked in that language's URL space");
|
||||||
|
assertEquals("__plugin__/blog/admin-edit", model.getAttribute(ConsoleScreen.CONTENT_TEMPLATE));
|
||||||
|
assertEquals("/__admin/blog/first-post", model.getAttribute("formAction"));
|
||||||
|
assertEquals(List.of("en", "es"), model.getAttribute("siteLocaleTags"));
|
||||||
|
assertEquals("en", model.getAttribute("defaultLocaleTag"));
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, String> bodies = (Map<String, String>) model.getAttribute("bodies");
|
||||||
|
assertEquals(Map.of("en", "Hello **world**.", "es", "Hola **mundo**."), bodies);
|
||||||
|
|
||||||
|
ExtendedModelMap creating = new ExtendedModelMap();
|
||||||
|
f.controller().createForm(creating);
|
||||||
|
assertEquals(List.of(), creating.getAttribute("shadowedBy"), "no advisory before the entry exists");
|
||||||
|
assertEquals("/__admin/blog/create", creating.getAttribute("formAction"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Toggling publish/unpublish must not erase the byline (the positional rebuild is a known-recurring hazard). */
|
||||||
|
@Test
|
||||||
|
void togglingPublishPreservesTheAuthor(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp);
|
||||||
|
f.store().save("acme", new BlogEntry("post", Map.of("en", "Post"), Map.of(), List.of("en"),
|
||||||
|
null, Map.of(), null, true, "2026-03-04", "Jane Doe", null), Map.of("en", "# Hi"));
|
||||||
|
f.controller().togglePublished("post", new RedirectAttributesModelMap());
|
||||||
|
BlogEntry hidden = f.store().read("acme", "post").orElseThrow();
|
||||||
|
assertFalse(hidden.published(), "precondition: the toggle actually flipped visibility");
|
||||||
|
assertEquals("Jane Doe", hidden.author(), "unpublishing must not un-attribute the entry");
|
||||||
|
f.controller().togglePublished("post", new RedirectAttributesModelMap());
|
||||||
|
assertEquals("Jane Doe", f.store().read("acme", "post").orElseThrow().author());
|
||||||
|
assertEquals("# Hi", f.store().readBody("acme", "post", "en"), "a toggle never touches a body");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void itIsAConsoleScreenWhoseMutationsArePermissionGatedPosts() {
|
||||||
|
Class<BlogAdminController> type = BlogAdminController.class;
|
||||||
|
assertNotNull(type.getAnnotation(Controller.class));
|
||||||
|
assertNotNull(type.getAnnotation(ConsoleScreen.class), "the kernel renders it inside the operator shell");
|
||||||
|
int gets = 0;
|
||||||
|
int posts = 0;
|
||||||
|
for (Method m : type.getDeclaredMethods()) {
|
||||||
|
GetMapping get = m.getAnnotation(GetMapping.class);
|
||||||
|
PostMapping post = m.getAnnotation(PostMapping.class);
|
||||||
|
if (get == null && post == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String[] paths = get != null ? get.value() : post.value();
|
||||||
|
for (String path : paths) {
|
||||||
|
assertTrue(path.equals("/__admin/blog") || path.startsWith("/__admin/blog/"),
|
||||||
|
m.getName() + ": every mapping lies under /__admin/blog (" + path + ")");
|
||||||
|
}
|
||||||
|
PreAuthorize gate = m.getAnnotation(PreAuthorize.class);
|
||||||
|
assertNotNull(gate, m.getName() + " is permission-gated");
|
||||||
|
assertEquals("@authz.may('blog|manage')", gate.value());
|
||||||
|
if (get != null) {
|
||||||
|
gets++;
|
||||||
|
assertTrue(Set.of("list", "createForm", "editForm").contains(m.getName()),
|
||||||
|
m.getName() + ": a GET only renders");
|
||||||
|
} else {
|
||||||
|
posts++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertEquals(3, gets);
|
||||||
|
assertEquals(4, posts, "create, update, publish toggle, delete — each a CSRF-checked POST");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the console templates ({@code admin-list}, {@code admin-edit}) through the real decoupled-logic pipeline
|
||||||
|
* with the models the controller builds — a binding typo (a {@code /} where {@code //} belongs, a broken selector) is
|
||||||
|
* a RUNTIME failure the unit tests can't see; this test turns it into a build failure. And it holds the templates to
|
||||||
|
* the {@code @ConsoleScreen} contract: the only shell variables they read are {@code _csrf} (and their own
|
||||||
|
* controller's model), they reach no bean, and every {@code #{…}} key is in this plugin's own bundle.
|
||||||
|
*/
|
||||||
|
class BlogAdminTemplatesRenderTest {
|
||||||
|
|
||||||
|
/** What the controller puts in the model for these templates — the plugin's own variables. */
|
||||||
|
private static final Set<String> OWN_MODEL = Set.of("rows", "row", "blogEnabled", "entry", "bodies", "creating",
|
||||||
|
"shadowedBy", "siteLocaleTags", "defaultLocaleTag", "formAction", "lang");
|
||||||
|
/** What the shell promises a console screen's content template (SPI {@code ConsoleScreen}). */
|
||||||
|
private static final Set<String> SHELL_CONTRACT = Set.of("_csrf", "tenantSiteId");
|
||||||
|
|
||||||
|
private static String live(String file) throws IOException {
|
||||||
|
return Files.readString(Path.of("templates", file), StandardCharsets.UTF_8).replaceAll("(?s)<!--.*?-->", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, Object> withCsrf(Map<String, Object> vars) {
|
||||||
|
Map<String, Object> all = new HashMap<>(vars);
|
||||||
|
// The shell's CsrfToken, as SpEL reads it (parameterName, token).
|
||||||
|
all.put("_csrf", Map.of("parameterName", "_csrf", "token", "tok-123"));
|
||||||
|
return all;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theConsoleTemplatesReadOnlyTheirOwnModelAndThePromisedShellVariables() throws IOException {
|
||||||
|
Pattern root = Pattern.compile("\\$\\{\\s*!?\\s*([A-Za-z_@#][\\w]*)");
|
||||||
|
Pattern message = Pattern.compile("#\\{([^}(]+)");
|
||||||
|
Set<String> bundle = BlogConfigTest.keys("i18n/messages.properties");
|
||||||
|
Set<String> roots = new TreeSet<>();
|
||||||
|
for (String file : List.of("admin-list.th.xml", "admin-edit.th.xml")) {
|
||||||
|
String logic = live(file);
|
||||||
|
Matcher m = root.matcher(logic);
|
||||||
|
while (m.find()) {
|
||||||
|
roots.add(m.group(1));
|
||||||
|
}
|
||||||
|
Matcher k = message.matcher(logic);
|
||||||
|
while (k.find()) {
|
||||||
|
assertTrue(bundle.contains(k.group(1).trim()), file + ": #{" + k.group(1)
|
||||||
|
+ "} is not in this plugin's bundle (no kernel console key is promised)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String r : roots) {
|
||||||
|
assertFalse(r.startsWith("@"), "no bean reference in the console templates: " + r);
|
||||||
|
assertTrue(r.startsWith("#") || OWN_MODEL.contains(r) || SHELL_CONTRACT.contains(r),
|
||||||
|
"a variable neither the controller nor the shell contract provides: " + r);
|
||||||
|
}
|
||||||
|
assertTrue(roots.contains("_csrf"), "every mutating form carries the CSRF token");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theListScreenRendersRowsBadgesPostFormsAndCsrf(@TempDir Path tmp) {
|
||||||
|
BlogEntry published = new BlogEntry("hello", Map.of("en", "Hello"), Map.of(), List.of("en", "es"),
|
||||||
|
null, Map.of(), null, true, "2026-07-17", null, null);
|
||||||
|
BlogEntry draft = new BlogEntry("secret", Map.of("en", "Secret"), Map.of(), List.of(),
|
||||||
|
null, Map.of(), null, false, null, null, null);
|
||||||
|
String html = new TemplateHarness(tmp).render("__plugin__/blog/admin-list", Locale.ENGLISH, withCsrf(Map.of(
|
||||||
|
"rows", List.of(new BlogAdminController.EntryRow(published, "/blog/hello"),
|
||||||
|
new BlogAdminController.EntryRow(draft, "/blog/secret")),
|
||||||
|
"blogEnabled", true)));
|
||||||
|
|
||||||
|
assertTrue(html.contains("/blog/hello") && html.contains("/blog/secret"), "the resolved public paths");
|
||||||
|
assertTrue(html.contains("en, es"), "the languages");
|
||||||
|
assertTrue(html.contains("2026-07-17"), "the date renders");
|
||||||
|
assertTrue(html.contains(">Published<") && html.contains(">Draft<"), "the plugin's badges");
|
||||||
|
assertTrue(html.contains("bg-green-lt") && html.contains("bg-yellow-lt"));
|
||||||
|
assertTrue(html.contains("href=\"/__admin/blog/hello/edit\""), "the edit link (a GET that only renders)");
|
||||||
|
assertTrue(html.contains("method=\"post\" action=\"/__admin/blog/hello/publish\""), "publish is a POST");
|
||||||
|
assertTrue(html.contains("method=\"post\" action=\"/__admin/blog/secret/delete\""), "delete is a POST");
|
||||||
|
assertEquals(4, html.split("name=\"_csrf\" value=\"tok-123\"", -1).length - 1,
|
||||||
|
"every mutating form (2 rows × publish + delete) carries the console's CSRF token");
|
||||||
|
assertFalse(html.contains("href=\"/__admin/blog/hello/publish\"") || html.contains("/delete\" href"),
|
||||||
|
"no link points at a mutation");
|
||||||
|
assertTrue(html.contains(">Site<"), "the pretitle comes from the plugin's own bundle");
|
||||||
|
assertFalse(html.contains("??"), "every message key resolved");
|
||||||
|
assertFalse(html.contains("id=\"bl-disabled\""), "no banner when enabled");
|
||||||
|
assertFalse(html.contains("id=\"bl-empty\""), "no empty row with entries");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theListScreenShowsTheEmptyRowAndTheDisabledBanner(@TempDir Path tmp) {
|
||||||
|
TemplateHarness harness = new TemplateHarness(tmp);
|
||||||
|
String disabled = harness.render("__plugin__/blog/admin-list", Locale.of("es"), withCsrf(Map.of(
|
||||||
|
"rows", List.<BlogAdminController.EntryRow>of(), "blogEnabled", false)));
|
||||||
|
assertTrue(disabled.contains("id=\"bl-disabled\""), "disabled banner present");
|
||||||
|
assertTrue(disabled.contains("id=\"bl-empty\""), "the empty row");
|
||||||
|
assertTrue(disabled.contains(">Sitio<"), "Spanish console words from the plugin's bundle");
|
||||||
|
assertFalse(disabled.contains("??"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theEditorRendersPerLanguageCardsForBothCreateAndEdit(@TempDir Path tmp) {
|
||||||
|
TemplateHarness harness = new TemplateHarness(tmp);
|
||||||
|
BlogEntry entry = new BlogEntry("hello", Map.of("en", "Hello", "es", "Hola"),
|
||||||
|
Map.of("en", "Desc"), List.of("en"), "hello-slug", Map.of("es", "hola-slug"),
|
||||||
|
"/custom", true, "2026-07-17", "Jane Doe", null);
|
||||||
|
Map<String, Object> vars = Map.of(
|
||||||
|
"formAction", "/__admin/blog/hello",
|
||||||
|
"entry", entry,
|
||||||
|
"bodies", Map.of("en", "# Body EN", "es", ""),
|
||||||
|
"creating", false,
|
||||||
|
"shadowedBy", List.of("about (en)"),
|
||||||
|
"siteLocaleTags", List.of("en", "es"),
|
||||||
|
"defaultLocaleTag", "en");
|
||||||
|
String html = harness.render("__plugin__/blog/admin-edit", Locale.ENGLISH, withCsrf(vars));
|
||||||
|
|
||||||
|
assertTrue(html.contains("method=\"post\" action=\"/__admin/blog/hello\""), "edit mode POSTs to the entry");
|
||||||
|
assertTrue(html.contains("name=\"_csrf\" value=\"tok-123\""), "with the console's CSRF token");
|
||||||
|
assertTrue(html.contains("name=\"title_en\"") && html.contains("name=\"title_es\""),
|
||||||
|
"one language card per site locale, fields renamed per language");
|
||||||
|
assertTrue(html.contains("value=\"Hello\"") && html.contains("value=\"Hola\""), "titles prefilled");
|
||||||
|
assertTrue(html.contains("value=\"hello-slug\""), "the default language's slug is the base slug");
|
||||||
|
assertTrue(html.contains("value=\"hola-slug\""), "the localized slug prefills");
|
||||||
|
assertTrue(html.contains("name=\"body_en\"") && html.contains("# Body EN"), "the Markdown body prefills");
|
||||||
|
assertTrue(html.contains("value=\"/custom\""), "the custom path prefills");
|
||||||
|
assertTrue(html.contains("value=\"Jane Doe\""), "the author prefills");
|
||||||
|
assertTrue(html.contains("name=\"locales_en\" checked"), "a published language is ticked");
|
||||||
|
assertTrue(html.contains("readonly"), "the id is readonly on edit");
|
||||||
|
assertTrue(html.contains("about (en)"), "the reverse advisory renders the winning page");
|
||||||
|
assertTrue(html.contains("en · default"), "the default language is marked");
|
||||||
|
assertFalse(html.contains("??"), "every message key resolved");
|
||||||
|
|
||||||
|
Map<String, Object> creating = Map.of(
|
||||||
|
"formAction", "/__admin/blog/create",
|
||||||
|
"entry", new BlogEntry("new-entry", Map.of(), Map.of(), List.of(), null, Map.of(),
|
||||||
|
null, false, null, null, null),
|
||||||
|
"bodies", Map.<String, String>of(),
|
||||||
|
"creating", true,
|
||||||
|
"shadowedBy", List.<String>of(),
|
||||||
|
"siteLocaleTags", List.of("en"),
|
||||||
|
"defaultLocaleTag", "en");
|
||||||
|
String createHtml = harness.render("__plugin__/blog/admin-edit", Locale.ENGLISH, withCsrf(creating));
|
||||||
|
assertTrue(createHtml.contains("action=\"/__admin/blog/create\""), "create mode posts to /create");
|
||||||
|
assertFalse(createHtml.contains("readonly"), "the id is editable on create");
|
||||||
|
assertFalse(createHtml.contains("id=\"be-shadowed\""), "no advisory on create");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import mx.quest.runway.spi.ContentSource;
|
||||||
|
import mx.quest.runway.spi.model.SiteView;
|
||||||
|
import mx.quest.runway.spi.service.ContentCatalogView;
|
||||||
|
import mx.quest.runway.spi.service.ContentChanges;
|
||||||
|
import mx.quest.runway.spi.service.PluginSettings;
|
||||||
|
import mx.quest.runway.spi.service.PluginSiteFiles;
|
||||||
|
import mx.quest.runway.spi.service.SiteEventListener;
|
||||||
|
import mx.quest.runway.spi.testkit.EventDispatch;
|
||||||
|
import mx.quest.runway.spi.testkit.FakeContentCatalog;
|
||||||
|
import mx.quest.runway.spi.testkit.FakePluginSettings;
|
||||||
|
import mx.quest.runway.spi.testkit.FakeSiteServices;
|
||||||
|
import mx.quest.runway.spi.testkit.TempDirSiteFiles;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The plugin's contract with the host, checked at build time: the wiring over SPI services only, the bean-name rule,
|
||||||
|
* the descriptor (SPI floor, release version, no personal data, the settings the code reads), the i18n bundles, and
|
||||||
|
* that the compiled classes link nothing of the host but the SPI — the same things the kernel's load-time checks
|
||||||
|
* warn about (and refuse from Runway 1.0).
|
||||||
|
*/
|
||||||
|
class BlogConfigTest {
|
||||||
|
|
||||||
|
private static final String PREFIX = "blog";
|
||||||
|
|
||||||
|
static Set<String> keys(String file) throws IOException {
|
||||||
|
Properties p = new Properties();
|
||||||
|
try (Reader in = Files.newBufferedReader(Path.of(file), StandardCharsets.UTF_8)) {
|
||||||
|
p.load(in);
|
||||||
|
}
|
||||||
|
return new TreeSet<>(p.stringPropertyNames());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private static Map<String, Object> descriptor() throws IOException {
|
||||||
|
try (Reader in = Files.newBufferedReader(Path.of("plugin.yml"), StandardCharsets.UTF_8)) {
|
||||||
|
return (Map<String, Object>) new Yaml().load(in);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Set<String> beanMethodNames() {
|
||||||
|
return Arrays.stream(BlogConfig.class.getDeclaredMethods())
|
||||||
|
.filter(m -> m.isAnnotationPresent(Bean.class))
|
||||||
|
.map(Method::getName)
|
||||||
|
.collect(Collectors.toCollection(TreeSet::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void wiresEverythingFromSpiServicesUnderPrefixedNames(@TempDir Path sites) throws IOException {
|
||||||
|
Files.createDirectories(sites.resolve("acme"));
|
||||||
|
FakeSiteServices kernel = new FakeSiteServices()
|
||||||
|
.site(new SiteView("acme", "Acme", Locale.ENGLISH, List.of(Locale.ENGLISH), null))
|
||||||
|
.current("acme");
|
||||||
|
try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
|
||||||
|
ctx.registerBean(PluginSettings.class, () -> new FakePluginSettings());
|
||||||
|
ctx.registerBean(PluginSiteFiles.class, () -> new TempDirSiteFiles(sites, "blog"));
|
||||||
|
ctx.registerBean(ContentCatalogView.class, () -> new FakeContentCatalog().site("acme"));
|
||||||
|
ctx.registerBean(ContentChanges.class, () -> new EventDispatch("blog", Set.of("blog")));
|
||||||
|
ctx.registerBean(FakeSiteServices.class, () -> kernel);
|
||||||
|
ctx.register(BlogConfig.class);
|
||||||
|
ctx.refresh();
|
||||||
|
|
||||||
|
assertEquals(Set.of("blogStore", "blogContentSource", "blogAdminController"),
|
||||||
|
new TreeSet<>(Arrays.stream(ctx.getBeanDefinitionNames())
|
||||||
|
.filter(n -> n.startsWith("blog") && !n.equals("blogConfig")).toList()),
|
||||||
|
"the mainClass itself is registered by the host as plugin:blog");
|
||||||
|
BlogContentSource source = ctx.getBean("blogContentSource", BlogContentSource.class);
|
||||||
|
assertSame(source, ctx.getBean(ContentSource.class), "collected as the site's content source");
|
||||||
|
assertSame(source, ctx.getBean(SiteEventListener.class), "…and as its own index's listener");
|
||||||
|
assertEquals("blog", source.key());
|
||||||
|
ctx.getBean("blogStore", BlogStore.class).save("acme", new BlogEntry("hi", Map.of("en", "Hi"), Map.of(),
|
||||||
|
List.of("en"), null, Map.of(), null, true, null, null, null), Map.of("en", "x"));
|
||||||
|
assertTrue(Files.isRegularFile(sites.resolve("acme/plugins/blog/entries/hi/entry.yml")),
|
||||||
|
"the store writes through the injected PluginSiteFiles");
|
||||||
|
org.springframework.ui.ExtendedModelMap model = new org.springframework.ui.ExtendedModelMap();
|
||||||
|
ctx.getBean("blogAdminController", BlogAdminController.class).list(model);
|
||||||
|
assertEquals(1, ((List<?>) model.getAttribute("rows")).size(),
|
||||||
|
"the controller reads the bound site through RequestContext");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void everyBeanNameStartsWithThePluginId() {
|
||||||
|
assertEquals(Set.of("blogStore", "blogContentSource", "blogAdminController"), beanMethodNames());
|
||||||
|
for (Method m : BlogConfig.class.getDeclaredMethods()) {
|
||||||
|
Bean bean = m.getAnnotation(Bean.class);
|
||||||
|
if (bean != null) {
|
||||||
|
for (String alias : bean.name()) {
|
||||||
|
assertTrue(alias.startsWith(PREFIX), "an explicit bean name must start with " + PREFIX + ": " + alias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theDescriptorDeclaresTheSpiFloorAndTheReleaseVersion() throws IOException {
|
||||||
|
Map<String, Object> yml = descriptor();
|
||||||
|
assertEquals("blog", yml.get("id"));
|
||||||
|
assertEquals(BlogConfig.class.getName(), yml.get("mainClass"));
|
||||||
|
assertEquals(">=1.0.0", yml.get("requiresSpi"), "built for the frozen SPI 1.0.0 contract");
|
||||||
|
String pom = Files.readString(Path.of("pom.xml"), StandardCharsets.UTF_8);
|
||||||
|
Matcher version = Pattern.compile("<artifactId>runway-plugin-blog</artifactId>\\s*<version>([^<]+)")
|
||||||
|
.matcher(pom);
|
||||||
|
assertTrue(version.find());
|
||||||
|
assertEquals("2.1.0", version.group(1));
|
||||||
|
assertEquals(version.group(1), String.valueOf(yml.get("version")), "plugin.yml and pom.xml agree");
|
||||||
|
assertTrue(pom.contains("<project.build.outputTimestamp>2026-10-21T18:56:00Z</project.build.outputTimestamp>"));
|
||||||
|
assertFalse(pom.contains("<artifactId>runway-app</artifactId>"), "no runway-app dependency in any scope");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
void theDescriptorDeclaresNoPersonalDataAndTheSettingsTheCodeReads() throws IOException {
|
||||||
|
Map<String, Object> yml = descriptor();
|
||||||
|
assertNull(yml.get("siteData"), "blog entries are published content the site's operators author, not personal data");
|
||||||
|
List<Map<String, Object>> schema = (List<Map<String, Object>>) yml.get("siteSettings");
|
||||||
|
Map<String, Object> byKey = new java.util.HashMap<>();
|
||||||
|
schema.forEach(s -> byKey.put(String.valueOf(s.get("key")), s.get("default")));
|
||||||
|
assertEquals(Map.of("enabled", true, "prefix", BlogSettings.DEFAULT_PREFIX,
|
||||||
|
"template", BlogSettings.DEFAULT_TEMPLATE), byKey, "the code's fallbacks match the declared defaults");
|
||||||
|
List<Map<String, Object>> permissions = (List<Map<String, Object>>) yml.get("permissions");
|
||||||
|
assertEquals(List.of("settings", "manage"), permissions.stream().map(p -> p.get("id")).toList());
|
||||||
|
List<Map<String, Object>> menu = (List<Map<String, Object>>) yml.get("menu");
|
||||||
|
assertEquals("/__admin/blog", menu.get(0).get("path"));
|
||||||
|
assertEquals("blog|manage", menu.get(0).get("permission"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theEnglishAndSpanishBundlesDefineTheSameKeysAndEveryDescriptorLabel() throws IOException {
|
||||||
|
Set<String> en = keys("i18n/messages.properties");
|
||||||
|
assertEquals(en, keys("i18n/messages_es.properties"));
|
||||||
|
String yml = Files.readString(Path.of("plugin.yml"), StandardCharsets.UTF_8);
|
||||||
|
Matcher label = Pattern.compile("label: (blog\\.[\\w.]+)").matcher(yml);
|
||||||
|
int found = 0;
|
||||||
|
while (label.find()) {
|
||||||
|
found++;
|
||||||
|
assertTrue(en.contains(label.group(1)), "descriptor label without words: " + label.group(1));
|
||||||
|
}
|
||||||
|
assertEquals(6, found, "2 permissions, 3 settings, 1 menu entry");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theCompiledClassesLinkNoHostInternals() throws IOException {
|
||||||
|
Path classes = Path.of("target", "classes");
|
||||||
|
Pattern host = Pattern.compile("mx[/.]quest[/.]runway[/.](?!spi[/.])[\\w/.$]*");
|
||||||
|
List<String> problems = new ArrayList<>();
|
||||||
|
int scanned = 0;
|
||||||
|
try (Stream<Path> files = Files.walk(classes)) {
|
||||||
|
for (Path file : files.filter(p -> p.toString().endsWith(".class")).toList()) {
|
||||||
|
scanned++;
|
||||||
|
String rel = classes.relativize(file).toString().replace('\\', '/');
|
||||||
|
if (rel.startsWith("mx/quest/runway/")) {
|
||||||
|
problems.add(rel + " lives under mx.quest.runway");
|
||||||
|
}
|
||||||
|
// The constant pool holds class names and descriptors as (modified) UTF-8; Latin-1 keeps every
|
||||||
|
// byte as one char, so an ASCII pattern finds them without parsing the class file.
|
||||||
|
Matcher m = host.matcher(new String(Files.readAllBytes(file), StandardCharsets.ISO_8859_1));
|
||||||
|
while (m.find()) {
|
||||||
|
problems.add(rel + " → " + m.group());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(scanned >= 6, "the compiled classes were found (" + scanned + ")");
|
||||||
|
assertTrue(problems.isEmpty(), "host linkage: " + problems);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,372 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import mx.quest.runway.spi.ContentSource;
|
||||||
|
import mx.quest.runway.spi.model.CatalogChange;
|
||||||
|
import mx.quest.runway.spi.model.ContentBody;
|
||||||
|
import mx.quest.runway.spi.model.ContentRef;
|
||||||
|
import mx.quest.runway.spi.model.SiteLifecycleEvent;
|
||||||
|
import mx.quest.runway.spi.model.SiteView;
|
||||||
|
import mx.quest.runway.spi.service.SiteEventListener;
|
||||||
|
import mx.quest.runway.spi.testkit.EventDispatch;
|
||||||
|
import mx.quest.runway.spi.testkit.FakeContentCatalog;
|
||||||
|
import mx.quest.runway.spi.testkit.FakePluginSettings;
|
||||||
|
import mx.quest.runway.spi.testkit.TempDirSiteFiles;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link BlogContentSource} against the ContentSource contract: published-only metadata enumeration, the O(1) URL
|
||||||
|
* index (prefix + localized slugs + custom paths), Markdown bodies fetched only via {@code body()}, the per-site enable
|
||||||
|
* switch and prefix setting (through {@code PluginSettings}, with the kernel's path rule) — and its index invalidation
|
||||||
|
* as a {@code SOURCE}-phase {@link SiteEventListener}, driven by the testkit's {@link EventDispatch} in the kernel's
|
||||||
|
* delivery order.
|
||||||
|
*/
|
||||||
|
class BlogContentSourceTest {
|
||||||
|
|
||||||
|
private static final Locale EN = Locale.ENGLISH;
|
||||||
|
private static final Locale ES = Locale.of("es");
|
||||||
|
private static final SiteView SITE = new SiteView("acme", "Acme", EN, List.of(EN, ES), null);
|
||||||
|
|
||||||
|
private record Fixture(BlogStore store, BlogContentSource source, FakePluginSettings settings,
|
||||||
|
EventDispatch events) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Fixture fixture(Path tmp, Map<String, Object> cfg) throws IOException {
|
||||||
|
Files.createDirectories(tmp.resolve("acme"));
|
||||||
|
BlogStore store = new BlogStore(new TempDirSiteFiles(tmp, "blog"));
|
||||||
|
FakePluginSettings settings = new FakePluginSettings()
|
||||||
|
.defaults(Map.of("enabled", true, "prefix", "/blog", "template", "entry-classic"))
|
||||||
|
.site("acme", cfg);
|
||||||
|
FakeContentCatalog catalog = new FakeContentCatalog().site("acme").route("/sitemap.xml");
|
||||||
|
BlogContentSource source = new BlogContentSource(store, settings, catalog);
|
||||||
|
EventDispatch events = new EventDispatch("blog", Set.of(BlogContentSource.KEY)).listener(source);
|
||||||
|
return new Fixture(store, source, settings, events);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BlogEntry entry(String id, boolean published) {
|
||||||
|
return new BlogEntry(id, Map.of("en", "T-" + id, "es", "ES-" + id), Map.of("en", "D"),
|
||||||
|
List.of("en", "es"), null, Map.of("es", id + "-es"), null, published, "2026-07-17", null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, ContentRef> byId(BlogContentSource source) {
|
||||||
|
Map<String, ContentRef> out = new HashMap<>();
|
||||||
|
for (ContentRef r : source.enumerate(SITE)) {
|
||||||
|
out.put(r.id(), r);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void enumeratesPublishedEntriesAsRefsUnderThePrefix(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", entry("hello", true), Map.of("en", "# Hi"));
|
||||||
|
f.store().save("acme", entry("draft", false), null);
|
||||||
|
|
||||||
|
List<ContentRef> refs = f.source().enumerate(SITE);
|
||||||
|
assertEquals(1, refs.size(), "unpublished entries are never enumerated (draft-leak fail-closed)");
|
||||||
|
ContentRef ref = refs.get(0);
|
||||||
|
assertEquals("hello", ref.id());
|
||||||
|
assertEquals("/blog/hello", ref.pathFor(EN), "default prefix + slug");
|
||||||
|
assertEquals("/blog/hello-es", ref.pathFor(ES), "localized slug under the same prefix");
|
||||||
|
assertEquals("T-hello", ref.titleFor(EN));
|
||||||
|
assertEquals("D", ref.descriptionFor(EN));
|
||||||
|
assertEquals(List.of(EN, ES), ref.locales());
|
||||||
|
assertEquals("__plugin__/blog/entry-classic", ref.bodyTemplate(), "the default template setting");
|
||||||
|
assertTrue(ref.published());
|
||||||
|
assertNotNull(ref.updatedAt(), "file-time-derived — a body edit moves the ETag automatically");
|
||||||
|
assertEquals(BlogContentSource.KEY, f.source().key());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void entriesWrittenBy131EnumerateAndResolveUnchanged(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
BlogStoreTest.install131(tmp, "acme");
|
||||||
|
Map<String, ContentRef> refs = byId(f.source());
|
||||||
|
assertEquals(Set.of("hello-world", "no-author", "launch"), refs.keySet(), "the draft stays out");
|
||||||
|
assertEquals("/blog/hello-world", refs.get("hello-world").pathFor(EN));
|
||||||
|
assertEquals("/blog/hola-mundo", refs.get("hello-world").pathFor(ES));
|
||||||
|
assertEquals("Jane Doe", refs.get("hello-world").author());
|
||||||
|
assertNull(refs.get("no-author").author(), "the entry with no author stays unattributed");
|
||||||
|
assertEquals(Instant.parse("2026-08-01T00:00:00Z"), refs.get("no-author").publishedAt());
|
||||||
|
assertEquals("/announcing-v2", refs.get("launch").pathFor(EN), "the custom path survives");
|
||||||
|
assertEquals("launch", f.source().resolve(SITE, "/announcing-v2", EN).orElseThrow().id());
|
||||||
|
assertTrue(f.source().body(SITE, "hello-world", EN).bodyHtml().contains("<strong>bold</strong>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void resolvesThroughTheIndexIncludingCustomPaths(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", entry("hello", true), null);
|
||||||
|
f.store().save("acme", new BlogEntry("launch", Map.of("en", "Launch"), Map.of(), List.of("en"),
|
||||||
|
null, Map.of(), "/announcing-v2", true, null, null, null), null);
|
||||||
|
|
||||||
|
assertEquals("hello", f.source().resolve(SITE, "/blog/hello", EN).orElseThrow().id());
|
||||||
|
assertEquals("hello", f.source().resolve(SITE, "/blog/hello-es", ES).orElseThrow().id(),
|
||||||
|
"the localized slug resolves under its own locale");
|
||||||
|
assertEquals(Optional.empty(), f.source().resolve(SITE, "/blog/hello-es", EN),
|
||||||
|
"a localized slug never doubles as another locale's URL");
|
||||||
|
assertEquals("launch", f.source().resolve(SITE, "/announcing-v2", EN).orElseThrow().id(),
|
||||||
|
"a custom path escapes the prefix (the arbitrary-paths capability)");
|
||||||
|
assertEquals(Optional.empty(), f.source().resolve(SITE, "/blog/nope", EN));
|
||||||
|
assertTrue(f.source().capabilities().has(ContentSource.CAP_ARBITRARY_PATHS));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void itIsASourcePhaseListener(@TempDir Path tmp) throws IOException {
|
||||||
|
assertEquals(SiteEventListener.Phase.SOURCE, fixture(tmp, Map.of()).source().phase(),
|
||||||
|
"its own index must drop BEFORE sitemap/search consumers re-read the listing");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void itsOwnContentChangeDropsTheIndexAndTheRefs(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", entry("hello", true), null);
|
||||||
|
f.source().resolve(SITE, "/blog/hello", EN);
|
||||||
|
assertNotNull(f.source().cachedIndex("acme"), "index built lazily on first resolve");
|
||||||
|
assertNotNull(f.source().cachedRefs("acme"));
|
||||||
|
|
||||||
|
// What the console calls after a save — delivered back as a CONTENT change for this source's key.
|
||||||
|
f.store().save("acme", entry("second", true), null);
|
||||||
|
f.events().changed("acme", BlogContentSource.KEY, "second");
|
||||||
|
assertNull(f.source().cachedIndex("acme"), "own-content change drops the index");
|
||||||
|
assertNull(f.source().cachedRefs("acme"), "…and the enumerated refs");
|
||||||
|
assertEquals("second", f.source().resolve(SITE, "/blog/second", EN).orElseThrow().id(),
|
||||||
|
"the next probe sees the new entry");
|
||||||
|
assertTrue(f.events().failures().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aReplayedChangeFromAPeerNodeDropsItToo(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", entry("hello", true), null);
|
||||||
|
f.source().resolve(SITE, "/blog/hello", EN);
|
||||||
|
f.events().catalog(new CatalogChange("acme", CatalogChange.Cause.CONTENT, BlogContentSource.KEY, null,
|
||||||
|
"blog", List.of(), List.of(), false));
|
||||||
|
assertNull(f.source().cachedIndex("acme"), "local == false still converges this node's index");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void otherChangesLeaveTheIndexAlone(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", entry("hello", true), null);
|
||||||
|
f.source().resolve(SITE, "/blog/hello", EN);
|
||||||
|
Map<String, String> built = f.source().cachedIndex("acme");
|
||||||
|
|
||||||
|
f.events().page("acme", "about", List.of(), List.of());
|
||||||
|
f.events().catalog(new CatalogChange("acme", CatalogChange.Cause.CONTENT, "products", "x", "shop",
|
||||||
|
List.of(), List.of(), true));
|
||||||
|
f.events().settings("acme", "search");
|
||||||
|
f.events().catalog(new CatalogChange("globex", CatalogChange.Cause.CONTENT, BlogContentSource.KEY, "x",
|
||||||
|
"blog", List.of(), List.of(), true));
|
||||||
|
assertTrue(built == f.source().cachedIndex("acme"),
|
||||||
|
"a page write, another source's change, another plugin's settings, another site: kept");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void itsOwnSettingsSaveDropsTheIndexAndRekeysEveryUrl(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", entry("hello", true), null);
|
||||||
|
assertEquals("/blog/hello", f.source().enumerate(SITE).get(0).pathFor(EN));
|
||||||
|
f.source().resolve(SITE, "/blog/hello", EN);
|
||||||
|
|
||||||
|
f.settings().site("acme", Map.of("prefix", "/news"));
|
||||||
|
f.events().settings("acme", "blog");
|
||||||
|
assertNull(f.source().cachedIndex("acme"), "a prefix change re-keys every URL — dropped");
|
||||||
|
assertEquals("/news/hello", f.source().enumerate(SITE).get(0).pathFor(EN));
|
||||||
|
assertEquals("hello", f.source().resolve(SITE, "/news/hello", EN).orElseThrow().id());
|
||||||
|
assertEquals(Optional.empty(), f.source().resolve(SITE, "/blog/hello", EN), "the old URL is gone");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void everyLifecycleEventDropsTheIndex(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", entry("hello", true), null);
|
||||||
|
for (SiteLifecycleEvent.Kind kind : SiteLifecycleEvent.Kind.values()) {
|
||||||
|
f.source().resolve(SITE, "/blog/hello", EN);
|
||||||
|
assertNotNull(f.source().cachedIndex("acme"));
|
||||||
|
f.events().lifecycle("acme", kind, kind == SiteLifecycleEvent.Kind.RESTORED);
|
||||||
|
assertNull(f.source().cachedIndex("acme"), kind + " drops it (a restore replaced the files wholesale)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void bodyRendersMarkdownAndCarriesThePublicationDate(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", entry("hello", true), Map.of("en", "# Title\n\nSome **bold** text."));
|
||||||
|
|
||||||
|
ContentBody body = f.source().body(SITE, "hello", EN);
|
||||||
|
assertTrue(body.bodyHtml().contains("<h1>Title</h1>"), "markdown heading rendered");
|
||||||
|
assertTrue(body.bodyHtml().contains("<strong>bold</strong>"), "markdown emphasis rendered");
|
||||||
|
assertEquals("2026-07-17", body.attributes().get("publishedOn"));
|
||||||
|
assertEquals("", f.source().body(SITE, "hello", ES).bodyHtml(), "no es body → empty (soft)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aCorruptEntryNeverBlanksTheRestOfTheBlog(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", entry("good", true), Map.of("en", "fine"));
|
||||||
|
Path corrupt = tmp.resolve("acme/plugins/blog/entries/broken");
|
||||||
|
Files.createDirectories(corrupt);
|
||||||
|
Files.writeString(corrupt.resolve("entry.yml"), "title: [unclosed");
|
||||||
|
|
||||||
|
List<ContentRef> refs = f.source().enumerate(SITE);
|
||||||
|
assertEquals(1, refs.size(), "the good entry survives its corrupt sibling");
|
||||||
|
assertEquals("good", f.source().resolve(SITE, "/blog/good", EN).orElseThrow().id());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void twoEntriesClaimingOnePathResolveDeterministically(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", new BlogEntry("one", Map.of("en", "One"), Map.of(), List.of("en"),
|
||||||
|
"shared", Map.of(), null, true, "2026-01-02", null, null), null);
|
||||||
|
f.store().save("acme", new BlogEntry("two", Map.of("en", "Two"), Map.of(), List.of("en"),
|
||||||
|
"shared", Map.of(), null, true, "2026-01-01", null, null), null);
|
||||||
|
String winner = f.source().resolve(SITE, "/blog/shared", EN).orElseThrow().id();
|
||||||
|
f.events().changed("acme", BlogContentSource.KEY, null);
|
||||||
|
assertEquals(winner, f.source().resolve(SITE, "/blog/shared", EN).orElseThrow().id(),
|
||||||
|
"one deterministic winner, the same after a rebuild");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aDisabledSiteServesAndListsNothing(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of("enabled", false));
|
||||||
|
f.store().save("acme", entry("hello", true), null);
|
||||||
|
assertTrue(f.source().enumerate(SITE).isEmpty());
|
||||||
|
assertEquals(Optional.empty(), f.source().resolve(SITE, "/blog/hello", EN));
|
||||||
|
assertTrue(!f.source().settings("acme").enabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aCustomPrefixRekeysEveryUrl(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of("prefix", "news/"));
|
||||||
|
f.store().save("acme", entry("hello", true), null);
|
||||||
|
assertEquals("/news/hello", f.source().enumerate(SITE).get(0).pathFor(EN), "normalized: leading /, no trailing");
|
||||||
|
assertEquals("hello", f.source().resolve(SITE, "/news/hello", EN).orElseThrow().id());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theRootPrefixServesEntriesAtTheTopLevel(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of("prefix", "/"));
|
||||||
|
f.store().save("acme", entry("hello", true), null);
|
||||||
|
assertEquals("/hello", f.source().enumerate(SITE).get(0).pathFor(EN), "never '//hello'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aPrefixTheKernelWouldNotServeFallsBackToBlog(@TempDir Path tmp) throws IOException {
|
||||||
|
for (String bad : List.of("/__admin", "/app", "/actuator", "/a|b", "/x/../y")) {
|
||||||
|
Fixture f = fixture(tmp.resolve("p" + Math.abs(bad.hashCode())), Map.of("prefix", bad));
|
||||||
|
assertEquals("/blog", f.source().settings("acme").prefix(),
|
||||||
|
bad + ": entries under it would silently vanish — the default is used instead");
|
||||||
|
}
|
||||||
|
for (String ok : List.of("/sitemap.xml", "/login", "/news/archive")) {
|
||||||
|
assertEquals(ok, fixture(tmp.resolve("ok" + Math.abs(ok.hashCode())), Map.of("prefix", ok))
|
||||||
|
.source().settings("acme").prefix(), ok + ": only the path an entry would get is checked");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theTemplateSettingFailsClosedToClassic(@TempDir Path tmp) throws IOException {
|
||||||
|
assertEquals("__plugin__/blog/entry-minimal",
|
||||||
|
fixture(tmp.resolve("a"), Map.of("template", "entry-minimal")).source().settings("acme").bodyTemplate());
|
||||||
|
assertEquals("__plugin__/blog/entry-classic",
|
||||||
|
fixture(tmp.resolve("b"), Map.of("template", "../../evil")).source().settings("acme").bodyTemplate(),
|
||||||
|
"an unknown template name never reaches the template lookup");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void indexableTextIsRenderedHtmlPerLocaleSoEnginesStripCleanly(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", entry("hello", true),
|
||||||
|
Map.of("en", "# Hi\n\nRunway makes [hosting](/x) simple.", "es", "# Hola"));
|
||||||
|
|
||||||
|
assertTrue(f.source().capabilities().has(ContentSource.CAP_INDEXABLE_TEXT),
|
||||||
|
"the blog opts into the search seam — entries are first-class search citizens");
|
||||||
|
String en = f.source().indexableText(SITE, "hello", EN);
|
||||||
|
assertTrue(en.contains("<h1>Hi</h1>"), "heading rendered, not left as '# Hi': " + en);
|
||||||
|
assertTrue(en.contains("<a href=\"/x\">hosting</a>"), "link rendered, not left as Markdown syntax: " + en);
|
||||||
|
assertTrue(f.source().indexableText(SITE, "hello", ES).contains("<h1>Hola</h1>"), "per-locale material");
|
||||||
|
assertEquals("", f.source().indexableText(SITE, "hello", Locale.FRENCH),
|
||||||
|
"an untranslated locale indexes as metadata only, never an error");
|
||||||
|
assertEquals("", f.source().indexableText(SITE, "no-such-entry", EN), "an unknown id degrades to empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Each entry carries ITS OWN publication date across the SPI boundary (not one shared schema block). */
|
||||||
|
@Test
|
||||||
|
void eachEntryCarriesItsOwnPublicationDate(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", new BlogEntry("older", Map.of("en", "Older"), Map.of(), List.of("en"),
|
||||||
|
null, Map.of(), null, true, "2026-03-04", null, null), null);
|
||||||
|
f.store().save("acme", new BlogEntry("newer", Map.of("en", "Newer"), Map.of(), List.of("en"),
|
||||||
|
null, Map.of(), null, true, "2026-09-10", null, null), null);
|
||||||
|
Map<String, ContentRef> refs = byId(f.source());
|
||||||
|
assertEquals(Instant.parse("2026-03-04T00:00:00Z"), refs.get("older").publishedAt());
|
||||||
|
assertEquals(Instant.parse("2026-09-10T00:00:00Z"), refs.get("newer").publishedAt());
|
||||||
|
assertNotEquals(refs.get("older").publishedAt(), refs.get("newer").publishedAt());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A free-form publishedOn yields NO date rather than a guess (a wrong datePublished is worse than none). */
|
||||||
|
@Test
|
||||||
|
void anUnparseablePublishedOnYieldsNoDateRatherThanAGuess(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", new BlogEntry("freeform", Map.of("en", "Freeform"), Map.of(), List.of("en"),
|
||||||
|
null, Map.of(), null, true, "last spring", null, null), null);
|
||||||
|
f.store().save("acme", new BlogEntry("undated", Map.of("en", "Undated"), Map.of(), List.of("en"),
|
||||||
|
null, Map.of(), null, true, null, null, null), null);
|
||||||
|
assertNull(byId(f.source()).get("freeform").publishedAt(), "a non-date must not become a fabricated instant");
|
||||||
|
assertNull(byId(f.source()).get("undated").publishedAt());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Each entry carries ITS OWN author across the SPI boundary, so structured data attributes the right person. */
|
||||||
|
@Test
|
||||||
|
void eachEntryCarriesItsOwnAuthor(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", new BlogEntry("ada", Map.of("en", "Ada"), Map.of(), List.of("en"),
|
||||||
|
null, Map.of(), null, true, "2026-03-04", "Jane Doe", null), null);
|
||||||
|
f.store().save("acme", new BlogEntry("anon", Map.of("en", "Anon"), Map.of(), List.of("en"),
|
||||||
|
null, Map.of(), null, true, "2026-03-04", " ", null), null);
|
||||||
|
assertEquals("Jane Doe", byId(f.source()).get("ada").author());
|
||||||
|
assertNull(byId(f.source()).get("anon").author(), "a blank byline must normalise to absent");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The byline reaches the RENDER attributes too — and is absent, not empty, when the entry has none. */
|
||||||
|
@Test
|
||||||
|
void theAuthorReachesTheRenderAttributes(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
f.store().save("acme", new BlogEntry("ada", Map.of("en", "Ada"), Map.of(), List.of("en"),
|
||||||
|
null, Map.of(), null, true, "2026-03-04", "Jane Doe", null), Map.of("en", "# Hello"));
|
||||||
|
f.store().save("acme", new BlogEntry("anon", Map.of("en", "Anon"), Map.of(), List.of("en"),
|
||||||
|
null, Map.of(), null, true, null, null, null), Map.of("en", "# Hi"));
|
||||||
|
assertEquals("Jane Doe", f.source().body(SITE, "ada", EN).attributes().get("author"));
|
||||||
|
assertEquals(Map.of(), f.source().body(SITE, "anon", EN).attributes(),
|
||||||
|
"an unattributed, undated entry puts nothing into the render attributes");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void publicPathsFollowTheRoutingSemantics(@TempDir Path tmp) throws IOException {
|
||||||
|
Fixture f = fixture(tmp, Map.of());
|
||||||
|
BlogEntry custom = new BlogEntry("launch", Map.of("en", "L"), Map.of(), List.of("en", "es"), "v2",
|
||||||
|
Map.of("es", "lanzamiento"), "/announcing-v2", true, null, null, null);
|
||||||
|
assertEquals("/announcing-v2", f.source().publicPath("acme", custom));
|
||||||
|
assertEquals("/blog/lanzamiento", f.source().publicPath("acme", custom, "es"), "the localized slug");
|
||||||
|
assertEquals("/announcing-v2", f.source().publicPath("acme", custom, "en"));
|
||||||
|
BlogEntry plain = new BlogEntry("plain", Map.of("en", "P"), Map.of(), List.of("en"), "slugged",
|
||||||
|
Map.of(), null, true, null, null, null);
|
||||||
|
assertEquals("/blog/slugged", f.source().publicPath("acme", plain));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,200 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import mx.quest.runway.spi.model.ContentBody;
|
||||||
|
import mx.quest.runway.spi.model.ContentRef;
|
||||||
|
import mx.quest.runway.spi.model.SiteView;
|
||||||
|
import mx.quest.runway.spi.testkit.FakeContentCatalog;
|
||||||
|
import mx.quest.runway.spi.testkit.FakePluginSettings;
|
||||||
|
import mx.quest.runway.spi.testkit.TempDirSiteFiles;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The entry body templates against the <b>documented body-template render model</b> — the SPI contract on
|
||||||
|
* {@code ContentSource} / {@code ContentRef.bodyTemplate} for {@code ${master}} and {@code ${content.*}}. The kernel
|
||||||
|
* promises exactly {@code master}, {@code content.{id, sourceKey, title, description, bodyHtml, attributes, updatedAt}},
|
||||||
|
* {@code locale} and {@code urls}; nothing else.
|
||||||
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li>Statically: every {@code ${…}} expression in the shipped entry templates starts from one of those four
|
||||||
|
* variables, and every {@code content.} key it reads is one the contract lists.</li>
|
||||||
|
* <li>Dynamically: an entry stored by {@link BlogStore} and projected by {@link BlogContentSource} renders through
|
||||||
|
* the real decoupled templates with a model built exactly to the contract — the tenant's master chrome around
|
||||||
|
* the Markdown body, the plugin's own labels, and the byline in each of its four states.</li>
|
||||||
|
* </ul>
|
||||||
|
* The real kernel render (routing, the locale ladder, the master resolution) is exercised by
|
||||||
|
* {@code scripts/verify-against-host.sh}.
|
||||||
|
*/
|
||||||
|
class BlogEntryTemplateContractTest {
|
||||||
|
|
||||||
|
private static final Set<String> MODEL_ROOTS = Set.of("master", "content", "locale", "urls");
|
||||||
|
private static final Set<String> CONTENT_KEYS =
|
||||||
|
Set.of("id", "sourceKey", "title", "description", "bodyHtml", "attributes", "updatedAt");
|
||||||
|
private static final List<String> ENTRY_TEMPLATES = List.of("entry-classic", "entry-minimal");
|
||||||
|
|
||||||
|
private static final Locale EN = Locale.ENGLISH;
|
||||||
|
private static final Locale ES = Locale.of("es");
|
||||||
|
private static final SiteView SITE = new SiteView("acme", "Acme", EN, List.of(EN, ES), null);
|
||||||
|
|
||||||
|
private static String liveLogic(String template) throws IOException {
|
||||||
|
return Files.readString(Path.of("templates", template + ".th.xml"), StandardCharsets.UTF_8)
|
||||||
|
.replaceAll("(?s)<!--.*?-->", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theEntryTemplatesReadOnlyTheDocumentedRenderModel() throws IOException {
|
||||||
|
Pattern expression = Pattern.compile("\\$\\{([^}]*)}");
|
||||||
|
Pattern root = Pattern.compile("^\\s*([A-Za-z_][\\w]*)");
|
||||||
|
Pattern contentKey = Pattern.compile("\\bcontent\\.(\\w+)");
|
||||||
|
Set<String> roots = new TreeSet<>();
|
||||||
|
Set<String> keys = new TreeSet<>();
|
||||||
|
for (String template : ENTRY_TEMPLATES) {
|
||||||
|
Matcher m = expression.matcher(liveLogic(template));
|
||||||
|
while (m.find()) {
|
||||||
|
Matcher r = root.matcher(m.group(1));
|
||||||
|
assertTrue(r.find(), template + ": an expression with no variable root: ${" + m.group(1) + "}");
|
||||||
|
roots.add(r.group(1));
|
||||||
|
Matcher k = contentKey.matcher(m.group(1));
|
||||||
|
while (k.find()) {
|
||||||
|
keys.add(k.group(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(MODEL_ROOTS.containsAll(roots), "variables outside the contract: " + roots);
|
||||||
|
assertTrue(CONTENT_KEYS.containsAll(keys), "content keys outside the contract: " + keys);
|
||||||
|
assertEquals(Set.of("master", "content", "urls"), roots, "the templates use the chrome, the payload and links");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theEntryTemplatesReferenceNoBeanAndOnlyThePluginsOwnMessages() throws IOException {
|
||||||
|
Set<String> bundle = BlogConfigTest.keys("i18n/messages.properties");
|
||||||
|
Pattern message = Pattern.compile("#\\{([^}(]+)");
|
||||||
|
for (String template : ENTRY_TEMPLATES) {
|
||||||
|
String logic = liveLogic(template);
|
||||||
|
assertFalse(logic.matches("(?s).*\\$\\{\\s*@.*"), template + " must not reach a bean (not in the contract)");
|
||||||
|
Matcher m = message.matcher(logic);
|
||||||
|
while (m.find()) {
|
||||||
|
assertTrue(bundle.contains(m.group(1).trim()), template + ": #{" + m.group(1)
|
||||||
|
+ "} is not in this plugin's bundle (a public page renders with the site's bundle + ours)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The model the kernel builds for a source item's 200 render, exactly as the SPI documents it. */
|
||||||
|
private static Map<String, Object> contractModel(String master, ContentRef ref, ContentBody body, Locale locale) {
|
||||||
|
Map<String, Object> content = new HashMap<>();
|
||||||
|
content.put("id", ref.id());
|
||||||
|
content.put("sourceKey", BlogContentSource.KEY);
|
||||||
|
content.put("title", ref.titleFor(locale));
|
||||||
|
content.put("description", ref.descriptionFor(locale));
|
||||||
|
content.put("bodyHtml", body.bodyHtml());
|
||||||
|
content.put("attributes", body.attributes());
|
||||||
|
content.put("updatedAt", ref.updatedAt() == null ? "" : ref.updatedAt().toString());
|
||||||
|
return Map.of("master", master, "content", Map.copyOf(content), "locale", locale,
|
||||||
|
"urls", Map.of("index", "/", "blog:" + ref.id(), ref.pathFor(locale)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private record Rig(TemplateHarness harness, BlogStore store, BlogContentSource source, String master) {
|
||||||
|
|
||||||
|
String render(String id, Locale locale) {
|
||||||
|
ContentRef ref = source.enumerate(SITE).stream().filter(r -> r.id().equals(id)).findFirst().orElseThrow();
|
||||||
|
return harness.render(ref.bodyTemplate(), locale,
|
||||||
|
contractModel(master, ref, source.body(SITE, id, locale), locale));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Rig rig(Path tmp, Map<String, Object> settings) throws IOException {
|
||||||
|
Path sites = tmp.resolve("sites");
|
||||||
|
Files.createDirectories(sites.resolve("acme"));
|
||||||
|
BlogStore store = new BlogStore(new TempDirSiteFiles(sites, "blog"));
|
||||||
|
BlogContentSource source = new BlogContentSource(store, new FakePluginSettings().site("acme", settings),
|
||||||
|
new FakeContentCatalog().site("acme"));
|
||||||
|
TemplateHarness harness = new TemplateHarness(tmp.resolve("templates"));
|
||||||
|
String master = harness.master("sites/acme/_master",
|
||||||
|
"<!DOCTYPE html><html><head><title>ACME-MASTER</title></head><body>"
|
||||||
|
+ "<header id=\"site-header\">acme header</header>"
|
||||||
|
+ "<main id=\"content\">m</main>"
|
||||||
|
+ "<footer id=\"site-footer\">acme footer</footer></body></html>");
|
||||||
|
return new Rig(harness, store, source, master);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BlogEntry entry(String id, String publishedOn, String author) {
|
||||||
|
return new BlogEntry(id, Map.of("en", "My first post", "es", "Mi primera entrada"),
|
||||||
|
Map.of("en", "The very first."), List.of("en", "es"), null, Map.of("es", "primera-entrada"),
|
||||||
|
null, true, publishedOn, author, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aMarkdownEntryRendersInsideTheTenantsChromeWithPluginLabels(@TempDir Path tmp) throws IOException {
|
||||||
|
Rig rig = rig(tmp, Map.of());
|
||||||
|
rig.store().save("acme", entry("first-post", "2026-07-17", null),
|
||||||
|
Map.of("en", "Hello **world**.", "es", "Hola **mundo**."));
|
||||||
|
|
||||||
|
String html = rig.render("first-post", EN);
|
||||||
|
assertTrue(html.contains("ACME-MASTER"), "the TENANT's master head wraps the entry");
|
||||||
|
assertTrue(html.contains("acme header") && html.contains("acme footer"), "tenant chrome seams");
|
||||||
|
assertTrue(html.contains("My first post"), "the entry title");
|
||||||
|
assertTrue(html.contains("Hello <strong>world</strong>."), "the Markdown body, rendered");
|
||||||
|
assertTrue(html.contains("Published on 2026-07-17") && html.contains("datetime=\"2026-07-17\""),
|
||||||
|
"the plugin's own #{} label + the publication date");
|
||||||
|
assertTrue(html.contains("href=\"/\""), "the back link reads urls['index']");
|
||||||
|
|
||||||
|
String es = rig.render("first-post", ES);
|
||||||
|
assertTrue(es.contains("Mi primera entrada") && es.contains("Hola <strong>mundo</strong>."), "the es payload");
|
||||||
|
assertTrue(es.contains("Publicado el 2026-07-17"), "the plugin's es label");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void anAuthoredEntryRendersAByline(@TempDir Path tmp) throws IOException {
|
||||||
|
Rig rig = rig(tmp, Map.of());
|
||||||
|
rig.store().save("acme", entry("authored", "2026-07-17", "Jane Doe"), Map.of("en", "Body."));
|
||||||
|
String html = rig.render("authored", EN);
|
||||||
|
assertTrue(html.contains("By Jane Doe"), () -> "expected a rendered byline; got:\n" + html);
|
||||||
|
assertTrue(html.contains("2026-07-17"), "the date still renders alongside it");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The meta line used to render only with a date; an undated but authored post must keep its byline. */
|
||||||
|
@Test
|
||||||
|
void anUndatedButAuthoredEntryStillRendersItsByline(@TempDir Path tmp) throws IOException {
|
||||||
|
Rig rig = rig(tmp, Map.of());
|
||||||
|
rig.store().save("acme", entry("undated", null, "Richard Roe"), Map.of("en", "Body."));
|
||||||
|
String html = rig.render("undated", EN);
|
||||||
|
assertTrue(html.contains("By Richard Roe"), () -> "an undated entry must still show its byline:\n" + html);
|
||||||
|
assertFalse(html.contains("Published on"), "…and must not show an empty date label");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void anEntryWithNeitherAuthorNorDateRendersNoMetaLine(@TempDir Path tmp) throws IOException {
|
||||||
|
Rig rig = rig(tmp, Map.of());
|
||||||
|
rig.store().save("acme", entry("bare", null, null), Map.of("en", "Body."));
|
||||||
|
String html = rig.render("bare", EN);
|
||||||
|
assertFalse(html.contains("blog-entry-meta"), () -> "no meta line when there is nothing in it:\n" + html);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theMinimalTemplateRendersTitleAndBodyOnly(@TempDir Path tmp) throws IOException {
|
||||||
|
Rig rig = rig(tmp, Map.of("template", "entry-minimal"));
|
||||||
|
rig.store().save("acme", entry("min", "2026-07-17", "Jane Doe"), Map.of("en", "Just **this**."));
|
||||||
|
String html = rig.render("min", EN);
|
||||||
|
assertTrue(html.contains("ACME-MASTER") && html.contains("acme footer"), "the same tenant chrome");
|
||||||
|
assertTrue(html.contains("My first post") && html.contains("Just <strong>this</strong>."), "title + body");
|
||||||
|
assertFalse(html.contains("Jane Doe") || html.contains("Published on") || html.contains("entry-back"),
|
||||||
|
"no byline, no date, no back link");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,266 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.attribute.FileTime;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import mx.quest.runway.spi.testkit.TempDirSiteFiles;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link BlogStore} over the kernel's {@code PluginSiteFiles} (the testkit's {@link TempDirSiteFiles}, which applies
|
||||||
|
* the kernel's confinement rules): the {@code entries/<id>/entry.yml} + {@code body-<lang>.md} layout under the
|
||||||
|
* site's own folder, the metadata/body split, id/lang safety, the derived {@code updatedAt} — and that entries
|
||||||
|
* <b>written by blog 1.3.1</b> (the fixture under {@code src/test/resources/fixtures/blog-1.3.1}, produced by the
|
||||||
|
* 1.3.1 store itself) load unchanged, and are written back byte for byte.
|
||||||
|
*/
|
||||||
|
class BlogStoreTest {
|
||||||
|
|
||||||
|
static final Path FIXTURE = Path.of("src/test/resources/fixtures/blog-1.3.1/entries");
|
||||||
|
|
||||||
|
private static BlogStore store(Path sites) throws IOException {
|
||||||
|
Files.createDirectories(sites.resolve("acme"));
|
||||||
|
Files.createDirectories(sites.resolve("globex"));
|
||||||
|
return new BlogStore(new TempDirSiteFiles(sites, "blog"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BlogEntry entry(String id) {
|
||||||
|
return new BlogEntry(id, Map.of("en", "Hello", "es", "Hola"), Map.of("en", "First post"),
|
||||||
|
List.of("en", "es"), null, Map.of("es", "hola-mundo"), null, true, "2026-07-17", null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Copies the 1.3.1 entries into a site's plugin subtree, exactly where 1.3.1 kept them. */
|
||||||
|
static Path install131(Path sites, String siteId) throws IOException {
|
||||||
|
Path entries = sites.resolve(siteId).resolve("plugins/blog/entries");
|
||||||
|
try (Stream<Path> walk = Files.walk(FIXTURE)) {
|
||||||
|
for (Path from : walk.toList()) {
|
||||||
|
Path to = entries.resolve(FIXTURE.relativize(from).toString());
|
||||||
|
if (Files.isDirectory(from)) {
|
||||||
|
Files.createDirectories(to);
|
||||||
|
} else {
|
||||||
|
Files.copy(from, to);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void saveAndReadRoundTripWithBodies(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
store.save("acme", entry("hello-world"), Map.of("en", "# Hi\n\nBody.", "es", "# Hola"));
|
||||||
|
|
||||||
|
BlogEntry read = store.read("acme", "hello-world").orElseThrow();
|
||||||
|
assertEquals("hello-world", read.id(), "the folder name is the id (never stored in the YAML)");
|
||||||
|
assertEquals("Hello", read.title().get("en"));
|
||||||
|
assertEquals("hola-mundo", read.localizedSlugs().get("es"));
|
||||||
|
assertEquals("hello-world", read.effectiveSlug(), "no explicit slug → the id");
|
||||||
|
assertTrue(read.published());
|
||||||
|
assertNotNull(read.updatedAt(), "updatedAt derived from file times");
|
||||||
|
assertEquals("# Hi\n\nBody.", store.readBody("acme", "hello-world", "en"));
|
||||||
|
assertEquals("", store.readBody("acme", "hello-world", "fr"), "no body for that language → empty");
|
||||||
|
assertEquals(List.of("en", "es"), store.bodyLangs("acme", "hello-world"));
|
||||||
|
|
||||||
|
// The files land inside the site's own folder, in the plugin's subtree — the backup-completeness guarantee.
|
||||||
|
Path dir = sites.resolve("acme/plugins/blog/entries/hello-world");
|
||||||
|
assertTrue(Files.isRegularFile(dir.resolve("entry.yml")));
|
||||||
|
assertTrue(Files.isRegularFile(dir.resolve("body-en.md")));
|
||||||
|
assertFalse(Files.readString(dir.resolve("entry.yml")).contains("hello-world"),
|
||||||
|
"the id is never written into the YAML");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void entriesWrittenBy131LoadUnchanged(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
install131(sites, "acme");
|
||||||
|
|
||||||
|
assertEquals(List.of("launch", "no-author", "hello-world", "draft-post"),
|
||||||
|
store.list("acme").stream().map(BlogEntry::id).toList(),
|
||||||
|
"all four, newest publication date first, undated last");
|
||||||
|
|
||||||
|
BlogEntry hello = store.read("acme", "hello-world").orElseThrow();
|
||||||
|
assertEquals(Map.of("en", "Hello world", "es", "Hola mundo"), hello.title());
|
||||||
|
assertEquals(Map.of("en", "The very first post.", "es", "La primera entrada."), hello.description());
|
||||||
|
assertEquals(List.of("en", "es"), hello.locales());
|
||||||
|
assertEquals(Map.of("es", "hola-mundo"), hello.localizedSlugs());
|
||||||
|
assertTrue(hello.published());
|
||||||
|
assertEquals("2026-07-17", hello.publishedOn());
|
||||||
|
assertEquals("Jane Doe", hello.author());
|
||||||
|
assertNotNull(hello.updatedAt());
|
||||||
|
assertEquals("# Hello\n\nSome **bold** words and a [link](/about).\n",
|
||||||
|
store.readBody("acme", "hello-world", "en"));
|
||||||
|
assertEquals(List.of("en", "es"), store.bodyLangs("acme", "hello-world"));
|
||||||
|
|
||||||
|
BlogEntry unattributed = store.read("acme", "no-author").orElseThrow();
|
||||||
|
assertNull(unattributed.author(), "an entry 1.3.1 wrote without an author loads unattributed");
|
||||||
|
assertEquals("2026-08-01", unattributed.publishedOn());
|
||||||
|
assertTrue(unattributed.published());
|
||||||
|
|
||||||
|
BlogEntry launch = store.read("acme", "launch").orElseThrow();
|
||||||
|
assertEquals("v2", launch.slug());
|
||||||
|
assertEquals("/announcing-v2", launch.customPath());
|
||||||
|
assertEquals("Richard Roe", launch.author());
|
||||||
|
|
||||||
|
BlogEntry draft = store.read("acme", "draft-post").orElseThrow();
|
||||||
|
assertFalse(draft.published());
|
||||||
|
assertNull(draft.publishedOn());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void savingAn131EntryBackWritesTheSameBytes(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
Path entries = install131(sites, "acme");
|
||||||
|
for (String id : List.of("hello-world", "no-author", "launch", "draft-post")) {
|
||||||
|
String before = Files.readString(entries.resolve(id).resolve("entry.yml"), StandardCharsets.UTF_8);
|
||||||
|
store.save("acme", store.read("acme", id).orElseThrow(), null);
|
||||||
|
assertEquals(before, Files.readString(entries.resolve(id).resolve("entry.yml"), StandardCharsets.UTF_8),
|
||||||
|
id + ": entry.yml is written back exactly as the 1.3.1 store wrote it");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aHandWrittenEntryWithMissingAndUnknownKeysStillLoads(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
Path dir = sites.resolve("acme/plugins/blog/entries/by-hand");
|
||||||
|
Files.createDirectories(dir);
|
||||||
|
Files.writeString(dir.resolve("entry.yml"), "title:\n en: \"By hand\"\nfutureKey: 42\n");
|
||||||
|
BlogEntry entry = store.read("acme", "by-hand").orElseThrow();
|
||||||
|
assertEquals("By hand", entry.title().get("en"));
|
||||||
|
assertFalse(entry.published(), "an omitted 'published:' defaults (lenient), never fails the entry");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void anEmptyEntryFileIsAbsent(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
Path dir = sites.resolve("acme/plugins/blog/entries/empty");
|
||||||
|
Files.createDirectories(dir);
|
||||||
|
Files.writeString(dir.resolve("entry.yml"), "");
|
||||||
|
assertTrue(store.read("acme", "empty").isEmpty());
|
||||||
|
assertTrue(store.list("acme").isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void updatedAtIsTheNewestFileTimeOfTheEntry(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
store.save("acme", entry("post"), Map.of("en", "body"));
|
||||||
|
Path dir = sites.resolve("acme/plugins/blog/entries/post");
|
||||||
|
Files.setLastModifiedTime(dir.resolve("entry.yml"), FileTime.from(Instant.parse("2026-01-01T00:00:00Z")));
|
||||||
|
Files.setLastModifiedTime(dir.resolve("body-en.md"), FileTime.from(Instant.parse("2026-03-01T00:00:00Z")));
|
||||||
|
assertEquals(Instant.parse("2026-03-01T00:00:00Z"), store.read("acme", "post").orElseThrow().updatedAt(),
|
||||||
|
"a body-only edit moves updatedAt (and so the ETag and <lastmod>)");
|
||||||
|
Files.setLastModifiedTime(dir.resolve("entry.yml"), FileTime.from(Instant.parse("2026-05-01T00:00:00Z")));
|
||||||
|
assertEquals(Instant.parse("2026-05-01T00:00:00Z"), store.read("acme", "post").orElseThrow().updatedAt());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aBlankBodyDeletesThatLanguagesFile(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
store.save("acme", entry("post"), Map.of("en", "text", "es", "texto"));
|
||||||
|
Map<String, String> bodies = new java.util.HashMap<>();
|
||||||
|
bodies.put("es", " ");
|
||||||
|
bodies.put("fr", null);
|
||||||
|
store.save("acme", entry("post"), bodies);
|
||||||
|
assertEquals("text", store.readBody("acme", "post", "en"), "untouched language kept");
|
||||||
|
assertEquals("", store.readBody("acme", "post", "es"), "blanked language's file removed");
|
||||||
|
assertEquals(List.of("en"), store.bodyLangs("acme", "post"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void deleteRemovesTheWholeEntry(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
store.save("acme", entry("gone"), Map.of("en", "x", "es", "y"));
|
||||||
|
store.save("acme", entry("kept"), Map.of("en", "z"));
|
||||||
|
store.delete("acme", "gone");
|
||||||
|
assertTrue(store.read("acme", "gone").isEmpty());
|
||||||
|
assertFalse(Files.exists(sites.resolve("acme/plugins/blog/entries/gone")));
|
||||||
|
assertTrue(store.read("acme", "kept").isPresent(), "only that entry");
|
||||||
|
store.delete("acme", "never-existed");
|
||||||
|
store.delete("acme", "../escape");
|
||||||
|
assertTrue(Files.isDirectory(sites.resolve("acme/plugins/blog/entries")), "unsafe ids are a no-op");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void unsafeIdsNeverTouchThePathAndUnsafeLangsThrowBeforeWriting(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
assertTrue(store.read("acme", "../escape").isEmpty(), "a traversal id is an empty read, not a probe");
|
||||||
|
assertTrue(store.read("acme", "has:colon").isEmpty(), "':' is out — blog:<id> must stay unambiguous");
|
||||||
|
assertEquals("", store.readBody("acme", "x", "../en"), "a traversal lang reads empty");
|
||||||
|
assertEquals("", store.readBody("acme", "../x", "en"), "a traversal id reads empty");
|
||||||
|
assertEquals(List.of(), store.bodyLangs("acme", "../x"));
|
||||||
|
assertThrows(IllegalArgumentException.class,
|
||||||
|
() -> store.save("acme", entry("post"), Map.of("../en", "x")), "an unsafe lang never writes");
|
||||||
|
assertTrue(store.read("acme", "post").isEmpty(), "…not even the metadata");
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> BlogStore.requireSafeId("Bad:Id"));
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> BlogStore.requireSafeId(null));
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> store.save("acme", entry("-bad"), null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void listSortsNewestFirstAndSkipsForeignFoldersAndFiles(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
store.save("acme", new BlogEntry("older", Map.of("en", "Old"), Map.of(), List.of("en"), null,
|
||||||
|
Map.of(), null, true, "2026-01-01", null, null), null);
|
||||||
|
store.save("acme", new BlogEntry("newer", Map.of("en", "New"), Map.of(), List.of("en"), null,
|
||||||
|
Map.of(), null, true, "2026-07-01", null, null), null);
|
||||||
|
store.save("acme", new BlogEntry("a-same-day", Map.of("en", "A"), Map.of(), List.of("en"), null,
|
||||||
|
Map.of(), null, true, "2026-07-01", null, null), null);
|
||||||
|
Files.createDirectories(sites.resolve("acme/plugins/blog/entries/.hidden-junk"));
|
||||||
|
Files.writeString(sites.resolve("acme/plugins/blog/entries/stray-file"), "x");
|
||||||
|
Files.createDirectories(sites.resolve("acme/plugins/blog/entries/no-metadata"));
|
||||||
|
|
||||||
|
assertEquals(List.of("a-same-day", "newer", "older"),
|
||||||
|
store.list("acme").stream().map(BlogEntry::id).toList(),
|
||||||
|
"newest publication date first, then id; non-conforming folders, files and empty folders skipped");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aCorruptEntryIsSkippedNotFatal(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
store.save("acme", entry("good"), Map.of("en", "fine"));
|
||||||
|
Path corrupt = sites.resolve("acme/plugins/blog/entries/broken");
|
||||||
|
Files.createDirectories(corrupt);
|
||||||
|
Files.writeString(corrupt.resolve("entry.yml"), "title: [unclosed");
|
||||||
|
assertEquals(List.of("good"), store.list("acme").stream().map(BlogEntry::id).toList());
|
||||||
|
assertTrue(store.read("acme", "broken").isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aSymlinkedEntryFolderCannotLeadOutOfTheSubtree(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
store.save("acme", entry("good"), Map.of("en", "fine"));
|
||||||
|
// Another site's data, reached through a link planted inside acme's blog folder.
|
||||||
|
store.save("globex", entry("secret"), Map.of("en", "globex only"));
|
||||||
|
Files.createSymbolicLink(sites.resolve("acme/plugins/blog/entries/secret"),
|
||||||
|
sites.resolve("globex/plugins/blog/entries/secret"));
|
||||||
|
assertEquals(List.of("good"), store.list("acme").stream().map(BlogEntry::id).toList(),
|
||||||
|
"a link is never listed");
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> store.read("acme", "secret"),
|
||||||
|
"reading through the link is refused by the kernel's real-path rule");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void sitesAreIsolated(@TempDir Path sites) throws IOException {
|
||||||
|
BlogStore store = store(sites);
|
||||||
|
store.save("acme", entry("post"), Map.of("en", "acme text"));
|
||||||
|
assertTrue(store.list("globex").isEmpty());
|
||||||
|
assertEquals("", store.readBody("globex", "post", "en"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aSiteWithNoBlogFolderListsNothing(@TempDir Path sites) throws IOException {
|
||||||
|
assertTrue(store(sites).list("acme").isEmpty());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package mx.quest.blog;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UncheckedIOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import org.springframework.context.support.GenericApplicationContext;
|
||||||
|
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
||||||
|
import org.springframework.core.convert.support.DefaultConversionService;
|
||||||
|
import org.thymeleaf.context.Context;
|
||||||
|
import org.thymeleaf.spring6.SpringTemplateEngine;
|
||||||
|
import org.thymeleaf.spring6.expression.ThymeleafEvaluationContext;
|
||||||
|
import org.thymeleaf.templatemode.TemplateMode;
|
||||||
|
import org.thymeleaf.templateresolver.FileTemplateResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders this plugin's SHIPPED templates ({@code templates/*.html} + their decoupled {@code .th.xml} logic) with
|
||||||
|
* Thymeleaf's own Spring engine — no kernel class. The templates are copied under the logical names the kernel uses
|
||||||
|
* ({@code __plugin__/blog/<name>}), a site master can be added next to them, and {@code #{…}} resolves from this
|
||||||
|
* plugin's own bundles ({@code i18n/messages*.properties}), as the kernel appends them.
|
||||||
|
*
|
||||||
|
* <p>What this cannot see is anything the kernel adds beyond the documented render model — which is the point: a
|
||||||
|
* template that renders here needs nothing but the contract.
|
||||||
|
*/
|
||||||
|
final class TemplateHarness {
|
||||||
|
|
||||||
|
private final Path root;
|
||||||
|
private final SpringTemplateEngine engine;
|
||||||
|
|
||||||
|
TemplateHarness(Path root) {
|
||||||
|
this.root = root;
|
||||||
|
try {
|
||||||
|
Path target = root.resolve("__plugin__/blog");
|
||||||
|
Files.createDirectories(target);
|
||||||
|
try (Stream<Path> files = Files.list(Path.of("templates"))) {
|
||||||
|
for (Path file : files.toList()) {
|
||||||
|
Files.copy(file, target.resolve(file.getFileName().toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new UncheckedIOException(e);
|
||||||
|
}
|
||||||
|
FileTemplateResolver resolver = new FileTemplateResolver();
|
||||||
|
resolver.setPrefix(root.toAbsolutePath() + "/");
|
||||||
|
resolver.setSuffix(".html");
|
||||||
|
resolver.setTemplateMode(TemplateMode.HTML);
|
||||||
|
resolver.setCharacterEncoding("UTF-8");
|
||||||
|
resolver.setUseDecoupledLogic(true);
|
||||||
|
resolver.setCacheable(false);
|
||||||
|
ReloadableResourceBundleMessageSource messages = new ReloadableResourceBundleMessageSource();
|
||||||
|
messages.setBasename("file:" + Path.of("i18n/messages").toAbsolutePath());
|
||||||
|
messages.setDefaultEncoding("UTF-8");
|
||||||
|
messages.setFallbackToSystemLocale(false);
|
||||||
|
engine = new SpringTemplateEngine();
|
||||||
|
engine.setTemplateResolver(resolver);
|
||||||
|
engine.setTemplateEngineMessageSource(messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Writes a site master ({@code <name>.html} + an empty logic file) and returns its logical name. */
|
||||||
|
String master(String name, String html) {
|
||||||
|
try {
|
||||||
|
Path file = root.resolve(name + ".html");
|
||||||
|
Files.createDirectories(file.getParent());
|
||||||
|
Files.writeString(file, html, StandardCharsets.UTF_8);
|
||||||
|
Files.writeString(root.resolve(name + ".th.xml"), "<?xml version=\"1.0\"?><thlogic></thlogic>",
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
return name;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new UncheckedIOException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String render(String template, Locale locale, Map<String, Object> vars) {
|
||||||
|
GenericApplicationContext app = new GenericApplicationContext();
|
||||||
|
app.refresh();
|
||||||
|
Context ctx = new Context(locale);
|
||||||
|
vars.forEach(ctx::setVariable);
|
||||||
|
ctx.setVariable(ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME,
|
||||||
|
new ThymeleafEvaluationContext(app, DefaultConversionService.getSharedInstance()));
|
||||||
|
return engine.process(template, ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Not yet.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
title:
|
||||||
|
en: "Work in progress"
|
||||||
|
description: {}
|
||||||
|
locales:
|
||||||
|
- "en"
|
||||||
|
localizedSlugs: {}
|
||||||
|
published: false
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Hello
|
||||||
|
|
||||||
|
Some **bold** words and a [link](/about).
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Hola
|
||||||
|
|
||||||
|
Unas palabras **en negrita**.
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
title:
|
||||||
|
es: "Hola mundo"
|
||||||
|
en: "Hello world"
|
||||||
|
description:
|
||||||
|
es: "La primera entrada."
|
||||||
|
en: "The very first post."
|
||||||
|
locales:
|
||||||
|
- "en"
|
||||||
|
- "es"
|
||||||
|
localizedSlugs:
|
||||||
|
es: "hola-mundo"
|
||||||
|
published: true
|
||||||
|
publishedOn: "2026-07-17"
|
||||||
|
author: "Jane Doe"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Version two is here.
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
title:
|
||||||
|
en: "Announcing v2"
|
||||||
|
description: {}
|
||||||
|
locales:
|
||||||
|
- "en"
|
||||||
|
slug: "v2"
|
||||||
|
localizedSlugs: {}
|
||||||
|
customPath: "/announcing-v2"
|
||||||
|
published: true
|
||||||
|
publishedOn: "2026-09-10"
|
||||||
|
author: "Richard Roe"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Written before bylines existed.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title:
|
||||||
|
en: "Unattributed"
|
||||||
|
description:
|
||||||
|
en: "Nobody signed this."
|
||||||
|
locales:
|
||||||
|
- "en"
|
||||||
|
localizedSlugs: {}
|
||||||
|
published: true
|
||||||
|
publishedOn: "2026-08-01"
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head><meta charset="utf-8"><title>Blog entry</title></head>
|
||||||
|
<body>
|
||||||
|
<div id="content">
|
||||||
|
<div class="page-header d-print-none mb-3">
|
||||||
|
<div class="row align-items-center">
|
||||||
|
<div class="col">
|
||||||
|
<div class="page-pretitle" id="be-pretitle">Site</div>
|
||||||
|
<h2 class="page-title" id="be-heading">Edit entry</h2>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto"><a class="btn" id="be-back" href="/__admin/blog">Back to blog</a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- The reverse advisory: a real PAGE owns this entry's URL — the
|
||||||
|
page wins, so the entry is unreachable there. Rendered only when it applies. -->
|
||||||
|
<div class="alert alert-warning" id="be-shadowed" role="alert">
|
||||||
|
<span id="be-shadowed-text">A page owns this entry's address.</span>
|
||||||
|
<span id="be-shadowed-by" class="font-monospace">page</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="be-form" method="post" action="/__admin/blog/x">
|
||||||
|
<input id="be-csrf" type="hidden" name="_csrf" value="">
|
||||||
|
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-header"><h3 class="card-title" id="be-l-entry">Entry</h3></div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="row g-3">
|
||||||
|
<div class="col-md-4" id="be-id-wrap">
|
||||||
|
<label class="form-label" id="be-l-id" for="be-id">Id</label>
|
||||||
|
<input id="be-id" class="form-control font-monospace" type="text" name="id" value=""
|
||||||
|
placeholder="my-first-post">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<label class="form-label" id="be-l-date" for="be-date">Publication date</label>
|
||||||
|
<input id="be-date" class="form-control" type="date" name="publishedOn" value="">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<label class="form-label" id="be-l-author" for="be-author">Author</label>
|
||||||
|
<input id="be-author" class="form-control" type="text" name="author" value=""
|
||||||
|
placeholder="Jane Doe">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<label class="form-label" id="be-l-custom" for="be-custom">Custom path</label>
|
||||||
|
<input id="be-custom" class="form-control font-monospace" type="text" name="customPath"
|
||||||
|
value="" placeholder="/announcing-v2">
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<label class="form-check form-switch">
|
||||||
|
<input id="be-published" class="form-check-input" type="checkbox" name="published">
|
||||||
|
<span class="form-check-label" id="be-l-published">Published</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- One card per site language: title, description, slug, body (Markdown). -->
|
||||||
|
<div class="card mb-3" id="be-lang-card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3 class="card-title"><span id="be-lang-name">en</span></h3>
|
||||||
|
<div class="card-actions">
|
||||||
|
<label class="form-check mb-0">
|
||||||
|
<input id="be-lang-on" class="form-check-input" type="checkbox" name="locales_en">
|
||||||
|
<span class="form-check-label" id="be-l-langon">Published in this language</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="row g-3">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<label class="form-label be-l-title">Title</label>
|
||||||
|
<input class="form-control be-title" type="text" name="title_en" value="">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<label class="form-label be-l-slug">Slug</label>
|
||||||
|
<input class="form-control font-monospace be-slug" type="text" name="slug_en" value="">
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<label class="form-label be-l-desc">Description</label>
|
||||||
|
<input class="form-control be-desc" type="text" name="description_en" value="">
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<label class="form-label be-l-body">Body (Markdown)</label>
|
||||||
|
<textarea class="form-control font-monospace be-body" name="body_en" rows="10"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary" id="be-save">Save</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Blog entry editor. One language card per SITE locale (th:each over siteLocaleTags); the default
|
||||||
|
language's slug field doubles as the base slug. On CREATE the form posts to /create with an editable id;
|
||||||
|
on EDIT the id is readonly and the form posts to /__admin/blog/<id>. `//` reaches nested elements
|
||||||
|
(`/` matches direct children only); the published/keep ternaries stay at the Thymeleaf level (a message
|
||||||
|
expression cannot nest inside a SpEL expression). -->
|
||||||
|
<thlogic>
|
||||||
|
<attr sel="#be-pretitle" th:text="#{blog.admin.pretitle}"/>
|
||||||
|
<attr sel="#be-heading" th:text="${creating} ? #{blog.edit.headingNew} : #{blog.edit.heading}"/>
|
||||||
|
<attr sel="#be-back" th:text="#{blog.edit.back}"/>
|
||||||
|
|
||||||
|
<attr sel="#be-shadowed" th:if="${!shadowedBy.isEmpty()}"/>
|
||||||
|
<attr sel="#be-shadowed-text" th:text="#{blog.edit.shadowed}"/>
|
||||||
|
<attr sel="#be-shadowed-by" th:text="${#strings.listJoin(shadowedBy, ', ')}"/>
|
||||||
|
|
||||||
|
<!-- The action is model-computed (two '/__admin' literals in one expression would trip Thymeleaf's
|
||||||
|
__…__ preprocessing). -->
|
||||||
|
<attr sel="#be-form" th:attr="action=${formAction}"/>
|
||||||
|
<attr sel="#be-csrf"
|
||||||
|
th:attr="name=${_csrf != null ? _csrf.parameterName : '_csrf'},value=${_csrf != null ? _csrf.token : ''}"/>
|
||||||
|
|
||||||
|
<attr sel="#be-l-entry" th:text="#{blog.edit.entry}"/>
|
||||||
|
<attr sel="#be-l-id" th:text="#{blog.edit.id}"/>
|
||||||
|
<attr sel="#be-id" th:attr="value=${creating ? '' : entry.id()},readonly=${creating ? null : 'readonly'},
|
||||||
|
title=#{blog.edit.id.tip}"/>
|
||||||
|
<attr sel="#be-l-date" th:text="#{blog.edit.date}"/>
|
||||||
|
<attr sel="#be-date" th:attr="value=${entry.publishedOn()}"/>
|
||||||
|
<attr sel="#be-l-author" th:text="#{blog.edit.author}"/>
|
||||||
|
<attr sel="#be-author" th:attr="value=${entry.author()},title=#{blog.edit.author.tip}"/>
|
||||||
|
<attr sel="#be-l-custom" th:text="#{blog.edit.customPath}"/>
|
||||||
|
<attr sel="#be-custom" th:attr="value=${entry.customPath()},title=#{blog.edit.customPath.tip}"/>
|
||||||
|
<attr sel="#be-l-published" th:text="#{blog.edit.published}"/>
|
||||||
|
<attr sel="#be-published" th:attr="checked=${entry.published() ? 'checked' : null}"/>
|
||||||
|
|
||||||
|
<!-- One card per site language; every inner field is renamed to its <field>_<lang> form name. -->
|
||||||
|
<attr sel="#be-lang-card" th:each="lang : ${siteLocaleTags}"/>
|
||||||
|
<attr sel="#be-lang-card//#be-lang-name"
|
||||||
|
th:text="${lang == defaultLocaleTag} ? (${lang} + ' · ' + #{blog.edit.defaultLang}) : ${lang}"/>
|
||||||
|
<attr sel="#be-lang-card//#be-lang-on"
|
||||||
|
th:attr="name='locales_' + ${lang},checked=${entry.locales().contains(lang) ? 'checked' : null}"/>
|
||||||
|
<attr sel="#be-lang-card//#be-l-langon" th:text="#{blog.edit.langOn}"/>
|
||||||
|
<attr sel="#be-lang-card//.be-l-title" th:text="#{blog.edit.title}"/>
|
||||||
|
<attr sel="#be-lang-card//.be-title"
|
||||||
|
th:attr="name='title_' + ${lang},value=${entry.title().get(lang)}"/>
|
||||||
|
<attr sel="#be-lang-card//.be-l-slug" th:text="#{blog.edit.slug}"/>
|
||||||
|
<attr sel="#be-lang-card//.be-slug"
|
||||||
|
th:attr="name='slug_' + ${lang},title=#{blog.edit.slug.tip},
|
||||||
|
value=${lang == defaultLocaleTag ? entry.effectiveSlug() : entry.localizedSlugs().get(lang)}"/>
|
||||||
|
<attr sel="#be-lang-card//.be-l-desc" th:text="#{blog.edit.description}"/>
|
||||||
|
<attr sel="#be-lang-card//.be-desc"
|
||||||
|
th:attr="name='description_' + ${lang},value=${entry.description().get(lang)}"/>
|
||||||
|
<attr sel="#be-lang-card//.be-l-body" th:text="#{blog.edit.body}"/>
|
||||||
|
<attr sel="#be-lang-card//.be-body"
|
||||||
|
th:attr="name='body_' + ${lang}" th:text="${bodies.get(lang)}"/>
|
||||||
|
|
||||||
|
<attr sel="#be-save" th:text="#{blog.edit.save}"/>
|
||||||
|
</thlogic>
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head><meta charset="utf-8"><title>Blog</title></head>
|
||||||
|
<body>
|
||||||
|
<div id="content">
|
||||||
|
<div class="page-header d-print-none mb-3">
|
||||||
|
<div class="row align-items-center">
|
||||||
|
<div class="col">
|
||||||
|
<div class="page-pretitle" id="bl-pretitle">Site</div>
|
||||||
|
<h2 class="page-title" id="bl-heading">Blog</h2>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto"><a class="btn btn-primary" id="bl-new" href="/__admin/blog/new">New entry</a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="alert alert-warning" id="bl-disabled" role="alert">
|
||||||
|
<span id="bl-disabled-text">The blog is disabled for this site (see the plugin's settings) — entries are
|
||||||
|
kept but none serves.</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-vcenter card-table" data-listing-table="runway.admin.blog">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-col-key="id" id="bl-h-id">Entry</th>
|
||||||
|
<th data-col-key="path" id="bl-h-path">Path</th>
|
||||||
|
<th data-col-key="langs" id="bl-h-langs">Languages</th>
|
||||||
|
<th data-col-key="date" id="bl-h-date">Date</th>
|
||||||
|
<th data-col-key="status" id="bl-h-status">Status</th>
|
||||||
|
<th data-nosort data-col-key="actions" id="bl-h-actions" class="w-1">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr id="bl-empty"><td colspan="6" class="text-secondary text-center" id="bl-empty-text">No entries yet.</td></tr>
|
||||||
|
<tr id="bl-row">
|
||||||
|
<td class="b-id font-monospace">id</td>
|
||||||
|
<td class="b-path text-secondary">—</td>
|
||||||
|
<td class="b-langs text-secondary">—</td>
|
||||||
|
<td class="b-date text-secondary">—</td>
|
||||||
|
<td><span class="badge b-badge">status</span></td>
|
||||||
|
<td>
|
||||||
|
<div class="btn-list flex-nowrap">
|
||||||
|
<a class="btn btn-sm b-edit" href="#">Edit</a>
|
||||||
|
<form class="b-publish-form d-inline" method="post" action="#">
|
||||||
|
<input class="b-csrf" type="hidden" name="_csrf" value="">
|
||||||
|
<button type="submit" class="btn btn-sm b-publish">Publish</button>
|
||||||
|
</form>
|
||||||
|
<form class="b-delete-form d-inline" method="post" action="#">
|
||||||
|
<input class="b-csrf" type="hidden" name="_csrf" value="">
|
||||||
|
<button type="submit" class="btn btn-sm btn-outline-danger b-delete"
|
||||||
|
data-confirm="Delete this entry and all its languages?">Delete</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Blog console list. One row per entry; the publish/delete forms are real POSTs (CSRF hidden input injected
|
||||||
|
per form — the per-site token from ${_csrf}). `//` reaches nested elements (`/` matches direct children only). -->
|
||||||
|
<thlogic>
|
||||||
|
<attr sel="#bl-pretitle" th:text="#{blog.admin.pretitle}"/>
|
||||||
|
<attr sel="#bl-heading" th:text="#{blog.admin.heading}"/>
|
||||||
|
<attr sel="#bl-new" th:text="#{blog.admin.new}" th:attr="title=#{blog.admin.new.tip}"/>
|
||||||
|
|
||||||
|
<attr sel="#bl-disabled" th:if="${!blogEnabled}"/>
|
||||||
|
<attr sel="#bl-disabled-text" th:text="#{blog.admin.disabled}"/>
|
||||||
|
|
||||||
|
<attr sel="#bl-h-id" th:text="#{blog.admin.col.entry}"/>
|
||||||
|
<attr sel="#bl-h-path" th:text="#{blog.admin.col.path}"/>
|
||||||
|
<attr sel="#bl-h-langs" th:text="#{blog.admin.col.langs}"/>
|
||||||
|
<attr sel="#bl-h-date" th:text="#{blog.admin.col.date}"/>
|
||||||
|
<attr sel="#bl-h-status" th:text="#{blog.admin.col.status}"/>
|
||||||
|
<attr sel="#bl-h-actions" th:text="#{blog.admin.col.actions}"/>
|
||||||
|
|
||||||
|
<attr sel="#bl-empty" th:if="${rows.isEmpty()}"/>
|
||||||
|
<attr sel="#bl-empty-text" th:text="#{blog.admin.empty}"/>
|
||||||
|
|
||||||
|
<attr sel="#bl-row" th:each="row : ${rows}"/>
|
||||||
|
<attr sel="#bl-row//.b-id" th:text="${row.entry().id()}"/>
|
||||||
|
<attr sel="#bl-row//.b-path" th:text="${row.publicPath()}"/>
|
||||||
|
<attr sel="#bl-row//.b-langs"
|
||||||
|
th:text="${row.entry().locales().isEmpty() ? '—' : #strings.listJoin(row.entry().locales(), ', ')}"/>
|
||||||
|
<attr sel="#bl-row//.b-date" th:text="${row.entry().publishedOn() != null ? row.entry().publishedOn() : '—'}"/>
|
||||||
|
<attr sel="#bl-row//.b-badge" th:text="${row.entry().published()} ? #{blog.admin.published} : #{blog.admin.draft}"
|
||||||
|
th:classappend="${row.entry().published() ? 'bg-green-lt' : 'bg-yellow-lt'}"/>
|
||||||
|
<attr sel="#bl-row//.b-edit" th:text="#{blog.admin.edit}"
|
||||||
|
th:attr="href='/__admin/blog/' + ${row.entry().id()} + '/edit'"/>
|
||||||
|
<attr sel="#bl-row//.b-publish-form"
|
||||||
|
th:attr="action='/__admin/blog/' + ${row.entry().id()} + '/publish'"/>
|
||||||
|
<attr sel="#bl-row//.b-publish"
|
||||||
|
th:text="${row.entry().published()} ? #{blog.admin.unpublish} : #{blog.admin.publish}"/>
|
||||||
|
<attr sel="#bl-row//.b-delete-form"
|
||||||
|
th:attr="action='/__admin/blog/' + ${row.entry().id()} + '/delete'"/>
|
||||||
|
<attr sel="#bl-row//.b-delete" th:text="#{blog.admin.delete}"
|
||||||
|
th:attr="data-confirm=#{blog.admin.delete.confirm}"/>
|
||||||
|
<!-- The per-site CSRF token on every mutating form (the messages-editor idiom). -->
|
||||||
|
<attr sel="#bl-row//.b-csrf"
|
||||||
|
th:attr="name=${_csrf != null ? _csrf.parameterName : '_csrf'},value=${_csrf != null ? _csrf.token : ''}"/>
|
||||||
|
</thlogic>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Blog entry</title>
|
||||||
|
<!-- Static preview head only — replaced at render by the TENANT's master head (the seam contract). -->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header id="site-header">Site header (from the master at render)</header>
|
||||||
|
|
||||||
|
<main id="content">
|
||||||
|
<article class="blog-entry">
|
||||||
|
<header class="blog-entry-header">
|
||||||
|
<h1 id="entry-title">Entry title</h1>
|
||||||
|
<p id="entry-meta" class="blog-entry-meta">
|
||||||
|
<time id="entry-date">2026-01-01</time>
|
||||||
|
<span id="entry-author">By Someone</span>
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
<div id="entry-body" class="blog-entry-body">
|
||||||
|
<p>The entry body renders here.</p>
|
||||||
|
</div>
|
||||||
|
<footer class="blog-entry-footer">
|
||||||
|
<a id="entry-back" href="/">Back</a>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer id="site-footer">Site footer (from the master at render)</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Blog entry (classic): the tenant's OWN master supplies head/header/footer (this file is byte-identical across
|
||||||
|
tenants; ALL variance flows through the model). It reads ONLY the body-template render model the
|
||||||
|
SPI documents on ContentSource/ContentRef.bodyTemplate: ${master}, ${content.*} (id, sourceKey,
|
||||||
|
title, description, bodyHtml, attributes, updatedAt), ${locale} and ${urls[...]} — BlogEntryTemplateContractTest
|
||||||
|
fails the build if anything else creeps in. Labels resolve via #{} from THIS plugin's bundles (appended last —
|
||||||
|
a site that defines the same key wins). `//` reaches nested elements (`/` matches direct children only). -->
|
||||||
|
<thlogic>
|
||||||
|
<attr sel="head" th:replace="~{${master} :: head}"/>
|
||||||
|
<attr sel="#site-header" th:replace="~{${master} :: #site-header}"/>
|
||||||
|
<attr sel="#site-footer" th:replace="~{${master} :: #site-footer}"/>
|
||||||
|
|
||||||
|
<attr sel="#entry-title" th:text="${content.title}"/>
|
||||||
|
<!-- Editorial byline. The meta line renders when the entry has a date OR an author, and each part renders
|
||||||
|
independently — an entry with an author but no date (or the reverse) is a normal state, and gating the
|
||||||
|
whole line on the date alone would silently swallow the byline. Each is absent from
|
||||||
|
content.attributes when unset, so nothing renders as an empty element. -->
|
||||||
|
<attr sel="#entry-meta"
|
||||||
|
th:if="${content.attributes['publishedOn'] != null or content.attributes['author'] != null}"/>
|
||||||
|
<attr sel="#entry-meta//#entry-date"
|
||||||
|
th:if="${content.attributes['publishedOn'] != null}"
|
||||||
|
th:text="#{blog.publishedOn} + ' ' + ${content.attributes['publishedOn']}"
|
||||||
|
th:attr="datetime=${content.attributes['publishedOn']}"/>
|
||||||
|
<attr sel="#entry-meta//#entry-author"
|
||||||
|
th:if="${content.attributes['author'] != null}"
|
||||||
|
th:text="#{blog.by} + ' ' + ${content.attributes['author']}"/>
|
||||||
|
<attr sel="#entry-body" th:utext="${content.bodyHtml}"/>
|
||||||
|
<!-- Back to the site home in the CURRENT locale (the home page's locale-correct URL when it exists). -->
|
||||||
|
<attr sel="#entry-back" th:text="#{blog.back}"
|
||||||
|
th:attr="href=${urls['index'] != null ? urls['index'] : '/'}"/>
|
||||||
|
</thlogic>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Blog entry</title>
|
||||||
|
<!-- Static preview head only — replaced at render by the TENANT's master head (the seam contract). -->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header id="site-header">Site header (from the master at render)</header>
|
||||||
|
|
||||||
|
<main id="content">
|
||||||
|
<article class="blog-entry blog-entry-minimal">
|
||||||
|
<h1 id="entry-title">Entry title</h1>
|
||||||
|
<div id="entry-body" class="blog-entry-body">
|
||||||
|
<p>The entry body renders here.</p>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer id="site-footer">Site footer (from the master at render)</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Blog entry (minimal): title + body only — no date line, no back link. Same contract as classic: the tenant's
|
||||||
|
master chrome, only the documented render model (${master}, ${content.*}), tenant-invariant file. -->
|
||||||
|
<thlogic>
|
||||||
|
<attr sel="head" th:replace="~{${master} :: head}"/>
|
||||||
|
<attr sel="#site-header" th:replace="~{${master} :: #site-header}"/>
|
||||||
|
<attr sel="#site-footer" th:replace="~{${master} :: #site-footer}"/>
|
||||||
|
|
||||||
|
<attr sel="#entry-title" th:text="${content.title}"/>
|
||||||
|
<attr sel="#entry-body" th:utext="${content.bodyHtml}"/>
|
||||||
|
</thlogic>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes are recorded here. Versions follow [Semantic Versioning](https://semver.org/).
|
||||||
|
|
||||||
|
## [2.1.0] — 2026-10-21
|
||||||
|
|
||||||
|
First public release of `carousel-manager`: an image/slide carousel content widget — slides configured per site,
|
||||||
|
placed on any page with a `data-widget` anchor; self-contained CSS and JavaScript, no external libraries. Requires SPI `1.0.0` (Runway `1.0.0` or later). Licensed under the GNU AGPL v3.0 with an additional permission for
|
||||||
|
plugins (`LICENSE`, `LICENSE-EXCEPTION`).
|
||||||
@@ -0,0 +1,661 @@
|
|||||||
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights
|
||||||
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified source code becomes available
|
||||||
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and
|
||||||
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
|
this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer
|
||||||
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for the
|
||||||
|
specific requirements.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
Runway — additional permission for plugins
|
||||||
|
(an additional permission under section 7 of the GNU Affero General Public License, version 3)
|
||||||
|
|
||||||
|
Copyright (C) 2026 Quest ICT SAS de CV
|
||||||
|
|
||||||
|
Runway is free software: you can redistribute it and/or modify it under the terms of the
|
||||||
|
GNU Affero General Public License as published by the Free Software Foundation, version 3
|
||||||
|
(the file LICENSE), with the additional permission below. Runway is distributed in the hope
|
||||||
|
that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||||
|
License for more details.
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
|
||||||
|
"Runway" means the Runway kernel and every Runway plugin whose source carries this file.
|
||||||
|
|
||||||
|
"Published SPI" means the public classes and interfaces of the runway-spi artifact
|
||||||
|
(the package mx.quest.runway.spi and its subpackages), together with the public classes
|
||||||
|
and interfaces of any package named "spi" that a part of Runway publishes for other
|
||||||
|
plugins to use (for example mx.quest.search.spi).
|
||||||
|
|
||||||
|
"Plugin" means an independent module that Runway loads as a plugin, that interacts with
|
||||||
|
Runway only through the Published SPI, and that is not based on any part of Runway other
|
||||||
|
than the Published SPI.
|
||||||
|
|
||||||
|
2. Permission
|
||||||
|
|
||||||
|
As an additional permission, the copyright holder gives you permission to combine Runway
|
||||||
|
with Plugins, and to convey and run the resulting combination, without the terms of the
|
||||||
|
GNU Affero General Public License applying to those Plugins. You may license, convey and
|
||||||
|
run your Plugins under terms of your choice, provided that you continue to meet the terms
|
||||||
|
of the GNU Affero General Public License for Runway itself, including offering the
|
||||||
|
Corresponding Source of Runway, and of any modification you make to it, as that license
|
||||||
|
requires.
|
||||||
|
|
||||||
|
3. Testing
|
||||||
|
|
||||||
|
Compiling a Plugin's tests against the runway-spi-testkit artifact, and running them, does
|
||||||
|
not by itself make the Plugin subject to the GNU Affero General Public License.
|
||||||
|
|
||||||
|
4. Modified versions
|
||||||
|
|
||||||
|
If you modify Runway, you may extend this additional permission to your version, but you
|
||||||
|
are not obliged to do so. If you do not wish to, delete this file from your version.
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Runway Carousel Manager plugin
|
||||||
|
|
||||||
|
An image/slide **carousel** content widget for [Runway](../README.md): configure slides per site, then drop the
|
||||||
|
carousel onto any page with a `data-widget` anchor. Self-contained CSS + JS, no external libraries.
|
||||||
|
|
||||||
|
- **Plugin id:** `carousel-manager` — install folder `external/plugins/carousel-manager/`
|
||||||
|
- **Java package:** `mx.quest.carousel` · **SPI:** `ContentWidget` (`key = "carousel"`) and the service
|
||||||
|
`PluginSettings` — it links **only the SPI**, no kernel class
|
||||||
|
- **Version 2.1.0** · built against Runway 1.0.0; needs a kernel whose SPI is **1.0.0 or later**
|
||||||
|
(`requiresSpi: ">=1.0.0"`; an older kernel blocks it with a reason). What changed: [`CHANGELOG.md`](CHANGELOG.md).
|
||||||
|
|
||||||
|
## Use it
|
||||||
|
|
||||||
|
1. On the carousel settings page, add slides (one per line): `imageUrl | caption | link`.
|
||||||
|
2. Put an anchor on a page: `<div id="hero" data-widget="carousel/hero"></div>`.
|
||||||
|
|
||||||
|
Settings: auto-advance interval (0 = off), show captions, show controls. See
|
||||||
|
[`docs/CAROUSEL-PLUGIN.md`](docs/CAROUSEL-PLUGIN.md).
|
||||||
|
|
||||||
|
> Note: this plugin does not yet declare a `widgetSettings:` schema, so the host's per-placement widget config
|
||||||
|
> (`/__admin/widgets`) does not apply to it and every `carousel/*` anchor on a site shows the same configured
|
||||||
|
> slides (one carousel per site).
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export JAVA_HOME=/path/to/jdk-25
|
||||||
|
mvn -q verify # jar + target/carousel-manager/ + the .zip
|
||||||
|
HOST_JAR=/path/to/runway-app-<ver>-exec.jar scripts/verify-against-host.sh # boot a packaged host with it
|
||||||
|
```
|
||||||
|
|
||||||
|
The first build downloads its Maven dependencies, and needs the `runway-spi` jars installed in `~/.m2` as the
|
||||||
|
[authoring guide §2](../docs/PLUGIN-AUTHORING-GUIDE.md#2-prerequisites) describes.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
GNU Affero General Public License v3.0 with an additional permission for plugins (`LICENSE`, `LICENSE-EXCEPTION`),
|
||||||
|
copyright Quest ICT SAS de CV. The permission means that a plugin which uses only the published SPI may carry any
|
||||||
|
license.
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
# Runway Carousel Manager — design & reference
|
||||||
|
|
||||||
|
> The reference for a **`ContentWidget`** plugin with **per-tenant content config** and bundled
|
||||||
|
> front-end assets. Grounded in the Runway kernel as built.
|
||||||
|
|
||||||
|
## 1. What it does
|
||||||
|
|
||||||
|
A `ContentWidget` (`key = "carousel"`) that renders an image carousel from the site's per-tenant configuration
|
||||||
|
wherever a page carries `<div id="…" data-widget="carousel/…"></div>`. It emits self-contained markup that pulls
|
||||||
|
in its own stylesheet and script (`/__plugin/carousel-manager/static/carousel.{css,js}`); the JS handles
|
||||||
|
auto-advance, prev/next, and pause-on-hover, and is idempotent so multiple carousels on a page don't double-bind.
|
||||||
|
With no slides configured the widget renders nothing.
|
||||||
|
|
||||||
|
## 2. Configuration (per-tenant, applied immediately)
|
||||||
|
|
||||||
|
| Key | Type | Default | Notes |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `slides` | **text** | — | One slide per line: `imageUrl \| caption \| link`. `text` (not `list`) so a caption with a comma survives. Image required; caption/link optional. |
|
||||||
|
| `intervalSeconds` | int (0–60) | `5` | Auto-advance interval; `0` disables auto-play. |
|
||||||
|
| `showCaptions` | boolean | `true` | Overlay captions on slides. |
|
||||||
|
| `showControls` | boolean | `true` | Show prev/next controls (only when >1 slide). |
|
||||||
|
|
||||||
|
Read live through the SPI service **`PluginSettings.site(siteId)`**, which answers a `SettingsView`: the
|
||||||
|
descriptor defaults above overlaid by what the site saved. A save applies immediately (the host evicts the cached
|
||||||
|
view on every node). The code fallbacks equal the descriptor defaults, so the widget renders the same either way;
|
||||||
|
`intervalSeconds` is clamped to `0..60`; a hand-edited value that does not parse falls back to the default. The
|
||||||
|
`settings` control point gates the editor. Every emitted value (image URL, caption, link) is HTML-escaped by
|
||||||
|
`Html.escape`.
|
||||||
|
|
||||||
|
## 3. One slide set per site (documented)
|
||||||
|
|
||||||
|
The host supports per-placement widget config (a `widgetSettings:` schema in `plugin.yml`, edited per anchor at
|
||||||
|
`/__admin/widgets`, delivered in `WidgetView.config()`), but this plugin does not declare a schema yet — so
|
||||||
|
`config()` is empty for it and every `carousel/*` anchor on a site renders the **same** configured slides from the
|
||||||
|
flat per-tenant `siteSettings` (one carousel per site). Distinct carousels per placement need this plugin to
|
||||||
|
declare a `widgetSettings:` schema and read `config()`; the widget already threads `instanceId` through for that.
|
||||||
|
|
||||||
|
## 4. Inventory
|
||||||
|
|
||||||
|
| Piece | Type | File |
|
||||||
|
|---|---|---|
|
||||||
|
| `mainClass` `@Configuration` | `CarouselConfig` | wires the widget (`carouselManagerWidget`) + admin model (`carouselManagerAdminModel`), each given the injected `PluginSettings` |
|
||||||
|
| Widget | `CarouselWidget` (`ContentWidget` `carousel`) | parse slides → render markup |
|
||||||
|
| Slide model | `Slide` | parse `imageUrl \| caption \| link` |
|
||||||
|
| Console model | `CarouselAdminModel` + `templates/` | dashboard card + admin status, read as `${@carouselManagerAdminModel.slideCount(tenantSiteId)}` |
|
||||||
|
| Front-end | `static/carousel.css`, `static/carousel.js`, `static/carousel-help.html` | self-contained assets |
|
||||||
|
| i18n (EN/ES) | `i18n/` | settings + console labels |
|
||||||
|
|
||||||
|
## 5. What it links: the SPI only
|
||||||
|
|
||||||
|
The plugin's compiled classes reference nothing of the kernel outside `mx.quest.runway.spi`, which is the contract
|
||||||
|
the Runway kernel enforces (its loader refuses a non-essential plugin that links host classes). Concretely:
|
||||||
|
|
||||||
|
- **Settings:** `mx.quest.runway.spi.service.PluginSettings`, injected as a `@Bean` method parameter of
|
||||||
|
`CarouselConfig`. The host binds it to `carousel-manager` by the jar `CarouselConfig` was loaded from — no id is
|
||||||
|
passed, so the plugin can only read its own settings.
|
||||||
|
- **Bean names** start with the plugin id in lowerCamelCase (`carouselManager…`): plugins share the host's bean
|
||||||
|
namespace, and the kernel refuses other names.
|
||||||
|
- **Descriptor:** `requiresSpi: ">=1.0.0"` — the plugin is built against the Runway 1.0.0 SPI. An older kernel
|
||||||
|
blocks the plugin with a reason rather than failing to wire it.
|
||||||
|
- **Build:** `pom.xml` depends on `runway-spi` (and `runway-spi-testkit` for tests), never on `runway-app`, so a
|
||||||
|
host import does not compile. `CarouselConfigTest` also scans the compiled classes' constant pools for any
|
||||||
|
`mx/quest/runway/` name outside `spi/`, checks every bean name's prefix, and checks that every
|
||||||
|
`${@bean…}` the templates use is one of the plugin's own beans.
|
||||||
|
|
||||||
|
## 6. Verify
|
||||||
|
|
||||||
|
`HOST_JAR=… scripts/verify-against-host.sh` builds the plugin offline (run `mvn verify` once first, so that its
|
||||||
|
dependencies are in the local Maven repository), boots the packaged host (wizard, then ACTIVE) with it installed,
|
||||||
|
and asserts:
|
||||||
|
|
||||||
|
- it loads — `plugins: 1 registered, 0 blocked` — with **zero** host-linkage findings and zero
|
||||||
|
bean-name/surface findings, and no WARN/ERROR line names it;
|
||||||
|
- it serves its static assets;
|
||||||
|
- signed in as the site owner, a slide set saved on its settings page is counted on the status fragment and
|
||||||
|
on the dashboard card, and renders (both slides, the comma caption intact, the saved interval) on the seeded
|
||||||
|
About page, into which the script plants a `data-widget="carousel/hero"` anchor before the ACTIVE boot.
|
||||||
|
|
||||||
|
Without `HOST_JAR` it takes the jar matching the host pom's version from the `runway-app/target` of the kernel
|
||||||
|
this plugin sits in (`HOST_TARGET` names another build directory); `JAVA_HOME` must name a JDK 25 and `MVN` names
|
||||||
|
Maven (default: `mvn` on the PATH). It never runs `mvn install`. `VERIFY_TMPDIR` sets where the throwaway deployment goes, `VERIFY_LOG_DIR` keeps the host
|
||||||
|
logs. The widget's rendering rules (parsing, escaping, flags, clamping, defaults, per-site isolation) are covered
|
||||||
|
by `CarouselWidgetTest`. Never `spring-boot:run`.
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Runway Carousel Manager plugin — English strings.
|
||||||
|
|
||||||
|
# Grantable permission (permissions matrix label)
|
||||||
|
carousel.perm.settings=Configure carousel
|
||||||
|
|
||||||
|
# Per-tenant settings form labels
|
||||||
|
carousel.set.slides=Slides (one per line: imageUrl | caption | link)
|
||||||
|
carousel.set.interval=Auto-advance seconds (0 = off)
|
||||||
|
carousel.set.captions=Show captions
|
||||||
|
carousel.set.controls=Show previous/next controls
|
||||||
|
|
||||||
|
# Dashboard card
|
||||||
|
carousel.card.title=Carousel
|
||||||
|
carousel.card.slides=slides
|
||||||
|
|
||||||
|
# Admin status fragment
|
||||||
|
carousel.admin.title=Carousel status
|
||||||
|
carousel.admin.slides=Configured slides
|
||||||
|
carousel.admin.help=Carousel help & reference
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Runway Carousel Manager plugin — cadenas en español.
|
||||||
|
|
||||||
|
# Permiso otorgable (etiqueta de la matriz de permisos)
|
||||||
|
carousel.perm.settings=Configurar carrusel
|
||||||
|
|
||||||
|
# Etiquetas del formulario de configuración por sitio
|
||||||
|
carousel.set.slides=Diapositivas (una por línea: urlImagen | leyenda | enlace)
|
||||||
|
carousel.set.interval=Segundos de avance automático (0 = desactivado)
|
||||||
|
carousel.set.captions=Mostrar leyendas
|
||||||
|
carousel.set.controls=Mostrar controles anterior/siguiente
|
||||||
|
|
||||||
|
# Tarjeta del panel
|
||||||
|
carousel.card.title=Carrusel
|
||||||
|
carousel.card.slides=diapositivas
|
||||||
|
|
||||||
|
# Fragmento de estado (admin)
|
||||||
|
carousel.admin.title=Estado del carrusel
|
||||||
|
carousel.admin.slides=Diapositivas configuradas
|
||||||
|
carousel.admin.help=Ayuda y referencia del carrusel
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# Runway Carousel Manager plugin — descriptor
|
||||||
|
# An image/slide carousel a site manager configures per site and drops onto any
|
||||||
|
# page with a data-widget anchor. Content widget + per-tenant slide config.
|
||||||
|
# The install folder name MUST equal this `id`: external/plugins/carousel-manager/.
|
||||||
|
# =============================================================================
|
||||||
|
id: carousel-manager
|
||||||
|
name: Carousel Manager
|
||||||
|
version: 2.1.0
|
||||||
|
|
||||||
|
# The @Configuration registered before refresh. Package mx.quest.carousel lives OUTSIDE mx.quest.runway.
|
||||||
|
mainClass: mx.quest.carousel.CarouselConfig
|
||||||
|
|
||||||
|
# Built against the Runway 1.0.0 SPI (service tier: PluginSettings). A kernel below SPI 1.0.0 BLOCKS this
|
||||||
|
# plugin at startup with a reason, instead of failing to wire it (no PluginSettings bean to inject).
|
||||||
|
requiresSpi: ">=1.0.0"
|
||||||
|
|
||||||
|
# No hard dependency (always loads); NOT essential.
|
||||||
|
|
||||||
|
# --- Grantable control-point permission (gates the per-tenant slide editor) ------------------------------
|
||||||
|
permissions:
|
||||||
|
- { id: settings, realm: tenant, label: carousel.perm.settings, defaultRoles: [] }
|
||||||
|
|
||||||
|
# --- Per-tenant settings (tenant-owned content; over sites/<id>/plugins/carousel-manager.yml) ------------
|
||||||
|
# `slides` is a `text` (verbatim, multi-line) field — one "imageUrl | caption | link" per line — NOT a
|
||||||
|
# `list`, whose comma-splitting would break a caption containing a comma.
|
||||||
|
siteSettings:
|
||||||
|
- { key: slides, type: text, label: carousel.set.slides }
|
||||||
|
- { key: intervalSeconds, type: int, default: 5, range: "0..60", label: carousel.set.interval }
|
||||||
|
- { key: showCaptions, type: boolean, default: true, label: carousel.set.captions }
|
||||||
|
- { key: showControls, type: boolean, default: true, label: carousel.set.controls }
|
||||||
|
|
||||||
|
# --- Tenant dashboard card (fragment resolves to __plugin__/carousel-manager/dashboard) ------------------
|
||||||
|
dashboardCards:
|
||||||
|
- { realm: tenant, order: 50, fragment: dashboard, permission: "carousel-manager|settings" }
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<!-- Inherit the SAME managed versions the kernel uses (Spring Boot 4.0.6) so every `provided` platform type
|
||||||
|
is byte-identical at runtime. NOT a Boot app — no repackage; `mvn package` produces a THIN jar. -->
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>4.0.6</version>
|
||||||
|
<relativePath/>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>mx.quest</groupId>
|
||||||
|
<artifactId>runway-plugin-carousel-manager</artifactId>
|
||||||
|
<version>2.1.0</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>Runway Carousel Manager Plugin</name>
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>GNU Affero General Public License v3.0, with the Runway additional permission for plugins</name>
|
||||||
|
<url>https://www.gnu.org/licenses/agpl-3.0.txt</url>
|
||||||
|
<distribution>repo</distribution>
|
||||||
|
<comments>See LICENSE and LICENSE-EXCEPTION.</comments>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
<description>
|
||||||
|
An image/slide carousel content widget for Runway: a site manager configures slides per site and drops
|
||||||
|
the carousel onto any page with a data-widget anchor. Self-contained CSS + JS, no external libraries.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>25</java.version>
|
||||||
|
<maven.compiler.release>25</maven.compiler.release>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<!-- Reproducible builds: pins every archive entry's timestamp so two builds of the same source
|
||||||
|
produce byte-identical artifacts. Without it a jar embeds the build time, so a rebuild can
|
||||||
|
never match what was published — which silently broke the "the tree holds what was shipped"
|
||||||
|
invariant that releases are checked against. Bump at each release. -->
|
||||||
|
<project.build.outputTimestamp>2026-10-21T18:56:00Z</project.build.outputTimestamp>
|
||||||
|
<runway.version>1.0.0</runway.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mx.quest</groupId>
|
||||||
|
<artifactId>runway-spi</artifactId>
|
||||||
|
<version>${runway.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- NO runway-app dependency, in any scope: the plugin links only the SPI, so a host
|
||||||
|
import no longer compiles and the kernel's host-linkage scanner finds nothing to report. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mx.quest</groupId>
|
||||||
|
<artifactId>runway-spi-testkit</artifactId>
|
||||||
|
<version>${runway.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>runway-plugin-carousel-manager</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>assemble-plugin-folder</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<property name="stage" value="${project.build.directory}/carousel-manager"/>
|
||||||
|
<delete dir="${stage}"/>
|
||||||
|
<mkdir dir="${stage}"/>
|
||||||
|
<copy file="${project.basedir}/plugin.yml" todir="${stage}"/>
|
||||||
|
<copy file="${project.basedir}/LICENSE" todir="${stage}"/>
|
||||||
|
<copy file="${project.basedir}/LICENSE-EXCEPTION" todir="${stage}"/>
|
||||||
|
<copy file="${project.build.directory}/runway-plugin-carousel-manager.jar" todir="${stage}"/>
|
||||||
|
<copy todir="${stage}/static">
|
||||||
|
<fileset dir="${project.basedir}/static"/>
|
||||||
|
</copy>
|
||||||
|
<copy todir="${stage}/templates">
|
||||||
|
<fileset dir="${project.basedir}/templates"/>
|
||||||
|
</copy>
|
||||||
|
<copy todir="${stage}/i18n">
|
||||||
|
<fileset dir="${project.basedir}/i18n"/>
|
||||||
|
</copy>
|
||||||
|
<!-- Ant's <zip> stamps each entry from the staged file's mtime, and the stage
|
||||||
|
is re-copied every build — so without this the zip differs on every run
|
||||||
|
even when the jar inside is byte-identical. Pin the stage to the same
|
||||||
|
instant as project.build.outputTimestamp so the archive is reproducible. -->
|
||||||
|
<!-- file="${stage}" is the STAGE ROOT itself: it becomes the archive's own
|
||||||
|
"carousel-manager/" entry, and neither <fileset> nor <dirset> covers the
|
||||||
|
base directory. Without it the archive differed by exactly two bytes —
|
||||||
|
that entry's DOS time in the local header and again in the central
|
||||||
|
directory. -->
|
||||||
|
<touch datetime="${project.build.outputTimestamp}"
|
||||||
|
pattern="yyyy-MM-dd'T'HH:mm:ss'Z'">
|
||||||
|
<fileset dir="${stage}"/>
|
||||||
|
<!-- DIRECTORIES TOO. A <fileset> matches files only, and the zip carries
|
||||||
|
an entry per directory whose DOS timestamp comes from the directory's
|
||||||
|
own mtime — so with files alone the archive still differed on every
|
||||||
|
build. `unzip -lv` hides this: it rounds the displayed time to the
|
||||||
|
minute, so the entry listings compare equal while the bytes do not. -->
|
||||||
|
<dirset dir="${stage}"/>
|
||||||
|
<!-- and the stage ROOT itself, which becomes the archive's own
|
||||||
|
"carousel-manager/" entry. Neither of the collections above covers a
|
||||||
|
base directory, and Ant refuses `file=` for a directory ("Use a
|
||||||
|
resource collection to touch directories") — so name it from its
|
||||||
|
PARENT. Without this the archive differed by exactly two bytes: that
|
||||||
|
entry's DOS time in the local header and again in the central dir. -->
|
||||||
|
<dirset dir="${project.build.directory}" includes="carousel-manager"/>
|
||||||
|
</touch>
|
||||||
|
<!-- The stamped files predate any earlier zip, so <zip> would skip the rebuild. -->
|
||||||
|
<delete file="${project.build.directory}/runway-plugin-carousel-manager-${project.version}.zip"/>
|
||||||
|
<zip destfile="${project.build.directory}/runway-plugin-carousel-manager-${project.version}.zip">
|
||||||
|
<!-- Zip the REAL staged directory rather than synthesising the folder
|
||||||
|
with prefix=. Ant stamps a prefix-synthesised directory entry with
|
||||||
|
the CURRENT time and ignores the touched directory's mtime, so the
|
||||||
|
archive stayed irreproducible by exactly those two bytes however the
|
||||||
|
stage was touched. Including the directory itself in the fileset
|
||||||
|
makes Ant use its (pinned) mtime. -->
|
||||||
|
<zipfileset dir="${project.build.directory}" includes="carousel-manager/**"/>
|
||||||
|
</zip>
|
||||||
|
<echo message="Staged install folder: ${stage}"/>
|
||||||
|
<echo message="UI-uploadable archive: ${project.build.directory}/runway-plugin-carousel-manager-${project.version}.zip"/>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
+134
@@ -0,0 +1,134 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build this plugin, drop it into a throwaway Runway deployment, boot the PACKAGED host in ACTIVE mode, and
|
||||||
|
# smoke-test it end to end: it loads with ZERO host-linkage and bean-name/surface findings (the SPI 1.0.0
|
||||||
|
# contract), serves its static assets, and — signed in as the site owner — a slide set saved on its settings
|
||||||
|
# page shows on the console card and renders on a page carrying a data-widget anchor (the anchor is planted in
|
||||||
|
# the seeded About page before the ACTIVE boot). Verify ONLY against the packaged jar — never spring-boot:run
|
||||||
|
# (its restart classloader loads ZERO plugins).
|
||||||
|
#
|
||||||
|
# Usage: scripts/verify-against-host.sh [--keep] [--port N]
|
||||||
|
# JAVA_HOME=/path/to/jdk-25 required: the JDK that builds the plugin and runs the host
|
||||||
|
# MVN=/path/to/mvn Maven (default: mvn on the PATH)
|
||||||
|
# HOST_TARGET=/path/to/runway/runway-app/target the host build (default: the kernel this plugin sits in, else ../runway)
|
||||||
|
# HOST_JAR=/path/to/runway-app-<ver>-exec.jar the kernel to verify against (default: the HOST_TARGET jar
|
||||||
|
# MATCHING the host pom's version)
|
||||||
|
# VERIFY_TMPDIR=/dir where the throwaway deployment goes (default: $TMPDIR or /tmp)
|
||||||
|
# VERIFY_LOG_DIR=/dir keep copies of the host's wizard/ACTIVE logs there (evidence)
|
||||||
|
# The script never runs `mvn install` (nothing is written to ~/.m2): it packages this plugin offline against
|
||||||
|
# whatever runway-spi is already in the local repository.
|
||||||
|
set -uo pipefail
|
||||||
|
|
||||||
|
HERE="$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)"
|
||||||
|
# JAVA_HOME must name a JDK 25. MVN (default: `mvn` on the PATH) and HOST_TARGET (default: see above) can be set in the environment.
|
||||||
|
if [ -z "${JAVA_HOME:-}" ] || [ ! -x "$JAVA_HOME/bin/java" ]; then echo "set JAVA_HOME to a JDK 25"; exit 2; fi
|
||||||
|
export JAVA_HOME
|
||||||
|
JAVA="$JAVA_HOME/bin/java"
|
||||||
|
MVN="${MVN:-mvn}"
|
||||||
|
# Default host: the kernel at the root of the repository this plugin sits in (plugins/<name>/), else a kernel
|
||||||
|
# checkout named `runway` beside the plugins checkout.
|
||||||
|
if [ -z "${HOST_TARGET:-}" ]; then
|
||||||
|
if [ -f "$HERE/../../runway-app/pom.xml" ]; then HOST_TARGET="$HERE/../../runway-app/target"
|
||||||
|
else HOST_TARGET="$HERE/../../runway/runway-app/target"; fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
KEEP="no"; PORT=""
|
||||||
|
while [ $# -gt 0 ]; do case "$1" in
|
||||||
|
--keep) KEEP="yes"; shift ;;
|
||||||
|
--port) PORT="${2:?}"; shift 2 ;;
|
||||||
|
*) echo "unknown arg: $1"; exit 2 ;;
|
||||||
|
esac; done
|
||||||
|
|
||||||
|
APP_USER=root; APP_PW=Carousel-Admin-2026; SITE_USER=owner; SITE_PW=Carousel-Site-2026
|
||||||
|
[ -n "$PORT" ] || PORT="$(python3 -c 'import socket;s=socket.socket();s.bind(("",0));print(s.getsockname()[1]);s.close()')"
|
||||||
|
BASE="http://localhost:$PORT"
|
||||||
|
|
||||||
|
echo "[verify] building the plugin ..."
|
||||||
|
( cd "$HERE" && "$MVN" -o -q -DskipTests package ) || { echo "plugin build failed"; exit 1; }
|
||||||
|
|
||||||
|
# The host jar MATCHING the host pom's version — never "the newest file": every reproducible jar carries the same
|
||||||
|
# fixed timestamp, so `ls -t` cannot tell a leftover release jar from the SNAPSHOT under test.
|
||||||
|
if [ -n "${HOST_JAR:-}" ]; then
|
||||||
|
JAR="$HOST_JAR"
|
||||||
|
else
|
||||||
|
HOST_VERSION="$(sed -n 's:.*<version>\(.*\)</version>.*:\1:p' "$HOST_TARGET/../pom.xml" | head -1)"
|
||||||
|
JAR="$HOST_TARGET/runway-app-$HOST_VERSION-exec.jar"
|
||||||
|
fi
|
||||||
|
[ -f "$JAR" ] || { echo "no host exec jar $JAR — build the host (mvn -pl runway-app package) or set HOST_JAR"; exit 1; }
|
||||||
|
echo "[verify] host jar: $JAR"
|
||||||
|
|
||||||
|
SCRATCH="$(mktemp -d "${VERIFY_TMPDIR:-${TMPDIR:-/tmp}}/carousel-verify.XXXXXX")"
|
||||||
|
cleanup() {
|
||||||
|
[ -z "${VERIFY_LOG_DIR:-}" ] || { mkdir -p "$VERIFY_LOG_DIR" && cp "$SCRATCH"/*.log "$VERIFY_LOG_DIR"/ 2>/dev/null; }
|
||||||
|
# Wait for the host to exit before deleting: a JVM still shutting down rewrites files under external/ and
|
||||||
|
# makes `rm -rf` leave the scratch folder behind.
|
||||||
|
[ "$KEEP" = "yes" ] || { kill "${PID:-0}" 2>/dev/null; wait "${PID:-0}" 2>/dev/null; rm -rf "$SCRATCH"; }
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
mkdir -p "$SCRATCH/external/plugins"
|
||||||
|
cp -r "$HERE/target/carousel-manager" "$SCRATCH/external/plugins/carousel-manager"
|
||||||
|
|
||||||
|
wait_for() { for _ in $(seq 1 "$3"); do grep -q "$2" "$1" 2>/dev/null && return 0; sleep 1; done; return 1; }
|
||||||
|
PASS=0; FAIL=0
|
||||||
|
ck() { if eval "$2" >/dev/null 2>&1; then echo " PASS $1"; PASS=$((PASS+1)); else echo " FAIL $1"; FAIL=$((FAIL+1)); fi; }
|
||||||
|
boot() { ( cd "$SCRATCH" && exec "$JAVA" -jar "$JAR" --server.port="$PORT" --runway.storage.external="$SCRATCH/external" ) >"$1" 2>&1 & PID=$!; }
|
||||||
|
|
||||||
|
echo "[verify] booting host (wizard) on :$PORT ..."
|
||||||
|
boot "$SCRATCH/wizard.log"
|
||||||
|
wait_for "$SCRATCH/wizard.log" "Started RunwayApplication" 90 || { echo "wizard did not start"; tail -20 "$SCRATCH/wizard.log"; exit 1; }
|
||||||
|
curl -s -o /dev/null -X POST "$BASE/setup" --data-urlencode "username=$APP_USER" --data-urlencode "password=$APP_PW" \
|
||||||
|
--data-urlencode "displayName=Root" --data-urlencode "siteAdminUsername=$SITE_USER" --data-urlencode "siteAdminPassword=$SITE_PW"
|
||||||
|
for _ in $(seq 1 30); do kill -0 "$PID" 2>/dev/null || break; sleep 1; done
|
||||||
|
|
||||||
|
# A page carrying the widget anchor: the seeded About page, edited on disk before the ACTIVE boot reads it.
|
||||||
|
ABOUT="$SCRATCH/external/sites/default/templates/about.html"
|
||||||
|
[ -f "$ABOUT" ] || { echo "the wizard did not seed $ABOUT"; exit 1; }
|
||||||
|
sed -i 's|<main id="content">|<main id="content"><div id="hero" data-widget="carousel/hero"></div>|' "$ABOUT"
|
||||||
|
|
||||||
|
echo "[verify] booting host (ACTIVE) ..."
|
||||||
|
boot "$SCRATCH/active.log"
|
||||||
|
wait_for "$SCRATCH/active.log" "Started RunwayApplication" 90 || { echo "ACTIVE did not start"; tail -20 "$SCRATCH/active.log"; exit 1; }
|
||||||
|
|
||||||
|
LOG="$SCRATCH/active.log"
|
||||||
|
echo "== plugin load (SPI 1.0.0 contract) =="
|
||||||
|
ck "plugin registered, 0 blocked" "grep -qE 'plugins: 1 registered, 0 blocked' '$LOG'"
|
||||||
|
ck "not blocked / quarantined" "! grep -qE \"plugin 'carousel-manager' is blocked|plugin-quarantine\" '$LOG'"
|
||||||
|
# Host linkage and the surface rules: the kernel BLOCKS such a plugin and logs "linkage scan: <reason>" / the surface
|
||||||
|
# reason; the patterns also match the warning wording ("uses host internals", "… allowed until Runway 1.0"), so
|
||||||
|
# either form fails the check.
|
||||||
|
ck "ZERO host-linkage findings" "! grep -qE \"uses host internals|plugin 'carousel-manager' linkage scan\" '$LOG'"
|
||||||
|
ck "ZERO bean-name/surface findings" "! grep -qE \"plugin 'carousel-manager'.*(allowed until Runway 1.0|bean name|may not contribute)\" '$LOG'"
|
||||||
|
ck "no WARN/ERROR names the plugin" "! grep -E ' (WARN|ERROR) ' '$LOG' | grep -q 'carousel'"
|
||||||
|
ck "no key collision / degraded" "! grep -qiE 'collision|duplicate key|degraded' '$LOG'"
|
||||||
|
|
||||||
|
echo "== static assets =="
|
||||||
|
ck "carousel.css served" "curl -s -o /dev/null -w '%{http_code}' '$BASE/__plugin/carousel-manager/static/carousel.css' | grep -q 200"
|
||||||
|
ck "carousel.js served" "curl -s -o /dev/null -w '%{http_code}' '$BASE/__plugin/carousel-manager/static/carousel.js' | grep -q 200"
|
||||||
|
ck "help page served" "curl -s -o /dev/null -w '%{http_code}' '$BASE/__plugin/carousel-manager/static/carousel-help.html' | grep -q 200"
|
||||||
|
|
||||||
|
echo "== settings → console card → widget (PluginSettings in the real host) =="
|
||||||
|
JAR_C="$SCRATCH/cookies.txt"
|
||||||
|
SETTINGS="$BASE/__admin/plugins/carousel-manager/settings"
|
||||||
|
c() { curl -s -H 'Accept-Language: en' -c "$JAR_C" -b "$JAR_C" "$@"; }
|
||||||
|
token() { grep -o 'name="_csrf" value="[^"]*"' | head -1 | sed 's/.*value="//; s/"$//'; }
|
||||||
|
ck "unconfigured: the anchor renders nothing" "! curl -s '$BASE/about' | grep -q 'rw-carousel'"
|
||||||
|
LOGIN_TOKEN="$(c "$BASE/login" | token)"
|
||||||
|
c -o /dev/null -X POST "$BASE/login" --data-urlencode "username=$SITE_USER" --data-urlencode "password=$SITE_PW" \
|
||||||
|
--data-urlencode "_csrf=$LOGIN_TOKEN"
|
||||||
|
c "$SETTINGS" > "$SCRATCH/settings-1.html"
|
||||||
|
ck "settings page renders the status card (0 slides)" "grep -q 'id=\"ca-slides\">0<' '$SCRATCH/settings-1.html'"
|
||||||
|
c -o /dev/null -X POST "$SETTINGS" \
|
||||||
|
--data-urlencode $'slides=/img/one.jpg | Fast, fresh | /menu\n/img/two.jpg | Second' \
|
||||||
|
--data-urlencode "intervalSeconds=7" --data-urlencode "showCaptions=true" --data-urlencode "showControls=true" \
|
||||||
|
--data-urlencode "_csrf=$(token < "$SCRATCH/settings-1.html")"
|
||||||
|
c "$SETTINGS" > "$SCRATCH/settings-2.html"
|
||||||
|
ck "after save: the status card counts 2 slides" "grep -q 'id=\"ca-slides\">2<' '$SCRATCH/settings-2.html'"
|
||||||
|
c "$BASE/__admin" > "$SCRATCH/dashboard.html"
|
||||||
|
ck "the dashboard card counts 2 slides" "grep -q 'id=\"cc-slides\">2<' '$SCRATCH/dashboard.html'"
|
||||||
|
curl -s "$BASE/about" > "$SCRATCH/about.html"
|
||||||
|
ck "the widget renders both slides" "grep -q 'src=\"/img/one.jpg\"' '$SCRATCH/about.html' && grep -q 'src=\"/img/two.jpg\"' '$SCRATCH/about.html'"
|
||||||
|
ck "…with the comma caption intact" "grep -q '>Fast, fresh</figcaption>' '$SCRATCH/about.html'"
|
||||||
|
ck "…and the saved interval" "grep -q 'data-interval=\"7\"' '$SCRATCH/about.html'"
|
||||||
|
|
||||||
|
echo; echo "RESULT: $PASS passed, $FAIL failed"
|
||||||
|
if [ "$KEEP" = "yes" ]; then echo "[verify] kept at $BASE (scratch $SCRATCH; kill $PID to stop)"; wait "$PID"; fi
|
||||||
|
exit "$FAIL"
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package mx.quest.carousel;
|
||||||
|
|
||||||
|
import mx.quest.runway.spi.service.PluginSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read-only status model for the console surfaces (dashboard card + admin fragment), read by template bean name,
|
||||||
|
* e.g. {@code ${@carouselManagerAdminModel.slideCount(tenantSiteId)}}.
|
||||||
|
*/
|
||||||
|
public class CarouselAdminModel {
|
||||||
|
|
||||||
|
private final PluginSettings settings;
|
||||||
|
|
||||||
|
public CarouselAdminModel(PluginSettings settings) {
|
||||||
|
this.settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** How many valid slides the site has configured (the same count the widget would render). */
|
||||||
|
public int slideCount(String siteId) {
|
||||||
|
return CarouselWidget.slides(settings.site(siteId)).size();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package mx.quest.carousel;
|
||||||
|
|
||||||
|
import mx.quest.runway.spi.ContentWidget;
|
||||||
|
import mx.quest.runway.spi.service.PluginSettings;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The plugin's {@code mainClass} — the single {@code @Configuration} registered into the host context before
|
||||||
|
* refresh. Beans are wired EXPLICITLY (no {@code @ComponentScan}). The package {@code mx.quest.carousel} lives
|
||||||
|
* OUTSIDE {@code mx.quest.runway} so the host never double-scans it, and the plugin links nothing but the SPI.
|
||||||
|
*
|
||||||
|
* <p><b>Bean names start with the plugin id in lowerCamelCase</b> ({@code carouselManager…}): plugins share the
|
||||||
|
* host's bean namespace, and the host refuses any other name. The templates read
|
||||||
|
* the admin model by that name ({@code ${@carouselManagerAdminModel…}}).
|
||||||
|
*
|
||||||
|
* <p>{@link PluginSettings} is injected as a {@code @Bean} method parameter of this class, which comes from the
|
||||||
|
* plugin's own jar — that is what binds the instance to {@code carousel-manager}'s settings; no id is passed.
|
||||||
|
* The {@link CarouselWidget} is a list-collected {@code ContentWidget} SPI — a plain {@code @Bean}, NEVER
|
||||||
|
* {@code @Primary}.
|
||||||
|
*/
|
||||||
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
public class CarouselConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ContentWidget carouselManagerWidget(PluginSettings settings) {
|
||||||
|
return new CarouselWidget(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public CarouselAdminModel carouselManagerAdminModel(PluginSettings settings) {
|
||||||
|
return new CarouselAdminModel(settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package mx.quest.carousel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import mx.quest.runway.spi.ContentWidget;
|
||||||
|
import mx.quest.runway.spi.model.Capabilities;
|
||||||
|
import mx.quest.runway.spi.model.RenderFragment;
|
||||||
|
import mx.quest.runway.spi.model.SettingsView;
|
||||||
|
import mx.quest.runway.spi.model.WidgetView;
|
||||||
|
import mx.quest.runway.spi.service.PluginSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@code carousel} content widget: a site manager drops
|
||||||
|
* {@code <div id="hero" data-widget="carousel/hero"></div>} on a page and the host asks this widget to render an
|
||||||
|
* image carousel from the site's per-tenant configuration. It emits self-contained markup that references the
|
||||||
|
* plugin's own stylesheet and script ({@code /__plugin/carousel-manager/static/carousel.{css,js}}) — the script
|
||||||
|
* is idempotent, so multiple carousels on a page are fine.
|
||||||
|
*
|
||||||
|
* <p><b>One slide set per site:</b> this plugin declares no {@code widgetSettings:} schema, so the host's
|
||||||
|
* per-placement config ({@code WidgetView.config()}, edited at {@code /__admin/widgets}) stays empty for it and
|
||||||
|
* every {@code carousel/*} anchor on a site renders the SAME configured slide set. Distinct carousels per
|
||||||
|
* placement need this plugin to declare such a schema and read {@code config()}; the {@code instanceId} is
|
||||||
|
* already carried through for that. With no slides configured the widget renders nothing
|
||||||
|
* ({@link RenderFragment#empty()}).
|
||||||
|
*
|
||||||
|
* <p><b>Settings</b> come from {@link PluginSettings#site(String)}: the descriptor's {@code siteSettings:}
|
||||||
|
* defaults overlaid by what the site saved. The code fallbacks below equal the descriptor defaults
|
||||||
|
* ({@code intervalSeconds: 5}, {@code showCaptions: true}, {@code showControls: true}), so the widget renders the
|
||||||
|
* same whether or not the host applied them; {@code intervalSeconds} is clamped to the declared {@code 0..60}.
|
||||||
|
*/
|
||||||
|
public class CarouselWidget implements ContentWidget {
|
||||||
|
|
||||||
|
private static final String STATIC = "/__plugin/carousel-manager/static";
|
||||||
|
|
||||||
|
private final PluginSettings settings;
|
||||||
|
|
||||||
|
public CarouselWidget(PluginSettings settings) {
|
||||||
|
this.settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String key() {
|
||||||
|
return "carousel";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RenderFragment render(WidgetView view) {
|
||||||
|
SettingsView cfg = settings.site(view.site().id());
|
||||||
|
List<Slide> slides = slides(cfg);
|
||||||
|
if (slides.isEmpty()) {
|
||||||
|
return RenderFragment.empty();
|
||||||
|
}
|
||||||
|
long interval = cfg.integer("intervalSeconds", 5, 0, 60);
|
||||||
|
boolean captions = cfg.bool("showCaptions", true);
|
||||||
|
boolean controls = cfg.bool("showControls", true);
|
||||||
|
|
||||||
|
StringBuilder b = new StringBuilder(512);
|
||||||
|
b.append("<link rel=\"stylesheet\" href=\"").append(STATIC).append("/carousel.css\">")
|
||||||
|
.append("<div class=\"rw-carousel\" data-interval=\"").append(interval)
|
||||||
|
.append("\" data-controls=\"").append(controls).append("\"><div class=\"rw-carousel-track\">");
|
||||||
|
for (int i = 0; i < slides.size(); i++) {
|
||||||
|
Slide s = slides.get(i);
|
||||||
|
b.append("<figure class=\"rw-carousel-slide").append(i == 0 ? " is-active" : "").append("\">");
|
||||||
|
boolean linked = !s.link().isBlank();
|
||||||
|
if (linked) {
|
||||||
|
b.append("<a class=\"rw-carousel-link\" href=\"").append(Html.escape(s.link())).append("\">");
|
||||||
|
}
|
||||||
|
b.append("<img class=\"rw-carousel-img\" src=\"").append(Html.escape(s.imageUrl()))
|
||||||
|
.append("\" alt=\"").append(Html.escape(s.caption())).append("\" loading=\"lazy\">");
|
||||||
|
if (linked) {
|
||||||
|
b.append("</a>");
|
||||||
|
}
|
||||||
|
if (captions && !s.caption().isBlank()) {
|
||||||
|
b.append("<figcaption class=\"rw-carousel-caption\">").append(Html.escape(s.caption()))
|
||||||
|
.append("</figcaption>");
|
||||||
|
}
|
||||||
|
b.append("</figure>");
|
||||||
|
}
|
||||||
|
b.append("</div>");
|
||||||
|
if (controls && slides.size() > 1) {
|
||||||
|
b.append("<button type=\"button\" class=\"rw-carousel-prev\" aria-label=\"Previous\">‹</button>")
|
||||||
|
.append("<button type=\"button\" class=\"rw-carousel-next\" aria-label=\"Next\">›</button>");
|
||||||
|
}
|
||||||
|
b.append("</div><script src=\"").append(STATIC).append("/carousel.js\" defer></script>");
|
||||||
|
return RenderFragment.of(b.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parses the per-tenant {@code slides} text (one {@code imageUrl | caption | link} per line). */
|
||||||
|
static List<Slide> slides(SettingsView cfg) {
|
||||||
|
List<Slide> out = new ArrayList<>();
|
||||||
|
for (String line : cfg.string("slides", "").split("\\R")) {
|
||||||
|
Slide slide = Slide.parse(line);
|
||||||
|
if (slide != null) {
|
||||||
|
out.add(slide);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Capabilities capabilities() {
|
||||||
|
return Capabilities.of("widget.carousel");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package mx.quest.carousel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimal HTML escaping for the values the carousel widget interpolates (image URLs, captions, links from the
|
||||||
|
* per-tenant config). The plugin owns escaping of its own output so a hand-entered caption or URL can never
|
||||||
|
* inject markup into a rendered page.
|
||||||
|
*/
|
||||||
|
final class Html {
|
||||||
|
|
||||||
|
private Html() {
|
||||||
|
}
|
||||||
|
|
||||||
|
static String escape(String value) {
|
||||||
|
if (value == null || value.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return value.replace("&", "&").replace("<", "<").replace(">", ">")
|
||||||
|
.replace("\"", """).replace("'", "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package mx.quest.carousel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One carousel slide, parsed from a per-tenant {@code slides} list entry of the form
|
||||||
|
* {@code imageUrl | caption | linkUrl} (caption and link optional). Immutable; all fields already trimmed and
|
||||||
|
* HTML-escaped at render time by the widget.
|
||||||
|
*
|
||||||
|
* @param imageUrl the slide image URL (required — a slide with no image is dropped)
|
||||||
|
* @param caption the optional caption text ({@code ""} if none)
|
||||||
|
* @param link the optional link the slide navigates to when clicked ({@code ""} if none)
|
||||||
|
*/
|
||||||
|
record Slide(String imageUrl, String caption, String link) {
|
||||||
|
|
||||||
|
/** Parses one {@code imageUrl | caption | linkUrl} entry; returns {@code null} if it has no usable image. */
|
||||||
|
static Slide parse(String entry) {
|
||||||
|
if (entry == null || entry.isBlank()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String[] parts = entry.split("\\|", 3);
|
||||||
|
String image = parts[0].strip();
|
||||||
|
if (image.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String caption = parts.length > 1 ? parts[1].strip() : "";
|
||||||
|
String link = parts.length > 2 ? parts[2].strip() : "";
|
||||||
|
return new Slide(image, caption, link);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package mx.quest.carousel;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import mx.quest.runway.spi.testkit.FakePluginSettings;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/** The console status model counts the slides the widget would render, per site. */
|
||||||
|
class CarouselAdminModelTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void countsOnlyRenderableSlidesPerSite() {
|
||||||
|
FakePluginSettings settings = new FakePluginSettings()
|
||||||
|
.site("acme", Map.of("slides", "/img/a.jpg | A\n\n | no image | /x\n/img/b.jpg"))
|
||||||
|
.site("other", Map.of("slides", "/img/c.jpg"));
|
||||||
|
CarouselAdminModel model = new CarouselAdminModel(settings);
|
||||||
|
assertEquals(2, model.slideCount("acme"), "blank lines and image-less lines are not slides");
|
||||||
|
assertEquals(1, model.slideCount("other"));
|
||||||
|
assertEquals(0, model.slideCount("unconfigured"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
package mx.quest.carousel;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import mx.quest.runway.spi.ContentWidget;
|
||||||
|
import mx.quest.runway.spi.service.PluginSettings;
|
||||||
|
import mx.quest.runway.spi.testkit.FakePluginSettings;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The plugin's contract with the host, checked at build time: the wiring, the bean-name rule, the bean names the
|
||||||
|
* templates reference, the descriptor floor, and that the compiled classes link nothing of the host but the SPI —
|
||||||
|
* the same things the kernel's load-time checks refuse.
|
||||||
|
*/
|
||||||
|
class CarouselConfigTest {
|
||||||
|
|
||||||
|
private static final String PREFIX = "carouselManager";
|
||||||
|
|
||||||
|
private static Set<String> beanMethodNames() {
|
||||||
|
return Arrays.stream(CarouselConfig.class.getDeclaredMethods())
|
||||||
|
.filter(m -> m.isAnnotationPresent(Bean.class))
|
||||||
|
.map(Method::getName)
|
||||||
|
.collect(Collectors.toCollection(TreeSet::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void wiresTheWidgetAndTheAdminModelUnderPrefixedNames() {
|
||||||
|
try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
|
||||||
|
ctx.registerBean(PluginSettings.class,
|
||||||
|
() -> new FakePluginSettings().site("acme", Map.of("slides", "/img/a.jpg\n/img/b.jpg")));
|
||||||
|
ctx.register(CarouselConfig.class);
|
||||||
|
ctx.refresh();
|
||||||
|
assertInstanceOf(CarouselWidget.class, ctx.getBean("carouselManagerWidget", ContentWidget.class));
|
||||||
|
assertEquals(2, ctx.getBean("carouselManagerAdminModel", CarouselAdminModel.class).slideCount("acme"),
|
||||||
|
"the admin model reads the injected settings");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void everyBeanNameStartsWithThePluginIdInLowerCamelCase() {
|
||||||
|
Set<String> names = beanMethodNames();
|
||||||
|
assertEquals(Set.of("carouselManagerWidget", "carouselManagerAdminModel"), names);
|
||||||
|
for (Method m : CarouselConfig.class.getDeclaredMethods()) {
|
||||||
|
Bean bean = m.getAnnotation(Bean.class);
|
||||||
|
if (bean != null) {
|
||||||
|
for (String alias : bean.name()) {
|
||||||
|
assertTrue(alias.startsWith(PREFIX), "an explicit bean name must start with " + PREFIX + ": " + alias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void everyBeanTheTemplatesReferenceIsOneOfOurs() throws IOException {
|
||||||
|
Set<String> referenced = new TreeSet<>();
|
||||||
|
try (Stream<Path> files = Files.list(Path.of("templates"))) {
|
||||||
|
for (Path file : files.filter(p -> p.toString().endsWith(".th.xml")).toList()) {
|
||||||
|
String text = Files.readString(file, StandardCharsets.UTF_8);
|
||||||
|
Matcher m = Pattern.compile("\\$\\{\\s*@(\\w+)").matcher(text);
|
||||||
|
while (m.find()) {
|
||||||
|
referenced.add(m.group(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertFalse(referenced.isEmpty(), "the console templates read the admin model");
|
||||||
|
assertTrue(beanMethodNames().containsAll(referenced), "templates reference unknown beans: " + referenced);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theDescriptorDeclaresTheSpiFloorAndTheReleaseVersion() throws IOException {
|
||||||
|
String yml = Files.readString(Path.of("plugin.yml"), StandardCharsets.UTF_8);
|
||||||
|
assertTrue(yml.contains("\nrequiresSpi: \">=1.0.0\"\n"), "built for the frozen SPI 1.0.0 contract");
|
||||||
|
String pom = Files.readString(Path.of("pom.xml"), StandardCharsets.UTF_8);
|
||||||
|
Matcher version = Pattern.compile("<artifactId>runway-plugin-carousel-manager</artifactId>\\s*<version>([^<]+)")
|
||||||
|
.matcher(pom);
|
||||||
|
assertTrue(version.find());
|
||||||
|
assertTrue(yml.contains("\nversion: " + version.group(1) + "\n"), "plugin.yml and pom.xml agree on the version");
|
||||||
|
assertFalse(pom.contains("<artifactId>runway-app</artifactId>"), "no runway-app dependency in any scope");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theCompiledClassesLinkNoHostInternals() throws IOException {
|
||||||
|
Path classes = Path.of("target", "classes");
|
||||||
|
Pattern host = Pattern.compile("mx[/.]quest[/.]runway[/.](?!spi[/.])[\\w/.$]*");
|
||||||
|
List<String> problems = new ArrayList<>();
|
||||||
|
int scanned = 0;
|
||||||
|
try (Stream<Path> files = Files.walk(classes)) {
|
||||||
|
for (Path file : files.filter(p -> p.toString().endsWith(".class")).toList()) {
|
||||||
|
scanned++;
|
||||||
|
String rel = classes.relativize(file).toString().replace('\\', '/');
|
||||||
|
if (rel.startsWith("mx/quest/runway/")) {
|
||||||
|
problems.add(rel + " lives under mx.quest.runway");
|
||||||
|
}
|
||||||
|
// The constant pool holds class names and descriptors as (modified) UTF-8; Latin-1 keeps every
|
||||||
|
// byte as one char, so an ASCII pattern finds them without parsing the class file.
|
||||||
|
Matcher m = host.matcher(new String(Files.readAllBytes(file), StandardCharsets.ISO_8859_1));
|
||||||
|
while (m.find()) {
|
||||||
|
problems.add(rel + " → " + m.group());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(scanned >= 4, "the compiled classes were found (" + scanned + ")");
|
||||||
|
assertTrue(problems.isEmpty(), "host linkage: " + problems);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
package mx.quest.carousel;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import mx.quest.runway.spi.model.PageMeta;
|
||||||
|
import mx.quest.runway.spi.model.RenderFragment;
|
||||||
|
import mx.quest.runway.spi.model.SiteView;
|
||||||
|
import mx.quest.runway.spi.model.WidgetView;
|
||||||
|
import mx.quest.runway.spi.testkit.FakePluginSettings;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The carousel widget: slide parsing, rendering, escaping, setting gating, defaults and clamping, and the
|
||||||
|
* empty-when-unconfigured case — against the SPI testkit's {@link FakePluginSettings}, configured with the
|
||||||
|
* descriptor's real {@code siteSettings:} defaults (read from {@code plugin.yml}) the way the kernel applies them.
|
||||||
|
*/
|
||||||
|
class CarouselWidgetTest {
|
||||||
|
|
||||||
|
private FakePluginSettings settings;
|
||||||
|
private CarouselWidget widget;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() throws IOException {
|
||||||
|
settings = new FakePluginSettings().defaults(descriptorDefaults());
|
||||||
|
widget = new CarouselWidget(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The {@code default:} of every {@code siteSettings:} entry in {@code plugin.yml}, typed as the kernel types them. */
|
||||||
|
static Map<String, Object> descriptorDefaults() throws IOException {
|
||||||
|
String yml = Files.readString(Path.of("plugin.yml"), StandardCharsets.UTF_8);
|
||||||
|
Matcher m = Pattern.compile("\\{\\s*key:\\s*(\\w+)\\s*,\\s*type:\\s*(\\w+)[^}]*?default:\\s*([^,}]+?)\\s*[,}]")
|
||||||
|
.matcher(yml);
|
||||||
|
Map<String, Object> out = new LinkedHashMap<>();
|
||||||
|
while (m.find()) {
|
||||||
|
String raw = m.group(3);
|
||||||
|
Object value = switch (m.group(2)) {
|
||||||
|
case "boolean" -> Boolean.valueOf(raw);
|
||||||
|
case "int" -> Long.valueOf(raw);
|
||||||
|
default -> raw;
|
||||||
|
};
|
||||||
|
out.put(m.group(1), value);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String html(String siteId) {
|
||||||
|
SiteView site = new SiteView(siteId, "Acme", Locale.ENGLISH, List.of(Locale.ENGLISH), null);
|
||||||
|
PageMeta page = new PageMeta("home", "Home", "", List.of(Locale.ENGLISH), Locale.ENGLISH, true, false);
|
||||||
|
RenderFragment fragment = widget.render(new WidgetView(site, page, Locale.ENGLISH, "hero", false, Map.of()));
|
||||||
|
return fragment.isEmpty() ? "" : fragment.html();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String render(Map<String, ?> stored) {
|
||||||
|
settings.site("acme", stored);
|
||||||
|
return html("acme");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String attr(String html, String name) {
|
||||||
|
Matcher m = Pattern.compile(name + "=\"([^\"]*)\"").matcher(html);
|
||||||
|
return m.find() ? m.group(1) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void keyIsCarousel() {
|
||||||
|
assertEquals("carousel", widget.key());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rendersConfiguredSlidesWithCaptionsAndLinks() {
|
||||||
|
String html = render(Map.of("slides", "/img/a.jpg | Welcome | /about\n/img/b.jpg | Our work | /work"));
|
||||||
|
assertTrue(html.contains("src=\"/img/a.jpg\""), "first slide image");
|
||||||
|
assertTrue(html.contains("src=\"/img/b.jpg\""), "second slide image");
|
||||||
|
assertTrue(html.contains(">Welcome</figcaption>"), "caption rendered");
|
||||||
|
assertTrue(html.contains("href=\"/about\""), "link rendered");
|
||||||
|
assertTrue(html.contains("/__plugin/carousel-manager/static/carousel.css"), "references the plugin CSS");
|
||||||
|
assertTrue(html.contains("/__plugin/carousel-manager/static/carousel.js"), "references the plugin JS");
|
||||||
|
assertEquals(1, html.split("is-active", -1).length - 1, "exactly the first slide is active");
|
||||||
|
assertTrue(html.indexOf("is-active") < html.indexOf("/img/a.jpg"), "…and it is the first one");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void anImageOnlySlideNeedsNoCaptionOrLink() {
|
||||||
|
String html = render(Map.of("slides", "/img/solo.jpg"));
|
||||||
|
assertTrue(html.contains("src=\"/img/solo.jpg\""));
|
||||||
|
assertFalse(html.contains("<a class=\"rw-carousel-link\""), "no link element when none configured");
|
||||||
|
assertFalse(html.contains("rw-carousel-caption"), "no caption element when none configured");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void noSlidesRendersEmpty() {
|
||||||
|
assertTrue(render(Map.of()).isEmpty(), "an unconfigured carousel renders nothing");
|
||||||
|
assertTrue(render(Map.of("slides", " \n ")).isEmpty(), "blank slide lines render nothing");
|
||||||
|
assertTrue(render(Map.of("slides", " | caption only | /x")).isEmpty(), "a line with no image is dropped");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aCaptionWithACommaSurvivesAndWindowsLineEndingsSplit() {
|
||||||
|
String html = render(Map.of("slides", "/img/a.jpg | Fast, fresh, local | /x\r\n/img/b.jpg"));
|
||||||
|
assertTrue(html.contains(">Fast, fresh, local</figcaption>"), "the text setting is never comma-split");
|
||||||
|
assertTrue(html.contains("src=\"/img/b.jpg\""), "a CRLF line ending separates slides");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void captionsAndControlsHonorTheirFlags() {
|
||||||
|
String noCaptions = render(Map.of("slides", "/img/a.jpg | Hi | /x\n/img/b.jpg | Yo | /y",
|
||||||
|
"showCaptions", false));
|
||||||
|
assertFalse(noCaptions.contains("rw-carousel-caption"), "captions off ⇒ no caption element");
|
||||||
|
assertTrue(noCaptions.contains("alt=\"Hi\""), "…the caption still serves as the image's alt text");
|
||||||
|
String noControls = render(Map.of("slides", "/img/a.jpg\n/img/b.jpg", "showControls", false));
|
||||||
|
assertFalse(noControls.contains("rw-carousel-next"), "controls off ⇒ no next button");
|
||||||
|
assertEquals("false", attr(noControls, "data-controls"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flagsStoredAsTextAreReadToo() {
|
||||||
|
String html = render(Map.of("slides", "/img/a.jpg | Hi\n/img/b.jpg", "showCaptions", "off",
|
||||||
|
"showControls", "no"));
|
||||||
|
assertFalse(html.contains("rw-carousel-caption"), "\"off\" turns captions off");
|
||||||
|
assertFalse(html.contains("rw-carousel-next"), "\"no\" turns controls off");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theDefaultsShowCaptionsAndControlsAndAdvanceEveryFiveSeconds() {
|
||||||
|
String html = render(Map.of("slides", "/img/a.jpg | Hi | /x\n/img/b.jpg"));
|
||||||
|
assertEquals("5", attr(html, "data-interval"));
|
||||||
|
assertEquals("true", attr(html, "data-controls"));
|
||||||
|
assertTrue(html.contains("rw-carousel-prev") && html.contains("rw-carousel-next"), "two slides ⇒ controls");
|
||||||
|
assertTrue(html.contains("rw-carousel-caption"), "captions on by default");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void controlsNeedMoreThanOneSlide() {
|
||||||
|
String html = render(Map.of("slides", "/img/a.jpg"));
|
||||||
|
assertFalse(html.contains("rw-carousel-prev"), "a single slide has nothing to step through");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theIntervalIsReadAndClampedToTheDeclaredRange() {
|
||||||
|
assertEquals("12", attr(render(Map.of("slides", "/img/a.jpg", "intervalSeconds", 12L)), "data-interval"));
|
||||||
|
assertEquals("12", attr(render(Map.of("slides", "/img/a.jpg", "intervalSeconds", "12")), "data-interval"));
|
||||||
|
assertEquals("0", attr(render(Map.of("slides", "/img/a.jpg", "intervalSeconds", 0L)), "data-interval"),
|
||||||
|
"0 = auto-advance off");
|
||||||
|
assertEquals("60", attr(render(Map.of("slides", "/img/a.jpg", "intervalSeconds", 600L)), "data-interval"));
|
||||||
|
assertEquals("0", attr(render(Map.of("slides", "/img/a.jpg", "intervalSeconds", -3L)), "data-interval"));
|
||||||
|
assertEquals("5", attr(render(Map.of("slides", "/img/a.jpg", "intervalSeconds", "soon")), "data-interval"),
|
||||||
|
"an unparsable hand-edited value falls back to the default");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void codeFallbacksEqualTheDescriptorDefaults() throws IOException {
|
||||||
|
Map<String, Object> declared = descriptorDefaults();
|
||||||
|
assertEquals(Map.of("intervalSeconds", 5L, "showCaptions", true, "showControls", true), declared,
|
||||||
|
"plugin.yml declares the defaults this test (and the docs) assume");
|
||||||
|
String slides = "/img/a.jpg | Hi | /x\n/img/b.jpg | Yo";
|
||||||
|
String withDefaults = render(Map.of("slides", slides));
|
||||||
|
widget = new CarouselWidget(new FakePluginSettings().site("acme", Map.of("slides", slides)));
|
||||||
|
assertEquals(withDefaults, html("acme"), "the widget renders the same with or without the host's defaults");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void eachSiteRendersItsOwnSlides() {
|
||||||
|
settings.site("acme", Map.of("slides", "/img/acme.jpg"));
|
||||||
|
settings.site("other", Map.of("slides", "/img/other.jpg"));
|
||||||
|
assertTrue(html("acme").contains("/img/acme.jpg") && !html("acme").contains("/img/other.jpg"));
|
||||||
|
assertTrue(html("other").contains("/img/other.jpg") && !html("other").contains("/img/acme.jpg"));
|
||||||
|
assertTrue(html("nobody").isEmpty(), "a site with nothing saved renders nothing");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aCraftedCaptionOrUrlIsEscaped() {
|
||||||
|
String html = render(Map.of("slides", "/img/a.jpg\" onerror=\"x | <script>x</script> | javascript:\"x"));
|
||||||
|
assertFalse(html.contains("<script>x</script>"), "the caption is HTML-escaped, never injected");
|
||||||
|
assertTrue(html.contains("<script>"), "…it appears escaped");
|
||||||
|
assertFalse(html.contains("\" onerror=\""), "an image URL cannot break out of its attribute");
|
||||||
|
assertTrue(html.contains("src=\"/img/a.jpg" onerror="x\""));
|
||||||
|
assertTrue(html.contains("href=\"javascript:"x\""), "the link's quote is escaped too");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void anUnsafeSiteIdIsRefusedNotRead() {
|
||||||
|
SiteView site = new SiteView("../etc", "x", Locale.ENGLISH, List.of(Locale.ENGLISH), null);
|
||||||
|
PageMeta page = new PageMeta("home", "Home", "", List.of(Locale.ENGLISH), Locale.ENGLISH, true, false);
|
||||||
|
assertThrows(IllegalArgumentException.class,
|
||||||
|
() -> widget.render(new WidgetView(site, page, Locale.ENGLISH, "hero", false, Map.of())),
|
||||||
|
"the settings service refuses it; the host's containment turns that into an empty widget");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void declaresItsCapability() {
|
||||||
|
assertTrue(widget.capabilities().toString().contains("widget.carousel"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta name="robots" content="noindex">
|
||||||
|
<title>Carousel plugin — help & reference</title>
|
||||||
|
<style>
|
||||||
|
body { max-width: 46rem; margin: 2rem auto; padding: 0 1rem;
|
||||||
|
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #1a1a1a; line-height: 1.5; }
|
||||||
|
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; margin-top: 1.75rem; }
|
||||||
|
code { background: #f3f3f3; padding: .1rem .3rem; border-radius: .25rem; }
|
||||||
|
pre { background: #f6f8fa; padding: .75rem 1rem; border-radius: .375rem; overflow: auto; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Carousel — help & reference</h1>
|
||||||
|
<p>The Carousel Manager plugin adds a configurable image/slide carousel you can place on any page.</p>
|
||||||
|
|
||||||
|
<h2>1. Configure the slides</h2>
|
||||||
|
<p>On the carousel settings page, fill <strong>Slides</strong> — one slide per line, fields separated by a pipe
|
||||||
|
(<code>|</code>):</p>
|
||||||
|
<pre>/static/img/hero1.jpg | Welcome to Acme | /about
|
||||||
|
/static/img/hero2.jpg | Our latest work | /work
|
||||||
|
/static/img/hero3.jpg</pre>
|
||||||
|
<p>Only the image URL is required; the caption and the click-through link are optional. Other settings: the
|
||||||
|
auto-advance interval (seconds; <code>0</code> disables auto-play), whether to show captions, and whether to
|
||||||
|
show the previous/next controls.</p>
|
||||||
|
|
||||||
|
<h2>2. Place the carousel on a page</h2>
|
||||||
|
<p>Add an anchor where the carousel should appear (the <code>id</code> and <code>data-widget</code> must be on the
|
||||||
|
<em>same</em> element):</p>
|
||||||
|
<pre><div id="hero" data-widget="carousel/hero"></div></pre>
|
||||||
|
<p>The widget renders your configured slides there, pulling in its own stylesheet and script automatically. With
|
||||||
|
no slides configured it renders nothing.</p>
|
||||||
|
|
||||||
|
<h2>Note: one carousel per site (for now)</h2>
|
||||||
|
<p>This plugin does not yet declare a per-placement widget configuration (Runway supports one), so every
|
||||||
|
<code>carousel/*</code> anchor on a site shows the <strong>same</strong> configured slides. Distinct carousels per
|
||||||
|
page need that declaration in a later version — the widget already carries the instance id for it.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
/* Runway Carousel Manager — styles. Served at /__plugin/carousel-manager/static/carousel.css.
|
||||||
|
Neutral defaults so it inherits the site's look; override any .rw-carousel* rule from your own CSS. */
|
||||||
|
|
||||||
|
.rw-carousel {
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
max-width: 100%;
|
||||||
|
border-radius: .5rem;
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rw-carousel-track {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rw-carousel-slide {
|
||||||
|
margin: 0;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rw-carousel-slide.is-active {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rw-carousel-img {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rw-carousel-caption {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: .75rem 1rem;
|
||||||
|
color: #fff;
|
||||||
|
background: linear-gradient(transparent, rgba(0, 0, 0, .6));
|
||||||
|
font: 500 1rem/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rw-carousel-link {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rw-carousel-prev,
|
||||||
|
.rw-carousel-next {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
border: 0;
|
||||||
|
width: 2.5rem;
|
||||||
|
height: 2.5rem;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: rgba(0, 0, 0, .4);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
line-height: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rw-carousel-prev { left: .5rem; }
|
||||||
|
.rw-carousel-next { right: .5rem; }
|
||||||
|
|
||||||
|
.rw-carousel-prev:hover,
|
||||||
|
.rw-carousel-next:hover {
|
||||||
|
background: rgba(0, 0, 0, .65);
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/* Runway Carousel Manager — behaviour. Served at /__plugin/carousel-manager/static/carousel.js.
|
||||||
|
Idempotent: initializes every .rw-carousel not already initialized, so the widget can include this script
|
||||||
|
once per instance without double-binding. No dependencies. */
|
||||||
|
(function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
function init(root) {
|
||||||
|
if (root.dataset.rwInit === "1") { return; }
|
||||||
|
root.dataset.rwInit = "1";
|
||||||
|
|
||||||
|
var slides = Array.prototype.slice.call(root.querySelectorAll(".rw-carousel-slide"));
|
||||||
|
if (slides.length === 0) { return; }
|
||||||
|
var index = slides.findIndex(function (s) { return s.classList.contains("is-active"); });
|
||||||
|
if (index < 0) { index = 0; }
|
||||||
|
|
||||||
|
function show(i) {
|
||||||
|
index = (i + slides.length) % slides.length;
|
||||||
|
slides.forEach(function (s, k) { s.classList.toggle("is-active", k === index); });
|
||||||
|
}
|
||||||
|
|
||||||
|
var prev = root.querySelector(".rw-carousel-prev");
|
||||||
|
var next = root.querySelector(".rw-carousel-next");
|
||||||
|
if (prev) { prev.addEventListener("click", function () { show(index - 1); pause(); }); }
|
||||||
|
if (next) { next.addEventListener("click", function () { show(index + 1); pause(); }); }
|
||||||
|
|
||||||
|
var interval = parseInt(root.dataset.interval, 10);
|
||||||
|
var timer = null;
|
||||||
|
function play() {
|
||||||
|
if (!(interval > 0) || slides.length < 2) { return; }
|
||||||
|
timer = window.setInterval(function () { show(index + 1); }, interval * 1000);
|
||||||
|
}
|
||||||
|
function pause() { if (timer) { window.clearInterval(timer); timer = null; } }
|
||||||
|
|
||||||
|
root.addEventListener("mouseenter", pause);
|
||||||
|
root.addEventListener("mouseleave", play);
|
||||||
|
show(index);
|
||||||
|
play();
|
||||||
|
}
|
||||||
|
|
||||||
|
function scan() {
|
||||||
|
Array.prototype.forEach.call(document.querySelectorAll(".rw-carousel"), init);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.readyState === "loading") {
|
||||||
|
document.addEventListener("DOMContentLoaded", scan);
|
||||||
|
} else {
|
||||||
|
scan();
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<!-- Admin status fragment — rendered below this plugin's per-tenant settings form. Bare fragment. -->
|
||||||
|
<div class="card mt-3">
|
||||||
|
<div class="card-header"><h3 class="card-title" id="ca-title">Carousel status</h3></div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="datagrid">
|
||||||
|
<div class="datagrid-item">
|
||||||
|
<div class="datagrid-title" id="ca-l-slides">Configured slides</div>
|
||||||
|
<div class="datagrid-content" id="ca-slides">0</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="text-secondary small mt-2 mb-0" id="ca-usage">
|
||||||
|
Add the carousel to a page with a data-widget anchor, e.g.
|
||||||
|
<code><div id="hero" data-widget="carousel/hero"></div></code>.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer">
|
||||||
|
<a id="ca-help" href="/__plugin/carousel-manager/static/carousel-help.html" target="_blank" rel="noopener">
|
||||||
|
<i class="fa-solid fa-circle-question me-1"></i><span id="ca-help-label">Carousel help & reference</span></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Admin fragment logic. Values from ${@carouselManagerAdminModel...(tenantSiteId)}. The usage line keeps its literal
|
||||||
|
HTML example (no binding) so it renders verbatim. -->
|
||||||
|
<thlogic>
|
||||||
|
<attr sel="#ca-title" th:text="#{carousel.admin.title}"/>
|
||||||
|
<attr sel="#ca-l-slides" th:text="#{carousel.admin.slides}"/>
|
||||||
|
<attr sel="#ca-slides" th:text="${@carouselManagerAdminModel.slideCount(tenantSiteId)}"/>
|
||||||
|
<attr sel="#ca-help-label" th:text="#{carousel.admin.help}"/>
|
||||||
|
</thlogic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<!-- Tenant dashboard card fragment — __plugin__/carousel-manager/dashboard. Bare fragment; binding in .th.xml. -->
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-status-start bg-pink"></div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<span class="bg-pink-lt avatar"><i class="fa-solid fa-images"></i></span>
|
||||||
|
<div class="ms-3">
|
||||||
|
<div class="fw-bold" id="cc-title">Carousel</div>
|
||||||
|
<div class="text-secondary small">
|
||||||
|
<span id="cc-slides">0</span> <span id="cc-slides-lbl">slides</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Dashboard card logic. Values from ${@carouselManagerAdminModel...(tenantSiteId)}. -->
|
||||||
|
<thlogic>
|
||||||
|
<attr sel="#cc-title" th:text="#{carousel.card.title}"/>
|
||||||
|
<attr sel="#cc-slides" th:text="${@carouselManagerAdminModel.slideCount(tenantSiteId)}"/>
|
||||||
|
<attr sel="#cc-slides-lbl" th:text="#{carousel.card.slides}"/>
|
||||||
|
</thlogic>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes are recorded here. Versions follow [Semantic Versioning](https://semver.org/).
|
||||||
|
|
||||||
|
## [2.1.0] — 2026-10-21
|
||||||
|
|
||||||
|
First public release of `contact`: an embeddable contact-form widget whose submissions are both emailed over the
|
||||||
|
site's own SMTP relay and stored as site data for the console, with CAPTCHA (when the site has one) and a
|
||||||
|
honeypot against spam. Requires SPI `1.0.0` (Runway `1.0.0` or later). Licensed under the GNU AGPL v3.0 with an additional permission for
|
||||||
|
plugins (`LICENSE`, `LICENSE-EXCEPTION`).
|
||||||
@@ -0,0 +1,661 @@
|
|||||||
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights
|
||||||
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified source code becomes available
|
||||||
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and
|
||||||
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
|
this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer
|
||||||
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for the
|
||||||
|
specific requirements.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
Runway — additional permission for plugins
|
||||||
|
(an additional permission under section 7 of the GNU Affero General Public License, version 3)
|
||||||
|
|
||||||
|
Copyright (C) 2026 Quest ICT SAS de CV
|
||||||
|
|
||||||
|
Runway is free software: you can redistribute it and/or modify it under the terms of the
|
||||||
|
GNU Affero General Public License as published by the Free Software Foundation, version 3
|
||||||
|
(the file LICENSE), with the additional permission below. Runway is distributed in the hope
|
||||||
|
that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||||
|
License for more details.
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
|
||||||
|
"Runway" means the Runway kernel and every Runway plugin whose source carries this file.
|
||||||
|
|
||||||
|
"Published SPI" means the public classes and interfaces of the runway-spi artifact
|
||||||
|
(the package mx.quest.runway.spi and its subpackages), together with the public classes
|
||||||
|
and interfaces of any package named "spi" that a part of Runway publishes for other
|
||||||
|
plugins to use (for example mx.quest.search.spi).
|
||||||
|
|
||||||
|
"Plugin" means an independent module that Runway loads as a plugin, that interacts with
|
||||||
|
Runway only through the Published SPI, and that is not based on any part of Runway other
|
||||||
|
than the Published SPI.
|
||||||
|
|
||||||
|
2. Permission
|
||||||
|
|
||||||
|
As an additional permission, the copyright holder gives you permission to combine Runway
|
||||||
|
with Plugins, and to convey and run the resulting combination, without the terms of the
|
||||||
|
GNU Affero General Public License applying to those Plugins. You may license, convey and
|
||||||
|
run your Plugins under terms of your choice, provided that you continue to meet the terms
|
||||||
|
of the GNU Affero General Public License for Runway itself, including offering the
|
||||||
|
Corresponding Source of Runway, and of any modification you make to it, as that license
|
||||||
|
requires.
|
||||||
|
|
||||||
|
3. Testing
|
||||||
|
|
||||||
|
Compiling a Plugin's tests against the runway-spi-testkit artifact, and running them, does
|
||||||
|
not by itself make the Plugin subject to the GNU Affero General Public License.
|
||||||
|
|
||||||
|
4. Modified versions
|
||||||
|
|
||||||
|
If you modify Runway, you may extend this additional permission to your version, but you
|
||||||
|
are not obliged to do so. If you do not wish to, delete this file from your version.
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
# Runway Contact plugin
|
||||||
|
|
||||||
|
A **contact form** for [Runway](../README.md): an embeddable form content widget that **POSTs** to an anonymous
|
||||||
|
`/contact/submit` route, which **both emails** each submission over the site's own SMTP relay **and stores** it as
|
||||||
|
tenant-owned data (read in the console) — belt-and-suspenders, so a message is never lost even if SMTP is down.
|
||||||
|
CAPTCHA (when the site has one) and honeypot anti-spam.
|
||||||
|
|
||||||
|
- **Plugin id:** `contact` — install folder `external/plugins/contact/` · **version 2.1.0**
|
||||||
|
- **Java package:** `mx.quest.contact` · **SPIs:** `ContentWidget` (`contact`) + `EndpointContributor`
|
||||||
|
(`POST /contact/submit` anonymous; `POST /contact/install-page` and `POST /contact/smtp-test`, CSRF-checked)
|
||||||
|
- **Links only the Runway SPI** (`requiresSpi: ">=1.0.0"`): `PluginSettings` (settings + the SMTP password secret),
|
||||||
|
`PluginSiteFiles` (submissions), `Messages`, `AccessCheck`, `SitePages` (the starter page), `CaptchaService`.
|
||||||
|
**Needs Runway 1.0.0 or later** (SPI `1.0.0`) — a kernel with an older SPI blocks this release at startup with
|
||||||
|
a reason. See [`CHANGELOG.md`](CHANGELOG.md).
|
||||||
|
- **No plugin dependency:** Jakarta Mail is part of the **core** Runway application (the kernel bundles it for
|
||||||
|
its own platform mailer), so `contact` compiles it as `provided` and resolves the kernel's copy at runtime.
|
||||||
|
|
||||||
|
## Use it
|
||||||
|
|
||||||
|
1. Install `contact`, then restart the host.
|
||||||
|
2. Enable the plugin, set your thank-you message, and fill in the **SMTP relay** (host, port, auth,
|
||||||
|
username/password, STARTTLS/SSL, from/to) on the Contact settings page — the password is stored encrypted.
|
||||||
|
3. Verify the relay with **Send a test email** on the settings page (operator-only).
|
||||||
|
4. Put a form on a page: install the ready-made **Contact page** from the settings (it follows the site's
|
||||||
|
publishing rules and says what happened), or add `<div id="contact" data-widget="contact/form"></div>` to any
|
||||||
|
page.
|
||||||
|
5. Read submissions on the Contact settings page (newest first) — a copy is kept even when email delivery fails.
|
||||||
|
|
||||||
|
> A site with a **blank** SMTP host/recipient simply stores messages (no email) — email is optional. A site sends
|
||||||
|
> with its **own** relay only (tenant isolation).
|
||||||
|
|
||||||
|
> **Privacy.** The form POSTs, so a visitor's fields never appear in a URL, browser history or proxy log. The
|
||||||
|
> stored submissions are declared **personal data** (`siteData.personal: [submissions.tsv]`): a site's **transfer
|
||||||
|
> copy** leaves them out (and lists the omission in its manifest); a **full backup** keeps them. See
|
||||||
|
> [`docs/CONTACT-PLUGIN.md`](docs/CONTACT-PLUGIN.md).
|
||||||
|
|
||||||
|
## Build and verify
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export JAVA_HOME=/path/to/jdk-25
|
||||||
|
mvn verify # 75 tests (send seam mocked — no socket)
|
||||||
|
mvn -DskipTests package # jar + target/contact/ + the .zip
|
||||||
|
HOST_JAR=/path/to/runway-app-<ver>-exec.jar VERIFY_TMPDIR=/somewhere scripts/verify-against-host.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
The first build downloads its Maven dependencies, and needs the `runway-spi` jars installed in `~/.m2` as the
|
||||||
|
[authoring guide §2](../docs/PLUGIN-AUTHORING-GUIDE.md#2-prerequisites) describes.
|
||||||
|
|
||||||
|
The verify boots the **packaged** host with this plugin (and, when built, the protection plugin from the host
|
||||||
|
checkout), on four sites (Advisory, Enforced, Reviewed, and one with a CAPTCHA), and checks 59 things (54 without
|
||||||
|
the protection plugin): zero
|
||||||
|
host-linkage and surface warnings; an anonymous POST with no session stored and answered `303` with only an
|
||||||
|
outcome flag; GET, honeypot, invalid, query-string and multipart submissions refused; the two operator actions
|
||||||
|
CSRF-checked (a GET changes nothing, a POST without the console token is `403`); the starter page installed
|
||||||
|
on every editorial level and never twice; the SMTP password stored `ENC(...)` and handed in clear to a local fake
|
||||||
|
relay; a full backup with the submissions and a transfer copy without them; a POST without the CAPTCHA token
|
||||||
|
refused.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
GNU Affero General Public License v3.0 with an additional permission for plugins (`LICENSE`, `LICENSE-EXCEPTION`),
|
||||||
|
copyright Quest ICT SAS de CV. The permission means that a plugin which uses only the published SPI may carry any
|
||||||
|
license.
|
||||||
@@ -0,0 +1,256 @@
|
|||||||
|
# Runway Contact plugin — design & reference
|
||||||
|
|
||||||
|
> The reference for a plugin that **accepts input from anonymous visitors**, **stores per-tenant
|
||||||
|
> personal data**, and **sends email** within the kernel's constraints (CSRF, servlet-free endpoints, tenant
|
||||||
|
> isolation, encrypted secrets) — using **only the Runway SPI** (version 2.1.0, SPI 1.0.0). Grounded in the Runway
|
||||||
|
> kernel as built.
|
||||||
|
|
||||||
|
## 1. What it does
|
||||||
|
|
||||||
|
- **Form widget** — a `ContentWidget` (`key = "contact"`) that renders the shared `ContactForm` inline wherever a
|
||||||
|
page carries `<div id="…" data-widget="contact/…"></div>`. Honors the per-tenant `enabled` flag. The plugin owns
|
||||||
|
**no visible page**: the form lives on a normal, editable site page. The widget is **query-aware** — the submit
|
||||||
|
handler redirects back with `?contact=sent|invalid|captcha|queued`, and the widget re-renders that outcome
|
||||||
|
(thank-you, or the form with an error) from the flag, so the page it sits on stays an ordinary, cacheable page.
|
||||||
|
- **`POST /contact/submit`** — an `EndpointContributor` route declared **anonymous** (`Route.anonymousPost`, §2)
|
||||||
|
that reads the fields from the url-encoded **body only**, runs the honeypot + (when configured) the CAPTCHA
|
||||||
|
check, and for a valid message **stores it AND emails it** over the site's own SMTP relay, then answers
|
||||||
|
**`303 See Other` back to the page the form lives on** (the same-origin `return` field, else the `Referer`) with
|
||||||
|
only the outcome flag. It renders nothing itself. Any other method on this path is a 404.
|
||||||
|
- **`POST /contact/install-page`** — an ordinary (CSRF-checked, §2a) route, operator-gated (`contact|settings`,
|
||||||
|
checked with `AccessCheck`; fails **closed** with a 404 otherwise): installs a ready-made, editable tenant page carrying the form widget (slug
|
||||||
|
`contact`, path `/contact`) through **`SitePages.install`**. The kernel never overwrites and follows the site's
|
||||||
|
editorial level; the plain-text answer names the outcome (§1c). Once installed it is an ordinary site page
|
||||||
|
(listed under Pages; restyle / move / rename it), so the operator, not the plugin, owns the URL and chrome.
|
||||||
|
- **`POST /contact/smtp-test`** — an operator-only diagnostic (same CSRF check and gate) that sends a test message
|
||||||
|
over the site's relay to verify the SMTP configuration — to the configured recipient, or to an optional `to` field
|
||||||
|
of the form body (never the query string).
|
||||||
|
- **Console** — a dashboard card (submission count) and an admin fragment with a **"Contact page"** card (install
|
||||||
|
the ready-made page with a button, or see its live path when already installed — read fresh with
|
||||||
|
`SitePages.pathOf`, so it follows a move and counts a draft or a page in review), the **SMTP readiness**
|
||||||
|
("Configured / Not configured" badge + a "Send a test email" button) and a list of
|
||||||
|
**recent submissions** (name, email, message excerpt, time), gated by the `settings` control point.
|
||||||
|
|
||||||
|
## 1a. Belt-and-suspenders: store AND send
|
||||||
|
|
||||||
|
A valid submission is **always stored first** (`ContactStore`, tenant TSV), **then** emailed (`ContactMailer`).
|
||||||
|
The store is unconditional, so a message is **never lost** even if SMTP is down:
|
||||||
|
|
||||||
|
- **Send OK** → stored + emailed; the visitor sees the thank-you.
|
||||||
|
- **Send FAILED** (a configured relay rejected/unreachable) → stored; the failure is logged and the visitor is
|
||||||
|
redirected with `?contact=queued`, which the widget renders as the thank-you plus an unobtrusive "message
|
||||||
|
received; email delivery is delayed" note. The relay internals
|
||||||
|
are never exposed to the visitor.
|
||||||
|
- **NOT_CONFIGURED** (blank host/recipient) → stored silently, no note — a site may legitimately choose to only
|
||||||
|
store messages and read them in the console.
|
||||||
|
- **PROVIDER_MISSING** (Jakarta Mail off the classloader) → stored; reported. The kernel bundles Jakarta Mail as
|
||||||
|
a core capability, so this is effectively unreachable, but `ContactMailer` still guards the `LinkageError` at
|
||||||
|
the send seam so the request can never crash.
|
||||||
|
|
||||||
|
## 1b. Email over the kernel's Jakarta Mail
|
||||||
|
|
||||||
|
The plugin compiles `jakarta.mail-api` as **`provided`** — the **kernel** bundles the Jakarta Mail + Angus stack
|
||||||
|
as a core capability (for its own platform mailer), and the plugin classloader reaches it parent-first. This
|
||||||
|
plugin **never bundles Jakarta Mail itself** (that would be a second, shadowing copy on the classloader). It
|
||||||
|
therefore needs **no `requires:`** gate.
|
||||||
|
|
||||||
|
- The send seam is the `MailTransport` interface (`JakartaMailTransport` delegates to `jakarta.mail.Transport` in
|
||||||
|
production; mocked in tests so no socket is opened).
|
||||||
|
- `ContactMailer.build(...)` constructs a `MimeMessage` from `SmtpSettings`: From = the site's `fromAddress` (or
|
||||||
|
the recipient when blank), To = the site's `toAddress`, Reply-To = the visitor's email (so a reply reaches
|
||||||
|
them), a site-prefixed Subject, and a plain-text body. The `Session` always uses the `smtp` protocol
|
||||||
|
(implicit TLS rides `mail.smtp.ssl.enable`, STARTTLS `mail.smtp.starttls.enable`) and a static `Authenticator`
|
||||||
|
when `smtpAuth` is on.
|
||||||
|
|
||||||
|
### Per-site SMTP settings (tenant-owned, isolated)
|
||||||
|
|
||||||
|
All relay config is per-tenant `siteSettings` over `sites/<id>/plugins/contact.yml`, so **a site sends with its
|
||||||
|
OWN relay only** — never another tenant's:
|
||||||
|
|
||||||
|
| key | type | notes |
|
||||||
|
|---|---|---|
|
||||||
|
| `smtpHost` | string | blank ⇒ not configured ⇒ mail skipped (stored only) |
|
||||||
|
| `smtpPort` | int (1..65535, default 25) | |
|
||||||
|
| `smtpAuth` | boolean (default false) | when on, uses username/password |
|
||||||
|
| `smtpUsername` | string | |
|
||||||
|
| `smtpPassword` | **secret** | stored `ENC(...)`-encrypted; the config file is `chmod 600`; **bound** to `smtpHost`, `smtpPort`, `smtpUsername`, `smtpStarttls`, `smtpSsl` (below) |
|
||||||
|
| `smtpStarttls` | boolean (default false) | STARTTLS upgrade on a plain connection |
|
||||||
|
| `smtpSsl` | boolean (default false) | implicit-TLS (SMTPS) |
|
||||||
|
| `fromAddress` | string | envelope From; blank ⇒ falls back to the recipient |
|
||||||
|
| `toAddress` | string | recipient; blank ⇒ not configured ⇒ mail skipped |
|
||||||
|
|
||||||
|
Every value is read from the `SettingsView` that `PluginSettings.site(siteId)` returns (the descriptor defaults
|
||||||
|
overlaid by what the operator saved). The **secret** password is stored `ENC(...)` by the platform; the plugin
|
||||||
|
reads it in clear with **`PluginSettings.secret(siteId, "smtpPassword")`** at send time — the kernel decrypts it
|
||||||
|
(a hand-written plaintext value is returned as is) and answers empty when it is unset or cannot be decrypted (the
|
||||||
|
relay then rejects the login and the submission is reported "delivery delayed", still stored). The password is
|
||||||
|
never taken from the settings view (the kernel leaves secret keys out of it, and a test holds the plugin to that).
|
||||||
|
The plaintext lives only in the transient `SmtpSettings` value handed to Jakarta Mail — never logged
|
||||||
|
(`SmtpSettings.toString()` masks it) and never stored by this plugin.
|
||||||
|
|
||||||
|
**The password is bound to the relay login (`secretBoundTo`).** The descriptor declares
|
||||||
|
`secretBoundTo: [smtpHost, smtpPort, smtpUsername, smtpStarttls, smtpSsl]` on `smtpPassword` (the TLS switches
|
||||||
|
too: turning TLS off toward the same host would otherwise send the stored password in clear). A settings save that
|
||||||
|
changes any of those five **without retyping the password** makes the kernel drop the stored password (the field is left blank, so the
|
||||||
|
next send fails the login and the submission is stored as "delivery delayed" until the password is entered again).
|
||||||
|
Why: the settings form never shows the stored password, but whoever may edit the settings could otherwise point the
|
||||||
|
site's saved credentials at a server of their own — change the host, keep the password, press **Send a test
|
||||||
|
email** — and read the password off the wire. Binding it means a stored password is only ever offered to the relay
|
||||||
|
login it was typed for. Retyping the password in the same save keeps it (the new value is stored). Changing any
|
||||||
|
other setting (`enabled`, the thank-you message, sender, recipient, `smtpAuth`) leaves it alone. The binding is
|
||||||
|
enforced by the kernel, which also tells the operator on the settings page when a save dropped the password.
|
||||||
|
|
||||||
|
## 1c. The starter page and the site's editorial level
|
||||||
|
|
||||||
|
`SitePages.install` creates the page as a draft and then applies the site's level; the endpoint reports each
|
||||||
|
`InstallResult` outcome in the operator's console language (`Messages.console`):
|
||||||
|
|
||||||
|
| Outcome | When | The answer (EN) |
|
||||||
|
|---|---|---|
|
||||||
|
| `PUBLISHED` | Advisory; Enforced or Reviewed with the checks passing (on Reviewed, for someone who may approve pages) | `Contact page installed at /contact` |
|
||||||
|
| `PENDING_REVIEW` | Reviewed, and the operator may not approve pages | `The contact page was created and is waiting in the review queue: /contact` |
|
||||||
|
| `DRAFT_BLOCKED` | the quality checks blocked publishing | `The contact page was created as a draft because the quality checks blocked publishing; fix it in the page editor: /contact` + one `- code: message` line per blocking finding |
|
||||||
|
| `ALREADY_EXISTS` | a page with the slug `contact` exists, in any state | `A contact page already exists at <its current path>` |
|
||||||
|
| a constant added in a later SPI | — | `The contact page install finished: <OUTCOME> <path>` |
|
||||||
|
|
||||||
|
A refused install (another page serves `/contact`, a write failure) answers `500` "Could not install the contact
|
||||||
|
page." and leaves no draft behind (the kernel removes it).
|
||||||
|
|
||||||
|
## 2. POST on an anonymous route (the CSRF constraint, solved)
|
||||||
|
|
||||||
|
A public form on a cacheable page cannot carry the tenant chain's **session-based CSRF token**. The easy way
|
||||||
|
around that — a form that submits by **GET** — would put a visitor's name, email and message in their browser
|
||||||
|
history, in `Referer` headers and in proxy logs. The SPI has a contract for exactly this case, and the plugin uses
|
||||||
|
it:
|
||||||
|
|
||||||
|
- The endpoint declares **`Route.anonymousPost("/contact/submit", posture)`**. The kernel exempts **exactly that
|
||||||
|
method and path** from CSRF, on a site's host only, and in exchange takes away what a forged cross-site
|
||||||
|
submission could use: the handler runs with **no principal** (`AccessCheck.may` is `false` even for a signed-in
|
||||||
|
administrator), it is handed only `application/x-www-form-urlencoded` bodies (anything else is answered `415`),
|
||||||
|
and every other route keeps its CSRF check.
|
||||||
|
- The form (`ContactForm`) is `method="post"` with that encoding. The handler reads the fields **from the body
|
||||||
|
only** (`RouteRequest.form()`), so a field put in a query string is ignored and personal data has no reason to
|
||||||
|
travel in a URL; the `303` back to the page carries only `?contact=<outcome>`.
|
||||||
|
- **The abuse guards stay in front of the store:** a hidden **honeypot** field (`website`; a submission that fills
|
||||||
|
it is silently dropped — the bot sees a fake success, nothing is stored or sent), the site's **CAPTCHA** when one
|
||||||
|
is configured (`CaptchaService.verify(site, token, req.clientIp())` — the client IP after the kernel's
|
||||||
|
trusted-proxy gate; the token is read from the body too), and the platform's **per-address rate limit** (the
|
||||||
|
protection plugin's edge guard, which sees every request before any endpoint).
|
||||||
|
|
||||||
|
## 2a. The operator actions are CSRF-checked POSTs
|
||||||
|
|
||||||
|
Installing the starter page creates a page, and the SMTP test sends an email. Were they `GET` links, a signed-in
|
||||||
|
site manager who followed a link on another web site — or merely loaded a page with an
|
||||||
|
`<img src="https://their-site/contact/install-page">` — would perform the action without meaning to (the browser
|
||||||
|
sends the session cookie with the request; the permission check passes because it *is* the manager). The SMTP test
|
||||||
|
would be worse: a `?to=` choosing the recipient would let such a link make the server email an arbitrary address.
|
||||||
|
|
||||||
|
Both are therefore **ordinary `POST` routes** — deliberately **not** `Route.anonymousPost`, which would switch the
|
||||||
|
CSRF check off. The kernel's tenant chain demands the console session's CSRF token on them:
|
||||||
|
|
||||||
|
- the admin fragment renders each action as a `<form method="post">` with a hidden `_csrf` field bound to the
|
||||||
|
request's token (`th:attr="name=${_csrf.parameterName},value=${_csrf.token}"`, the same pattern as the search
|
||||||
|
plugin's "Clear list"); the answer opens in a new tab;
|
||||||
|
- a `POST` without a valid token is refused `403` by the kernel (the "session expired" page) before the plugin runs;
|
||||||
|
- a `GET` (a link, an `<img>`) matches no route, so the kernel answers `404` and nothing changes; the handler also
|
||||||
|
refuses any non-`POST` method itself, as a second line;
|
||||||
|
- the `contact|settings` permission check still runs after the token check (an anonymous visitor who holds a valid
|
||||||
|
session token gets `404`).
|
||||||
|
|
||||||
|
**The body reaches the plugin whole.** The SMTP test's optional `to` override is read from the form body only,
|
||||||
|
never the query string. The kernel keeps the url-encoded body for the route after its CSRF check, so `form()`
|
||||||
|
carries every field whether the token travels as the `_csrf` form field — as a browser form sends it — or in the
|
||||||
|
`X-CSRF-TOKEN` header. The console's SMTP-test button sends no `to`, so it always mails the configured recipient;
|
||||||
|
the override is for a scripted call.
|
||||||
|
|
||||||
|
## 3. Storage (tenant-owned, backup-safe)
|
||||||
|
|
||||||
|
Submissions go through the kernel's **`PluginSiteFiles`** (this plugin's per-site folder, bound to the plugin by
|
||||||
|
its jar; the kernel confines every path to `sites/<id>/plugins/contact/`, real path included) to
|
||||||
|
`sites/<id>/plugins/contact/submissions.tsv` (an existing file is read and appended in place, so stored
|
||||||
|
submissions survive an upgrade of the plugin):
|
||||||
|
|
||||||
|
- **Outside** the served `static/` tree — never publicly downloadable (the verify asserts a traversal attempt on
|
||||||
|
it does not return 200).
|
||||||
|
- **Inside** the tenant folder — so a **full backup** carries it automatically; no `BackupParticipant` needed.
|
||||||
|
- **Declared personal data** in `plugin.yml` (`siteData: personal: [submissions.tsv]`): a **transfer copy** of the
|
||||||
|
site (the console's "Download a transfer copy") leaves it out and lists `plugins/contact/submissions.tsv` under
|
||||||
|
`omitted:` in the archive's `manifest.yml`. A restored transfer copy starts with no submissions, which the store
|
||||||
|
reads as empty.
|
||||||
|
- One **sanitized** TSV line per submission (`epochMillis \t name \t email \t message`; tabs/newlines stripped so
|
||||||
|
the format is unambiguous, fields length-capped at 4,000 characters), bounded to the most recent
|
||||||
|
`MAX_SUBMISSIONS` (500), which keeps the file far below the kernel's 16 MiB write cap. Each kernel write is
|
||||||
|
atomic; the append (a read-modify-write) is serialized per site by the store. An append that cannot read the
|
||||||
|
existing file fails rather than rewriting it from nothing; the console count and list then show nothing (logged).
|
||||||
|
|
||||||
|
Everywhere the plugin echoes a value (form re-render, thank-you, admin listing) it HTML-escapes it (`Html.escape`).
|
||||||
|
|
||||||
|
## 4. Inventory
|
||||||
|
|
||||||
|
| Piece | Type | File |
|
||||||
|
|---|---|---|
|
||||||
|
| `mainClass` `@Configuration` | `ContactConfig` | wires widget + endpoint + store + mailer + admin model from SPI services; every bean name starts with `contact` |
|
||||||
|
| Form widget | `ContactWidget` (`ContentWidget` `contact`, query-aware) | inline form + outcome re-render |
|
||||||
|
| Endpoint | `ContactEndpoint` (`EndpointContributor`: anonymous `POST /contact/submit`; CSRF-checked `POST /contact/install-page` and `POST /contact/smtp-test`) | submit+store+send+303, starter page via `SitePages`, gated test |
|
||||||
|
| Shared form markup | `ContactForm` | the `<form>` the widget renders |
|
||||||
|
| Storage | `ContactStore` + `ContactSubmission` | append/read tenant TSV |
|
||||||
|
| Mail send | `ContactMailer` + `MailTransport`/`JakartaMailTransport` + `SmtpSettings` + `MailSendResult` | build MIME + send over the site relay |
|
||||||
|
| Console model | `ContactAdminModel` (+ `SitePages.pathOf`) + `templates/` | contact-page install card + dashboard card + readiness + submissions table |
|
||||||
|
| Front-end | `static/contact.css`, `static/contact-help.html` | self-contained |
|
||||||
|
| i18n (EN/ES) | `i18n/` | form + console + SMTP labels/results |
|
||||||
|
|
||||||
|
## 5. What it links (SPI 1.0.0)
|
||||||
|
|
||||||
|
`pom.xml` depends on `runway-spi` only (`runway-spi-testkit` for tests); **`runway-app` is not a dependency in any
|
||||||
|
scope**, so a host import does not compile, and `ContactConfigTest` scans the compiled classes' constant pools for
|
||||||
|
any `mx.quest.runway` reference outside `mx.quest.runway.spi` — the kernel's own load-time scan finds nothing.
|
||||||
|
|
||||||
|
| Need | SPI service |
|
||||||
|
|---|---|
|
||||||
|
| the site's settings | `PluginSettings.site(site)` → `SettingsView` |
|
||||||
|
| the SMTP password in clear, at send time | `PluginSettings.secret(site, "smtpPassword")` |
|
||||||
|
| the stored submissions | `PluginSiteFiles` (`submissions.tsv`) |
|
||||||
|
| visitor text / operator answers | `Messages.site` / `Messages.console` |
|
||||||
|
| the operator gate | `AccessCheck` (the `authz` bean) |
|
||||||
|
| the starter page | `SitePages.install` / `SitePages.pathOf` |
|
||||||
|
| the site's CAPTCHA | `CaptchaService.verify(site, token, req.clientIp())` |
|
||||||
|
| the submitted fields | `RouteRequest.form()` of an anonymous POST |
|
||||||
|
|
||||||
|
`requiresSpi: ">=1.0.0"`: a kernel with an older SPI blocks the plugin before wiring, with a reason.
|
||||||
|
|
||||||
|
## 6. Verify
|
||||||
|
|
||||||
|
`scripts/verify-against-host.sh` (honours `JAVA_HOME` (required), `MVN`, `HOST_TARGET`, `HOST_JAR`, `VERIFY_TMPDIR`,
|
||||||
|
`VERIFY_LOG_DIR`, `PROTECTION_DIR`; never
|
||||||
|
runs `mvn install`) boots the **packaged** host in ACTIVE mode with four sites — the wizard's default (Advisory)
|
||||||
|
plus an Enforced, a Reviewed and a CAPTCHA site copied from it — and, when it is built, the protection plugin from
|
||||||
|
the host checkout. It checks: the plugin loads with zero host-linkage and bean-name/surface warnings; an anonymous
|
||||||
|
form POST with no session or token is stored and answered `303 ?contact=sent` with no submitted value in the
|
||||||
|
`Location`; a GET submission is a 404, a honeypot fakes success, an invalid email, fields only in the query string
|
||||||
|
and a multipart body are refused, and nothing of those is stored; the operator actions are CSRF-checked POSTs
|
||||||
|
(a `GET` of either is a `404` and changes nothing even for the signed-in owner, a `POST` without or with a forged
|
||||||
|
token is a `403` with no page created and no email sent, an anonymous `POST` holding a valid session token is a
|
||||||
|
`404`, and the settings page renders both as `POST` forms carrying a non-empty token and links to neither); the
|
||||||
|
starter page installs (`POST` with the settings page's token) on all three editorial levels and a second install
|
||||||
|
changes nothing; the settings page shows the page's path and the count; the SMTP
|
||||||
|
password saved through the settings form is stored `ENC(...)` and is offered in clear to a local fake relay (a
|
||||||
|
small Python SMTP listener) for a submission and for the SMTP test (the console form to the configured
|
||||||
|
recipient; a body `to` override with the token as a form field, as a browser form sends it, and again with it in
|
||||||
|
the `X-CSRF-TOKEN` header; a `to` in the query string is ignored); a full backup carries `submissions.tsv` and a
|
||||||
|
transfer copy does not, its manifest listing the omission; on the CAPTCHA site a POST without (or with a blank)
|
||||||
|
token is answered `?contact=captcha` and nothing is stored; the static assets serve and the submissions are never
|
||||||
|
served publicly.
|
||||||
|
|
||||||
|
Unit tests (75) cover the store over the testkit's `TempDirSiteFiles` (`ContactStoreTest`, incl. an existing file
|
||||||
|
read in place and the unreadable-file rule), the widget rendering incl. the POST form, outcome flags + escaping
|
||||||
|
(`ContactWidgetTest`), the endpoint incl. POST-only and body-only acceptance, the CAPTCHA with the gated client
|
||||||
|
IP, store-then-send ordering, redirect outcomes, return-path safety, every install outcome, the gated SMTP test, POST-only operator actions (a GET installs and
|
||||||
|
sends nothing even for a permitted operator; the SMTP recipient is read from the body only) (`ContactEndpointTest`),
|
||||||
|
the admin fragment's POST forms carrying the CSRF token, no link to an action, unique ids
|
||||||
|
(`ContactAdminTemplateTest`), the send path incl. the MIME build against a mock transport and the password taken only
|
||||||
|
from the secret (`ContactMailerTest`), and the plugin's contract with the host (`ContactConfigTest`: wiring from
|
||||||
|
SPI services, bean-name prefix, template bean references, the floor, version, personal-data and secret
|
||||||
|
declarations, EN/ES key parity, the constant-pool scan).
|
||||||
|
|
||||||
|
> **Send tests open no socket.** The send seam (`MailTransport`) is mocked, so `ContactMailerTest` exercises the
|
||||||
|
> full `MimeMessage` build and the store/send/report contract without touching the network.
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
# Runway Contact plugin — English strings. Console labels resolve automatically; public-facing strings
|
||||||
|
# (contact.form.*, contact.success/error.*, contact.page.title) are looked up with Messages.site for the visitor's
|
||||||
|
# locale, and the plain-text answers of the operator actions (contact.page.*, contact.test.*) with
|
||||||
|
# Messages.console in the operator's console language.
|
||||||
|
|
||||||
|
# Grantable permission (permissions matrix label)
|
||||||
|
contact.perm.settings=Configure contact form
|
||||||
|
|
||||||
|
# Per-tenant settings form labels
|
||||||
|
contact.set.enabled=Enable contact form
|
||||||
|
contact.set.success=Thank-you message
|
||||||
|
contact.set.smtpHost=SMTP host
|
||||||
|
contact.set.smtpPort=SMTP port
|
||||||
|
contact.set.smtpAuth=SMTP authentication
|
||||||
|
contact.set.smtpUsername=SMTP username
|
||||||
|
contact.set.smtpPassword=SMTP password
|
||||||
|
contact.set.smtpStarttls=Use STARTTLS
|
||||||
|
contact.set.smtpSsl=Use SSL/TLS (SMTPS)
|
||||||
|
contact.set.fromAddress=From address
|
||||||
|
contact.set.toAddress=Send submissions to
|
||||||
|
|
||||||
|
# Dashboard card
|
||||||
|
contact.card.title=Contact
|
||||||
|
contact.card.submissions=submissions
|
||||||
|
|
||||||
|
# Admin status fragment
|
||||||
|
contact.admin.title=Contact submissions
|
||||||
|
contact.admin.empty=No submissions yet.
|
||||||
|
contact.admin.when=When
|
||||||
|
contact.admin.help=Contact help & reference
|
||||||
|
contact.admin.smtp=SMTP relay
|
||||||
|
contact.admin.smtp.ok=Configured
|
||||||
|
contact.admin.smtp.missing=Not configured
|
||||||
|
contact.admin.smtp.test=Send a test email
|
||||||
|
contact.admin.smtp.test.tip=Send a test message over this site's SMTP relay to verify the configuration
|
||||||
|
|
||||||
|
# SMTP test result (public text response of /contact/smtp-test)
|
||||||
|
contact.test.ok=Test message sent.
|
||||||
|
contact.test.notConfigured=No SMTP relay is configured for this site.
|
||||||
|
contact.test.providerMissing=Mail libraries are not available on the server, so email cannot be sent.
|
||||||
|
contact.test.failed=Test message failed:
|
||||||
|
|
||||||
|
# Ready-made "Contact page" install card (admin fragment) + install-action result text
|
||||||
|
contact.page.card.title=Contact page
|
||||||
|
contact.page.card.desc=Install a ready-made contact page carrying the form. It becomes a normal site page — edit, restyle, move or rename it from Pages.
|
||||||
|
contact.page.card.install=Install contact page
|
||||||
|
contact.page.card.install.tip=Seed a ready-made, editable contact page (idempotent — it never overwrites an existing page)
|
||||||
|
contact.page.card.badge=Installed
|
||||||
|
contact.page.card.at=Installed at
|
||||||
|
contact.page.card.edit=— edit it under Pages.
|
||||||
|
# install-page action result (plain text)
|
||||||
|
contact.page.title=Contact
|
||||||
|
contact.page.installed=Contact page installed at
|
||||||
|
contact.page.exists=A contact page already exists at
|
||||||
|
contact.page.failed=Could not install the contact page.
|
||||||
|
contact.page.pending=The contact page was created and is waiting in the review queue:
|
||||||
|
contact.page.blocked=The contact page was created as a draft because the quality checks blocked publishing; fix it in the page editor:
|
||||||
|
contact.page.other=The contact page install finished:
|
||||||
|
|
||||||
|
# Public-facing form + result
|
||||||
|
contact.heading=Contact
|
||||||
|
contact.form.name=Name
|
||||||
|
contact.form.email=Email
|
||||||
|
contact.form.message=Message
|
||||||
|
contact.form.submit=Send
|
||||||
|
contact.success=Thanks — your message has been sent.
|
||||||
|
contact.note.stored=Your message was received; email delivery is delayed.
|
||||||
|
contact.error.invalid=Please enter your email and a message.
|
||||||
|
contact.error.captcha=Please complete the challenge and try again.
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
# Runway Contact plugin — cadenas en español.
|
||||||
|
|
||||||
|
# Permiso otorgable (etiqueta de la matriz de permisos)
|
||||||
|
contact.perm.settings=Configurar formulario de contacto
|
||||||
|
|
||||||
|
# Etiquetas del formulario de configuración por sitio
|
||||||
|
contact.set.enabled=Activar formulario de contacto
|
||||||
|
contact.set.success=Mensaje de agradecimiento
|
||||||
|
contact.set.smtpHost=Servidor SMTP
|
||||||
|
contact.set.smtpPort=Puerto SMTP
|
||||||
|
contact.set.smtpAuth=Autenticación SMTP
|
||||||
|
contact.set.smtpUsername=Usuario SMTP
|
||||||
|
contact.set.smtpPassword=Contraseña SMTP
|
||||||
|
contact.set.smtpStarttls=Usar STARTTLS
|
||||||
|
contact.set.smtpSsl=Usar SSL/TLS (SMTPS)
|
||||||
|
contact.set.fromAddress=Dirección de remitente
|
||||||
|
contact.set.toAddress=Enviar los mensajes a
|
||||||
|
|
||||||
|
# Tarjeta del panel
|
||||||
|
contact.card.title=Contacto
|
||||||
|
contact.card.submissions=mensajes
|
||||||
|
|
||||||
|
# Fragmento de estado (admin)
|
||||||
|
contact.admin.title=Mensajes de contacto
|
||||||
|
contact.admin.empty=Aún no hay mensajes.
|
||||||
|
contact.admin.when=Fecha
|
||||||
|
contact.admin.help=Ayuda y referencia de contacto
|
||||||
|
contact.admin.smtp=Relé SMTP
|
||||||
|
contact.admin.smtp.ok=Configurado
|
||||||
|
contact.admin.smtp.missing=Sin configurar
|
||||||
|
contact.admin.smtp.test=Enviar un correo de prueba
|
||||||
|
contact.admin.smtp.test.tip=Envía un mensaje de prueba por el relé SMTP de este sitio para verificar la configuración
|
||||||
|
|
||||||
|
# Resultado de la prueba SMTP (respuesta de texto de /contact/smtp-test)
|
||||||
|
contact.test.ok=Mensaje de prueba enviado.
|
||||||
|
contact.test.notConfigured=No hay ningún relé SMTP configurado para este sitio.
|
||||||
|
contact.test.providerMissing=Las bibliotecas de correo no están disponibles en el servidor, así que no se puede enviar correo.
|
||||||
|
contact.test.failed=La prueba de envío falló:
|
||||||
|
|
||||||
|
# Tarjeta de instalación de la «Página de contacto» (fragmento admin) + texto del resultado de la acción
|
||||||
|
contact.page.card.title=Página de contacto
|
||||||
|
contact.page.card.desc=Instala una página de contacto lista para usar con el formulario. Se convierte en una página normal del sitio: edítala, cámbiale el estilo, muévela o renómbrala desde Páginas.
|
||||||
|
contact.page.card.install=Instalar página de contacto
|
||||||
|
contact.page.card.install.tip=Crea una página de contacto lista y editable (idempotente: nunca sobrescribe una página existente)
|
||||||
|
contact.page.card.badge=Instalada
|
||||||
|
contact.page.card.at=Instalada en
|
||||||
|
contact.page.card.edit=— edítala desde Páginas.
|
||||||
|
# Resultado de la acción de instalación (texto plano)
|
||||||
|
contact.page.title=Contacto
|
||||||
|
contact.page.installed=Página de contacto instalada en
|
||||||
|
contact.page.exists=Ya existe una página de contacto en
|
||||||
|
contact.page.failed=No se pudo instalar la página de contacto.
|
||||||
|
contact.page.pending=Se creó la página de contacto y está esperando en la cola de revisión:
|
||||||
|
contact.page.blocked=Se creó la página de contacto como borrador porque las comprobaciones de calidad bloquearon la publicación; corrígela en el editor de páginas:
|
||||||
|
contact.page.other=La instalación de la página de contacto terminó:
|
||||||
|
|
||||||
|
# De cara al público (formulario + resultado)
|
||||||
|
contact.heading=Contacto
|
||||||
|
contact.form.name=Nombre
|
||||||
|
contact.form.email=Correo electrónico
|
||||||
|
contact.form.message=Mensaje
|
||||||
|
contact.form.submit=Enviar
|
||||||
|
contact.success=Gracias: tu mensaje ha sido enviado.
|
||||||
|
contact.note.stored=Hemos recibido tu mensaje; el envío por correo se ha retrasado.
|
||||||
|
contact.error.invalid=Introduce tu correo electrónico y un mensaje.
|
||||||
|
contact.error.captcha=Completa el desafío e inténtalo de nuevo.
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# Runway Contact plugin — descriptor
|
||||||
|
# A contact form delivered as a CONTENT WIDGET on a normal, editable site page
|
||||||
|
# (no plugin-owned page): drop <div id=.. data-widget="contact/form"> on a page,
|
||||||
|
# or install a ready-made contact page in one click from the settings — it then
|
||||||
|
# behaves like any site page (listed under Pages; restyle/move/rename it). The
|
||||||
|
# endpoint owns only the ANONYMOUS POST /contact/submit handler (CSRF-exempt by
|
||||||
|
# the kernel for exactly that method and path; 303s back to the form's page with
|
||||||
|
# a ?contact= outcome), the operator-gated, CSRF-checked POSTs /contact/install-page
|
||||||
|
# and /contact/smtp-test. A submission is BOTH emailed to the site's recipient over
|
||||||
|
# the site's own SMTP relay AND kept as a stored record (belt-and-suspenders —
|
||||||
|
# never lost even if SMTP is down). CAPTCHA (when the site has one) + honeypot.
|
||||||
|
# Links ONLY the Runway SPI (SPI 1.0.0).
|
||||||
|
# The install folder name MUST equal this `id`: external/plugins/contact/.
|
||||||
|
# =============================================================================
|
||||||
|
id: contact
|
||||||
|
name: Contact form
|
||||||
|
version: 2.1.0
|
||||||
|
|
||||||
|
# The @Configuration registered before refresh. Package mx.quest.contact lives OUTSIDE mx.quest.runway.
|
||||||
|
mainClass: mx.quest.contact.ContactConfig
|
||||||
|
|
||||||
|
# Built against the frozen SPI 1.0.0 contract (the service tier: PluginSettings, PluginSiteFiles, Messages,
|
||||||
|
# AccessCheck, SitePages and anonymous POST routes). A kernel with an older SPI BLOCKS this plugin at startup
|
||||||
|
# with a reason.
|
||||||
|
requiresSpi: ">=1.0.0"
|
||||||
|
|
||||||
|
# --- Personal data (siteData) ------------------------------------------------------------------------------
|
||||||
|
# submissions.tsv holds what visitors typed (names, emails, messages). A TRANSFER copy of a site (the one
|
||||||
|
# meant for someone outside the organisation) leaves it out and lists it in the archive's manifest; a FULL
|
||||||
|
# backup keeps it. Path relative to sites/<id>/plugins/contact/.
|
||||||
|
siteData:
|
||||||
|
personal:
|
||||||
|
- submissions.tsv
|
||||||
|
|
||||||
|
# --- Dependencies ----------------------------------------------------------------------------------------
|
||||||
|
# No plugin dependency: the Jakarta Mail stack is part of the CORE application (the kernel bundles it for
|
||||||
|
# its own platform mailer). This plugin compiles Jakarta Mail as `provided` and resolves the kernel's copy at
|
||||||
|
# runtime via the plugin classloader's parent-first delegation, so no `requires:` gate is needed.
|
||||||
|
|
||||||
|
# --- Grantable control-point permission (gates the settings editor, the submissions view + the SMTP test) --
|
||||||
|
permissions:
|
||||||
|
- { id: settings, realm: tenant, label: contact.perm.settings, defaultRoles: [] }
|
||||||
|
|
||||||
|
# --- Per-tenant settings (tenant-owned behaviour; over sites/<id>/plugins/contact.yml) -------------------
|
||||||
|
# The SMTP relay is the TENANT's own mail transport — isolation: a site sends with its OWN settings only.
|
||||||
|
# The password is a `secret` → stored ENC(...)-encrypted and the config file is chmod 600; the plugin reads it
|
||||||
|
# in clear only through PluginSettings.secret(site, "smtpPassword"), at send time. A blank host
|
||||||
|
# (or a blank recipient) simply means "don't send" — the submission is still stored.
|
||||||
|
# secretBoundTo: the stored password belongs to ONE relay login. A save that changes the host, port, username or a TLS switch
|
||||||
|
# without retyping the password makes the kernel DROP the stored password, so whoever may edit the settings
|
||||||
|
# cannot point the site's saved credentials at a server of their choosing and read them off the wire.
|
||||||
|
siteSettings:
|
||||||
|
- { key: enabled, type: boolean, default: true, label: contact.set.enabled }
|
||||||
|
- { key: successMessage, type: text, label: contact.set.success }
|
||||||
|
# --- SMTP relay -------------------------------------------------------------------------------------
|
||||||
|
- { key: smtpHost, type: string, label: contact.set.smtpHost }
|
||||||
|
- { key: smtpPort, type: int, default: 25, range: "1..65535", label: contact.set.smtpPort }
|
||||||
|
- { key: smtpAuth, type: boolean, default: false, label: contact.set.smtpAuth }
|
||||||
|
- { key: smtpUsername, type: string, label: contact.set.smtpUsername }
|
||||||
|
- { key: smtpPassword, type: secret, label: contact.set.smtpPassword,
|
||||||
|
secretBoundTo: [smtpHost, smtpPort, smtpUsername, smtpStarttls, smtpSsl] }
|
||||||
|
- { key: smtpStarttls, type: boolean, default: false, label: contact.set.smtpStarttls }
|
||||||
|
- { key: smtpSsl, type: boolean, default: false, label: contact.set.smtpSsl }
|
||||||
|
- { key: fromAddress, type: string, label: contact.set.fromAddress }
|
||||||
|
- { key: toAddress, type: string, label: contact.set.toAddress }
|
||||||
|
|
||||||
|
# --- Tenant dashboard card (fragment resolves to __plugin__/contact/dashboard) ---------------------------
|
||||||
|
dashboardCards:
|
||||||
|
- { realm: tenant, order: 45, fragment: dashboard, permission: "contact|settings" }
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<!-- Inherit the SAME managed versions the kernel uses (Spring Boot 4.0.6). NOT a Boot app — no repackage;
|
||||||
|
`mvn package` produces a THIN jar of only this plugin's classes. -->
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>4.0.6</version>
|
||||||
|
<relativePath/>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>mx.quest</groupId>
|
||||||
|
<artifactId>runway-plugin-contact</artifactId>
|
||||||
|
<version>2.1.0</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>Runway Contact Plugin</name>
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>GNU Affero General Public License v3.0, with the Runway additional permission for plugins</name>
|
||||||
|
<url>https://www.gnu.org/licenses/agpl-3.0.txt</url>
|
||||||
|
<distribution>repo</distribution>
|
||||||
|
<comments>See LICENSE and LICENSE-EXCEPTION.</comments>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
<description>
|
||||||
|
A contact form for Runway: an embeddable form content widget that POSTs to an anonymous /contact/submit
|
||||||
|
route. A submission is BOTH emailed over the site's own SMTP relay (via Jakarta Mail, a core capability the
|
||||||
|
kernel bundles) AND kept as a stored tenant-owned record (viewable in the console; declared personal data,
|
||||||
|
so transfer copies leave it out), with CAPTCHA and honeypot anti-spam. Links only the Runway SPI.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>25</java.version>
|
||||||
|
<maven.compiler.release>25</maven.compiler.release>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<!-- Reproducible builds: pins every archive entry's timestamp so two builds of the same source
|
||||||
|
produce byte-identical artifacts. Without it a jar embeds the build time, so a rebuild can
|
||||||
|
never match what was published. Bump at each release. -->
|
||||||
|
<project.build.outputTimestamp>2026-10-21T18:56:00Z</project.build.outputTimestamp>
|
||||||
|
<runway.version>1.0.0</runway.version>
|
||||||
|
<!-- Kept in lock-step with the Jakarta Mail the KERNEL bundles (mail is a core capability).
|
||||||
|
Compile-only here; the kernel supplies it at runtime. -->
|
||||||
|
<jakarta.mail-api.version>2.1.5</jakarta.mail-api.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mx.quest</groupId>
|
||||||
|
<artifactId>runway-spi</artifactId>
|
||||||
|
<version>${runway.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- NO runway-app dependency, in any scope: the plugin links only the SPI, so a host
|
||||||
|
import does not compile and the kernel's host-linkage scanner finds nothing to report. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mx.quest</groupId>
|
||||||
|
<artifactId>runway-spi-testkit</artifactId>
|
||||||
|
<version>${runway.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Jakarta Mail API — PROVIDED at runtime by the KERNEL (which bundles the Jakarta Mail stack for its
|
||||||
|
own platform mailer). Compile-only here: NEVER bundle it into this plugin's own lib/ (that would be a
|
||||||
|
second Jakarta Mail copy on the classloader, shadowing the kernel's). The plugin classloader delegates
|
||||||
|
parent-first, so the kernel's API + Angus SMTP implementation resolve at runtime via META-INF/services. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.mail</groupId>
|
||||||
|
<artifactId>jakarta.mail-api</artifactId>
|
||||||
|
<version>${jakarta.mail-api.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Tests exercise the send path against a MOCK MailTransport (no socket) and the Angus implementation
|
||||||
|
is needed to actually construct MimeMessage/Session in-process, so bring it in at test scope. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.angus</groupId>
|
||||||
|
<artifactId>angus-mail</artifactId>
|
||||||
|
<version>2.0.5</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>runway-plugin-contact</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>assemble-plugin-folder</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<property name="stage" value="${project.build.directory}/contact"/>
|
||||||
|
<delete dir="${stage}"/>
|
||||||
|
<mkdir dir="${stage}"/>
|
||||||
|
<copy file="${project.basedir}/plugin.yml" todir="${stage}"/>
|
||||||
|
<copy file="${project.basedir}/LICENSE" todir="${stage}"/>
|
||||||
|
<copy file="${project.basedir}/LICENSE-EXCEPTION" todir="${stage}"/>
|
||||||
|
<copy file="${project.build.directory}/runway-plugin-contact.jar" todir="${stage}"/>
|
||||||
|
<copy todir="${stage}/static">
|
||||||
|
<fileset dir="${project.basedir}/static"/>
|
||||||
|
</copy>
|
||||||
|
<copy todir="${stage}/templates">
|
||||||
|
<fileset dir="${project.basedir}/templates"/>
|
||||||
|
</copy>
|
||||||
|
<copy todir="${stage}/i18n">
|
||||||
|
<fileset dir="${project.basedir}/i18n"/>
|
||||||
|
</copy>
|
||||||
|
<touch datetime="${project.build.outputTimestamp}"
|
||||||
|
pattern="yyyy-MM-dd'T'HH:mm:ss'Z'">
|
||||||
|
<fileset dir="${stage}"/>
|
||||||
|
<dirset dir="${stage}"/>
|
||||||
|
<dirset dir="${project.build.directory}" includes="contact"/>
|
||||||
|
</touch>
|
||||||
|
<!-- The stamped files predate any earlier zip, so <zip> would skip the rebuild. -->
|
||||||
|
<delete file="${project.build.directory}/runway-plugin-contact-${project.version}.zip"/>
|
||||||
|
<zip destfile="${project.build.directory}/runway-plugin-contact-${project.version}.zip">
|
||||||
|
<zipfileset dir="${project.build.directory}" includes="contact/**"/>
|
||||||
|
</zip>
|
||||||
|
<echo message="Staged install folder: ${stage}"/>
|
||||||
|
<echo message="UI-uploadable archive: ${project.build.directory}/runway-plugin-contact-${project.version}.zip"/>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
+383
@@ -0,0 +1,383 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build this plugin, drop it into a throwaway Runway deployment, boot the PACKAGED host in ACTIVE mode, and prove
|
||||||
|
# the contact contract end to end (SPI 1.0.0):
|
||||||
|
# - it loads with ZERO host-linkage and bean-name/surface warnings;
|
||||||
|
# - an anonymous visitor's form POST (no session, no CSRF token) to the anonymous route is stored and 303s back
|
||||||
|
# with only an outcome flag; GET submission is gone; honeypot / invalid / non-form bodies are refused;
|
||||||
|
# - the two operator actions are CSRF-protected POSTs: a GET (a cross-site link or <img>) changes nothing even
|
||||||
|
# for a signed-in owner, a POST without the console's CSRF token is refused 403, and an anonymous caller holding
|
||||||
|
# a token is still refused by the permission check (404);
|
||||||
|
# - signed in as the site owner, the starter page installs (POST + the token from the settings page) through
|
||||||
|
# SitePages on an Advisory, an Enforced and a Reviewed site (each outcome reported), and a second install
|
||||||
|
# changes nothing;
|
||||||
|
# - the SMTP password saved through the settings form is stored ENC(...) and reaches a local fake relay in clear
|
||||||
|
# (PluginSettings.secret), both for a submission and for the operator's SMTP test, whose body `to` override
|
||||||
|
# arrives with the CSRF token as a form field or a header;
|
||||||
|
# - a FULL backup carries submissions.tsv and a TRANSFER copy leaves it out and lists it in its manifest;
|
||||||
|
# - with the protection plugin installed (from the host checkout, when built) and a CAPTCHA configured on one
|
||||||
|
# site, a POST without the CAPTCHA token is refused and nothing is stored.
|
||||||
|
# The deployment holds four sites copied from the wizard's default one before the ACTIVE boot: default (Advisory),
|
||||||
|
# enforced, reviewed, captcha — addressed by Host name through curl --resolve. Verify ONLY against the packaged jar
|
||||||
|
# — never spring-boot:run (its restart classloader loads ZERO plugins).
|
||||||
|
#
|
||||||
|
# Usage: scripts/verify-against-host.sh [--keep] [--port N]
|
||||||
|
# JAVA_HOME=/path/to/jdk-25 required: the JDK that builds the plugin and runs the host
|
||||||
|
# MVN=/path/to/mvn Maven (default: mvn on the PATH)
|
||||||
|
# HOST_TARGET=/path/to/runway/runway-app/target the host build (default: the kernel this plugin sits in, else ../runway)
|
||||||
|
# HOST_JAR=/path/to/runway-app-<ver>-exec.jar the kernel to verify against (default: the host checkout's
|
||||||
|
# runway-app/target jar MATCHING its pom version)
|
||||||
|
# PROTECTION_DIR=/dir the protection plugin's source folder (plugin.yml, i18n/, templates/,
|
||||||
|
# target/runway-plugin-protection.jar); default: the host checkout's
|
||||||
|
# runway-plugin-protection/.
|
||||||
|
# Set it to "" to skip the CAPTCHA checks.
|
||||||
|
# VERIFY_TMPDIR=/dir where the throwaway deployment goes (default: $TMPDIR or /tmp)
|
||||||
|
# VERIFY_LOG_DIR=/dir keep copies of the host logs, the fake relay's log and the two
|
||||||
|
# backup manifests there (evidence)
|
||||||
|
# The script never runs `mvn install` (nothing is written to ~/.m2): it packages this plugin offline against
|
||||||
|
# whatever runway-spi is already in the local repository.
|
||||||
|
set -uo pipefail
|
||||||
|
|
||||||
|
HERE="$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)"
|
||||||
|
# JAVA_HOME must name a JDK 25. MVN (default: `mvn` on the PATH), HOST_TARGET and PROTECTION_DIR (defaults: see
|
||||||
|
# above) can be set in the environment.
|
||||||
|
if [ -z "${JAVA_HOME:-}" ] || [ ! -x "$JAVA_HOME/bin/java" ]; then echo "set JAVA_HOME to a JDK 25"; exit 2; fi
|
||||||
|
export JAVA_HOME
|
||||||
|
JAVA="$JAVA_HOME/bin/java"
|
||||||
|
MVN="${MVN:-mvn}"
|
||||||
|
# Default host: the kernel at the root of the repository this plugin sits in (plugins/<name>/), else a kernel
|
||||||
|
# checkout named `runway` beside the plugins checkout.
|
||||||
|
if [ -z "${HOST_TARGET:-}" ]; then
|
||||||
|
if [ -f "$HERE/../../runway-app/pom.xml" ]; then HOST_TARGET="$HERE/../../runway-app/target"
|
||||||
|
else HOST_TARGET="$HERE/../../runway/runway-app/target"; fi
|
||||||
|
fi
|
||||||
|
PROTECTION_DIR="${PROTECTION_DIR-$HOST_TARGET/../../runway-plugin-protection}"
|
||||||
|
|
||||||
|
KEEP="no"; PORT=""
|
||||||
|
while [ $# -gt 0 ]; do case "$1" in
|
||||||
|
--keep) KEEP="yes"; shift ;;
|
||||||
|
--port) PORT="${2:?}"; shift 2 ;;
|
||||||
|
*) echo "unknown arg: $1"; exit 2 ;;
|
||||||
|
esac; done
|
||||||
|
|
||||||
|
APP_USER=root; APP_PW=Contact-Admin-2026; SITE_USER=owner; SITE_PW=Contact-Site-2026
|
||||||
|
SECRET_KEY=contact-verify-master-key-2026; RELAY_USER=relay-user; RELAY_PW='Relay-Secret-42'
|
||||||
|
free_port() { python3 -I -c 'import socket;s=socket.socket();s.bind(("127.0.0.1",0));print(s.getsockname()[1]);s.close()'; }
|
||||||
|
[ -n "$PORT" ] || PORT="$(free_port)"
|
||||||
|
SMTP_PORT="$(free_port)"
|
||||||
|
BASE="http://localhost:$PORT"
|
||||||
|
|
||||||
|
echo "[verify] building the plugin ..."
|
||||||
|
( cd "$HERE" && "$MVN" -o -q -DskipTests package ) || { echo "plugin build failed"; exit 1; }
|
||||||
|
|
||||||
|
# The host jar MATCHING the host pom's version — never "the newest file": every reproducible jar carries the same
|
||||||
|
# fixed timestamp, so `ls -t` cannot tell a leftover release jar from the SNAPSHOT under test.
|
||||||
|
if [ -n "${HOST_JAR:-}" ]; then
|
||||||
|
JAR="$HOST_JAR"
|
||||||
|
else
|
||||||
|
HOST_VERSION="$(sed -n 's:.*<version>\(.*\)</version>.*:\1:p' "$HOST_TARGET/../pom.xml" | head -1)"
|
||||||
|
JAR="$HOST_TARGET/runway-app-$HOST_VERSION-exec.jar"
|
||||||
|
fi
|
||||||
|
[ -f "$JAR" ] || { echo "no host exec jar $JAR — build the host (mvn -pl runway-app package) or set HOST_JAR"; exit 1; }
|
||||||
|
echo "[verify] host jar: $JAR"
|
||||||
|
|
||||||
|
SCRATCH="$(mktemp -d "${VERIFY_TMPDIR:-${TMPDIR:-/tmp}}/contact-verify.XXXXXX")"
|
||||||
|
cleanup() {
|
||||||
|
[ -z "${VERIFY_LOG_DIR:-}" ] || { mkdir -p "$VERIFY_LOG_DIR" \
|
||||||
|
&& cp "$SCRATCH"/*.log "$SCRATCH"/*-manifest.yml "$VERIFY_LOG_DIR"/ 2>/dev/null; }
|
||||||
|
kill "${SMTP_PID:-0}" 2>/dev/null
|
||||||
|
# Wait for the host to exit before deleting: a JVM still shutting down rewrites files under external/ and
|
||||||
|
# makes `rm -rf` leave the scratch folder behind.
|
||||||
|
[ "$KEEP" = "yes" ] || { kill "${PID:-0}" 2>/dev/null; wait "${PID:-0}" 2>/dev/null; rm -rf "$SCRATCH"; }
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
EXT="$SCRATCH/external"
|
||||||
|
mkdir -p "$EXT/plugins"
|
||||||
|
cp -r "$HERE/target/contact" "$EXT/plugins/contact"
|
||||||
|
|
||||||
|
wait_for() { for _ in $(seq 1 "$3"); do grep -q "$2" "$1" 2>/dev/null && return 0; sleep 1; done; return 1; }
|
||||||
|
PASS=0; FAIL=0; SKIP=0
|
||||||
|
ck() { if eval "$2" >/dev/null 2>&1; then echo " PASS $1"; PASS=$((PASS+1)); else echo " FAIL $1"; FAIL=$((FAIL+1)); fi; }
|
||||||
|
skip() { echo " SKIP $1"; SKIP=$((SKIP+1)); }
|
||||||
|
boot() { ( cd "$SCRATCH" && exec "$JAVA" -jar "$JAR" --server.port="$PORT" --runway.storage.external="$EXT" \
|
||||||
|
--runway.security.secret-key="$SECRET_KEY" ) >"$1" 2>&1 & PID=$!; }
|
||||||
|
|
||||||
|
echo "[verify] booting host (wizard) on :$PORT ..."
|
||||||
|
boot "$SCRATCH/wizard.log"
|
||||||
|
wait_for "$SCRATCH/wizard.log" "Started RunwayApplication" 90 || { echo "wizard did not start"; tail -20 "$SCRATCH/wizard.log"; exit 1; }
|
||||||
|
curl -s -o /dev/null -X POST "$BASE/setup" --data-urlencode "username=$APP_USER" --data-urlencode "password=$APP_PW" \
|
||||||
|
--data-urlencode "displayName=Root" --data-urlencode "siteAdminUsername=$SITE_USER" --data-urlencode "siteAdminPassword=$SITE_PW"
|
||||||
|
for _ in $(seq 1 30); do kill -0 "$PID" 2>/dev/null || break; sleep 1; done
|
||||||
|
|
||||||
|
# --- Three more sites, copied from the seeded default one (same owner), before the ACTIVE boot reads them --------
|
||||||
|
SITES="$EXT/sites"
|
||||||
|
[ -f "$SITES/default/site.yml" ] || { echo "the wizard did not seed $SITES/default"; exit 1; }
|
||||||
|
make_site() { # id editorial-level
|
||||||
|
cp -r "$SITES/default" "$SITES/$1"
|
||||||
|
sed -i -e "s/^id: .*/id: \"$1\"/" -e "s/^- \"localhost\"/- \"$1.test\"/" -e "s/^editorial: .*/editorial: \"$2\"/" \
|
||||||
|
"$SITES/$1/site.yml"
|
||||||
|
}
|
||||||
|
make_site enforced enforced
|
||||||
|
make_site reviewed reviewed
|
||||||
|
make_site captcha advisory
|
||||||
|
sed -i 's/^ - "default"$/ - "default"\n - "enforced"\n - "reviewed"/' "$EXT/site-users.yml"
|
||||||
|
# A page carrying the widget anchor on the captcha site: its seeded About page, edited on disk.
|
||||||
|
sed -i 's|<main id="content">|<main id="content"><div id="contact-form" data-widget="contact/form"></div>|' \
|
||||||
|
"$SITES/captcha/templates/about.html"
|
||||||
|
PROTECTION="no"
|
||||||
|
if [ -n "$PROTECTION_DIR" ] && [ -f "$PROTECTION_DIR/target/runway-plugin-protection.jar" ]; then
|
||||||
|
mkdir -p "$EXT/plugins/protection"
|
||||||
|
cp "$PROTECTION_DIR/plugin.yml" "$PROTECTION_DIR/target/runway-plugin-protection.jar" "$EXT/plugins/protection/"
|
||||||
|
cp -r "$PROTECTION_DIR/i18n" "$PROTECTION_DIR/templates" "$EXT/plugins/protection/"
|
||||||
|
mkdir -p "$SITES/captcha/plugins"
|
||||||
|
# A reCAPTCHA v2 configuration for the captcha site only (a hand-written plaintext secret is accepted). A POST
|
||||||
|
# without a token is refused before any call to the provider, so no network is needed.
|
||||||
|
cat > "$SITES/captcha/plugins/protection.yml" <<'YML'
|
||||||
|
honeypotEnabled: true
|
||||||
|
captcha:
|
||||||
|
enabled: true
|
||||||
|
provider: recaptcha-v2
|
||||||
|
siteKey: verify-site-key
|
||||||
|
secretKey: verify-secret-key
|
||||||
|
YML
|
||||||
|
PROTECTION="yes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[verify] booting host (ACTIVE) ..."
|
||||||
|
boot "$SCRATCH/active.log"
|
||||||
|
wait_for "$SCRATCH/active.log" "Started RunwayApplication" 90 || { echo "ACTIVE did not start"; tail -20 "$SCRATCH/active.log"; exit 1; }
|
||||||
|
LOG="$SCRATCH/active.log"
|
||||||
|
TSV="$SITES/default/plugins/contact/submissions.tsv"
|
||||||
|
lines() { if [ -f "$1" ]; then grep -c . "$1"; else echo 0; fi; }
|
||||||
|
|
||||||
|
echo "== plugin load (SPI 1.0.0 contract) =="
|
||||||
|
EXPECTED=1; [ "$PROTECTION" = "yes" ] && EXPECTED=2
|
||||||
|
ck "plugins registered ($EXPECTED), 0 blocked" "grep -qE 'plugins: $EXPECTED registered, 0 blocked' '$LOG'"
|
||||||
|
ck "not blocked / quarantined" "! grep -qE \"plugin 'contact' is blocked|plugin-quarantine\" '$LOG'"
|
||||||
|
# Host linkage and the surface rules, in both kernels' words: SPI 0.6.0 WARNed ("uses host internals", "… allowed until
|
||||||
|
# Runway 1.0"); from SPI 1.0.0 the kernel BLOCKS and logs "linkage scan: <reason>" / the surface reason — a grep for the
|
||||||
|
# 0.6.0 wording alone can never fail on a 1.0 kernel.
|
||||||
|
ck "ZERO host-linkage findings" "! grep -qE \"uses host internals|plugin 'contact' linkage scan\" '$LOG'"
|
||||||
|
ck "ZERO bean-name/surface findings" "! grep -qE \"plugin 'contact'.*(allowed until Runway 1.0|bean name|may not contribute)\" '$LOG'"
|
||||||
|
ck "no WARN/ERROR names the plugin" "! grep -E ' (WARN|ERROR) ' '$LOG' | grep -qi 'contact'"
|
||||||
|
ck "no key collision / degraded" "! grep -qiE 'collision|duplicate key|degraded' '$LOG'"
|
||||||
|
|
||||||
|
echo "== static assets =="
|
||||||
|
ck "contact.css served" "curl -s -o /dev/null -w '%{http_code}' '$BASE/__plugin/contact/static/contact.css' | grep -q 200"
|
||||||
|
ck "help page served" "curl -s -o /dev/null -w '%{http_code}' '$BASE/__plugin/contact/static/contact-help.html' | grep -q 200"
|
||||||
|
|
||||||
|
echo "== anonymous POST /contact/submit (no session, no CSRF token) =="
|
||||||
|
post() { curl -s -o /dev/null -w '%{http_code} %{redirect_url}' -X POST "$@"; }
|
||||||
|
R="$(post "$BASE/contact/submit" --data-urlencode 'return=/' --data-urlencode 'name=Ann Visitor' \
|
||||||
|
--data-urlencode 'email=ann@example.com' --data-urlencode 'message=Hello from a POST' --data-urlencode 'website=')"
|
||||||
|
ck "valid POST -> 303 ?contact=sent" "[ \"\${R%% *}\" = 303 ] && echo '$R' | grep -q 'contact=sent'"
|
||||||
|
ck "the redirect carries no submitted value" "! echo '$R' | grep -qiE 'ann|example|hello'"
|
||||||
|
ck "the submission is stored (appended to submissions.tsv)" "grep -q $'\tAnn Visitor\tann@example.com\tHello from a POST' '$TSV'"
|
||||||
|
ck "a GET submission is gone (404) and stores nothing" \
|
||||||
|
"[ \"\$(curl -s -o /dev/null -w '%{http_code}' '$BASE/contact/submit?return=/&name=Get&email=get%40example.com&message=via%20GET&website=')\" = 404 ] && ! grep -q 'get@example.com' '$TSV'"
|
||||||
|
ck "a filled honeypot fakes success and stores nothing" \
|
||||||
|
"post '$BASE/contact/submit' -d 'return=/&name=Bot&email=bot%40example.com&message=spam&website=http://spam' | grep -q 'contact=sent' && ! grep -q 'bot@example.com' '$TSV'"
|
||||||
|
ck "an invalid email -> ?contact=invalid, not stored" \
|
||||||
|
"post '$BASE/contact/submit' -d 'return=/&name=Bad&email=nope&message=hi&website=' | grep -q 'contact=invalid' && ! grep -q $'\tBad\t' '$TSV'"
|
||||||
|
ck "fields in the query string are ignored -> invalid" \
|
||||||
|
"post '$BASE/contact/submit?name=Q&email=q%40example.com&message=query' -d 'return=/' | grep -q 'contact=invalid' && ! grep -q 'q@example.com' '$TSV'"
|
||||||
|
ck "a multipart body is refused 415 by the kernel" \
|
||||||
|
"[ \"\$(curl -s -o /dev/null -w '%{http_code}' -X POST '$BASE/contact/submit' -F 'name=M' -F 'email=m@example.com' -F 'message=multi')\" = 415 ]"
|
||||||
|
ck "exactly one stored submission so far" "[ \"\$(lines '$TSV')\" = 1 ]"
|
||||||
|
|
||||||
|
ck "submissions.tsv is never served publicly" \
|
||||||
|
"( for u in '/static/../plugins/contact/submissions.tsv' '/plugins/contact/submissions.tsv' '/__plugin/contact/static/../../submissions.tsv'; do curl -s --path-as-is '$BASE'\$u | grep -q 'ann@example.com' && exit 1; done; exit 0 )"
|
||||||
|
|
||||||
|
echo "== the starter page through SitePages (Advisory, Enforced, Reviewed) =="
|
||||||
|
token() { grep -o 'name="_csrf" value="[^"]*"' | head -1 | sed 's/.*value="//; s/"$//'; }
|
||||||
|
# One cookie jar per site host; curl --resolve maps <site>.test to the local host so cookies scope correctly.
|
||||||
|
site_url() { [ "$1" = default ] && echo "$BASE" || echo "http://$1.test:$PORT"; }
|
||||||
|
sc() { # site curl-args...
|
||||||
|
local site="$1"; shift
|
||||||
|
curl -s -H 'Accept-Language: en' --resolve "$site.test:$PORT:127.0.0.1" \
|
||||||
|
-c "$SCRATCH/cookies-$site.txt" -b "$SCRATCH/cookies-$site.txt" "$@"
|
||||||
|
}
|
||||||
|
login() {
|
||||||
|
local u; u="$(site_url "$1")"
|
||||||
|
sc "$1" -o /dev/null -X POST "$u/login" --data-urlencode "username=$SITE_USER" --data-urlencode "password=$SITE_PW" \
|
||||||
|
--data-urlencode "_csrf=$(sc "$1" "$u/login" | token)"
|
||||||
|
}
|
||||||
|
code() { curl -s -o /dev/null -w '%{http_code}' "$@"; }
|
||||||
|
SETTINGS="$BASE/__admin/plugins/contact/settings"
|
||||||
|
no_page() { ! ls "$SITES/$1/templates"/contact.* >/dev/null 2>&1; }
|
||||||
|
|
||||||
|
echo "== the operator actions are CSRF-protected POSTs (a link or an <img> changes nothing) =="
|
||||||
|
ck "anonymous GET of either action -> 404 (no GET route)" \
|
||||||
|
"[ \"\$(code '$BASE/contact/install-page')\" = 404 ] && [ \"\$(code '$BASE/contact/smtp-test')\" = 404 ]"
|
||||||
|
ck "anonymous POST without a CSRF token -> 403 (the tenant chain's CSRF check)" \
|
||||||
|
"[ \"\$(code -X POST '$BASE/contact/install-page' -d x=1)\" = 403 ] && [ \"\$(code -X POST '$BASE/contact/smtp-test' -d x=1)\" = 403 ]"
|
||||||
|
ANON_JAR="$SCRATCH/cookies-anon.txt"
|
||||||
|
ANON_TOKEN="$(curl -s -c "$ANON_JAR" -b "$ANON_JAR" "$BASE/login" | token)"
|
||||||
|
ck "anonymous POST WITH a valid session token -> 404 (the permission check still applies)" \
|
||||||
|
"[ -n '$ANON_TOKEN' ] && [ \"\$(code -c '$ANON_JAR' -b '$ANON_JAR' -X POST '$BASE/contact/install-page' --data-urlencode '_csrf=$ANON_TOKEN')\" = 404 ]"
|
||||||
|
ck "…and nothing was installed by any of that" "no_page default"
|
||||||
|
for site in default enforced reviewed; do login "$site"; done
|
||||||
|
ck "signed-in owner: GET /contact/install-page -> 404 and no page (a cross-site link installs nothing)" \
|
||||||
|
"[ \"\$(sc default -o /dev/null -w '%{http_code}' '$BASE/contact/install-page')\" = 404 ] && no_page default"
|
||||||
|
ck "signed-in owner: POST without the CSRF token -> 403 and no page" \
|
||||||
|
"[ \"\$(sc default -o /dev/null -w '%{http_code}' -X POST '$BASE/contact/install-page' -d x=1)\" = 403 ] && no_page default"
|
||||||
|
ck "signed-in owner: POST with a forged CSRF token -> 403 and no page" \
|
||||||
|
"[ \"\$(sc default -o /dev/null -w '%{http_code}' -X POST '$BASE/contact/install-page' -d _csrf=forged-token)\" = 403 ] && no_page default"
|
||||||
|
sc default "$SETTINGS" > "$SCRATCH/settings-0.html"
|
||||||
|
ck "the settings page offers the install as a POST form carrying a non-empty CSRF token" \
|
||||||
|
"grep -q 'id=\"cp-install-form\" method=\"post\" action=\"/contact/install-page\"' '$SCRATCH/settings-0.html' && grep -qE 'id=\"cp-csrf\" type=\"hidden\" name=\"_csrf\" value=\"[^\"]+\"' '$SCRATCH/settings-0.html'"
|
||||||
|
ck "…and the SMTP test as a POST form carrying a non-empty CSRF token" \
|
||||||
|
"grep -q 'id=\"cn-smtp-test-form\" method=\"post\" action=\"/contact/smtp-test\"' '$SCRATCH/settings-0.html' && grep -qE 'id=\"cn-csrf\" type=\"hidden\" name=\"_csrf\" value=\"[^\"]+\"' '$SCRATCH/settings-0.html'"
|
||||||
|
ck "…and no link points at either action" "! grep -qE 'href=\"/contact/(install-page|smtp-test)' '$SCRATCH/settings-0.html'"
|
||||||
|
install() { # site -> the install action's answer, POSTed with the token from that site's settings page
|
||||||
|
local u; u="$(site_url "$1")"
|
||||||
|
sc "$1" -X POST "$u/contact/install-page" --data-urlencode "_csrf=$(sc "$1" "$u/__admin/plugins/contact/settings" | token)"
|
||||||
|
}
|
||||||
|
install default > "$SCRATCH/install-default.txt"
|
||||||
|
ck "Advisory: POST with the token installs and publishes at /contact" "grep -qx 'Contact page installed at /contact' '$SCRATCH/install-default.txt'"
|
||||||
|
curl -s "$BASE/contact" > "$SCRATCH/contact-page.html"
|
||||||
|
ck "…the public page renders the form as a POST to the anonymous route" \
|
||||||
|
"grep -q 'method=\"post\" action=\"/contact/submit\"' '$SCRATCH/contact-page.html' && ! grep -q 'name=\"_csrf\"' '$SCRATCH/contact-page.html'"
|
||||||
|
ck "…with the return path of the page" "grep -q 'name=\"return\" value=\"/contact\"' '$SCRATCH/contact-page.html'"
|
||||||
|
install default > "$SCRATCH/install-again.txt"
|
||||||
|
ck "a second install changes nothing and says where the page is" "grep -qx 'A contact page already exists at /contact' '$SCRATCH/install-again.txt'"
|
||||||
|
for site in enforced reviewed; do
|
||||||
|
install "$site" > "$SCRATCH/install-$site.txt"
|
||||||
|
echo " $site says: $(head -c 300 "$SCRATCH/install-$site.txt" | tr '\n' ' ')"
|
||||||
|
done
|
||||||
|
# Enforced: published when the quality checks pass, else a draft with the blocking findings listed.
|
||||||
|
ck "Enforced: a documented outcome, never an error" \
|
||||||
|
"grep -qE '^(Contact page installed at /contact|The contact page was created as a draft because the quality checks blocked publishing; fix it in the page editor: /contact)' '$SCRATCH/install-enforced.txt'"
|
||||||
|
# Reviewed: the owner holds APPROVE_PAGES, so the gated publish runs; without it the page would wait for review.
|
||||||
|
ck "Reviewed (as the owner, who may approve): a documented outcome" \
|
||||||
|
"grep -qE '^(Contact page installed at /contact|The contact page was created and is waiting in the review queue: /contact|The contact page was created as a draft)' '$SCRATCH/install-reviewed.txt'"
|
||||||
|
ck "the installed pages exist on every site" \
|
||||||
|
"( for s in default enforced reviewed; do ls \"$SITES/\$s/templates\"/contact.* >/dev/null || exit 1; done )"
|
||||||
|
sc default "$SETTINGS" > "$SCRATCH/settings-1.html"
|
||||||
|
ck "the settings page shows the installed page's live path" "grep -q 'id=\"cp-path\"[^>]*>/contact<' '$SCRATCH/settings-1.html'"
|
||||||
|
ck "…and counts the stored submission" "grep -q 'id=\"cn-count\">1<' '$SCRATCH/settings-1.html'"
|
||||||
|
|
||||||
|
echo "== the SMTP password: saved ENC(...), handed to the relay in clear (PluginSettings.secret) =="
|
||||||
|
# A minimal local SMTP relay that accepts AUTH LOGIN/PLAIN and records the credentials and the message.
|
||||||
|
cat > "$SCRATCH/fake_smtp.py" <<'PY'
|
||||||
|
import base64, socket, sys, threading
|
||||||
|
port, log = int(sys.argv[1]), open(sys.argv[2], "a", buffering=1)
|
||||||
|
def b64(s):
|
||||||
|
return base64.b64decode(s.strip()).decode("utf-8", "replace")
|
||||||
|
def serve(c):
|
||||||
|
f = c.makefile("rwb", buffering=0)
|
||||||
|
def say(line): f.write((line + "\r\n").encode())
|
||||||
|
say("220 fake ESMTP")
|
||||||
|
while True:
|
||||||
|
raw = f.readline()
|
||||||
|
if not raw: break
|
||||||
|
line = raw.decode("utf-8", "replace").rstrip("\r\n"); up = line.upper()
|
||||||
|
if up.startswith(("EHLO", "HELO")): say("250-fake"); say("250 AUTH LOGIN PLAIN")
|
||||||
|
elif up.startswith("AUTH PLAIN"):
|
||||||
|
arg = line[10:].strip()
|
||||||
|
if not arg: say("334 "); arg = f.readline().decode()
|
||||||
|
parts = b64(arg).split("\0"); log.write("AUTH user=%s pass=%s\n" % (parts[1], parts[2])); say("235 ok")
|
||||||
|
elif up.startswith("AUTH LOGIN"):
|
||||||
|
arg = line[10:].strip()
|
||||||
|
if not arg: say("334 VXNlcm5hbWU6"); arg = f.readline().decode()
|
||||||
|
user = b64(arg); say("334 UGFzc3dvcmQ6"); pw = b64(f.readline().decode())
|
||||||
|
log.write("AUTH user=%s pass=%s\n" % (user, pw)); say("235 ok")
|
||||||
|
elif up.startswith(("MAIL", "RCPT", "RSET", "NOOP")): log.write(line + "\n"); say("250 ok")
|
||||||
|
elif up == "DATA":
|
||||||
|
say("354 go")
|
||||||
|
while True:
|
||||||
|
d = f.readline().decode("utf-8", "replace")
|
||||||
|
if d in (".\r\n", ".\n", ""): break
|
||||||
|
log.write("DATA " + d.rstrip("\r\n") + "\n")
|
||||||
|
say("250 queued")
|
||||||
|
elif up == "QUIT": say("221 bye"); break
|
||||||
|
else: say("250 ok")
|
||||||
|
c.close()
|
||||||
|
s = socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1); s.bind(("127.0.0.1", port)); s.listen(5)
|
||||||
|
while True:
|
||||||
|
conn, _ = s.accept(); threading.Thread(target=serve, args=(conn,), daemon=True).start()
|
||||||
|
PY
|
||||||
|
python3 -I "$SCRATCH/fake_smtp.py" "$SMTP_PORT" "$SCRATCH/smtp.log" & SMTP_PID=$!
|
||||||
|
sc default -o /dev/null -X POST "$SETTINGS" --data-urlencode "enabled=true" \
|
||||||
|
--data-urlencode "smtpHost=127.0.0.1" --data-urlencode "smtpPort=$SMTP_PORT" --data-urlencode "smtpAuth=true" \
|
||||||
|
--data-urlencode "smtpUsername=$RELAY_USER" --data-urlencode "smtpPassword=$RELAY_PW" \
|
||||||
|
--data-urlencode "fromAddress=site@example.test" --data-urlencode "toAddress=owner@example.test" \
|
||||||
|
--data-urlencode "_csrf=$(token < "$SCRATCH/settings-1.html")"
|
||||||
|
CFG="$SITES/default/plugins/contact.yml"
|
||||||
|
ck "the password is stored ENC(...), never in clear" "grep -q 'smtpPassword: .*ENC(' '$CFG' && ! grep -q '$RELAY_PW' '$CFG'"
|
||||||
|
R="$(post "$BASE/contact/submit" --data-urlencode 'return=/contact' --data-urlencode 'name=Bea Mailer' \
|
||||||
|
--data-urlencode 'email=bea@example.com' --data-urlencode 'message=Please call me back' --data-urlencode 'website=')"
|
||||||
|
ck "a submission over the configured relay -> ?contact=sent (not queued)" "echo '$R' | grep -q '/contact?contact=sent'"
|
||||||
|
ck "…the relay was offered the secret in clear" "grep -qx 'AUTH user=$RELAY_USER pass=$RELAY_PW' '$SCRATCH/smtp.log'"
|
||||||
|
ck "…and received the visitor's message" "grep -q 'DATA Please call me back' '$SCRATCH/smtp.log'"
|
||||||
|
ck "…which is stored as well" "grep -q 'bea@example.com' '$TSV'"
|
||||||
|
ck "signed-in owner: GET /contact/smtp-test?to=… -> 404 and no email (a cross-site link sends nothing)" \
|
||||||
|
"[ \"\$(sc default -o /dev/null -w '%{http_code}' '$BASE/contact/smtp-test?to=link@example.test')\" = 404 ] && ! grep -q 'link@example.test' '$SCRATCH/smtp.log'"
|
||||||
|
ck "signed-in owner: POST /contact/smtp-test without the CSRF token -> 403 and no email" \
|
||||||
|
"[ \"\$(sc default -o /dev/null -w '%{http_code}' -X POST '$BASE/contact/smtp-test' --data-urlencode 'to=forged@example.test')\" = 403 ] && ! grep -q 'forged@example.test' '$SCRATCH/smtp.log'"
|
||||||
|
# The console's button: a form POST carrying only the token -> the test goes to the configured recipient.
|
||||||
|
sc default -X POST "$BASE/contact/smtp-test" --data-urlencode "_csrf=$(sc default "$SETTINGS" | token)" \
|
||||||
|
> "$SCRATCH/smtp-test.txt"
|
||||||
|
ck "the operator's SMTP test (the console form: POST + token) sends over the same relay to the configured recipient" \
|
||||||
|
"grep -qx 'Test message sent.' '$SCRATCH/smtp-test.txt' && [ \"\$(grep -c 'RCPT TO:<owner@example.test>' '$SCRATCH/smtp.log')\" = 2 ]"
|
||||||
|
# The optional `to` override is read from the form BODY, never the query string. A browser form sends the CSRF
|
||||||
|
# token as the `_csrf` FIELD next to it, so that is the case that must work: the kernel keeps the url-encoded body
|
||||||
|
# for the route after its CSRF check, so form() carries the field whether the token came as the field or in the
|
||||||
|
# X-CSRF-TOKEN header. Both ways are checked.
|
||||||
|
sc default -X POST "$BASE/contact/smtp-test" --data-urlencode "_csrf=$(sc default "$SETTINGS" | token)" \
|
||||||
|
--data-urlencode "to=field@example.test" > "$SCRATCH/smtp-test-to-field.txt"
|
||||||
|
ck "…and honours a 'to' override in the body with the token as a form field (as a browser form sends it)" \
|
||||||
|
"grep -qx 'Test message sent.' '$SCRATCH/smtp-test-to-field.txt' && grep -q 'RCPT TO:<field@example.test>' '$SCRATCH/smtp.log'"
|
||||||
|
sc default -X POST "$BASE/contact/smtp-test" -H "X-CSRF-TOKEN: $(sc default "$SETTINGS" | token)" \
|
||||||
|
--data-urlencode "to=header@example.test" > "$SCRATCH/smtp-test-to-header.txt"
|
||||||
|
ck "…and with the token in the X-CSRF-TOKEN header" \
|
||||||
|
"grep -qx 'Test message sent.' '$SCRATCH/smtp-test-to-header.txt' && grep -q 'RCPT TO:<header@example.test>' '$SCRATCH/smtp.log'"
|
||||||
|
sc default -X POST "$BASE/contact/smtp-test?to=query@example.test" \
|
||||||
|
--data-urlencode "_csrf=$(sc default "$SETTINGS" | token)" > "$SCRATCH/smtp-test-to-query.txt"
|
||||||
|
ck "…but ignores a 'to' in the query string (the test goes to the configured recipient)" \
|
||||||
|
"grep -qx 'Test message sent.' '$SCRATCH/smtp-test-to-query.txt' && ! grep -q 'query@example.test' '$SCRATCH/smtp.log' && [ \"\$(grep -c 'RCPT TO:<owner@example.test>' '$SCRATCH/smtp.log')\" = 3 ]"
|
||||||
|
|
||||||
|
echo "== backups: a full backup keeps submissions.tsv, a transfer copy leaves it out =="
|
||||||
|
sc default -o "$SCRATCH/full.zip" "$BASE/__admin/backups/download"
|
||||||
|
sc default -o "$SCRATCH/transfer.zip" "$BASE/__admin/backups/download-transfer"
|
||||||
|
zipq() { # zip mode -> prints what was asked
|
||||||
|
python3 -I - "$@" <<'PY'
|
||||||
|
import sys, zipfile
|
||||||
|
z = zipfile.ZipFile(sys.argv[1]); mode = sys.argv[2]
|
||||||
|
names = z.namelist()
|
||||||
|
if mode == "has":
|
||||||
|
sys.exit(0 if any(n.endswith(sys.argv[3]) for n in names) else 1)
|
||||||
|
if mode == "read":
|
||||||
|
n = next(n for n in names if n.endswith(sys.argv[3])); sys.stdout.write(z.read(n).decode("utf-8"))
|
||||||
|
PY
|
||||||
|
}
|
||||||
|
zipq "$SCRATCH/full.zip" read manifest.yml > "$SCRATCH/full-manifest.yml" 2>/dev/null
|
||||||
|
zipq "$SCRATCH/transfer.zip" read manifest.yml > "$SCRATCH/transfer-manifest.yml" 2>/dev/null
|
||||||
|
ck "the full backup carries plugins/contact/submissions.tsv" "zipq '$SCRATCH/full.zip' has plugins/contact/submissions.tsv"
|
||||||
|
ck "…with the submissions in it" "zipq '$SCRATCH/full.zip' read plugins/contact/submissions.tsv | grep -q 'ann@example.com'"
|
||||||
|
ck "the transfer copy has NO plugins/contact/submissions.tsv" "! zipq '$SCRATCH/transfer.zip' has plugins/contact/submissions.tsv"
|
||||||
|
ck "…and its manifest lists the omission" "grep -q 'plugins/contact/submissions.tsv' '$SCRATCH/transfer-manifest.yml'"
|
||||||
|
ck "…while the settings file travels (secret blanked)" \
|
||||||
|
"zipq '$SCRATCH/transfer.zip' has plugins/contact.yml && ! zipq '$SCRATCH/transfer.zip' read plugins/contact.yml | grep -q 'ENC('"
|
||||||
|
ck "the full backup's manifest omits nothing of contact" "! grep -q 'plugins/contact/submissions.tsv' '$SCRATCH/full-manifest.yml'"
|
||||||
|
|
||||||
|
echo "== CAPTCHA still enforced on the anonymous POST (protection plugin, one site) =="
|
||||||
|
if [ "$PROTECTION" = "yes" ]; then
|
||||||
|
CTSV="$SITES/captcha/plugins/contact/submissions.tsv"
|
||||||
|
CURL_C="http://captcha.test:$PORT"
|
||||||
|
curl -s --resolve "captcha.test:$PORT:127.0.0.1" "$CURL_C/about" > "$SCRATCH/captcha-about.html"
|
||||||
|
ck "the form carries the site's CAPTCHA challenge" \
|
||||||
|
"grep -q 'data-sitekey=\"verify-site-key\"' '$SCRATCH/captcha-about.html' && grep -q 'method=\"post\" action=\"/contact/submit\"' '$SCRATCH/captcha-about.html'"
|
||||||
|
ck "a POST without the CAPTCHA token -> ?contact=captcha" \
|
||||||
|
"post --resolve 'captcha.test:$PORT:127.0.0.1' '$CURL_C/contact/submit' -d 'return=/about&name=Cy&email=cy%40example.com&message=no%20token&website=' | grep -q '/about?contact=captcha'"
|
||||||
|
ck "a POST with a blank CAPTCHA token -> ?contact=captcha" \
|
||||||
|
"post --resolve 'captcha.test:$PORT:127.0.0.1' '$CURL_C/contact/submit' -d 'return=/about&name=Cy&email=cy%40example.com&message=blank&website=&g-recaptcha-response=' | grep -q 'contact=captcha'"
|
||||||
|
ck "a filled honeypot on that site still fakes success" \
|
||||||
|
"post --resolve 'captcha.test:$PORT:127.0.0.1' '$CURL_C/contact/submit' -d 'return=/about&name=Bot&email=b%40example.com&message=x&website=http://spam' | grep -q 'contact=sent'"
|
||||||
|
ck "nothing was stored for the CAPTCHA site" "[ \"\$(lines '$CTSV')\" = 0 ]"
|
||||||
|
else
|
||||||
|
skip "CAPTCHA checks (no built protection plugin at '$PROTECTION_DIR')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo; echo "RESULT: $PASS passed, $FAIL failed, $SKIP skipped"
|
||||||
|
if [ "$KEEP" = "yes" ]; then echo "[verify] kept at $BASE (scratch $SCRATCH; kill $PID to stop)"; wait "$PID"; fi
|
||||||
|
exit "$FAIL"
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import mx.quest.runway.spi.service.SitePages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read-only status model for the console surfaces (dashboard card + admin fragment), read by template bean name,
|
||||||
|
* e.g. {@code ${@contactAdminModel.count(tenantSiteId)}} and iterated for the recent-submissions table. Also
|
||||||
|
* exposes the SMTP <b>readiness</b> ({@link #smtpConfigured(String)}) and the test-action URL so the admin
|
||||||
|
* fragment can show "Configured / Not configured" and offer the operator-only SMTP self-test, plus the
|
||||||
|
* ready-made-page <b>install status</b> ({@link #pageInstalled(String)} / {@link #pagePath(String)}) — read
|
||||||
|
* fresh from the kernel's {@link SitePages#pathOf} so a moved/renamed page reports its current path. Gated in the console
|
||||||
|
* by the plugin's {@code settings} control point.
|
||||||
|
*/
|
||||||
|
public class ContactAdminModel {
|
||||||
|
|
||||||
|
private static final int RECENT = 20;
|
||||||
|
|
||||||
|
private final ContactStore store;
|
||||||
|
private final ContactMailer mailer;
|
||||||
|
private final SitePages pages;
|
||||||
|
|
||||||
|
public ContactAdminModel(ContactStore store, ContactMailer mailer, SitePages pages) {
|
||||||
|
this.store = store;
|
||||||
|
this.mailer = mailer;
|
||||||
|
this.pages = pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Total stored submissions for the site. */
|
||||||
|
public int count(String siteId) {
|
||||||
|
return store.count(siteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The most recent submissions (newest first) for the admin listing. */
|
||||||
|
public List<ContactSubmission> recent(String siteId) {
|
||||||
|
return store.recent(siteId, RECENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this site has a usable SMTP relay (a non-blank host AND recipient). When false, submissions are
|
||||||
|
* stored only — the readiness badge shows "Not configured" and no email is sent.
|
||||||
|
*/
|
||||||
|
public boolean smtpConfigured(String siteId) {
|
||||||
|
return mailer.settingsFor(siteId).isConfigured();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The recipient address configured for this site (for display), or an empty string when none is set. */
|
||||||
|
public String recipient(String siteId) {
|
||||||
|
return mailer.settingsFor(siteId).to();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this site already has the ready-made contact page (the one {@code /contact/install-page} seeds).
|
||||||
|
* Read fresh through {@link SitePages#pathOf} by the installer's stable slug, in any state (a draft or a page
|
||||||
|
* waiting for review counts), so it stays true even after the operator moves or renames the page (the slug is
|
||||||
|
* the page's identity; only its path changes).
|
||||||
|
*/
|
||||||
|
public boolean pageInstalled(String siteId) {
|
||||||
|
return pages.pathOf(siteId, ContactEndpoint.INSTALLED_PAGE_SLUG).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current URL path of the installed contact page (e.g. {@code /contact}, or wherever the operator moved
|
||||||
|
* it), or an empty string when it is not installed. Read live so the console always shows the real location.
|
||||||
|
*/
|
||||||
|
public String pagePath(String siteId) {
|
||||||
|
return pages.pathOf(siteId, ContactEndpoint.INSTALLED_PAGE_SLUG).orElse("");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
import mx.quest.runway.spi.CaptchaService;
|
||||||
|
import mx.quest.runway.spi.ContentWidget;
|
||||||
|
import mx.quest.runway.spi.EndpointContributor;
|
||||||
|
import mx.quest.runway.spi.service.AccessCheck;
|
||||||
|
import mx.quest.runway.spi.service.Messages;
|
||||||
|
import mx.quest.runway.spi.service.PluginSettings;
|
||||||
|
import mx.quest.runway.spi.service.PluginSiteFiles;
|
||||||
|
import mx.quest.runway.spi.service.SitePages;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The plugin's {@code mainClass} — the single {@code @Configuration} registered into the host context before
|
||||||
|
* refresh. Beans are wired EXPLICITLY (no {@code @ComponentScan}). The package {@code mx.quest.contact} lives
|
||||||
|
* OUTSIDE {@code mx.quest.runway} so the host never double-scans it.
|
||||||
|
*
|
||||||
|
* <p><b>SPI only.</b> Everything this plugin needs from the kernel arrives as an SPI service (SPI 1.0.0):
|
||||||
|
* {@link PluginSettings} (this plugin's per-site settings, and the SMTP password secret in clear) and
|
||||||
|
* {@link PluginSiteFiles} (this plugin's per-site folder, where submissions are kept) are bound to this plugin by
|
||||||
|
* the jar this class was loaded from; {@link Messages}, {@link AccessCheck}, {@link SitePages} and the
|
||||||
|
* {@link CaptchaService} are kernel singletons. Nothing outside {@code mx.quest.runway.spi} is linked.
|
||||||
|
*
|
||||||
|
* <p>The {@link ContactWidget} ({@code ContentWidget}) and {@link ContactEndpoint} ({@code EndpointContributor})
|
||||||
|
* are list-collected SPIs — plain {@code @Bean}s, NEVER {@code @Primary}. Every bean name starts with the plugin
|
||||||
|
* id ({@code contact…}), the kernel's rule for a bean namespace plugins share. The email seam is
|
||||||
|
* {@link MailTransport} ({@link JakartaMailTransport} in production, using the Jakarta Mail stack the KERNEL
|
||||||
|
* bundles as a core capability).
|
||||||
|
*/
|
||||||
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
public class ContactConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ContactStore contactStore(PluginSiteFiles files) {
|
||||||
|
return new ContactStore(files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The production send seam — delegates to {@code jakarta.mail.Transport} (the kernel bundles Jakarta Mail). */
|
||||||
|
@Bean
|
||||||
|
public MailTransport contactMailTransport() {
|
||||||
|
return new JakartaMailTransport();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ContactMailer contactMailer(PluginSettings settings, MailTransport transport) {
|
||||||
|
return new ContactMailer(settings, transport);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ContentWidget contactWidget(PluginSettings settings, Messages messages, CaptchaService captcha) {
|
||||||
|
return new ContactWidget(settings, messages, captcha);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public EndpointContributor contactEndpoint(ContactStore store, ContactMailer mailer, PluginSettings settings,
|
||||||
|
Messages messages, AccessCheck access, CaptchaService captcha,
|
||||||
|
SitePages pages) {
|
||||||
|
return new ContactEndpoint(store, mailer, settings, messages, access, captcha, pages);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ContactAdminModel contactAdminModel(ContactStore store, ContactMailer mailer, SitePages pages) {
|
||||||
|
return new ContactAdminModel(store, mailer, pages);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,310 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import mx.quest.runway.spi.CaptchaService;
|
||||||
|
import mx.quest.runway.spi.EndpointContributor;
|
||||||
|
import mx.quest.runway.spi.model.Capabilities;
|
||||||
|
import mx.quest.runway.spi.model.CaptchaWidget;
|
||||||
|
import mx.quest.runway.spi.model.Finding;
|
||||||
|
import mx.quest.runway.spi.model.InstallResult;
|
||||||
|
import mx.quest.runway.spi.model.Realm;
|
||||||
|
import mx.quest.runway.spi.model.Route;
|
||||||
|
import mx.quest.runway.spi.model.RouteRequest;
|
||||||
|
import mx.quest.runway.spi.model.RouteResponse;
|
||||||
|
import mx.quest.runway.spi.model.StarterPage;
|
||||||
|
import mx.quest.runway.spi.model.SurfacePosture;
|
||||||
|
import mx.quest.runway.spi.service.AccessCheck;
|
||||||
|
import mx.quest.runway.spi.service.Messages;
|
||||||
|
import mx.quest.runway.spi.service.PluginSettings;
|
||||||
|
import mx.quest.runway.spi.service.SitePages;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The contact plugin's tiny request-handling surface — it owns <b>no visible page</b>. The contact form lives on a
|
||||||
|
* normal, editable site page (via the {@link ContactWidget} anchor; the operator installs the ready-made one from
|
||||||
|
* the plugin settings). This endpoint only:
|
||||||
|
* <ul>
|
||||||
|
* <li><b>{@code POST /contact/submit}</b> — an <b>anonymous</b> route ({@code Route.anonymousPost}): the kernel
|
||||||
|
* exempts exactly this method and path from CSRF (a public form on a cacheable page has no session token),
|
||||||
|
* hands it only {@code application/x-www-form-urlencoded} bodies and runs it with no principal. The fields
|
||||||
|
* are read from the <b>form body only</b> — a field put in the query string is ignored, so a visitor's
|
||||||
|
* personal data never has to travel in a URL. It stores + emails the submission, then answers {@code 303}
|
||||||
|
* back to the page the form lives on (the {@code return} field, or the {@code Referer}) with a
|
||||||
|
* {@code ?contact=sent|invalid|captcha|queued} flag the widget re-renders the outcome from. The abuse guards
|
||||||
|
* stay in front of the store: a filled honeypot fakes success (stores/sends nothing), an invalid submission
|
||||||
|
* or an unsolved CAPTCHA (verified with the kernel-gated {@code clientIp}) redirects with an error flag, and
|
||||||
|
* the platform's per-address rate limit (the protection plugin's edge guard) applies to this path like any
|
||||||
|
* other. A valid submission is <b>stored first</b> ({@link ContactStore}) and then <b>emailed</b> over the
|
||||||
|
* site's own relay, so a send failure never loses the message. Any other method on this path is a 404.</li>
|
||||||
|
* <li><b>{@code POST /contact/install-page}</b> — operator-gated ({@code contact|settings}): installs a real,
|
||||||
|
* editable page carrying the contact-form widget through {@link SitePages#install}, which respects the
|
||||||
|
* site's editorial level and never overwrites; the operator is told which of the outcomes happened.</li>
|
||||||
|
* <li><b>{@code POST /contact/smtp-test}</b> — operator-gated SMTP self-test; an optional {@code to} field of the
|
||||||
|
* form body overrides the recipient.</li>
|
||||||
|
* </ul>
|
||||||
|
* The two operator actions change something (a page is created, an email is sent), so they are <b>ordinary,
|
||||||
|
* non-anonymous {@code POST} routes</b>: the kernel's tenant chain demands the console session's CSRF token on them
|
||||||
|
* (the admin fragment's forms carry it), which is what stops another web site from triggering them through a
|
||||||
|
* signed-in operator's browser with a link or an {@code <img>}. A {@code GET} on either path matches no route and
|
||||||
|
* changes nothing (the kernel answers 404); {@link #handle} refuses any other method too, as a second line.
|
||||||
|
* Neither action reads the query string.
|
||||||
|
* Honors the per-site {@code enabled} setting (disabled ⇒ a submission is a no-op 404). All redirect targets are
|
||||||
|
* validated as same-origin local paths.
|
||||||
|
*/
|
||||||
|
public class ContactEndpoint implements EndpointContributor {
|
||||||
|
|
||||||
|
/** The anonymous form-submission route; the {@link ContactForm} posts here. */
|
||||||
|
static final String SUBMIT_PATH = "/contact/submit";
|
||||||
|
static final String INSTALL_PATH = "/contact/install-page";
|
||||||
|
static final String SMTP_TEST_PATH = "/contact/smtp-test";
|
||||||
|
/** The slug/path the ready-made contact page is installed at (then owned + movable by the operator). */
|
||||||
|
static final String INSTALLED_PAGE_SLUG = "contact";
|
||||||
|
static final String SETTINGS_PERMISSION = "contact|settings";
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ContactEndpoint.class);
|
||||||
|
|
||||||
|
private final ContactStore store;
|
||||||
|
private final ContactMailer mailer;
|
||||||
|
private final PluginSettings settings;
|
||||||
|
private final Messages messages;
|
||||||
|
private final AccessCheck access;
|
||||||
|
private final CaptchaService captcha;
|
||||||
|
private final SitePages pages;
|
||||||
|
|
||||||
|
public ContactEndpoint(ContactStore store, ContactMailer mailer, PluginSettings settings, Messages messages,
|
||||||
|
AccessCheck access, CaptchaService captcha, SitePages pages) {
|
||||||
|
this.store = store;
|
||||||
|
this.mailer = mailer;
|
||||||
|
this.settings = settings;
|
||||||
|
this.messages = messages;
|
||||||
|
this.access = access;
|
||||||
|
this.captcha = captcha;
|
||||||
|
this.pages = pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String key() {
|
||||||
|
return "contact/form";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Route> routes() {
|
||||||
|
// No public /contact PAGE — the form lives on a normal editable page. These are the submit handler + the
|
||||||
|
// two operator actions; all safeDefault (noindex/no-store), never advertised or crawled. The operator
|
||||||
|
// actions are POST and NOT anonymous: they change state, so the kernel's CSRF check must apply to them.
|
||||||
|
return List.of(
|
||||||
|
Route.anonymousPost(SUBMIT_PATH, SurfacePosture.safeDefault()),
|
||||||
|
new Route("POST", INSTALL_PATH, Realm.TENANT, SurfacePosture.safeDefault()),
|
||||||
|
new Route("POST", SMTP_TEST_PATH, Realm.TENANT, SurfacePosture.safeDefault()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RouteResponse handle(RouteRequest req) {
|
||||||
|
// Every route here is POST-only; the kernel dispatches by method + path, and this check is the second line.
|
||||||
|
if (!"POST".equalsIgnoreCase(req.method())) {
|
||||||
|
return RouteResponse.notFound();
|
||||||
|
}
|
||||||
|
return switch (req.path()) {
|
||||||
|
case SUBMIT_PATH -> handleSubmit(req);
|
||||||
|
case INSTALL_PATH -> handleInstallPage(req);
|
||||||
|
case SMTP_TEST_PATH -> handleSmtpTest(req);
|
||||||
|
default -> RouteResponse.notFound();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Stores + emails a submission, then redirects back to the form's page with an outcome flag. */
|
||||||
|
private RouteResponse handleSubmit(RouteRequest req) {
|
||||||
|
String siteId = req.site().id();
|
||||||
|
if (!settings.site(siteId).bool("enabled", true)) {
|
||||||
|
return RouteResponse.notFound();
|
||||||
|
}
|
||||||
|
String back = resolveReturn(req);
|
||||||
|
String name = formField(req, "name");
|
||||||
|
String email = formField(req, "email");
|
||||||
|
String message = formField(req, "message");
|
||||||
|
String honeypot = formField(req, "website");
|
||||||
|
|
||||||
|
if (!honeypot.isBlank()) {
|
||||||
|
return redirect(back, "sent"); // a bot filled the trap — fake success, store/send nothing
|
||||||
|
}
|
||||||
|
if (message.isBlank() || !isEmail(email)) {
|
||||||
|
return redirect(back, "invalid");
|
||||||
|
}
|
||||||
|
CaptchaWidget widget = captcha.widgetForSite(siteId);
|
||||||
|
if (widget.active() && !captcha.verify(siteId, formField(req, widget.tokenField()), req.clientIp())) {
|
||||||
|
return redirect(back, "captcha");
|
||||||
|
}
|
||||||
|
// Belt-and-suspenders: STORE first (never lose a message), THEN email over the site's relay.
|
||||||
|
store.add(siteId, name, email, message, System.currentTimeMillis());
|
||||||
|
MailSendResult sent = mailer.send(siteId, req.site().displayName(), name, email, message);
|
||||||
|
// "queued" ⇒ stored but the configured relay failed (an unobtrusive "delivery delayed" note); NOT_CONFIGURED
|
||||||
|
// is silent (the site simply stores messages) — so only a real relay failure downgrades to "queued".
|
||||||
|
boolean delayed = sent != null && !sent.wasSent()
|
||||||
|
&& sent.status() != MailSendResult.Status.NOT_CONFIGURED;
|
||||||
|
return redirect(back, delayed ? "queued" : "sent");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Installs the ready-made, editable contact page (idempotent). {@code POST} only, CSRF-checked by the kernel;
|
||||||
|
* operator-gated, failing closed with a 404.
|
||||||
|
*/
|
||||||
|
private RouteResponse handleInstallPage(RouteRequest req) {
|
||||||
|
if (!access.may(SETTINGS_PERMISSION)) {
|
||||||
|
return RouteResponse.notFound();
|
||||||
|
}
|
||||||
|
String siteId = req.site().id();
|
||||||
|
Locale siteDefault = req.site().defaultLocale();
|
||||||
|
String title = messages.site(siteId, siteDefault, "contact.page.title", "Contact");
|
||||||
|
StarterPage page = new StarterPage(INSTALLED_PAGE_SLUG, "/" + INSTALLED_PAGE_SLUG,
|
||||||
|
Map.of(siteDefault.getLanguage(), title), installedPageHtml(title), installedPageLogic(), false);
|
||||||
|
InstallResult result;
|
||||||
|
try {
|
||||||
|
result = pages.install(siteId, page);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
// IllegalStateException: a path another page serves, an unknown site, a failed write (no stray draft
|
||||||
|
// is left behind). Anything else is equally "not installed" to the operator.
|
||||||
|
log.warn("contact page install failed for site {}: {}", siteId, e.toString());
|
||||||
|
return RouteResponse.text(500, console("contact.page.failed", "Could not install the contact page."));
|
||||||
|
}
|
||||||
|
return RouteResponse.text(200, describe(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The operator's words for each install outcome; an outcome added in a later SPI MINOR gets a neutral line. */
|
||||||
|
private String describe(InstallResult result) {
|
||||||
|
String path = result.path();
|
||||||
|
return switch (result.outcome()) {
|
||||||
|
case PUBLISHED -> console("contact.page.installed", "Contact page installed at") + " " + path;
|
||||||
|
case PENDING_REVIEW -> console("contact.page.pending",
|
||||||
|
"The contact page was created and is waiting in the review queue:") + " " + path;
|
||||||
|
case DRAFT_BLOCKED -> {
|
||||||
|
StringBuilder text = new StringBuilder(console("contact.page.blocked",
|
||||||
|
"The contact page was created as a draft because the quality checks blocked publishing; "
|
||||||
|
+ "fix it in the page editor:")).append(' ').append(path);
|
||||||
|
for (Finding finding : result.blocking()) {
|
||||||
|
text.append("\n- ").append(finding.code()).append(": ").append(finding.message());
|
||||||
|
}
|
||||||
|
yield text.toString();
|
||||||
|
}
|
||||||
|
case ALREADY_EXISTS -> console("contact.page.exists", "A contact page already exists at") + " " + path;
|
||||||
|
default -> console("contact.page.other", "The contact page install finished:") + " "
|
||||||
|
+ result.outcome() + " " + path;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The operator-only SMTP self-test ({@code POST}, CSRF-checked by the kernel) — fails closed unless the caller
|
||||||
|
* holds {@code contact|settings}.
|
||||||
|
*/
|
||||||
|
private RouteResponse handleSmtpTest(RouteRequest req) {
|
||||||
|
if (!access.may(SETTINGS_PERMISSION)) {
|
||||||
|
return RouteResponse.notFound();
|
||||||
|
}
|
||||||
|
// The override recipient comes from the form body only — never the query string.
|
||||||
|
MailSendResult result = mailer.sendTest(req.site().id(), req.site().displayName(), formField(req, "to"));
|
||||||
|
String text = switch (result.status()) {
|
||||||
|
case SENT -> console("contact.test.ok", "Test message sent.");
|
||||||
|
case NOT_CONFIGURED -> console("contact.test.notConfigured", "No SMTP relay is configured for this site.");
|
||||||
|
case PROVIDER_MISSING -> console("contact.test.providerMissing",
|
||||||
|
"Mail libraries are not available on the server.");
|
||||||
|
case FAILED -> console("contact.test.failed", "Test message failed:") + " " + result.detail();
|
||||||
|
};
|
||||||
|
return RouteResponse.text(result.wasSent() ? 200 : 502, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The page the form lives on: the same-origin {@code return} field, else the {@code Referer} path, else "/". */
|
||||||
|
private static String resolveReturn(RouteRequest req) {
|
||||||
|
String fromField = safeLocalPath(formField(req, "return"));
|
||||||
|
if (fromField != null) {
|
||||||
|
return fromField;
|
||||||
|
}
|
||||||
|
String fromReferer = safeLocalPath(refererPath(req.headers().get("referer")));
|
||||||
|
return fromReferer != null ? fromReferer : "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The path (with query stripped) of a Referer, or {@code null} when absent. */
|
||||||
|
private static String refererPath(String referer) {
|
||||||
|
if (referer == null || referer.isBlank()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int scheme = referer.indexOf("://");
|
||||||
|
String path = referer;
|
||||||
|
if (scheme >= 0) {
|
||||||
|
int slash = referer.indexOf('/', scheme + 3);
|
||||||
|
path = slash < 0 ? "/" : referer.substring(slash);
|
||||||
|
}
|
||||||
|
int q = path.indexOf('?');
|
||||||
|
return q < 0 ? path : path.substring(0, q);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@code 303 See Other} back to {@code path} carrying only the outcome flag (never a submitted value); the
|
||||||
|
* browser follows it with a GET and the widget on that page re-renders from the flag (post/redirect/get, so a
|
||||||
|
* reload never resubmits).
|
||||||
|
*/
|
||||||
|
private static RouteResponse redirect(String path, String outcome) {
|
||||||
|
String location = path + (path.contains("?") ? "&" : "?") + "contact=" + outcome;
|
||||||
|
return new RouteResponse(303, Map.of("Location", location), new byte[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reduces a candidate to a safe same-origin path (a single leading "/", no scheme/backslash/space/control). */
|
||||||
|
private static String safeLocalPath(String p) {
|
||||||
|
if (p == null || p.isBlank() || !p.startsWith("/") || p.startsWith("//") || p.contains("://")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < p.length(); i++) {
|
||||||
|
char c = p.charAt(i);
|
||||||
|
if (c < 0x20 || c == '\\' || c == ' ') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The body of the installed page: chrome seams ({@code head}/{@code #site-header}/{@code #site-footer}, filled
|
||||||
|
* from the master by {@link #installedPageLogic()}) and a {@code #content} carrying the contact-form widget
|
||||||
|
* anchor. The anchor bears both an {@code id} and {@code data-widget="contact/form"} on one element (the
|
||||||
|
* widget-binding contract), so the host renders the form in place.
|
||||||
|
*/
|
||||||
|
private static String installedPageHtml(String title) {
|
||||||
|
String t = Html.escape(title);
|
||||||
|
return "<!DOCTYPE html>\n<html>\n<head><title>" + t + "</title></head>\n<body>\n"
|
||||||
|
+ "<header id=\"site-header\"></header>\n<main id=\"content\">\n"
|
||||||
|
+ " <h1 id=\"contact-page-title\">" + t + "</h1>\n"
|
||||||
|
+ " <div id=\"contact-form\" data-widget=\"contact/form\"></div>\n"
|
||||||
|
+ "</main>\n<footer id=\"site-footer\"></footer>\n</body>\n</html>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The decoupled logic of the installed page: pulls the master chrome via {@code ${master}} (never a literal). */
|
||||||
|
private static String installedPageLogic() {
|
||||||
|
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<thlogic>\n"
|
||||||
|
+ " <attr sel=\"head\" th:replace=\"~{${master} :: head}\"/>\n"
|
||||||
|
+ " <attr sel=\"#site-header\" th:replace=\"~{${master} :: #site-header}\"/>\n"
|
||||||
|
+ " <attr sel=\"#site-footer\" th:replace=\"~{${master} :: #site-footer}\"/>\n"
|
||||||
|
+ " <attr sel=\"#contact-page-title\" th:text=\"${pageTitle}\"/>\n"
|
||||||
|
+ "</thlogic>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isEmail(String value) {
|
||||||
|
int at = value.indexOf('@');
|
||||||
|
return at > 0 && at < value.length() - 1 && value.indexOf('.', at) > at;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A field of the form BODY (never the query string), stripped; "" when absent. */
|
||||||
|
private static String formField(RouteRequest req, String name) {
|
||||||
|
List<String> values = req.form().get(name);
|
||||||
|
return (values == null || values.isEmpty()) ? "" : values.get(0).strip();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String console(String code, String fallback) {
|
||||||
|
return messages.console(code, fallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Capabilities capabilities() {
|
||||||
|
return Capabilities.of("endpoint.tenant", "contact.form");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import mx.quest.runway.spi.service.Messages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the contact-form markup the {@link ContactWidget} renders inline on a page. The form <b>POSTs</b> an
|
||||||
|
* {@code application/x-www-form-urlencoded} body to {@value ContactEndpoint#SUBMIT_PATH}, a route the
|
||||||
|
* {@link ContactEndpoint} declares <b>anonymous</b> ({@code Route.anonymousPost}): the kernel exempts exactly that
|
||||||
|
* method and path from CSRF, because a public form on a cacheable page cannot carry a per-session token. So the
|
||||||
|
* visitor's name, email and message travel in the request body — never in a URL, browser history, a
|
||||||
|
* {@code Referer} or a proxy log. A hidden honeypot field ({@code website}) catches naive bots; {@code captchaHtml}
|
||||||
|
* (when non-empty) adds the site's CAPTCHA challenge from the platform's {@code CaptchaService} — trusted,
|
||||||
|
* pre-rendered markup. Every label is looked up with {@link Messages#site} for the visitor's locale; every value
|
||||||
|
* that came from a request or a setting is HTML-escaped.
|
||||||
|
*/
|
||||||
|
final class ContactForm {
|
||||||
|
|
||||||
|
private ContactForm() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the contact form. It submits to the anonymous {@code POST} handler, which stores + emails the message
|
||||||
|
* and answers {@code 303} back to {@code returnPath} with a {@code ?contact=sent|invalid|captcha|queued} flag —
|
||||||
|
* so the visible page stays a normal, editable site page (the widget re-renders the outcome from that flag).
|
||||||
|
*/
|
||||||
|
static String render(Messages messages, String siteId, Locale locale, String error, String captchaHtml,
|
||||||
|
String returnPath) {
|
||||||
|
String nameLbl = messages.site(siteId, locale, "contact.form.name", "Name");
|
||||||
|
String emailLbl = messages.site(siteId, locale, "contact.form.email", "Email");
|
||||||
|
String messageLbl = messages.site(siteId, locale, "contact.form.message", "Message");
|
||||||
|
String submitLbl = messages.site(siteId, locale, "contact.form.submit", "Send");
|
||||||
|
|
||||||
|
StringBuilder b = new StringBuilder(768);
|
||||||
|
b.append("<link rel=\"stylesheet\" href=\"/__plugin/contact/static/contact.css\">")
|
||||||
|
.append("<form class=\"rw-contact\" method=\"post\" action=\"").append(ContactEndpoint.SUBMIT_PATH)
|
||||||
|
.append("\" enctype=\"application/x-www-form-urlencoded\">")
|
||||||
|
// Where the submit handler redirects back to (this page); validated server-side as a local path.
|
||||||
|
.append("<input type=\"hidden\" name=\"return\" value=\"").append(Html.escape(returnPath)).append("\">");
|
||||||
|
if (error != null && !error.isBlank()) {
|
||||||
|
b.append("<p class=\"rw-contact-error\">").append(Html.escape(error)).append("</p>");
|
||||||
|
}
|
||||||
|
b.append(field("text", "name", nameLbl))
|
||||||
|
.append(field("email", "email", emailLbl))
|
||||||
|
.append("<label class=\"rw-contact-label\">").append(Html.escape(messageLbl))
|
||||||
|
.append("<textarea class=\"rw-contact-input\" name=\"message\" rows=\"5\" required></textarea></label>")
|
||||||
|
// Honeypot: hidden from humans, left blank; a bot that fills it is dropped as spam.
|
||||||
|
.append("<div class=\"rw-contact-hp\" aria-hidden=\"true\">")
|
||||||
|
.append("<label>Website<input type=\"text\" name=\"website\" tabindex=\"-1\" autocomplete=\"off\"></label></div>");
|
||||||
|
// Real CAPTCHA challenge (only when the site configured one — trusted markup from the platform seam).
|
||||||
|
if (captchaHtml != null && !captchaHtml.isBlank()) {
|
||||||
|
b.append("<div class=\"rw-contact-captcha\">").append(captchaHtml).append("</div>");
|
||||||
|
}
|
||||||
|
b.append("<button class=\"rw-contact-submit\" type=\"submit\">").append(Html.escape(submitLbl))
|
||||||
|
.append("</button></form>");
|
||||||
|
return b.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String field(String type, String fieldName, String label) {
|
||||||
|
return "<label class=\"rw-contact-label\">" + Html.escape(label)
|
||||||
|
+ "<input class=\"rw-contact-input\" type=\"" + type + "\" name=\"" + fieldName + "\" required></label>";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
import jakarta.mail.Authenticator;
|
||||||
|
import jakarta.mail.Message;
|
||||||
|
import jakarta.mail.MessagingException;
|
||||||
|
import jakarta.mail.PasswordAuthentication;
|
||||||
|
import jakarta.mail.Session;
|
||||||
|
import jakarta.mail.internet.InternetAddress;
|
||||||
|
import jakarta.mail.internet.MimeMessage;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Properties;
|
||||||
|
import mx.quest.runway.spi.service.PluginSettings;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds and sends the notification email for a contact submission over the <b>site's own</b> SMTP relay, then
|
||||||
|
* reports the outcome as a {@link MailSendResult}. It NEVER stores anything and NEVER throws for an operational
|
||||||
|
* failure — the {@link ContactEndpoint} always stores the submission first, so a relay problem degrades to a
|
||||||
|
* reported (not lost) message.
|
||||||
|
*
|
||||||
|
* <p><b>Isolation.</b> The relay coordinates come only from {@link SmtpSettings#from} over this site's settings
|
||||||
|
* ({@link PluginSettings}, bound by the kernel to this plugin), so a site sends exclusively through the relay it
|
||||||
|
* configured (a tenant can never send through another's). The password is the site's {@code smtpPassword} secret,
|
||||||
|
* read in clear with {@link PluginSettings#secret} at send time and never kept.
|
||||||
|
*
|
||||||
|
* <p><b>Degrade-don't-crash.</b> Three non-fatal outcomes are reported rather than thrown:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link MailSendResult#notConfigured()} — no host/recipient set (nothing to send to);</li>
|
||||||
|
* <li>{@link MailSendResult#providerMissing()} — the Jakarta Mail classes are not on the classloader (a
|
||||||
|
* {@link NoClassDefFoundError}/{@link LinkageError} at the seam). The kernel now bundles Jakarta Mail as a
|
||||||
|
* core capability, so this is effectively unreachable; the guard is kept purely so a broken deployment can
|
||||||
|
* never crash the request;</li>
|
||||||
|
* <li>{@link MailSendResult#failed(String)} — a configured relay rejected the message or was unreachable.</li>
|
||||||
|
* </ul>
|
||||||
|
* The build/send seam is {@link MailTransport}, injected so tests exercise the full MIME build against a mock
|
||||||
|
* with no socket opened.
|
||||||
|
*/
|
||||||
|
public class ContactMailer {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ContactMailer.class);
|
||||||
|
private static final int MAX_SUBJECT_SOURCE = 120;
|
||||||
|
/** The declared {@code type: secret} key of the SMTP password (plugin.yml). */
|
||||||
|
static final String PASSWORD_KEY = "smtpPassword";
|
||||||
|
|
||||||
|
private final PluginSettings settings;
|
||||||
|
private final MailTransport transport;
|
||||||
|
|
||||||
|
public ContactMailer(PluginSettings settings, MailTransport transport) {
|
||||||
|
this.settings = settings;
|
||||||
|
this.transport = transport;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This site's current SMTP settings (the secret password in clear). Used by the send and the readiness badge. */
|
||||||
|
public SmtpSettings settingsFor(String siteId) {
|
||||||
|
return SmtpSettings.from(settings.site(siteId), settings.secret(siteId, PASSWORD_KEY));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emails a stored submission's contents to the site's recipient. Never throws for an operational failure —
|
||||||
|
* the outcome is always a {@link MailSendResult}.
|
||||||
|
*
|
||||||
|
* @param siteId the bound site (its own relay is used)
|
||||||
|
* @param displayName the site's display name (for the subject / body context)
|
||||||
|
* @param name the submitter's name
|
||||||
|
* @param email the submitter's email (used as Reply-To so a reply reaches the visitor)
|
||||||
|
* @param message the message body
|
||||||
|
*/
|
||||||
|
public MailSendResult send(String siteId, String displayName, String name, String email, String message) {
|
||||||
|
SmtpSettings smtp = settingsFor(siteId);
|
||||||
|
if (!smtp.isConfigured()) {
|
||||||
|
return MailSendResult.notConfigured();
|
||||||
|
}
|
||||||
|
String subject = "[" + displayName + "] " + subjectExcerpt(name, message);
|
||||||
|
String body = "New contact submission on " + displayName + "\n\n"
|
||||||
|
+ "Name: " + orDash(name) + "\n"
|
||||||
|
+ "Email: " + orDash(email) + "\n\n"
|
||||||
|
+ message;
|
||||||
|
return dispatch(smtp, smtp.effectiveFrom(), smtp.to(), subject, body, blankToNull(email));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a diagnostic test message to {@code testTo} over the site's relay, to verify the SMTP configuration
|
||||||
|
* from the console. Same degrade contract as {@link #send} — the outcome is reported, never thrown.
|
||||||
|
*/
|
||||||
|
public MailSendResult sendTest(String siteId, String displayName, String testTo) {
|
||||||
|
SmtpSettings smtp = settingsFor(siteId);
|
||||||
|
// A test still needs a usable relay (host + a configured recipient) even though we override the To.
|
||||||
|
if (!smtp.isConfigured()) {
|
||||||
|
return MailSendResult.notConfigured();
|
||||||
|
}
|
||||||
|
String to = (testTo == null || testTo.isBlank()) ? smtp.to() : testTo.strip();
|
||||||
|
String body = "This is a test message from the Runway contact plugin for site '" + displayName + "'.\n"
|
||||||
|
+ "If you received it, the site's SMTP relay is configured correctly.";
|
||||||
|
return dispatch(smtp, smtp.effectiveFrom(), to, "[" + displayName + "] SMTP test", body, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MailSendResult dispatch(SmtpSettings smtp, String from, String to, String subject, String body,
|
||||||
|
String replyTo) {
|
||||||
|
try {
|
||||||
|
MimeMessage msg = build(smtp, from, to, subject, body, replyTo);
|
||||||
|
transport.send(msg);
|
||||||
|
return MailSendResult.sent();
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
log.warn("contact mail send failed for relay {}: {}", smtp, e.toString());
|
||||||
|
return MailSendResult.failed(rootMessage(e));
|
||||||
|
} catch (LinkageError e) {
|
||||||
|
// Jakarta Mail not on the classpath. The kernel bundles it as a core capability, so this is
|
||||||
|
// effectively unreachable; guard it anyway so a broken deployment never crashes the request.
|
||||||
|
log.warn("contact mail send skipped: Jakarta Mail unavailable on the classloader: {}", e.toString());
|
||||||
|
return MailSendResult.providerMissing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Builds the MIME message from the site's relay settings. Package-visible for direct MIME-shape testing. */
|
||||||
|
MimeMessage build(SmtpSettings smtp, String from, String to, String subject, String body, String replyTo)
|
||||||
|
throws MessagingException {
|
||||||
|
Session session = session(smtp);
|
||||||
|
MimeMessage msg = new MimeMessage(session);
|
||||||
|
msg.setFrom(new InternetAddress(from));
|
||||||
|
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
|
||||||
|
if (replyTo != null) {
|
||||||
|
try {
|
||||||
|
msg.setReplyTo(InternetAddress.parse(replyTo, false));
|
||||||
|
} catch (MessagingException badReplyTo) {
|
||||||
|
// A visitor-supplied email that isn't a valid address must not block the notification.
|
||||||
|
log.debug("ignoring invalid Reply-To '{}': {}", replyTo, badReplyTo.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg.setSubject(subject, StandardCharsets.UTF_8.name());
|
||||||
|
msg.setText(body, StandardCharsets.UTF_8.name());
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Jakarta Mail {@link Session} from the relay settings (host/port, TLS mode + auth).
|
||||||
|
*
|
||||||
|
* <p><b>The protocol is always {@code smtp}, even for implicit TLS.</b> We send with the static
|
||||||
|
* {@link jakarta.mail.Transport#send(jakarta.mail.Message)}, which resolves an {@code rfc822} recipient to
|
||||||
|
* the {@code smtp} transport via Jakarta Mail's address map — that lookup <b>ignores</b>
|
||||||
|
* {@code mail.transport.protocol}. Selecting {@code smtps} therefore leaves {@code mail.smtp.host} unset, so
|
||||||
|
* the send silently dials {@code localhost:25} and fails with "Connection refused". Implicit TLS (SMTPS, e.g.
|
||||||
|
* port 465) must instead ride {@code mail.smtp.ssl.enable}; explicit TLS (e.g. 587) rides
|
||||||
|
* {@code mail.smtp.starttls.enable}. Package-visible so a test can assert the resolved properties.
|
||||||
|
*/
|
||||||
|
static Session session(SmtpSettings smtp) {
|
||||||
|
boolean ssl = smtp.ssl();
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.put("mail.transport.protocol", "smtp");
|
||||||
|
props.put("mail.smtp.host", smtp.host());
|
||||||
|
props.put("mail.smtp.port", String.valueOf(smtp.port()));
|
||||||
|
props.put("mail.smtp.auth", String.valueOf(smtp.auth()));
|
||||||
|
if (ssl) {
|
||||||
|
props.put("mail.smtp.ssl.enable", "true"); // implicit TLS on connect (SMTPS, e.g. 465)
|
||||||
|
} else {
|
||||||
|
props.put("mail.smtp.starttls.enable", String.valueOf(smtp.starttls())); // opportunistic STARTTLS (e.g. 587)
|
||||||
|
}
|
||||||
|
if (smtp.auth()) {
|
||||||
|
Authenticator auth = new Authenticator() {
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(smtp.username(), smtp.password());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return Session.getInstance(props, auth);
|
||||||
|
}
|
||||||
|
return Session.getInstance(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String subjectExcerpt(String name, String message) {
|
||||||
|
String source = (name != null && !name.isBlank()) ? name : message;
|
||||||
|
String s = source == null ? "message" : source.strip().replaceAll("\\s+", " ");
|
||||||
|
if (s.isEmpty()) {
|
||||||
|
s = "message";
|
||||||
|
}
|
||||||
|
return s.length() <= MAX_SUBJECT_SOURCE ? s : s.substring(0, MAX_SUBJECT_SOURCE).stripTrailing() + "…";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String rootMessage(Throwable t) {
|
||||||
|
Throwable cur = t;
|
||||||
|
while (cur.getCause() != null && cur.getCause() != cur) {
|
||||||
|
cur = cur.getCause();
|
||||||
|
}
|
||||||
|
String m = cur.getMessage();
|
||||||
|
return (m == null || m.isBlank()) ? cur.getClass().getSimpleName() : m;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String orDash(String value) {
|
||||||
|
return (value == null || value.isBlank()) ? "—" : value.strip();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String blankToNull(String value) {
|
||||||
|
return (value == null || value.isBlank()) ? null : value.strip();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UncheckedIOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
import mx.quest.runway.spi.service.PluginSiteFiles;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persists contact-form submissions as tenant-owned data in this plugin's per-site folder, through the kernel's
|
||||||
|
* {@link PluginSiteFiles}: {@value #FILE} under {@code sites/<id>/plugins/contact/}; an existing file is read and
|
||||||
|
* appended in place. The folder is <b>outside</b> the served {@code static/} tree (never publicly downloadable) and
|
||||||
|
* inside the site folder, so full backups carry it. The file holds what visitors typed, so {@code plugin.yml}
|
||||||
|
* declares it <b>personal data</b> ({@code siteData.personal}) and a transfer copy of the site leaves it out.
|
||||||
|
*
|
||||||
|
* <p>One tab-separated line per submission ({@code epochMillis \t name \t email \t message}); fields are
|
||||||
|
* sanitized to strip tabs/newlines so the format stays unambiguous, and each field is capped at
|
||||||
|
* {@value #MAX_FIELD} characters. The file is bounded to the most recent {@link #MAX_SUBMISSIONS}, so it stays
|
||||||
|
* a few MiB — well under the kernel's per-write cap.
|
||||||
|
*
|
||||||
|
* <p><b>Concurrency.</b> Each kernel write is atomic, but appending is a read-modify-write, which the service
|
||||||
|
* leaves to the plugin: it is serialized here per site (contact volume is low). <b>Failure.</b> A read failure
|
||||||
|
* during {@link #add} aborts the append rather than rewriting the file from nothing (which would lose every
|
||||||
|
* stored submission); the console reads ({@link #count}, {@link #recent}) degrade to empty with a warning so an
|
||||||
|
* unreadable file never takes the settings screen down.
|
||||||
|
*/
|
||||||
|
public class ContactStore {
|
||||||
|
|
||||||
|
static final int MAX_SUBMISSIONS = 500;
|
||||||
|
static final String FILE = "submissions.tsv";
|
||||||
|
static final int MAX_FIELD = 4000;
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ContactStore.class);
|
||||||
|
|
||||||
|
private final PluginSiteFiles files;
|
||||||
|
private final ConcurrentMap<String, Object> locks = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public ContactStore(PluginSiteFiles files) {
|
||||||
|
this.files = files;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends a submission (stamped {@code epochMillis}), keeping only the most recent {@link #MAX_SUBMISSIONS}.
|
||||||
|
*
|
||||||
|
* @throws UncheckedIOException when the file cannot be read or written (nothing is lost: an unreadable file is
|
||||||
|
* left untouched)
|
||||||
|
*/
|
||||||
|
public void add(String siteId, String name, String email, String message, long epochMillis) {
|
||||||
|
String line = epochMillis + "\t" + sanitize(name) + "\t" + sanitize(email) + "\t" + sanitize(message);
|
||||||
|
synchronized (locks.computeIfAbsent(siteId, k -> new Object())) {
|
||||||
|
try {
|
||||||
|
List<String> lines = new ArrayList<>(rawLines(siteId));
|
||||||
|
lines.add(line);
|
||||||
|
if (lines.size() > MAX_SUBMISSIONS) {
|
||||||
|
lines = lines.subList(lines.size() - MAX_SUBMISSIONS, lines.size());
|
||||||
|
}
|
||||||
|
files.writeText(siteId, FILE, String.join("\n", lines) + "\n");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new UncheckedIOException("storing a contact submission for site " + siteId, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The most recent submissions, newest first, at most {@code limit}; empty when the file cannot be read. */
|
||||||
|
public List<ContactSubmission> recent(String siteId, int limit) {
|
||||||
|
List<String> lines = new ArrayList<>(readableLines(siteId));
|
||||||
|
Collections.reverse(lines);
|
||||||
|
List<ContactSubmission> out = new ArrayList<>();
|
||||||
|
for (String line : lines) {
|
||||||
|
if (out.size() >= limit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ContactSubmission s = parse(line);
|
||||||
|
if (s != null) {
|
||||||
|
out.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return List.copyOf(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The total number of stored submissions; 0 when the file cannot be read. */
|
||||||
|
public int count(String siteId) {
|
||||||
|
return readableLines(siteId).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> readableLines(String siteId) {
|
||||||
|
try {
|
||||||
|
return rawLines(siteId);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.warn("contact submissions of site {} could not be read: {}", siteId, e.toString());
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> rawLines(String siteId) throws IOException {
|
||||||
|
return files.readText(siteId, FILE)
|
||||||
|
.map(text -> List.of(text.split("\n")).stream().filter(l -> !l.isBlank()).toList())
|
||||||
|
.orElse(List.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContactSubmission parse(String line) {
|
||||||
|
String[] p = line.split("\t", 4);
|
||||||
|
if (p.length < 4) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return new ContactSubmission(Long.parseLong(p[0].trim()), p[1], p[2], p[3]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String sanitize(String value) {
|
||||||
|
if (value == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String s = value.replace('\t', ' ').replace('\r', ' ').replace('\n', ' ').strip();
|
||||||
|
return s.length() > MAX_FIELD ? s.substring(0, MAX_FIELD) : s;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One stored contact-form submission. Immutable; fields are already sanitized (no tabs/newlines) by
|
||||||
|
* {@link ContactStore} so the on-disk TSV format stays unambiguous.
|
||||||
|
*
|
||||||
|
* @param epochMillis when it was received
|
||||||
|
* @param name the submitter's name
|
||||||
|
* @param email the submitter's email
|
||||||
|
* @param message the message (newlines collapsed to spaces on storage)
|
||||||
|
*/
|
||||||
|
public record ContactSubmission(long epochMillis, String name, String email, String message) {
|
||||||
|
|
||||||
|
private static final DateTimeFormatter WHEN =
|
||||||
|
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm").withZone(ZoneId.systemDefault());
|
||||||
|
|
||||||
|
/** A {@code yyyy-MM-dd HH:mm} timestamp for display. */
|
||||||
|
public String time() {
|
||||||
|
return WHEN.format(Instant.ofEpochMilli(epochMillis));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A short excerpt of the message for a listing cell. */
|
||||||
|
public String excerpt() {
|
||||||
|
String m = message == null ? "" : message.strip();
|
||||||
|
return m.length() <= 80 ? m : m.substring(0, 80).stripTrailing() + "…";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import mx.quest.runway.spi.CaptchaService;
|
||||||
|
import mx.quest.runway.spi.ContentWidget;
|
||||||
|
import mx.quest.runway.spi.model.Capabilities;
|
||||||
|
import mx.quest.runway.spi.model.RenderFragment;
|
||||||
|
import mx.quest.runway.spi.model.SettingsView;
|
||||||
|
import mx.quest.runway.spi.model.WidgetView;
|
||||||
|
import mx.quest.runway.spi.service.Messages;
|
||||||
|
import mx.quest.runway.spi.service.PluginSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@code contact} content widget: a site manager drops
|
||||||
|
* {@code <div id="contact" data-widget="contact/form"></div>} on a page and the host renders the contact form
|
||||||
|
* inline (it POSTs to the {@link ContactEndpoint}). Honors the per-site {@code enabled} setting (disabled ⇒
|
||||||
|
* {@link RenderFragment#empty()}). The markup is the shared {@link ContactForm}; public text comes from
|
||||||
|
* {@link Messages#site} in the visitor's locale.
|
||||||
|
*/
|
||||||
|
public class ContactWidget implements ContentWidget {
|
||||||
|
|
||||||
|
private final PluginSettings settings;
|
||||||
|
private final Messages messages;
|
||||||
|
private final CaptchaService captcha;
|
||||||
|
|
||||||
|
public ContactWidget(PluginSettings settings, Messages messages, CaptchaService captcha) {
|
||||||
|
this.settings = settings;
|
||||||
|
this.messages = messages;
|
||||||
|
this.captcha = captcha;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String key() {
|
||||||
|
return "contact";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RenderFragment render(WidgetView view) {
|
||||||
|
String siteId = view.site().id();
|
||||||
|
SettingsView config = settings.site(siteId);
|
||||||
|
if (!config.bool("enabled", true)) {
|
||||||
|
return RenderFragment.empty();
|
||||||
|
}
|
||||||
|
Locale locale = view.locale();
|
||||||
|
// The submit handler redirects back here with ?contact=sent|invalid|captcha; the widget re-renders the
|
||||||
|
// outcome from that flag. A pure read of the request — the store/send side effects live in the endpoint.
|
||||||
|
String outcome = view.query().get("contact");
|
||||||
|
if ("sent".equals(outcome) || "queued".equals(outcome)) {
|
||||||
|
String success = config.string("successMessage",
|
||||||
|
messages.site(siteId, locale, "contact.success", "Thanks — your message has been sent."));
|
||||||
|
String html = "<p class=\"rw-contact-success\">" + Html.escape(success.strip()) + "</p>";
|
||||||
|
if ("queued".equals(outcome)) {
|
||||||
|
// Stored, but the site's relay failed: say so quietly, so the visitor does not send it again.
|
||||||
|
html += "<p class=\"rw-contact-note\">" + Html.escape(messages.site(siteId, locale,
|
||||||
|
"contact.note.stored", "Your message was received; email delivery is delayed.")) + "</p>";
|
||||||
|
}
|
||||||
|
return RenderFragment.of(html);
|
||||||
|
}
|
||||||
|
String error = null;
|
||||||
|
if ("invalid".equals(outcome)) {
|
||||||
|
error = messages.site(siteId, locale, "contact.error.invalid", "Please enter your email and a message.");
|
||||||
|
} else if ("captcha".equals(outcome)) {
|
||||||
|
error = messages.site(siteId, locale, "contact.error.captcha",
|
||||||
|
"Please complete the challenge and try again.");
|
||||||
|
}
|
||||||
|
String captchaHtml = captcha.widgetForSite(siteId).html();
|
||||||
|
// Land the visitor back on THIS page after submit: the request path as served (locale prefix and all),
|
||||||
|
// from the view — NEVER built from the slug, which for a content source's page (a blog entry rendering
|
||||||
|
// this widget in the master chrome) is a composite identity like "blog:my-post", not a path. The slug
|
||||||
|
// form remains only as the legacy fallback for a host that predates WidgetView.path.
|
||||||
|
String returnPath = view.path().isEmpty() ? "/" + view.page().slug() : view.path();
|
||||||
|
return RenderFragment.of(ContactForm.render(messages, siteId, locale, error, captchaHtml, returnPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Capabilities capabilities() {
|
||||||
|
return Capabilities.of("widget.contact");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimal HTML escaping for the values the contact plugin interpolates into its form and its stored/echoed
|
||||||
|
* submissions. The plugin owns escaping of its own output so a crafted name/email/message can never inject
|
||||||
|
* markup into the form page, the thank-you page, or the admin listing.
|
||||||
|
*/
|
||||||
|
final class Html {
|
||||||
|
|
||||||
|
private Html() {
|
||||||
|
}
|
||||||
|
|
||||||
|
static String escape(String value) {
|
||||||
|
if (value == null || value.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return value.replace("&", "&").replace("<", "<").replace(">", ">")
|
||||||
|
.replace("\"", """).replace("'", "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
import jakarta.mail.MessagingException;
|
||||||
|
import jakarta.mail.Transport;
|
||||||
|
import jakarta.mail.internet.MimeMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The production {@link MailTransport}: hands the message to {@code jakarta.mail.Transport}, which resolves the
|
||||||
|
* {@code smtp}/{@code smtps} provider from the message's {@link jakarta.mail.Session} (the Angus reference
|
||||||
|
* implementation, discovered at runtime via {@code META-INF/services/jakarta.mail.Provider} — now supplied by
|
||||||
|
* the KERNEL, which bundles the Jakarta Mail stack as a core capability and is reached parent-first from the
|
||||||
|
* plugin classloader).
|
||||||
|
*
|
||||||
|
* <p>Authentication is carried on the {@code Session} the {@link ContactMailer} built (with {@code mail.smtp.auth}
|
||||||
|
* and a static {@link jakarta.mail.Authenticator} when the relay requires it), so {@link Transport#send(jakarta.mail.Message)}
|
||||||
|
* with the message alone is sufficient — no separate connect/credentials call. Stateless and thread-safe.
|
||||||
|
*/
|
||||||
|
public class JakartaMailTransport implements MailTransport {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void send(MimeMessage message) throws MessagingException {
|
||||||
|
Transport.send(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The reported outcome of trying to email a contact submission. A submission is <b>always</b> stored first
|
||||||
|
* (belt-and-suspenders), so this result is <em>advisory</em> — it never means the message was lost, only whether
|
||||||
|
* the email went out. The {@link ContactEndpoint} uses it to decide what the visitor sees; the plugin logs a
|
||||||
|
* failure but keeps the stored copy.
|
||||||
|
*/
|
||||||
|
public record MailSendResult(Status status, String detail) {
|
||||||
|
|
||||||
|
/** Which way the send went. */
|
||||||
|
public enum Status {
|
||||||
|
/** The message was handed to the site's SMTP relay successfully. */
|
||||||
|
SENT,
|
||||||
|
/** No relay is configured for this site (blank host or recipient) — nothing was sent, only stored. */
|
||||||
|
NOT_CONFIGURED,
|
||||||
|
/** Jakarta Mail is not on the classpath (a broken deployment; the kernel bundles it) — stored only. */
|
||||||
|
PROVIDER_MISSING,
|
||||||
|
/** A relay is configured but the send failed (rejected / unreachable / auth) — {@link #detail} says why. */
|
||||||
|
FAILED
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The email was sent. */
|
||||||
|
public static MailSendResult sent() {
|
||||||
|
return new MailSendResult(Status.SENT, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** No SMTP relay configured for this site (stored only). */
|
||||||
|
public static MailSendResult notConfigured() {
|
||||||
|
return new MailSendResult(Status.NOT_CONFIGURED, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Jakarta Mail is unavailable on the classloader (a broken deployment; stored only). */
|
||||||
|
public static MailSendResult providerMissing() {
|
||||||
|
return new MailSendResult(Status.PROVIDER_MISSING, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The send failed for the given reason (stored only). */
|
||||||
|
public static MailSendResult failed(String detail) {
|
||||||
|
return new MailSendResult(Status.FAILED, detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether the email actually went out (as opposed to being stored only). */
|
||||||
|
public boolean wasSent() {
|
||||||
|
return status == Status.SENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
import jakarta.mail.MessagingException;
|
||||||
|
import jakarta.mail.internet.MimeMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The send seam: the single point where a built {@link MimeMessage} actually leaves the JVM over SMTP. Factored
|
||||||
|
* out as an interface so the {@link ContactMailer}'s build-and-send logic can be unit-tested against a mock
|
||||||
|
* transport with <b>no socket opened</b> (the production {@link JakartaMailTransport} delegates to
|
||||||
|
* {@code jakarta.mail.Transport}).
|
||||||
|
*
|
||||||
|
* <p>Implementations MUST NOT swallow a failure — a broken relay has to be reported so the {@link ContactMailer}
|
||||||
|
* can surface it (the stored copy of the submission still lands regardless). A {@link MessagingException} means
|
||||||
|
* the send failed; returning normally means it was handed to the relay.
|
||||||
|
*/
|
||||||
|
public interface MailTransport {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends an already-built, already-addressed message.
|
||||||
|
*
|
||||||
|
* @param message the MIME message to transmit (From/To/Subject/body all set by the caller)
|
||||||
|
* @throws MessagingException if the relay rejected the message or could not be reached
|
||||||
|
*/
|
||||||
|
void send(MimeMessage message) throws MessagingException;
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import mx.quest.runway.spi.model.SettingsView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The per-site SMTP relay configuration, materialized from a site's {@code contact} plugin settings (the
|
||||||
|
* {@code smtp*} + {@code fromAddress}/{@code toAddress} {@code siteSettings}). Immutable; a pure value.
|
||||||
|
*
|
||||||
|
* <p><b>Isolation.</b> Every field comes from <em>this</em> site's own {@code sites/<id>/plugins/contact.yml};
|
||||||
|
* a site can therefore only ever send through the relay <em>it</em> configured — never another tenant's.
|
||||||
|
*
|
||||||
|
* <p><b>Secret handling.</b> The password is a {@code secret} setting, stored {@code ENC(...)}-encrypted by the
|
||||||
|
* platform. It never appears in the {@link SettingsView} (the kernel leaves secret keys out of it); the caller
|
||||||
|
* hands it over separately, already in clear, from {@code PluginSettings.secret(siteId, "smtpPassword")}. The
|
||||||
|
* plaintext lives only in this transient value and is handed straight to Jakarta Mail, never logged (see
|
||||||
|
* {@link #toString()}) and never stored by this plugin.
|
||||||
|
*
|
||||||
|
* @param host the SMTP server host; blank ⇒ {@link #isConfigured()} is false (mail is skipped)
|
||||||
|
* @param port the SMTP server port (1..65535; default 25)
|
||||||
|
* @param auth whether to authenticate (SMTP AUTH) with {@code username}/{@code password}
|
||||||
|
* @param username the SMTP username (used only when {@code auth})
|
||||||
|
* @param password the SMTP password in PLAINTEXT (already decrypted; used only when {@code auth})
|
||||||
|
* @param starttls whether to upgrade a plain connection with STARTTLS
|
||||||
|
* @param ssl whether to open an implicit-TLS (SMTPS) connection
|
||||||
|
* @param from the envelope/From address; blank ⇒ falls back to {@code to}
|
||||||
|
* @param to the recipient address; blank ⇒ {@link #isConfigured()} is false (mail is skipped)
|
||||||
|
*/
|
||||||
|
public record SmtpSettings(String host, int port, boolean auth, String username, String password,
|
||||||
|
boolean starttls, boolean ssl, String from, String to) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the SMTP relay from a site's contact settings.
|
||||||
|
*
|
||||||
|
* @param view the site's effective contact settings ({@code PluginSettings.site}) — declared defaults
|
||||||
|
* overlaid by what the operator saved; secret keys are absent from it by contract
|
||||||
|
* @param password the {@code smtpPassword} secret in clear ({@code PluginSettings.secret}); empty when unset
|
||||||
|
* or undecryptable — the relay then authenticates with a blank password and reports the failure
|
||||||
|
* @return the materialized, immutable settings (never {@code null}); {@link #isConfigured()} reports usability
|
||||||
|
*/
|
||||||
|
public static SmtpSettings from(SettingsView view, Optional<String> password) {
|
||||||
|
Objects.requireNonNull(view, "view");
|
||||||
|
String host = text(view, "smtpHost");
|
||||||
|
int port = (int) view.integer("smtpPort", 25L, 1, 65535);
|
||||||
|
boolean auth = view.bool("smtpAuth", false);
|
||||||
|
String username = text(view, "smtpUsername");
|
||||||
|
String clear = password == null ? "" : password.orElse("");
|
||||||
|
boolean starttls = view.bool("smtpStarttls", false);
|
||||||
|
boolean ssl = view.bool("smtpSsl", false);
|
||||||
|
String from = text(view, "fromAddress");
|
||||||
|
String to = text(view, "toAddress");
|
||||||
|
return new SmtpSettings(host, port, auth, username, clear, starttls, ssl, from, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether enough is set to attempt a send: a non-blank host AND a non-blank recipient. When false the
|
||||||
|
* {@link ContactMailer} reports {@code NOT_CONFIGURED} and the submission is stored only (never lost).
|
||||||
|
*/
|
||||||
|
public boolean isConfigured() {
|
||||||
|
return host != null && !host.isBlank() && to != null && !to.isBlank();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The effective From address: the configured one, or the recipient when From is blank (a sane default). */
|
||||||
|
public String effectiveFrom() {
|
||||||
|
return (from == null || from.isBlank()) ? to : from;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String text(SettingsView view, String key) {
|
||||||
|
return view.string(key, "").strip();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Never leak the password in logs / diagnostics. */
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SmtpSettings[host=" + host + ", port=" + port + ", auth=" + auth + ", username=" + username
|
||||||
|
+ ", starttls=" + starttls + ", ssl=" + ssl + ", from=" + from + ", to=" + to
|
||||||
|
+ ", password=" + (password == null || password.isBlank() ? "<none>" : "<set>") + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package mx.quest.contact;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import mx.quest.runway.spi.model.Route;
|
||||||
|
import mx.quest.runway.spi.testkit.FakePluginSettings;
|
||||||
|
import mx.quest.runway.spi.testkit.FakeSiteServices;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console side of the CSRF fix: every operator action the endpoint declares (a non-anonymous {@code POST}) is
|
||||||
|
* reached from the admin fragment by a {@code <form method="post">} that carries the console session's CSRF token,
|
||||||
|
* and no link points at it any more (a link is a {@code GET}, and a {@code GET} on those paths changes nothing).
|
||||||
|
* The markup is read from {@code templates/} as shipped; the token binding from the sibling {@code .th.xml}.
|
||||||
|
*/
|
||||||
|
class ContactAdminTemplateTest {
|
||||||
|
|
||||||
|
private static final Pattern FORM = Pattern.compile("(?s)<form\\b([^>]*)>(.*?)</form>");
|
||||||
|
private static final Pattern CSRF_INPUT =
|
||||||
|
Pattern.compile("<input\\b[^>]*\\bid=\"([^\"]+)\"[^>]*\\bname=\"_csrf\"[^>]*>");
|
||||||
|
private static final String TOKEN_BINDING =
|
||||||
|
"th:attr=\"name=${_csrf != null ? _csrf.parameterName : '_csrf'},value=${_csrf != null ? _csrf.token : ''}\"";
|
||||||
|
|
||||||
|
private static String read(String file) throws IOException {
|
||||||
|
return Files.readString(Path.of("templates", file), StandardCharsets.UTF_8).replaceAll("(?s)<!--.*?-->", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> operatorActions() {
|
||||||
|
ContactEndpoint endpoint = new ContactEndpoint(null, null, new FakePluginSettings(), new FakeSiteServices(),
|
||||||
|
new FakeSiteServices(), null, new FakeSiteServices());
|
||||||
|
List<String> paths = new ArrayList<>();
|
||||||
|
for (Route r : endpoint.routes()) {
|
||||||
|
if (!r.anonymous()) {
|
||||||
|
paths.add(r.pathPattern());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theOperatorActionsAreTheInstallAndTheSmtpTest() {
|
||||||
|
assertEquals(List.of("/contact/install-page", "/contact/smtp-test"), operatorActions());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void everyOperatorActionIsAPostFormCarryingTheCsrfToken() throws IOException {
|
||||||
|
String html = read("admin.html");
|
||||||
|
String logic = read("admin.th.xml");
|
||||||
|
for (String action : operatorActions()) {
|
||||||
|
Matcher form = FORM.matcher(html);
|
||||||
|
boolean found = false;
|
||||||
|
while (form.find()) {
|
||||||
|
String attrs = form.group(1);
|
||||||
|
if (!attrs.contains("action=\"" + action + "\"")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
found = true;
|
||||||
|
assertTrue(attrs.contains("method=\"post\""), action + " must be submitted by POST: " + attrs);
|
||||||
|
Matcher csrf = CSRF_INPUT.matcher(form.group(2));
|
||||||
|
assertTrue(csrf.find(), action + "'s form carries a hidden _csrf field");
|
||||||
|
String id = csrf.group(1);
|
||||||
|
assertTrue(logic.contains("<attr sel=\"#" + id + "\"\n " + TOKEN_BINDING + "/>"),
|
||||||
|
"#" + id + " is bound to the console session's CSRF token in admin.th.xml");
|
||||||
|
}
|
||||||
|
assertTrue(found, "the admin fragment has a form for " + action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void noLinkPointsAtAnOperatorAction() throws IOException {
|
||||||
|
String html = read("admin.html");
|
||||||
|
for (String action : operatorActions()) {
|
||||||
|
assertFalse(html.contains("href=\"" + action), "a link is a GET and would not carry the token: " + action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void theAdminFragmentsIdsAreUnique() throws IOException {
|
||||||
|
// A duplicate id in a decoupled template is a hard Thymeleaf error that would 500 the settings page.
|
||||||
|
Matcher ids = Pattern.compile("\\bid=\"([^\"]+)\"").matcher(read("admin.html"));
|
||||||
|
Set<String> seen = new HashSet<>();
|
||||||
|
while (ids.find()) {
|
||||||
|
assertTrue(seen.add(ids.group(1)), "duplicate id " + ids.group(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loaded 100 of 468 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user