feat: qualify content publications and independent signed website deployment
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
|||||||
artifacts/
|
artifacts/
|
||||||
*.user
|
*.user
|
||||||
.env
|
.env
|
||||||
|
**/__pycache__/
|
||||||
|
|||||||
41
AGENTS.md
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# PlotDirector Website
|
||||||
|
|
||||||
|
Repository: `/srv/repos/PlotDirector.Website`; Gitea `nick/PlotDirector.Website`.
|
||||||
|
This is the public ASP.NET Core .NET 10 MVC/Razor website for `https://plotdirector.com`.
|
||||||
|
It is an architectural extraction, not a redesign. Preserve existing routes, content,
|
||||||
|
branding, responsive behaviour, accessibility and released feature claims.
|
||||||
|
|
||||||
|
## Boundaries
|
||||||
|
No SQL Server, Dapper, application authentication/session, application runtime,
|
||||||
|
SignalR, PWA manifest or service worker. Public account/billing links use configured
|
||||||
|
`Application:BaseUrl`; Production is `https://app.plotdirector.com`.
|
||||||
|
Do not modify `/srv/repos/PlotDirector` as part of website work. Coordinate an
|
||||||
|
explicit application task when its authoritative documentation/brand needs changes.
|
||||||
|
Do not copy secrets, uploads or application configuration into this repository.
|
||||||
|
|
||||||
|
## Architecture and content
|
||||||
|
Controllers and Razor views retain the extracted rendering. `Content/solver.json`
|
||||||
|
is a validated published graph; editorial/presentation JSON supplies existing copy.
|
||||||
|
`Content/pricing.json` contains public plan facts, never provider secrets or user entitlements.
|
||||||
|
The solver engine snapshot is extraction version 1 from application baseline 9dcd29d4;
|
||||||
|
application workspace/billing business logic is not implemented here.
|
||||||
|
`Help/published` is a generated immutable artifact, NOT an independently edited source.
|
||||||
|
PlotDirector remains authoritative. See `Docs/Content.md` for publication and consumption.
|
||||||
|
Public brand assets are versioned as extraction v1; shared snapshots have provenance
|
||||||
|
in `Content/brand-manifest.json`. Do not silently modify consumed package files.
|
||||||
|
|
||||||
|
## Build and qualification
|
||||||
|
`dotnet build PlotDirector.Website.slnx`
|
||||||
|
`python3 Tests/verify.py --origin http://127.0.0.1:5051`
|
||||||
|
Browser verification uses Playwright against the running service. Record real evidence.
|
||||||
|
Development sends noindex headers and robots Disallow. Production must retain canonical
|
||||||
|
plotdirector.com URLs, metadata, JSON-LD, public sitemap and verification assets.
|
||||||
|
Sitemap entries come only from published content. Do not invent modification dates,
|
||||||
|
features, marketing sections or guaranteed AI ranking claims. Unknown pages return 404.
|
||||||
|
|
||||||
|
## Operations
|
||||||
|
See `Docs/Publishing.md`. Website deployment MUST NOT invoke application migrations,
|
||||||
|
restart the application or change its database/configuration. Use separate identity,
|
||||||
|
service, port, immutable releases, signing key, receipts and rollback.
|
||||||
|
No Production activation or infrastructure modification without explicit approval.
|
||||||
|
Do not modify unrelated web1 sites, especially catherinelynwood.com.
|
||||||
87
Docs/Content.md
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
# Shared public content
|
||||||
|
|
||||||
|
The authoritative application-help source remains
|
||||||
|
`PlotDirector/PlotLine/Help/Articles`. Context keys, category slugs, article slugs,
|
||||||
|
search, related articles and the existing Markdown renderer are retained. The
|
||||||
|
application's contextual drawer continues to read its own source. Website content
|
||||||
|
never comes from a running application, SQL query or an HTTP call to the application.
|
||||||
|
|
||||||
|
`Help/published` is the checked-in, generated bootstrap publication, not an editable
|
||||||
|
second documentation source. Its manifest identifies source commit, publication
|
||||||
|
channel, version and every SHA-256. Normal publication uses the external content
|
||||||
|
store, so documentation updates require no application/website restart or deployment.
|
||||||
|
The website reloads the current publication when its manifest changes and generates
|
||||||
|
its index, categories, search results, canonical article URLs and sitemap from those
|
||||||
|
same approved records. Original identifiers and collision-resolved slugs are exported
|
||||||
|
by the existing application HelpService, rather than independently recomputed.
|
||||||
|
Modification dates come from each article's last Git commit, not packaging time.
|
||||||
|
|
||||||
|
## Application developer: publish
|
||||||
|
|
||||||
|
1. Commit the help changes in the application repository. Review exactly which
|
||||||
|
public article URLs and linked assets are appropriate for the target release.
|
||||||
|
Never publish a directory glob. Internal and unreleased content needs exclusion.
|
||||||
|
2. Create a private approval JSON outside the checkout with `sourceCommit` (full
|
||||||
|
current SHA), `channel` (`Development` or `Production`), `version` (unique content
|
||||||
|
version) and `articles` (explicit array of existing public article URLs).
|
||||||
|
`Tools/PublicContent/production-approval.json` records the initial released URL
|
||||||
|
approval; it is historical input, not blanket approval for later changes.
|
||||||
|
3. For Production, confirm that the content describes the deployed application or
|
||||||
|
has explicit approval as compatible with it. Development approval is insufficient.
|
||||||
|
4. Export from the exact source commit to a new directory:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
dotnet run --project Tools/PublicContent/PublicContent.csproj -- \
|
||||||
|
/srv/repos/PlotDirector /absolute/approval.json /absolute/new-help-publication
|
||||||
|
sha256sum /absolute/new-help-publication/manifest.json
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Retain the artifact and approval with the release evidence. Pass the manifest
|
||||||
|
digest through the reviewed publication record, separately from untrusted files.
|
||||||
|
A tar.zst archive of this directory is sufficient for transport; extract only
|
||||||
|
trusted archives to a private staging directory. No new shared repository needed.
|
||||||
|
Publishing help does not activate application code or invoke database operations.
|
||||||
|
|
||||||
|
## Website developer/operator: consume
|
||||||
|
|
||||||
|
Use the independent website checkout:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python3 Tools/consume_help.py /absolute/new-help-publication \
|
||||||
|
--store /absolute/content-store \
|
||||||
|
--channel Development \
|
||||||
|
--manifest-sha256 APPROVED_SHA256
|
||||||
|
```
|
||||||
|
|
||||||
|
For the installed Atlas website, the administrator uses
|
||||||
|
`--store /opt/plotdirector-website-dev/shared/help`; Production uses
|
||||||
|
`/srv/plotdirector-website/shared/help` and **must use `--channel Production`**.
|
||||||
|
Both channels are usable in Development, but explicitly choose the approved channel.
|
||||||
|
The store is administrator-owned. The helper validates checksums, channel, paths and
|
||||||
|
public article identities, installs an immutable digest-named directory and atomically
|
||||||
|
switches `current`. No service restart follows. `HelpContent__Path` selects `current`.
|
||||||
|
Retain old directories. Rollback is an atomic `current` symlink replacement to a
|
||||||
|
previous approved directory; never edit a published directory. A website code release
|
||||||
|
keeps the external content pointer, so its rollback does not silently republish help.
|
||||||
|
|
||||||
|
## Other public content and branding
|
||||||
|
|
||||||
|
`Content/solver.json` is the complete published Development graph exported read-only
|
||||||
|
through `dbo.WritingSolver_Get`, without SQL/authentication dependencies in this product.
|
||||||
|
Editorial/result/payoff JSON and the deterministic engine are retained as extraction
|
||||||
|
version 1. The public website now owns future public solver development; application
|
||||||
|
workspace actions remain application functionality. Validate the whole graph before
|
||||||
|
publishing. Do not maintain parallel edits to the old application's public catalogue.
|
||||||
|
Before Production approval, compare this approved graph against the currently public
|
||||||
|
solver; it was intentionally excluded from the Production sitemap and remains so.
|
||||||
|
|
||||||
|
`Content/pricing.json` is a public plan snapshot, not an entitlement or checkout engine.
|
||||||
|
Payment actions always go to the application, which remains authoritative for billing.
|
||||||
|
A pricing publication must be checked against released plan facts. No provider price
|
||||||
|
IDs or account data are required. Prices must never be inferred from marketing text.
|
||||||
|
|
||||||
|
The initial shared brand is version `public-brand-v1`, with source provenance and
|
||||||
|
checksums in `Content/brand-manifest.json`. Website owns public brand development.
|
||||||
|
`Tools/brand_package.py` publishes/consumes an explicitly versioned CSS/asset snapshot
|
||||||
|
for the application's authentication shell. The application pins a reviewed version;
|
||||||
|
independent deployments need not share a live filesystem or update simultaneously.
|
||||||
110
Docs/Publishing.md
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
# Independent website publishing
|
||||||
|
|
||||||
|
Development runs on Atlas as `plotdirector-website-dev`, identity
|
||||||
|
`plotdirector-website`, port 5051. Actual LAN URL: **http://192.168.10.10:5051/**
|
||||||
|
(or **http://atlas:5051/** where Atlas resolves). Application Development remains
|
||||||
|
**https://dev.plotdirector.com/**, port 5050, identity/service unchanged.
|
||||||
|
An optional public HTTPS edge template is prepared at
|
||||||
|
`Tools/Deployment/production/nginx-development.conf`; DNS, TLS and edge administrator
|
||||||
|
installation are required before `https://website-dev.plotdirector.com` exists.
|
||||||
|
|
||||||
|
Start independent Codex sessions:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd /srv/repos/PlotDirector.Website && codex
|
||||||
|
cd /srv/repos/PlotDirector && codex
|
||||||
|
```
|
||||||
|
|
||||||
|
Build: `dotnet build PlotDirector.Website.slnx`.
|
||||||
|
HTTP qualification: `python3 Tests/verify.py --origin http://127.0.0.1:5051`.
|
||||||
|
Browser qualification: `npm ci && WEBSITE_ORIGIN=http://127.0.0.1:5051 npm run test:browser`.
|
||||||
|
Browser installation: `npx playwright install chromium`, only if missing.
|
||||||
|
Deployment-security qualification: `python3 Tests/test_deployment.py`.
|
||||||
|
Build and regression gates run serially. Website has no application project reference.
|
||||||
|
|
||||||
|
## Atlas setup (one time)
|
||||||
|
|
||||||
|
`sudo -n bash Tools/Deployment/provision-development.sh` installs the fixed website
|
||||||
|
profile. It refuses an existing target; maintenance requires explicit review and
|
||||||
|
administrator installation, rather than trusting files from a submitted release.
|
||||||
|
Independent signing material lives in
|
||||||
|
`~/.local/share/plotdirector-website-development/signing/`, private key 0600/parent 0700.
|
||||||
|
Install approved help as described in Content.md before activation.
|
||||||
|
|
||||||
|
## Development release
|
||||||
|
|
||||||
|
Use a clean committed checkout and unique release identifier/output directory:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python3 Tools/Deployment/website_release.py prepare \
|
||||||
|
--source /srv/repos/PlotDirector.Website \
|
||||||
|
--output /home/nick/.local/share/plotdirector-website-development/releases/RELEASE-ID \
|
||||||
|
--release-id RELEASE-ID \
|
||||||
|
--signing-key /home/nick/.local/share/plotdirector-website-development/signing/private.pem \
|
||||||
|
--public-key /home/nick/.local/share/plotdirector-website-development/signing/public.pem
|
||||||
|
sg plotdirector-website-deploy -c 'cp -R /home/nick/.local/share/plotdirector-website-development/releases/RELEASE-ID /opt/plotdirector-website-dev/incoming/RELEASE-ID'
|
||||||
|
sudo -n /usr/local/sbin/deploy-plotdirector-website-development validate RELEASE-ID
|
||||||
|
sudo -n /usr/local/sbin/deploy-plotdirector-website-development activate RELEASE-ID
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `sg ... -c 'sudo ...'` when group membership is not yet active. Keep incoming
|
||||||
|
packages for explicit rollback. Preparation retains existing Zstandard level 6/four
|
||||||
|
workers/frame checksum and Ed25519 authorization plus transport signatures. The
|
||||||
|
vendored transport verifier checks signatures and compressed checksums before bounded
|
||||||
|
decoding, then checks every extracted file and the exact manifest/product identity.
|
||||||
|
Website manifests contain no SQL; this helper never invokes a database worker.
|
||||||
|
|
||||||
|
The root-owned helper locks its own target, snapshots/verifies untrusted input,
|
||||||
|
installs immutable files, atomically switches `current`, restarts only its own service,
|
||||||
|
and checks health/product/source identity. Failures record receipts and, after a
|
||||||
|
failed switch with a previous release, restore that previous website. No SQL rollback
|
||||||
|
is involved. Receipts: `/opt/plotdirector-website-dev/receipts/*.json`; current marker
|
||||||
|
`active-deployment.json`; releases under `releases/RELEASE-ID/app`. Signing is separate
|
||||||
|
from activation, and neither runtime nor transfer group can replace the trusted helper.
|
||||||
|
|
||||||
|
Restart/logs: `sudo systemctl restart plotdirector-website-dev` and
|
||||||
|
`journalctl -u plotdirector-website-dev`. Neither command touches the application.
|
||||||
|
|
||||||
|
Explicit independent website rollback:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo -n /usr/local/sbin/deploy-plotdirector-website-development rollback PREVIOUS-RELEASE-ID
|
||||||
|
```
|
||||||
|
|
||||||
|
This re-verifies the retained signed package and retained files before switching, and
|
||||||
|
writes a new rollback receipt. It does not roll back shared help; select its prior
|
||||||
|
approved content publication independently if necessary.
|
||||||
|
|
||||||
|
## Production (prepared; NOT activated)
|
||||||
|
|
||||||
|
Templates are in `Tools/Deployment/production`. Production preparation must use a
|
||||||
|
separate signing key and deployment SSH identity. The website uses port 5004, service
|
||||||
|
`plotdirector-website`, `/srv/plotdirector-website`, independent trust/configuration
|
||||||
|
`/etc/plotdirector-website-production`. Ports 5002/5003 and unrelated sites are untouched.
|
||||||
|
The fixed Production profile refuses non-web1 hosts and any other root/service/endpoint.
|
||||||
|
|
||||||
|
An administrator must install the helper/vendor modules and SSH dispatcher root-owned
|
||||||
|
under `/usr/local/lib/plotdirector-website-deployment`, plus the fixed launcher under
|
||||||
|
`/usr/local/sbin/deploy-plotdirector-website-production`. Install the target/public key,
|
||||||
|
service/env, sshd Match and sudoers from the reviewed templates. Runtime and transfer
|
||||||
|
identities are separate locked system users, with no sudo/adm/docker membership.
|
||||||
|
See the application's `Docs/Separation/Cutover.md` for exact directory permissions,
|
||||||
|
preflight, backups, Nginx/TLS and activation order. Do not change Production without
|
||||||
|
owner approval. No administrative key is currently required for Development work.
|
||||||
|
|
||||||
|
Prepare with the same `website_release.py prepare` command using Production signing
|
||||||
|
material. Transfer independently:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python3 Tools/Deployment/transfer.py /absolute/qualified-bundle \
|
||||||
|
--identity /home/nick/.ssh/plotdirector-website-production
|
||||||
|
```
|
||||||
|
|
||||||
|
Restricted SSH commands on `plotdirector-website-deploy@85.190.124.132`:
|
||||||
|
`validate RELEASE-ID`, `activate RELEASE-ID`, `rollback PREVIOUS-ID`, `receipt UUID`.
|
||||||
|
Use the application's documented pinned SSH options and verified web1 host key.
|
||||||
|
Preparation/transfer/validation do not authorize activation. Retain receipts/releases.
|
||||||
|
|
||||||
|
The application's independent Development/Production commands remain documented in
|
||||||
|
`/srv/repos/PlotDirector/Docs/Codex/Deployment.md` and `Docs/Deployment/Production.md`.
|
||||||
|
Website publication never invokes those commands and never deploys application SQL.
|
||||||
121
PlotDirector.Website/Content/brand-manifest.json
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
{
|
||||||
|
"version": "public-brand-v1",
|
||||||
|
"sourceRepository": "PlotDirector",
|
||||||
|
"sourceCommit": "9dcd29d423b20e373e49fb28180d993c40aa165d",
|
||||||
|
"files": {
|
||||||
|
"favicon.svg": "5e6e25eb171c2412a29195aa38d072661527656aee9e88dbd2beec602bfe0942",
|
||||||
|
"css/public-art-direction.css": "2904aab72eb3d163be5e4d587ee1a615a4dc2f469b99f60732e3fae9290d93e5",
|
||||||
|
"css/public-visual-system.css": "a03516b852f515f3aa66581b0bbd1a93427bcfe7afd9d2dd43cceaa6448d4151",
|
||||||
|
"css/public-site.css": "b83c4887a10d612d8cb753e11301ad4a74a301d2e33f1547923be7cb39d43a44",
|
||||||
|
"images/public/writing-solver-desk.avif": "cfa88ade93b69e09d28fda7f4c4d21ce140fa81eae3f74983b584c6b2c861abf",
|
||||||
|
"images/public/scene.jpg": "bc9f463551287f5134798e8ea1478992faa1c5fe73716f58c1da9b242e059be0",
|
||||||
|
"images/public/workspace.jpg": "1d6eb0e94ad74b1e908dc494d8a2b265cee8eede08c820f149eaf1f2170c8394",
|
||||||
|
"images/public/characters.jpg": "c7b6c84c89378bd65929431f910d2102ef7523d38fa43718e65aff4a0fde1400",
|
||||||
|
"images/public/calendar.jpg": "4f76b99137b6279b1a5c88dd75eb77201ab34dc94b3598ec53eb90d214a3a197",
|
||||||
|
"images/public/plot-lines.jpg": "67360624010008f780c9fc149a361ce570dedeef9f7dd74c698e3b9b39a6e52f",
|
||||||
|
"images/public/writing.jpg": "92dcb47be1f4e37bb805863c80ce0ca6b8bf18aed3c4dd5e7b0d79386f0ce06c",
|
||||||
|
"images/public/plotdirector-social.png": "d37613226d3dfd6919f10a7f80214b4f501ac0a8c956fcbb00371de27b2be1ae",
|
||||||
|
"images/public/writing-solver-desk.png": "2eda96496578abba65e076550d94a743c953cea85cc6aebc98d7f40761ff7a95",
|
||||||
|
"images/public/import.jpg": "c16723d8acbf08c3e898e73f6248819a5eb0a8683730a59a442f6fb7c0037ef3",
|
||||||
|
"images/public/continuity.jpg": "bbdf542d935a5a00e53311a2c9bfc27ced022c53e72f658b7951df52f09bf528",
|
||||||
|
"images/public/knowledge.jpg": "d491c0ffe228d682fe04e2d9cc2f791c082e5961a47838bd102442c9918409a3",
|
||||||
|
"images/public/writing-solver-desk.webp": "3b2745aeca34658131941dac13326573b67498b79a3c38e3226050c57392ce3d",
|
||||||
|
"images/public/insights.jpg": "9a583a26c48547982f371b4d4807b6dc1904e56e46c4d79783dab50921b5c7b6",
|
||||||
|
"images/public/application/calendar-640.avif": "101d675ef1fb463f9075465ab40d4956bc36eb8056fb1d422cb3e4554dca3b2f",
|
||||||
|
"images/public/application/dark-overview-1280.avif": "0114ba718eeca44c667a6407fbc14676d2a28f153ef248efc4a62154bba59004",
|
||||||
|
"images/public/application/dark-knowledge-1280.avif": "db488952028d5455c4cedf4894204ceb73828d769ccfcd541472e46823a6fdab",
|
||||||
|
"images/public/application/person-fragment-640.webp": "36b74ca20e2c9b1a44ae3dcd3c9f384d7dbe6dfd2020989ea5fc1b575a466611",
|
||||||
|
"images/public/application/import-640.webp": "cded739f0beda831ae0b567d3a36c4fa47eb0d545c3f9320b6d82292c4e9f8fe",
|
||||||
|
"images/public/application/calendar-640.webp": "f1bc0d534eee49e7a57f8d5deaaf8362a74a834695e5ee32719e49f6838afc25",
|
||||||
|
"images/public/application/person-fragment-960.webp": "07919befa4a50b6539478e39b2c0d6ca66d0dcdd5d299b7981cb13a7413efe47",
|
||||||
|
"images/public/application/characters-1280.avif": "ac0ac408897af9f110e6337be27d90692933e2a4893a00eb3c1444a331fc8b30",
|
||||||
|
"images/public/application/scene-960.avif": "b65ac59fc88acd74778fce8cee94721840af722ed3ddc866dc360634dc554181",
|
||||||
|
"images/public/application/dark-overview-960.avif": "8d23d4fcb6df4648555c790edb5fa6fde3fa90aed0e0c031628bc6d27ceb2eed",
|
||||||
|
"images/public/application/dark-overview-1280.webp": "e4348033e2bddab081ebd04ce2db95957fbce9d9b23d59e9fe928b8e5ca36dcd",
|
||||||
|
"images/public/application/dark-knowledge-fragment-1280.webp": "9562927ea4ca3ac26a5f114fbba5b7129e58d7f7760f50b2737be4879adc268a",
|
||||||
|
"images/public/application/writing-960.webp": "5466c106a2177fc4218b29c291f920af9b4fbf0ac601c504f5d479a67369e06c",
|
||||||
|
"images/public/application/knowledge-fragment-1280.avif": "b5245426d8dd2faecdd16d4ee974766285769172816228d792a7682e2faf5ae7",
|
||||||
|
"images/public/application/dark-overview-640.webp": "4dd3168e02395b4087de7e08520c431456726a1a91813bfdbb90943f955fb63a",
|
||||||
|
"images/public/application/characters-640.avif": "257247b574466bf7e4ff3a0fb96387add799c1a05b04b81b87d9d457ee0aa1e8",
|
||||||
|
"images/public/application/scene-640.webp": "ee1c98909f6dc838e1e14c71b845427aa52127f94ac02b08ad7a101d659adf75",
|
||||||
|
"images/public/application/dark-knowledge-fragment-960.avif": "c92765da0e29311d92c366d68f94a7974801735ddfe343d4d90e288b35dc1086",
|
||||||
|
"images/public/application/calendar-1280.avif": "98c0a44984dd314355b11c1b08841639f832a0f4545d01add6b3414e9c745848",
|
||||||
|
"images/public/application/characters-960.webp": "685e70a8a88e8519c0bb9c15ef3f569fc18ef90b9fdb99dd4e1b75706dfdcabc",
|
||||||
|
"images/public/application/import-1280.avif": "f40d8ddc0eec272a52d09bd9a787c4ed9c52460964439c442ce99e54cc3862d1",
|
||||||
|
"images/public/application/dark-overview-960.webp": "c981f4377022097b1177b7a48616d990b2dd8101bb9f8fe299447a335056549f",
|
||||||
|
"images/public/application/person-fragment-960.avif": "50cf6c56407f19445a0d49a09768ef39c8b48476e689c055eb6f6e60e838c941",
|
||||||
|
"images/public/application/writing-1280.avif": "febb2eb8badbd69796ffe36669c438d60edb0e0ae55acb158f07155d07975868",
|
||||||
|
"images/public/application/import-1280.webp": "63e6ad1a73e7c41e7b2d0a0bc713094621140d86c27e91f068e2ed4d3afb23c5",
|
||||||
|
"images/public/application/person-fragment-640.avif": "377cf923e2a69793f8bad8654a99e0217e6b761d4057a15e49a601e48fdd2594",
|
||||||
|
"images/public/application/dark-knowledge-640.avif": "e8b02923db162946f0358bff0d6cc37895226dc88b0e5d248e6c0379b335dfee",
|
||||||
|
"images/public/application/dark-knowledge-1280.webp": "db6e3f078b08bb455cb6ffc8253dea13b0faca0f9fbac194d65905f8e1638f87",
|
||||||
|
"images/public/application/knowledge-fragment-1280.webp": "00f72b466441f737c872ff215df233dd32d813809401d9d2ca18ad064c832e8d",
|
||||||
|
"images/public/application/writing-1280.webp": "f50cb33ce54b6dc82a7578cb6249b81577f7b55ae2f76c89f59967816a82b088",
|
||||||
|
"images/public/application/dark-plot-lines-960.avif": "cc0b5ae5b6527d01f5d103cfceeda1e026bb26056a5b4c5524e793ce88a5bd0b",
|
||||||
|
"images/public/application/dark-plot-lines-640.webp": "30899580c28c72f6f0df8d296df50d6a1d926c12922696a516623351847de571",
|
||||||
|
"images/public/application/import-960.webp": "831022d2fceac78b5147fc6193cb3ee9539ae1579ce5e4cddf69c7ac8196b681",
|
||||||
|
"images/public/application/dark-plot-lines-1280.webp": "d82cd414e6dcda5e7e85cae93df10df685d10929e98990c98e9831ee5b11cb66",
|
||||||
|
"images/public/application/dark-plot-lines-1280.avif": "856b3c1e60fe2f981c309556adbaa7ad78f75f8c07e4823549e42436a1298117",
|
||||||
|
"images/public/application/knowledge-fragment-960.webp": "ceb4461883821eae089d415870d83a780ef9d5794d246274030eaad3869f1098",
|
||||||
|
"images/public/application/dark-knowledge-640.webp": "8a23ee9b2398044390f7c55316a1a029d1617ccca4d8f2acc96f61bead607fd4",
|
||||||
|
"images/public/application/import-960.avif": "d6298a640e5aa42dfd69becaaef8522176b7094e8b83e2e81262e430f7ae7ed1",
|
||||||
|
"images/public/application/scene-640.avif": "4b9996a591bf4781687bd6ba3de43f7d55f7b24381fb2eb8dc524c85ee3cdd21",
|
||||||
|
"images/public/application/dark-knowledge-960.avif": "efab88cb2d07260d7d454475f9859bd2f273023740bb9efd94b092fe61507daa",
|
||||||
|
"images/public/application/dark-plot-lines-960.webp": "f32469c4f464d390848302c63655a870a629d14603dd223d8774b14eaecae6a5",
|
||||||
|
"images/public/application/scene-1280.webp": "884b0c41d9895cf237b82caf32571a8ef0758e7538d25e350970922ed9dd4cc2",
|
||||||
|
"images/public/application/knowledge-fragment-640.webp": "3d7467cc14835533e4cfa73a14b83bf8975a451016814c11b416db0b3283f788",
|
||||||
|
"images/public/application/scene-1280.avif": "7bb747e048837968cbffe487ce08a4420ab6d304a9b6c12f3247ea2405452245",
|
||||||
|
"images/public/application/characters-960.avif": "230bf613e5c788258edf2a60ecb827a929b85d075f6d40f278b2516952c925ad",
|
||||||
|
"images/public/application/person-fragment-1280.webp": "667db2efaab8e8d1f8ebd2bd9a94033543cee7c70483e12733c3bf1218b4d397",
|
||||||
|
"images/public/application/dark-overview-640.avif": "293cf8fe7450d4d3783f213ebde8763a80ebb3eedc398367946904baa7f33d20",
|
||||||
|
"images/public/application/dark-knowledge-960.webp": "b9c6e5cd2ccf9fc2c001ff4297903cc2ef3d7a65aec910662b7075e2b722b77e",
|
||||||
|
"images/public/application/dark-plot-lines-640.avif": "379befa985c0896e5c22e23424267652b43b12ae0a45d7d8f13238ae72168b6e",
|
||||||
|
"images/public/application/dark-knowledge-fragment-640.avif": "7ac830ad8bf1046e59482900ef2e3faf14280e2ea539fb388290cab117c7da5b",
|
||||||
|
"images/public/application/writing-640.webp": "2a331f8525f3c05ba19c10f2d7976fbeed85d76b16facc5bc2ccf6c6303301ce",
|
||||||
|
"images/public/application/knowledge-fragment-960.avif": "79e84356818521cd6348470cc723f76fd306992114fffc8a329c6bdc3ddd3cd1",
|
||||||
|
"images/public/application/writing-640.avif": "a1ff3fccca82a4b963ae5e1f805595b1d2f3cf7a84a55b1b3812abdbf6e64e36",
|
||||||
|
"images/public/application/import-640.avif": "b0567999c1bc61a0dfd4c88a75f71749164f193f96ad3c44a4354b98db9e0f22",
|
||||||
|
"images/public/application/calendar-960.avif": "170db6561c8a71fa6ebb34446902a828981c9aa52aaac4a167d249389d8bad3f",
|
||||||
|
"images/public/application/calendar-960.webp": "13e9e1936a51c3c43545a1b048e4a955779ed73d5168512a87529797da5bb5b0",
|
||||||
|
"images/public/application/scene-960.webp": "619e57607c830a5a48b9ab09d28292bc06db74a5186f9bb793a1e5c80077ced8",
|
||||||
|
"images/public/application/dark-knowledge-fragment-640.webp": "e9100c526c8ef1c1d5884d71436233697d5e8cfcda91f0059502ddb49a6562e0",
|
||||||
|
"images/public/application/person-fragment-1280.avif": "d3bad883e0ccf3e81443a8205ba86c9052abbda26dbebfbe42fae5f9dd75ec8c",
|
||||||
|
"images/public/application/writing-960.avif": "f8e08f7229f42324e70d2a9db064608ce84c80a38a0586c1460c8b0c60b1234f",
|
||||||
|
"images/public/application/characters-640.webp": "39a44114d25f1c1bf42e0790a7a53aa24ca82afe2f27100159dd163b630babc2",
|
||||||
|
"images/public/application/knowledge-fragment-640.avif": "fd2aaf377288e4647e338d34aaf2eefd07866d74b5de59e14bd3b11f3fd076c6",
|
||||||
|
"images/public/application/characters-1280.webp": "3b41b5a7c3e5c23016da3c05ece5606247a57c0c85e9d078103758230ab33924",
|
||||||
|
"images/public/application/dark-knowledge-fragment-960.webp": "f20f8756fc9e3bf9d1060bb133d1b7d50a1f7643fcc905027ee475a19f3aac3d",
|
||||||
|
"images/public/application/calendar-1280.webp": "ccdce87659aef80cb564a5931e44703e98adb58d7da33fe769bff582258b5c61",
|
||||||
|
"images/public/application/dark-knowledge-fragment-1280.avif": "70ed81515b346cfd19ab26c5319f853a9227bf7273efb5631d553045db83ea2b",
|
||||||
|
"images/public/scenes/pricing-mobile-704.webp": "cd4fa98ce7bde73e446791943a061eadbace1cba90487fe870fc00bd1a5bab54",
|
||||||
|
"images/public/scenes/tour-wide-768.avif": "72ea208af431a531805d9e1025c36c4007093c0d825a11aff76bcf5e571679ea",
|
||||||
|
"images/public/scenes/tour-wide-1152.webp": "c7b5b13fc1bae91968522b49af7b273944caea413ff3254e8b6e33664604973c",
|
||||||
|
"images/public/scenes/tour-mobile-704.avif": "83479b5f6a52925728415b3f95a99cf06f47f8266307a4fe6dd5eada32d68342",
|
||||||
|
"images/public/scenes/home-mobile-480.webp": "2f294c956e633f8fe1f67138b98dcd402f9455e150430dafa9c758063c418ce5",
|
||||||
|
"images/public/scenes/home-wide-1536.avif": "de7c304b4c821952556bf38f59ad5addbc0daa890b5d4c63abc1bfe4b274416f",
|
||||||
|
"images/public/scenes/pricing-wide-1152.avif": "895f769eafef5ae8963d783a002d760b3e9015b6118d40d8e5f4667fafffa17a",
|
||||||
|
"images/public/scenes/pricing-wide-768.webp": "2b5c4ab3b993b7b8291a7e2bcc649625c6c87d406398934d5735c328e77c6b7d",
|
||||||
|
"images/public/scenes/pricing-wide-1536.webp": "af32ab8b873140ab2033eccfd2bcba4d2d8a424e484ad407ecbe3b1920c5897c",
|
||||||
|
"images/public/scenes/tour-mobile-704.webp": "ed97981d9178c893c8e3d564bde050c8277302faf0edf60c79203868ba3c9c4e",
|
||||||
|
"images/public/scenes/home-mobile-480.avif": "88476e5339631b58022651eeac99d252e32e1041f24e5074ce6fe1ee2a432096",
|
||||||
|
"images/public/scenes/tour-mobile-480.avif": "e34ff4df1eca65532f2e9f44eede3296133928451de584dba87bee8a004dca97",
|
||||||
|
"images/public/scenes/pricing-mobile-704.avif": "9a1ce580f198554a028a0d91c103a921c6110b1c5f9717712aab53463665b43a",
|
||||||
|
"images/public/scenes/home-wide-768.avif": "2ba570ff7c8e392e7cb6af82087dbe9d0a60903d9fe3ef8f995639a842371033",
|
||||||
|
"images/public/scenes/pricing-mobile-480.webp": "457cc87933155dd5ada883cf37ac6ff50b6a26bcced9e9ca3453e4fd0da96397",
|
||||||
|
"images/public/scenes/pricing-wide-1536.avif": "e527ebf025931535e8e1dc671cf854e122d9e0342b58b0e248d0558b45828e8e",
|
||||||
|
"images/public/scenes/pricing-mobile-480.avif": "85f6a2772e54975b93d17b75c97f0a29b86ed353c2975d31981944e05508701e",
|
||||||
|
"images/public/scenes/tour-wide-1536.webp": "43f208e5bd6cff5e3be1103dd02537a2bc402b49a0a63d199e5667f21f90e541",
|
||||||
|
"images/public/scenes/tour-wide-768.webp": "fc4ec7b6c3791e87c233bd1159e4a477e6826c129556961ac9036a77524c9a9a",
|
||||||
|
"images/public/scenes/tour-mobile-480.webp": "7f50f8796f0154a44e815e36f6d489d29207307c2f6a028dfbf5d27a94103f21",
|
||||||
|
"images/public/scenes/home-wide-1152.avif": "9dc21996acb07e3c950dfb86a1cc24f637af41faf31312099a32089fe7d3823c",
|
||||||
|
"images/public/scenes/tour-wide-1152.avif": "bfa22a244ddf1e1f9e62e911afcef597205e0121979fdf9f466d4872b6fc940e",
|
||||||
|
"images/public/scenes/pricing-wide-1152.webp": "e2bdf155617f6d131261201095344ad1eae35cb22ebcb8f2ed0bfa34dfbd38bf",
|
||||||
|
"images/public/scenes/home-wide-1536.webp": "73e68f74611300caee6770317bd72204d3453364785dbedb496859c57c989aba",
|
||||||
|
"images/public/scenes/home-wide-768.webp": "d29ef313b95fbb469bc79ece3b2dd30439a6776232957ad88c904d595c4473a2",
|
||||||
|
"images/public/scenes/home-mobile-704.avif": "74603655b831d2352d4dd37ebcd5ee4904a94ef49332ca230b551193f1211050",
|
||||||
|
"images/public/scenes/home-wide-1152.webp": "fab58f544cd1d1fb9e7d527755d5a38b3af15adb3d8cbd875c7050d65f73c69e",
|
||||||
|
"images/public/scenes/pricing-wide-768.avif": "8bb1a0735413f2b9f80ec310f336b35e61996ffbe9741f0196daff5f657f7af6",
|
||||||
|
"images/public/scenes/tour-wide-1536.avif": "2d7e9c0cbb3fdfd7cff91c51dd7331613b79a974cb18bcb0ebd71fbf83173982",
|
||||||
|
"images/public/scenes/home-mobile-704.webp": "cd3d6ca5f6724f481c7120a5c0530d23ac0aa247196cc77184e4163d88f1c1d0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -111,6 +111,7 @@ public sealed class HelpController(IHelpService help, IHelpMarkdownRenderer mark
|
|||||||
var article = help.GetBySlugs(categorySlug, articleSlug);
|
var article = help.GetBySlugs(categorySlug, articleSlug);
|
||||||
if (article is null)
|
if (article is null)
|
||||||
{
|
{
|
||||||
|
Response.StatusCode = 404;
|
||||||
return View("ArticleNotFound", $"{categorySlug}/{articleSlug}");
|
return View("ArticleNotFound", $"{categorySlug}/{articleSlug}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
PlotDirector.Website/Controllers/HelpImageController.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
namespace PlotDirector.Website.Controllers;
|
||||||
|
public sealed class HelpImageController(IWebHostEnvironment environment,IConfiguration configuration):Controller
|
||||||
|
{
|
||||||
|
[HttpGet("/HelpDrawer/Image")]
|
||||||
|
public IActionResult Image(string file)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(file))return NotFound();
|
||||||
|
var root=Path.GetFullPath(Path.Combine(configuration["HelpContent:Path"]??Path.Combine(environment.ContentRootPath,"Help/published"),"assets"));
|
||||||
|
var path=Path.GetFullPath(Path.Combine(root,file));
|
||||||
|
if(!path.StartsWith(root+Path.DirectorySeparatorChar,StringComparison.Ordinal)||!System.IO.File.Exists(path))return NotFound();
|
||||||
|
var type=Path.GetExtension(path).ToLowerInvariant() switch {".png"=>"image/png",".jpg" or ".jpeg"=>"image/jpeg",".webp"=>"image/webp",".avif"=>"image/avif",_=>null};
|
||||||
|
return type is null?NotFound():PhysicalFile(path,type);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
PlotDirector.Website/Help/README.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Generated publication snapshots only. Do not edit. Author help in PlotDirector/PlotLine/Help/Articles and publish an explicitly approved package.
|
||||||
@ -5,7 +5,8 @@ using PlotDirector.Website.Services;
|
|||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
builder.Services.AddMemoryCache();
|
builder.Services.AddMemoryCache();
|
||||||
builder.Services.AddDataProtection().SetApplicationName("PlotDirector.Website");
|
var protection = builder.Services.AddDataProtection().SetApplicationName("PlotDirector.Website");
|
||||||
|
if (builder.Configuration["DataProtection:KeysPath"] is string keysPath) protection.PersistKeysToFileSystem(new DirectoryInfo(keysPath));
|
||||||
builder.Services.Configure<ForwardedHeadersOptions>(o => { o.ForwardedHeaders=ForwardedHeaders.XForwardedFor|ForwardedHeaders.XForwardedProto; });
|
builder.Services.Configure<ForwardedHeadersOptions>(o => { o.ForwardedHeaders=ForwardedHeaders.XForwardedFor|ForwardedHeaders.XForwardedProto; });
|
||||||
builder.Services.AddResponseCompression(o=>o.EnableForHttps=true);
|
builder.Services.AddResponseCompression(o=>o.EnableForHttps=true);
|
||||||
builder.Services.AddSingleton<IHelpService,HelpService>();
|
builder.Services.AddSingleton<IHelpService,HelpService>();
|
||||||
@ -21,6 +22,6 @@ app.UseResponseCompression();
|
|||||||
app.UseDevelopmentNoIndex();
|
app.UseDevelopmentNoIndex();
|
||||||
app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse=c=>c.Context.Response.Headers.CacheControl="public,max-age=86400" });
|
app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse=c=>c.Context.Response.Headers.CacheControl="public,max-age=86400" });
|
||||||
app.MapGet("/robots.txt",(IWebHostEnvironment env)=>Results.Text(env.IsProduction()?"User-agent: *\nAllow: /\nDisallow: /Account/\nDisallow: /Pricing/Checkout\nSitemap: https://plotdirector.com/sitemap.xml\n":"User-agent: *\nDisallow: /\n","text/plain"));
|
app.MapGet("/robots.txt",(IWebHostEnvironment env)=>Results.Text(env.IsProduction()?"User-agent: *\nAllow: /\nDisallow: /Account/\nDisallow: /Pricing/Checkout\nSitemap: https://plotdirector.com/sitemap.xml\n":"User-agent: *\nDisallow: /\n","text/plain"));
|
||||||
app.MapGet("/health",()=>Results.Json(new {healthy=true,product="PlotDirector.Website"}));
|
app.MapGet("/health",()=>Results.Json(new {healthy=true,product="PlotDirector.Website",sourceCommit=typeof(Program).Assembly.GetCustomAttributes(typeof(System.Reflection.AssemblyInformationalVersionAttribute),false).Cast<System.Reflection.AssemblyInformationalVersionAttribute>().Single().InformationalVersion.Split('+').Last()}));
|
||||||
app.MapControllerRoute("default","{controller=Home}/{action=Index}/{id?}");
|
app.MapControllerRoute("default","{controller=Home}/{action=Index}/{id?}");
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|||||||
@ -9,7 +9,7 @@ public interface IHelpMarkdownRenderer
|
|||||||
string Render(string markdown);
|
string Render(string markdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed partial class HelpMarkdownRenderer(IHelpService help) : IHelpMarkdownRenderer
|
public sealed partial class HelpMarkdownRenderer(IHelpService help, IConfiguration configuration) : IHelpMarkdownRenderer
|
||||||
{
|
{
|
||||||
public string Render(string markdown)
|
public string Render(string markdown)
|
||||||
{
|
{
|
||||||
@ -143,6 +143,8 @@ public sealed partial class HelpMarkdownRenderer(IHelpService help) : IHelpMarkd
|
|||||||
{
|
{
|
||||||
var text = match.Groups["text"].Value;
|
var text = match.Groups["text"].Value;
|
||||||
var url = RewriteHelpUrl(match.Groups["url"].Value);
|
var url = RewriteHelpUrl(match.Groups["url"].Value);
|
||||||
|
if (url.StartsWith('/') && !url.StartsWith("//") && !url.StartsWith("/help", StringComparison.OrdinalIgnoreCase))
|
||||||
|
url = (configuration["Application:BaseUrl"] ?? "https://app.plotdirector.com").TrimEnd('/') + url;
|
||||||
return $"<a href=\"{url}\" target=\"_blank\" rel=\"noopener\">{text}</a>";
|
return $"<a href=\"{url}\" target=\"_blank\" rel=\"noopener\">{text}</a>";
|
||||||
});
|
});
|
||||||
encoded = StrongRegex().Replace(encoded, "<strong>$1</strong>");
|
encoded = StrongRegex().Replace(encoded, "<strong>$1</strong>");
|
||||||
|
|||||||
@ -20,22 +20,25 @@ public interface IHelpService
|
|||||||
IReadOnlyList<HelpCoverageItem> GetCoverage();
|
IReadOnlyList<HelpCoverageItem> GetCoverage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class HelpService(IWebHostEnvironment environment) : IHelpService
|
public sealed class HelpService(IWebHostEnvironment environment, IConfiguration configuration) : IHelpService
|
||||||
{
|
{
|
||||||
private readonly object cacheLock = new();
|
private readonly object cacheLock = new();
|
||||||
private IReadOnlyList<HelpArticle>? cachedArticles;
|
private IReadOnlyList<HelpArticle>? cachedArticles;
|
||||||
|
|
||||||
private DateTime packageModified;
|
private string? packageIdentity;
|
||||||
public IReadOnlyList<HelpArticle> GetAllArticles()
|
public IReadOnlyList<HelpArticle> GetAllArticles()
|
||||||
{
|
{
|
||||||
var package = Path.Combine(environment.ContentRootPath, "Help", "published", "articles.json");
|
var root = configuration["HelpContent:Path"] ?? Path.Combine(environment.ContentRootPath, "Help", "published");
|
||||||
var modified = File.GetLastWriteTimeUtc(package);
|
var directory = new DirectoryInfo(root);
|
||||||
|
root = directory.LinkTarget is null ? root : directory.ResolveLinkTarget(true)!.FullName;
|
||||||
|
var package = Path.Combine(root, "articles.json");
|
||||||
|
var identity = File.ReadAllText(Path.Combine(root, "manifest.json"));
|
||||||
lock(cacheLock)
|
lock(cacheLock)
|
||||||
{
|
{
|
||||||
if(cachedArticles is null || modified != packageModified)
|
if(cachedArticles is null || identity != packageIdentity)
|
||||||
{
|
{
|
||||||
cachedArticles = System.Text.Json.JsonSerializer.Deserialize<List<HelpArticle>>(File.ReadAllText(package))!;
|
cachedArticles = System.Text.Json.JsonSerializer.Deserialize<List<HelpArticle>>(File.ReadAllText(package))!;
|
||||||
packageModified = modified;
|
packageIdentity = identity;
|
||||||
}
|
}
|
||||||
return cachedArticles;
|
return cachedArticles;
|
||||||
}
|
}
|
||||||
|
|||||||
25
PlotDirector.Website/Services/WritingSolverTraversal.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using PlotDirector.Website.Models.WritingSolver;
|
||||||
|
namespace PlotDirector.Website.Services;
|
||||||
|
|
||||||
|
// The queue contains unique semantic states. Duplicate answers with identical evidence
|
||||||
|
// must not consume the distinct-state budget before they are dequeued.
|
||||||
|
public static class WritingSolverTraversal
|
||||||
|
{
|
||||||
|
public static string Key(SolverOutcome outcome) => string.Join(",",outcome.Answers.Select(a=>a.Node))+":"+
|
||||||
|
string.Join(",",outcome.Scores.OrderBy(s=>s.Key).Select(s=>$"{s.Key}={s.Value}"))+":"+outcome.Next?.Id;
|
||||||
|
public static IEnumerable<SolverAnswer[]> Extensions(SolverOutcome outcome)
|
||||||
|
{
|
||||||
|
if(outcome.Next is not {} node)yield break;
|
||||||
|
foreach(var choice in node.Choices.Where(c=>c.Active))yield return [..outcome.Answers,new(node.Id,[choice.Id])];
|
||||||
|
if(!node.Multiple)yield break;
|
||||||
|
var substantive=node.Choices.Where(c=>c.Active && !c.Fallback).ToArray();
|
||||||
|
if(substantive.Length>12)throw new InvalidDataException("Split multi-select nodes with more than 12 substantive choices.");
|
||||||
|
for(var mask=1;mask<(1<<substantive.Length);mask++)
|
||||||
|
{
|
||||||
|
if((mask & (mask-1))==0)continue;
|
||||||
|
var ids=substantive.Where((_,i)=>(mask & (1<<i))!=0).Select(c=>c.Id).ToArray();
|
||||||
|
if(node.MaxChoices>0 && ids.Length>node.MaxChoices)continue;
|
||||||
|
yield return [..outcome.Answers,new(node.Id,ids)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,7 +3,7 @@ namespace PlotDirector.Website.TagHelpers;
|
|||||||
[HtmlTargetElement("a",Attributes="asp-controller")]
|
[HtmlTargetElement("a",Attributes="asp-controller")]
|
||||||
public sealed class ApplicationLinkTagHelper(IConfiguration configuration):TagHelper
|
public sealed class ApplicationLinkTagHelper(IConfiguration configuration):TagHelper
|
||||||
{
|
{
|
||||||
public override int Order=>-1001;
|
public override int Order=>1001;
|
||||||
[HtmlAttributeName("asp-controller")] public string Controller {get;set;}="";
|
[HtmlAttributeName("asp-controller")] public string Controller {get;set;}="";
|
||||||
[HtmlAttributeName("asp-action")] public string Action {get;set;}="Index";
|
[HtmlAttributeName("asp-action")] public string Action {get;set;}="Index";
|
||||||
public override void Process(TagHelperContext context,TagHelperOutput output)
|
public override void Process(TagHelperContext context,TagHelperOutput output)
|
||||||
|
|||||||
@ -0,0 +1,11 @@
|
|||||||
|
@model (string Asset, string Alt)
|
||||||
|
@{
|
||||||
|
// Canonical PlotDirector captures, or an explicitly labelled alternative-theme composition.
|
||||||
|
var shared = Model.Asset switch { "plot-lines" => "plot-lines-weave", "workspace" => "series-project", "knowledge" => "character-knowledge", "continuity" => "continuity-story-state", "insights" => "timeline-story-values", _ => null };
|
||||||
|
var stem = shared is null ? "/images/public/application/" + Model.Asset : "/images/writing-solver/" + shared;
|
||||||
|
var dimensions = Model.Asset switch { "workspace" => (1440,760), "knowledge" => (1280,660), "person-fragment" => (380,110), "knowledge-fragment" => (1000,175), "dark-knowledge-fragment" => (1000,82), _ => (1280,800) };
|
||||||
|
}
|
||||||
|
<picture data-marketing-screenshot="@Model.Asset" data-screenshot-theme="@(Model.Asset.StartsWith("dark-", StringComparison.Ordinal) ? "modern-dark" : "plotdirector")">
|
||||||
|
<source type="image/avif" srcset="@(stem)-640.avif 640w, @(stem)-960.avif 960w, @(stem)-1280.avif 1280w" sizes="(max-width:600px) 90vw, (max-width:1000px) 80vw, 900px" />
|
||||||
|
<img src="@(stem)-1280.webp" srcset="@(stem)-640.webp 640w, @(stem)-960.webp 960w, @(stem)-1280.webp 1280w" sizes="(max-width:600px) 90vw, (max-width:1000px) 80vw, 900px" width="@dimensions.Item1" height="@dimensions.Item2" loading="lazy" decoding="async" alt="@Model.Alt" />
|
||||||
|
</picture>
|
||||||
@ -81,7 +81,7 @@
|
|||||||
}
|
}
|
||||||
else { <p><a class="editorial-link" href="/problem-solver/browse">Browse writing problems →</a></p><p class="solver-promises">A few quiet minutes <span>·</span> No sign-up required <span>·</span> Advice you can use straight away</p> }
|
else { <p><a class="editorial-link" href="/problem-solver/browse">Browse writing problems →</a></p><p class="solver-promises">A few quiet minutes <span>·</span> No sign-up required <span>·</span> Advice you can use straight away</p> }
|
||||||
@if(Model.Graph.IsDemo) { <p class="solver-demo">Preview journey · This small plot-line demonstration will grow into a curated collection of writing problems.</p> }
|
@if(Model.Graph.IsDemo) { <p class="solver-demo">Preview journey · This small plot-line demonstration will grow into a curated collection of writing problems.</p> }
|
||||||
<partial name="Review" model="Model" />
|
|
||||||
@if(presentation is not null){<partial name="ImageDialog" />}
|
@if(presentation is not null){<partial name="ImageDialog" />}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 57 KiB |
22
PlotDirector.Website/wwwroot/js/writing-solver.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
(() => {
|
||||||
|
const form = document.querySelector('.solver-form');
|
||||||
|
if (!form) return;
|
||||||
|
const inputs = [...form.querySelectorAll('input[name="choices"]')];
|
||||||
|
inputs.forEach(input => input.addEventListener('change', () => {
|
||||||
|
if (input.checked) inputs.forEach(other => {
|
||||||
|
if (other !== input && (input.closest('.solver-choice--fallback') || other.closest('.solver-choice--fallback'))) other.checked = false;
|
||||||
|
});
|
||||||
|
form.querySelector('.solver-selection-error').hidden = true;
|
||||||
|
}));
|
||||||
|
form.addEventListener('submit', event => {
|
||||||
|
const limit = Number(form.querySelector('fieldset').dataset.maxChoices || 0);
|
||||||
|
const count = inputs.filter(input => input.checked).length;
|
||||||
|
if (!count || (limit && count > limit)) {
|
||||||
|
event.preventDefault();
|
||||||
|
const error = form.querySelector('.solver-selection-error');
|
||||||
|
error.textContent = count ? `Please choose up to ${limit} areas so we can focus on what is troubling you most.` : 'Please choose an answer to continue.';
|
||||||
|
error.hidden = false;
|
||||||
|
inputs[0]?.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
@ -1,116 +1,16 @@
|
|||||||
# PlotDirector
|
# PlotDirector
|
||||||
|
|
||||||
## Summary
|
PlotDirector is novel planning and writing software for authors. This public
|
||||||
|
website describes released capabilities; the authenticated application is at
|
||||||
|
https://app.plotdirector.com. Public documentation is explicitly published from
|
||||||
|
the application repository.
|
||||||
|
|
||||||
PlotDirector is a web-based planning and continuity platform for novel writers. It helps authors organise stories from the earliest ideas through to the finished manuscript by bringing together timelines, characters, locations, plot threads, relationships, story metrics and writing tools within a single project.
|
- [Tour](https://plotdirector.com/features)
|
||||||
|
- [Pricing](https://plotdirector.com/pricing)
|
||||||
|
- [Problem Solver](https://plotdirector.com/problem-solver)
|
||||||
|
- [Help Centre](https://plotdirector.com/help)
|
||||||
|
- [About](https://plotdirector.com/about)
|
||||||
|
- [Contact](https://plotdirector.com/contact)
|
||||||
|
- [Sitemap](https://plotdirector.com/sitemap.xml)
|
||||||
|
|
||||||
Unlike traditional writing software, PlotDirector focuses on understanding the structure and continuity of a story. It analyses relationships between scenes, characters, locations, assets and knowledge to help authors identify inconsistencies before publication.
|
This supplementary guide does not replace the crawlable HTML or sitemap.
|
||||||
|
|
||||||
## Audience
|
|
||||||
|
|
||||||
PlotDirector is designed for:
|
|
||||||
|
|
||||||
* Novelists
|
|
||||||
* Fiction writers
|
|
||||||
* Authors writing book series
|
|
||||||
* Historical fiction authors
|
|
||||||
* Fantasy and science fiction authors
|
|
||||||
* Mystery and thriller writers
|
|
||||||
* Editors
|
|
||||||
* Developmental editors
|
|
||||||
|
|
||||||
## Core Features
|
|
||||||
|
|
||||||
* Multi-book project management
|
|
||||||
* Book, chapter and scene organisation
|
|
||||||
* Story Timeline
|
|
||||||
* Plot Threads
|
|
||||||
* Character management
|
|
||||||
* Character relationships
|
|
||||||
* Character knowledge tracking
|
|
||||||
* Character appearance tracking
|
|
||||||
* Locations
|
|
||||||
* Interactive floor plans
|
|
||||||
* Asset management
|
|
||||||
* Asset custody tracking
|
|
||||||
* Continuity Explorer
|
|
||||||
* Story Health metrics
|
|
||||||
* Writing Schedule Planner
|
|
||||||
* Writer Workspace
|
|
||||||
* Microsoft Word Companion
|
|
||||||
* Import and export
|
|
||||||
* Collaboration
|
|
||||||
|
|
||||||
## Public Pages
|
|
||||||
|
|
||||||
Home
|
|
||||||
https://plotdirector.com/
|
|
||||||
|
|
||||||
Features
|
|
||||||
https://plotdirector.com/features
|
|
||||||
|
|
||||||
Pricing
|
|
||||||
https://plotdirector.com/pricing
|
|
||||||
|
|
||||||
Help
|
|
||||||
https://plotdirector.com/help
|
|
||||||
|
|
||||||
About
|
|
||||||
https://plotdirector.com/about
|
|
||||||
|
|
||||||
Contact
|
|
||||||
https://plotdirector.com/contact
|
|
||||||
|
|
||||||
Privacy Policy
|
|
||||||
https://plotdirector.com/privacy
|
|
||||||
|
|
||||||
Terms of Service
|
|
||||||
https://plotdirector.com/terms
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
The Help section contains detailed documentation covering all major features together with workflow guidance and examples.
|
|
||||||
|
|
||||||
## Supported Platforms
|
|
||||||
|
|
||||||
* Modern desktop web browsers
|
|
||||||
* Microsoft Word via the PlotDirector Word Companion
|
|
||||||
* Windows
|
|
||||||
* macOS
|
|
||||||
|
|
||||||
## Terminology
|
|
||||||
|
|
||||||
Project
|
|
||||||
A collection of one or more related books.
|
|
||||||
|
|
||||||
Book
|
|
||||||
A novel within a project.
|
|
||||||
|
|
||||||
Chapter
|
|
||||||
A major division of a book.
|
|
||||||
|
|
||||||
Scene
|
|
||||||
The primary unit of planning and writing.
|
|
||||||
|
|
||||||
Plot Thread
|
|
||||||
A storyline that progresses through scenes.
|
|
||||||
|
|
||||||
Continuity Explorer
|
|
||||||
A tool for analysing character, asset and location continuity throughout a story.
|
|
||||||
|
|
||||||
Story Health
|
|
||||||
A collection of metrics that highlight structural strengths and potential issues within a manuscript.
|
|
||||||
|
|
||||||
Word Companion
|
|
||||||
A Microsoft Word add-in that synchronises manuscripts with PlotDirector.
|
|
||||||
|
|
||||||
## Company
|
|
||||||
|
|
||||||
PlotDirector
|
|
||||||
|
|
||||||
Website
|
|
||||||
https://plotdirector.com
|
|
||||||
|
|
||||||
## Copyright
|
|
||||||
|
|
||||||
Copyright © PlotDirector. All rights reserved.
|
|
||||||
|
|||||||
29
Tests/browser.cjs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
const { chromium }=require('playwright');
|
||||||
|
const fs=require('node:fs'),path=require('node:path'),assert=require('node:assert/strict');
|
||||||
|
const origin=process.env.WEBSITE_ORIGIN||'http://127.0.0.1:5051',out=process.env.EVIDENCE_DIR||'/tmp/plotdirector-website-browser';fs.mkdirSync(out,{recursive:true});
|
||||||
|
(async()=>{const browser=await chromium.launch({headless:true});const errors=[],failed=[],checks=[];try{
|
||||||
|
const context=await browser.newContext();const page=await context.newPage();page.on('pageerror',e=>errors.push(e.message));page.on('response',r=>{if(r.url().startsWith(origin)&&r.status()>=400)failed.push({url:r.url(),status:r.status()});});
|
||||||
|
for(const viewport of [{width:1440,height:1000},{width:390,height:844}]){
|
||||||
|
await page.setViewportSize(viewport);
|
||||||
|
for(const route of ['/','/features','/pricing','/problem-solver','/problem-solver/browse','/help','/about','/contact','/privacy','/terms']){
|
||||||
|
const r=await page.goto(origin+route);assert.equal(r.status(),200,route);await page.locator('main').waitFor();
|
||||||
|
assert(await page.locator('h1').count()>0,route+' heading');
|
||||||
|
const overflow=await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth+2);assert.equal(overflow,false,route+' horizontal overflow');
|
||||||
|
const broken=await page.locator('img').evaluateAll(async imgs=>{for(const img of imgs)img.loading='eager';await Promise.all(imgs.map(i=>i.decode().catch(()=>{})));return imgs.filter(i=>!i.naturalWidth).map(i=>i.currentSrc||i.src);});assert.deepEqual(broken,[],route+' loaded images');await page.evaluate(()=>document.fonts.ready);
|
||||||
|
await page.screenshot({path:path.join(out,`${viewport.width}-${route.replaceAll('/','-')||'home'}.png`),fullPage:true});checks.push(`${viewport.width} ${route}`);
|
||||||
|
}
|
||||||
|
if(viewport.width<500){await page.goto(origin+'/');await page.getByRole('button',{name:'Open navigation'}).click();await page.getByRole('navigation',{name:'Main navigation'}).getByRole('link',{name:'Tour',exact:true}).click();assert.equal(new URL(page.url()).pathname,'/features');checks.push('mobile navigation');}
|
||||||
|
}
|
||||||
|
await page.goto(origin+'/help?q=projects');assert(await page.locator('a[href^="/help/"]').count()>2);checks.push('server-rendered help search');
|
||||||
|
const help=JSON.parse(fs.readFileSync(path.join(__dirname,'../PlotDirector.Website/Help/published/articles.json')))[0];
|
||||||
|
await page.goto(origin+help.Url);assert.equal((await page.locator('h1').first().textContent()).trim(),help.Title);checks.push('published help article');
|
||||||
|
await page.goto(origin+'/problem-solver');let steps=0;
|
||||||
|
for(;steps<25;steps++){
|
||||||
|
const form=page.locator('form[action="/problem-solver/answer"]');if(!await form.count())break;
|
||||||
|
await form.locator('input[name="choices"]').first().check();await Promise.all([page.waitForNavigation(),form.locator('button[type="submit"]').click()]);
|
||||||
|
}
|
||||||
|
assert(steps>0&&steps<25,'solver completes bounded journey');assert(!page.url().includes('choose=true'));checks.push(`Problem Solver completed ${steps} answers`);await page.screenshot({path:path.join(out,'solver-completion.png'),fullPage:true});
|
||||||
|
assert.equal(await page.locator('link[rel="manifest"]').count(),0);assert.equal(await page.evaluate(async()=>('serviceWorker' in navigator)?(await navigator.serviceWorker.getRegistrations()).length:0),0);checks.push('no website PWA installation');
|
||||||
|
await page.setViewportSize({width:1440,height:1000});await page.goto(origin+'/');const account=await page.getByRole('link',{name:'Sign in',exact:true}).getAttribute('href');assert(account.startsWith(process.env.APPLICATION_ORIGIN||'https://dev.plotdirector.com'));checks.push('application account links');
|
||||||
|
assert.deepEqual(errors,[]);assert.deepEqual(failed,[]);fs.writeFileSync(path.join(out,'results.json'),JSON.stringify({passed:true,origin,checks,errors,failed},null,2));console.log(JSON.stringify({passed:true,checks:checks.length,out}));
|
||||||
|
}catch(e){fs.writeFileSync(path.join(out,'results.json'),JSON.stringify({passed:false,origin,checks,errors,failed,error:String(e)},null,2));throw e;}finally{await browser.close();}})().catch(e=>{console.error(e);process.exitCode=1;});
|
||||||
549
Tests/public-urls.json
Normal file
@ -0,0 +1,549 @@
|
|||||||
|
{
|
||||||
|
"source": "https://plotdirector.com/sitemap.xml",
|
||||||
|
"baselineCommit": "9dcd29d423b20e373e49fb28180d993c40aa165d",
|
||||||
|
"urls": [
|
||||||
|
"https://plotdirector.com/",
|
||||||
|
"https://plotdirector.com/features",
|
||||||
|
"https://plotdirector.com/pricing",
|
||||||
|
"https://plotdirector.com/help",
|
||||||
|
"https://plotdirector.com/about",
|
||||||
|
"https://plotdirector.com/contact",
|
||||||
|
"https://plotdirector.com/privacy",
|
||||||
|
"https://plotdirector.com/terms",
|
||||||
|
"https://plotdirector.com/help/archive",
|
||||||
|
"https://plotdirector.com/help/at-this-point",
|
||||||
|
"https://plotdirector.com/help/book-recovery",
|
||||||
|
"https://plotdirector.com/help/books",
|
||||||
|
"https://plotdirector.com/help/chapters",
|
||||||
|
"https://plotdirector.com/help/characters",
|
||||||
|
"https://plotdirector.com/help/floor-plans",
|
||||||
|
"https://plotdirector.com/help/getting-started",
|
||||||
|
"https://plotdirector.com/help/help-centre",
|
||||||
|
"https://plotdirector.com/help/imports",
|
||||||
|
"https://plotdirector.com/help/locations",
|
||||||
|
"https://plotdirector.com/help/maps",
|
||||||
|
"https://plotdirector.com/help/names-library",
|
||||||
|
"https://plotdirector.com/help/plot-lines",
|
||||||
|
"https://plotdirector.com/help/projects",
|
||||||
|
"https://plotdirector.com/help/relationship-map",
|
||||||
|
"https://plotdirector.com/help/restore-points",
|
||||||
|
"https://plotdirector.com/help/scenarios",
|
||||||
|
"https://plotdirector.com/help/scene-inspector",
|
||||||
|
"https://plotdirector.com/help/scene-metrics",
|
||||||
|
"https://plotdirector.com/help/scenes",
|
||||||
|
"https://plotdirector.com/help/story-assets",
|
||||||
|
"https://plotdirector.com/help/story-bible",
|
||||||
|
"https://plotdirector.com/help/story-calendar",
|
||||||
|
"https://plotdirector.com/help/story-dynamics",
|
||||||
|
"https://plotdirector.com/help/story-health",
|
||||||
|
"https://plotdirector.com/help/story-intelligence",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin",
|
||||||
|
"https://plotdirector.com/help/timeline",
|
||||||
|
"https://plotdirector.com/help/warnings",
|
||||||
|
"https://plotdirector.com/help/word-companion",
|
||||||
|
"https://plotdirector.com/help/workspace",
|
||||||
|
"https://plotdirector.com/help/archive/archived-items",
|
||||||
|
"https://plotdirector.com/help/archive/archived-records",
|
||||||
|
"https://plotdirector.com/help/at-this-point/assets-at-this-point",
|
||||||
|
"https://plotdirector.com/help/at-this-point/at-this-point",
|
||||||
|
"https://plotdirector.com/help/at-this-point/characters-at-this-point",
|
||||||
|
"https://plotdirector.com/help/at-this-point/choosing-a-story-point",
|
||||||
|
"https://plotdirector.com/help/at-this-point/continuity-checks-at-this-point",
|
||||||
|
"https://plotdirector.com/help/at-this-point/knowledge-at-this-point",
|
||||||
|
"https://plotdirector.com/help/at-this-point/location-at-this-point",
|
||||||
|
"https://plotdirector.com/help/at-this-point/relationships-at-this-point",
|
||||||
|
"https://plotdirector.com/help/at-this-point/threads-at-this-point",
|
||||||
|
"https://plotdirector.com/help/book-recovery/overview",
|
||||||
|
"https://plotdirector.com/help/books/book-chapters",
|
||||||
|
"https://plotdirector.com/help/books/book-number",
|
||||||
|
"https://plotdirector.com/help/books/books",
|
||||||
|
"https://plotdirector.com/help/books/create-or-edit-a-book",
|
||||||
|
"https://plotdirector.com/help/chapters/chapter-number",
|
||||||
|
"https://plotdirector.com/help/chapters/chapter-revision-status",
|
||||||
|
"https://plotdirector.com/help/chapters/chapter-scenes",
|
||||||
|
"https://plotdirector.com/help/chapters/chapters",
|
||||||
|
"https://plotdirector.com/help/chapters/create-or-edit-a-chapter",
|
||||||
|
"https://plotdirector.com/help/characters/attribute-history",
|
||||||
|
"https://plotdirector.com/help/characters/character-details",
|
||||||
|
"https://plotdirector.com/help/characters/character-knowledge",
|
||||||
|
"https://plotdirector.com/help/characters/characters",
|
||||||
|
"https://plotdirector.com/help/characters/confidence-intensity",
|
||||||
|
"https://plotdirector.com/help/characters/create-or-edit-a-character",
|
||||||
|
"https://plotdirector.com/help/characters/current-relationships",
|
||||||
|
"https://plotdirector.com/help/characters/initial-book",
|
||||||
|
"https://plotdirector.com/help/characters/initial-relationships",
|
||||||
|
"https://plotdirector.com/help/characters/reader-initially-knows",
|
||||||
|
"https://plotdirector.com/help/characters/reciprocal-relationship",
|
||||||
|
"https://plotdirector.com/help/characters/related-character",
|
||||||
|
"https://plotdirector.com/help/characters/relationship-awareness",
|
||||||
|
"https://plotdirector.com/help/characters/relationship-events",
|
||||||
|
"https://plotdirector.com/help/characters/relationship-notes",
|
||||||
|
"https://plotdirector.com/help/characters/relationship-type",
|
||||||
|
"https://plotdirector.com/help/characters/scene-appearances",
|
||||||
|
"https://plotdirector.com/help/characters/story-importance",
|
||||||
|
"https://plotdirector.com/help/floor-plans/add-block",
|
||||||
|
"https://plotdirector.com/help/floor-plans/add-floor",
|
||||||
|
"https://plotdirector.com/help/floor-plans/background-controls",
|
||||||
|
"https://plotdirector.com/help/floor-plans/background-image",
|
||||||
|
"https://plotdirector.com/help/floor-plans/block-location",
|
||||||
|
"https://plotdirector.com/help/floor-plans/block-type",
|
||||||
|
"https://plotdirector.com/help/floor-plans/block-width-and-height",
|
||||||
|
"https://plotdirector.com/help/floor-plans/create-transition",
|
||||||
|
"https://plotdirector.com/help/floor-plans/creating-floors-and-rooms",
|
||||||
|
"https://plotdirector.com/help/floor-plans/delete-block",
|
||||||
|
"https://plotdirector.com/help/floor-plans/existing-or-new-location",
|
||||||
|
"https://plotdirector.com/help/floor-plans/existing-transitions",
|
||||||
|
"https://plotdirector.com/help/floor-plans/floor-level",
|
||||||
|
"https://plotdirector.com/help/floor-plans/floor-name",
|
||||||
|
"https://plotdirector.com/help/floor-plans/floor-plan-best-practices",
|
||||||
|
"https://plotdirector.com/help/floor-plans/floor-plan-notes",
|
||||||
|
"https://plotdirector.com/help/floor-plans/floor-plans-overview",
|
||||||
|
"https://plotdirector.com/help/floor-plans/from-location",
|
||||||
|
"https://plotdirector.com/help/floor-plans/grid-coordinates",
|
||||||
|
"https://plotdirector.com/help/floor-plans/grid-height",
|
||||||
|
"https://plotdirector.com/help/floor-plans/grid-width",
|
||||||
|
"https://plotdirector.com/help/floor-plans/hidden-door",
|
||||||
|
"https://plotdirector.com/help/floor-plans/label-override",
|
||||||
|
"https://plotdirector.com/help/floor-plans/ladder",
|
||||||
|
"https://plotdirector.com/help/floor-plans/occupancy-mode",
|
||||||
|
"https://plotdirector.com/help/floor-plans/occupancy-scene-selector",
|
||||||
|
"https://plotdirector.com/help/floor-plans/occupancy-tokens",
|
||||||
|
"https://plotdirector.com/help/floor-plans/occupancy-warnings",
|
||||||
|
"https://plotdirector.com/help/floor-plans/occupants-on-other-floors",
|
||||||
|
"https://plotdirector.com/help/floor-plans/position-within-location",
|
||||||
|
"https://plotdirector.com/help/floor-plans/previous-and-next-scene",
|
||||||
|
"https://plotdirector.com/help/floor-plans/reference-floor",
|
||||||
|
"https://plotdirector.com/help/floor-plans/reference-floors-backgrounds-and-grid-guides",
|
||||||
|
"https://plotdirector.com/help/floor-plans/root-location",
|
||||||
|
"https://plotdirector.com/help/floor-plans/secret-passage",
|
||||||
|
"https://plotdirector.com/help/floor-plans/size-preset",
|
||||||
|
"https://plotdirector.com/help/floor-plans/stairs-ladders-and-floor-levels",
|
||||||
|
"https://plotdirector.com/help/floor-plans/stairs-up-and-down",
|
||||||
|
"https://plotdirector.com/help/floor-plans/structure-mode",
|
||||||
|
"https://plotdirector.com/help/floor-plans/to-location",
|
||||||
|
"https://plotdirector.com/help/floor-plans/transition-type",
|
||||||
|
"https://plotdirector.com/help/floor-plans/transitions-doors-and-entrances",
|
||||||
|
"https://plotdirector.com/help/floor-plans/transitions-toolbox",
|
||||||
|
"https://plotdirector.com/help/floor-plans/x-coordinate",
|
||||||
|
"https://plotdirector.com/help/floor-plans/y-coordinate",
|
||||||
|
"https://plotdirector.com/help/getting-started/first-book",
|
||||||
|
"https://plotdirector.com/help/help-centre/help-centre",
|
||||||
|
"https://plotdirector.com/help/imports/bring-your-writing-into-plotdirector",
|
||||||
|
"https://plotdirector.com/help/locations/child-locations",
|
||||||
|
"https://plotdirector.com/help/locations/create-or-edit-location",
|
||||||
|
"https://plotdirector.com/help/locations/location-details",
|
||||||
|
"https://plotdirector.com/help/locations/location-quick-add",
|
||||||
|
"https://plotdirector.com/help/locations/location-relationships",
|
||||||
|
"https://plotdirector.com/help/locations/location-type",
|
||||||
|
"https://plotdirector.com/help/locations/locations",
|
||||||
|
"https://plotdirector.com/help/locations/parent-location",
|
||||||
|
"https://plotdirector.com/help/locations/used-here",
|
||||||
|
"https://plotdirector.com/help/maps/maps-workspace",
|
||||||
|
"https://plotdirector.com/help/names-library/gender-prior",
|
||||||
|
"https://plotdirector.com/help/names-library/name-birth-year",
|
||||||
|
"https://plotdirector.com/help/names-library/name-commonness",
|
||||||
|
"https://plotdirector.com/help/names-library/name-locale",
|
||||||
|
"https://plotdirector.com/help/names-library/name-results",
|
||||||
|
"https://plotdirector.com/help/names-library/name-type",
|
||||||
|
"https://plotdirector.com/help/names-library/name-usage-filter",
|
||||||
|
"https://plotdirector.com/help/names-library/name-used-scope",
|
||||||
|
"https://plotdirector.com/help/names-library/names-library",
|
||||||
|
"https://plotdirector.com/help/plot-lines/create-or-edit-a-plot-line",
|
||||||
|
"https://plotdirector.com/help/plot-lines/create-or-edit-a-plot-thread",
|
||||||
|
"https://plotdirector.com/help/plot-lines/introduced-scene",
|
||||||
|
"https://plotdirector.com/help/plot-lines/main-plot",
|
||||||
|
"https://plotdirector.com/help/plot-lines/parent-plot-line",
|
||||||
|
"https://plotdirector.com/help/plot-lines/plot-line-book-scope",
|
||||||
|
"https://plotdirector.com/help/plot-lines/plot-line-type",
|
||||||
|
"https://plotdirector.com/help/plot-lines/plot-line-visibility",
|
||||||
|
"https://plotdirector.com/help/plot-lines/plot-lines",
|
||||||
|
"https://plotdirector.com/help/plot-lines/plot-lines-workspace",
|
||||||
|
"https://plotdirector.com/help/plot-lines/plot-thread-events",
|
||||||
|
"https://plotdirector.com/help/plot-lines/plot-thread-importance",
|
||||||
|
"https://plotdirector.com/help/plot-lines/plot-thread-status",
|
||||||
|
"https://plotdirector.com/help/plot-lines/plot-thread-type",
|
||||||
|
"https://plotdirector.com/help/plot-lines/plot-threads",
|
||||||
|
"https://plotdirector.com/help/plot-lines/plot-threads-plotthreads-index",
|
||||||
|
"https://plotdirector.com/help/plot-lines/thread-plot-line",
|
||||||
|
"https://plotdirector.com/help/plot-lines/thread-resolution",
|
||||||
|
"https://plotdirector.com/help/projects/genre-metric-preset",
|
||||||
|
"https://plotdirector.com/help/projects/project-books",
|
||||||
|
"https://plotdirector.com/help/projects/project-dashboard",
|
||||||
|
"https://plotdirector.com/help/projects/project-settings",
|
||||||
|
"https://plotdirector.com/help/projects/projects",
|
||||||
|
"https://plotdirector.com/help/relationship-map/relationship-map",
|
||||||
|
"https://plotdirector.com/help/restore-points/restore-points",
|
||||||
|
"https://plotdirector.com/help/scenarios/apply-scenario-to-main",
|
||||||
|
"https://plotdirector.com/help/scenarios/compare-scenario",
|
||||||
|
"https://plotdirector.com/help/scenarios/confirmation-text",
|
||||||
|
"https://plotdirector.com/help/scenarios/create-scenario",
|
||||||
|
"https://plotdirector.com/help/scenarios/main-vs-scenario",
|
||||||
|
"https://plotdirector.com/help/scenarios/scenario-scope",
|
||||||
|
"https://plotdirector.com/help/scenarios/scenario-timeline",
|
||||||
|
"https://plotdirector.com/help/scenarios/scenario-validation-notes",
|
||||||
|
"https://plotdirector.com/help/scenarios/scenarios",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/asset-event-type",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/asset-kind",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/asset-location",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/asset-locations",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/asset-selector",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/asset-state",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/assets",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/attachment-type",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/attachments-and-research",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/character-attribute-type",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/character-attribute-value",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/character-attributes",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/character-location-fields",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/character-presence",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/character-role",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/character-selector",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/characters",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/checklist-completion",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/continuity-warnings",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/custodians",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/custody",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/custody-event-type",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/custody-role",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/duration-unit",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/knowledge",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/knowledge-state",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/knowledge-subject",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/move-and-reorder",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/move-controls",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/other-character-knows",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/plot-thread-selector",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/primary-location",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/purpose-and-outcome",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/relationship-characters",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/relationship-intensity",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/relationship-selector",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/relationship-state",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/relationship-type",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/relationships",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/scene-checklist",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/scene-dependencies",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/scene-dependency-controls",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/scene-inspector",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/scene-note-type",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/scene-notes",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/scene-revision-status",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/story-state",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/thread-event-targets",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/thread-event-type",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/thread-marker-type",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/thread-type",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/threads",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/time",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/time-confidence",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/time-mode",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/update-current-location",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/warning-actions",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/word-companion-suggestions",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/writer-blocked",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/writer-priority",
|
||||||
|
"https://plotdirector.com/help/scene-inspector/writer-workspace",
|
||||||
|
"https://plotdirector.com/help/scene-metrics/active-metric",
|
||||||
|
"https://plotdirector.com/help/scene-metrics/add-scene-metric",
|
||||||
|
"https://plotdirector.com/help/scene-metrics/default-scene-metrics",
|
||||||
|
"https://plotdirector.com/help/scene-metrics/default-value",
|
||||||
|
"https://plotdirector.com/help/scene-metrics/edit-scene-metric",
|
||||||
|
"https://plotdirector.com/help/scene-metrics/maximum-value",
|
||||||
|
"https://plotdirector.com/help/scene-metrics/minimum-value",
|
||||||
|
"https://plotdirector.com/help/scene-metrics/project-scene-metrics",
|
||||||
|
"https://plotdirector.com/help/scene-metrics/scene-metrics",
|
||||||
|
"https://plotdirector.com/help/scene-metrics/sort-order",
|
||||||
|
"https://plotdirector.com/help/scenes/create-or-edit-a-scene",
|
||||||
|
"https://plotdirector.com/help/scenes/scenes",
|
||||||
|
"https://plotdirector.com/help/story-assets/asset-current-location-field",
|
||||||
|
"https://plotdirector.com/help/story-assets/asset-current-state-field",
|
||||||
|
"https://plotdirector.com/help/story-assets/dependency-description",
|
||||||
|
"https://plotdirector.com/help/story-assets/dependency-source-asset",
|
||||||
|
"https://plotdirector.com/help/story-assets/dependency-target-asset",
|
||||||
|
"https://plotdirector.com/help/story-assets/dependency-type",
|
||||||
|
"https://plotdirector.com/help/story-assets/edit-story-asset",
|
||||||
|
"https://plotdirector.com/help/story-assets/events-across-scenes",
|
||||||
|
"https://plotdirector.com/help/story-assets/show-in-quick-add-bar",
|
||||||
|
"https://plotdirector.com/help/story-assets/source-required-state",
|
||||||
|
"https://plotdirector.com/help/story-assets/story-asset-current-state",
|
||||||
|
"https://plotdirector.com/help/story-assets/story-asset-custody",
|
||||||
|
"https://plotdirector.com/help/story-assets/story-asset-dependencies",
|
||||||
|
"https://plotdirector.com/help/story-assets/story-asset-details",
|
||||||
|
"https://plotdirector.com/help/story-assets/story-asset-importance",
|
||||||
|
"https://plotdirector.com/help/story-assets/story-asset-kind",
|
||||||
|
"https://plotdirector.com/help/story-assets/story-asset-resolved",
|
||||||
|
"https://plotdirector.com/help/story-assets/story-assets",
|
||||||
|
"https://plotdirector.com/help/story-assets/target-blocked-state",
|
||||||
|
"https://plotdirector.com/help/story-bible/story-bible",
|
||||||
|
"https://plotdirector.com/help/story-bible/story-bible-attention-items",
|
||||||
|
"https://plotdirector.com/help/story-bible/story-bible-revision-status",
|
||||||
|
"https://plotdirector.com/help/story-bible/story-bible-timeline-summary",
|
||||||
|
"https://plotdirector.com/help/story-calendar/calendar-book-filter",
|
||||||
|
"https://plotdirector.com/help/story-calendar/calendar-month-selection",
|
||||||
|
"https://plotdirector.com/help/story-calendar/calendar-month-view-and-navigation",
|
||||||
|
"https://plotdirector.com/help/story-calendar/calendar-selected-day",
|
||||||
|
"https://plotdirector.com/help/story-calendar/calendar-unplaced-scenes",
|
||||||
|
"https://plotdirector.com/help/story-calendar/story-calendar",
|
||||||
|
"https://plotdirector.com/help/story-dynamics/story-dynamics",
|
||||||
|
"https://plotdirector.com/help/story-health/pacing-review",
|
||||||
|
"https://plotdirector.com/help/story-health/plot-thread-health",
|
||||||
|
"https://plotdirector.com/help/story-health/revision-summary",
|
||||||
|
"https://plotdirector.com/help/story-health/scene-metric-shape",
|
||||||
|
"https://plotdirector.com/help/story-health/scene-purpose-balance",
|
||||||
|
"https://plotdirector.com/help/story-health/story-asset-health",
|
||||||
|
"https://plotdirector.com/help/story-health/story-health",
|
||||||
|
"https://plotdirector.com/help/story-health/warning-hotspots",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/analysis-already-started",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/appearance-baseline",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/asset-review-decisions",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/author-plot-context",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/awareness-of-a-relationship-state",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/cancel-or-continue-analysis",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/candidate-for-merge",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/character-knowledge-state",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/character-review-decisions",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/choosing-story-and-portrait-defaults",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/current-analysis-activity",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/existing-plot-line-for-merge",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/existing-related-plot-line",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/following-manuscript-analysis",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/include-a-proposed-timeline-event",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/knowledge-merge-target",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/knowledge-review-decisions",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/latest-scene-summary",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/location-review-decisions",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/location-review-filters",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/name-to-import",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/narrative-event-description",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/narrative-event-title",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/narrative-timeline-event-type",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/parent-location",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/plot-line-and-thread-decisions",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/plot-line-guidance",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/preparing-story-intelligence",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/primary-character-age-group",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/proposed-narrative-timeline-events",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/proposed-parent-plot-line",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/recent-story-discoveries",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/relationship-development-or-discovery",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/relationship-direction",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/relationship-emotional-intensity",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/relationship-scene-proposal-decisions",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/relationship-state-in-this-scene",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/relationship-track",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/reverse-relationship-direction",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/reviewing-plot-lines-and-threads",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/reviewing-story-intelligence-assets",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/reviewing-story-intelligence-characters",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/reviewing-story-intelligence-knowledge",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/reviewing-story-intelligence-locations",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/reviewing-story-intelligence-relationships",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/same-asset-as",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/same-character-as",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/same-location-as",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/story-and-portrait-context",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/story-database-build-summary",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/story-era-baseline",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/story-intelligence-completion",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/story-intelligence-review-centre",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/story-intelligence-scene-metrics",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/story-intelligence-workflow",
|
||||||
|
"https://plotdirector.com/help/story-intelligence/story-location-baseline",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/admin-story-intelligence-import-preview",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/analyse-an-existing-chapter",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/analysis-book-context",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/analysis-chapter-context",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/analysis-chapter-number",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/analysis-configuration-status",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/analysis-project-context",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/analysis-prompt-availability",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/analysis-run-metadata",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/analysis-scene-context",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/analysis-scene-number",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/analysis-source-label",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/chapter-analysis-pre-flight",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/chapter-analysis-result",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/chapter-structure-test-model",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/chapter-test-source-text",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/chapter-text-upload",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/combined-chapter-analysis-test",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/confirming-an-admin-scene-import",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/development-data-reset",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/full-chapter-analysis-test",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/illustration-admin-notes",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/illustration-category-filter",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/illustration-generation-prompt",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/illustration-generation-queue",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/illustration-library-search",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/illustration-metadata",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/illustration-specification",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/illustration-status-filter",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/inspecting-a-story-intelligence-run",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/parsed-analysis-output",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/raw-analysis-response",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/reviewing-a-library-illustration",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/saved-story-intelligence-runs",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/scene-analysis-results",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/scene-intelligence-test-model",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/scene-test-context-output",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/scene-test-source-text",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/selected-chapter-source",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/story-intelligence-diagnostics",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/story-intelligence-illustration-library",
|
||||||
|
"https://plotdirector.com/help/story-intelligence-admin/story-intelligence-scene-dry-run",
|
||||||
|
"https://plotdirector.com/help/timeline/asset-events",
|
||||||
|
"https://plotdirector.com/help/timeline/character-appearances",
|
||||||
|
"https://plotdirector.com/help/timeline/filters-and-focus",
|
||||||
|
"https://plotdirector.com/help/timeline/metrics",
|
||||||
|
"https://plotdirector.com/help/timeline/plot-line-scene-filtering",
|
||||||
|
"https://plotdirector.com/help/timeline/plot-lines",
|
||||||
|
"https://plotdirector.com/help/timeline/plot-thread-review",
|
||||||
|
"https://plotdirector.com/help/timeline/saved-view-name",
|
||||||
|
"https://plotdirector.com/help/timeline/saved-views",
|
||||||
|
"https://plotdirector.com/help/timeline/scene-cards",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-asset-dependency-drop",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-asset-drop-event",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-book-filter",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-chapter-range",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-character-drop-role",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-density",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-focus-id",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-focus-type",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-jump-controls",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-location-filter",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-location-relationship-drop",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-metric-editing",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-pov-character-filter",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-revision-status-filter",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-scene-purpose-filter",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-scene-range",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-warning-options",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-warning-severity-filter",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-warning-type-filter",
|
||||||
|
"https://plotdirector.com/help/timeline/timeline-zoom",
|
||||||
|
"https://plotdirector.com/help/warnings/continuity-warnings",
|
||||||
|
"https://plotdirector.com/help/warnings/warning-list",
|
||||||
|
"https://plotdirector.com/help/warnings/warning-severity-summary",
|
||||||
|
"https://plotdirector.com/help/warnings/warning-type-summary",
|
||||||
|
"https://plotdirector.com/help/word-companion/install",
|
||||||
|
"https://plotdirector.com/help/workspace/chapter-goals",
|
||||||
|
"https://plotdirector.com/help/workspace/chapter-workflow",
|
||||||
|
"https://plotdirector.com/help/workspace/desktop",
|
||||||
|
"https://plotdirector.com/help/workspace/explore-your-story",
|
||||||
|
"https://plotdirector.com/help/workspace/final-pass",
|
||||||
|
"https://plotdirector.com/help/workspace/plan-your-writing",
|
||||||
|
"https://plotdirector.com/help/workspace/practical-blockers",
|
||||||
|
"https://plotdirector.com/help/workspace/read-notice-and-decide",
|
||||||
|
"https://plotdirector.com/help/workspace/reflect-on-your-writing",
|
||||||
|
"https://plotdirector.com/help/workspace/review-your-writing",
|
||||||
|
"https://plotdirector.com/help/workspace/revision-queue",
|
||||||
|
"https://plotdirector.com/help/workspace/word-and-your-writing-focus",
|
||||||
|
"https://plotdirector.com/help/workspace/work-through-a-story-concern",
|
||||||
|
"https://plotdirector.com/help/workspace/workflow-summary",
|
||||||
|
"https://plotdirector.com/help/workspace/workspace-reminders",
|
||||||
|
"https://plotdirector.com/help/workspace/write",
|
||||||
|
"https://plotdirector.com/help/workspace/write-intentions-and-reminders",
|
||||||
|
"https://plotdirector.com/help/workspace/write-next",
|
||||||
|
"https://plotdirector.com/help/workspace/writer-home",
|
||||||
|
"https://plotdirector.com/help/workspace/writer-workspace",
|
||||||
|
"https://plotdirector.com/help/workspace/writer-workspace-layout",
|
||||||
|
"https://plotdirector.com/help/workspace/writing-dashboard",
|
||||||
|
"https://plotdirector.com/help/workspace/writing-plans-and-recorded-work",
|
||||||
|
"https://plotdirector.com/help/workspace/your-working-context"
|
||||||
|
],
|
||||||
|
"nonIndexedPublicRoutes": [
|
||||||
|
"/problem-solver",
|
||||||
|
"/problem-solver/browse",
|
||||||
|
"/problem-solver/browse/plots",
|
||||||
|
"/problem-solver/browse/people",
|
||||||
|
"/problem-solver/browse/relationships",
|
||||||
|
"/problem-solver/browse/knowledge",
|
||||||
|
"/problem-solver/browse/time",
|
||||||
|
"/problem-solver/browse/structure",
|
||||||
|
"/problem-solver/browse/world",
|
||||||
|
"/problem-solver/browse/revision",
|
||||||
|
"/problem-solver/browse/projects",
|
||||||
|
"/problem-solver/too-many-storylines-to-manage",
|
||||||
|
"/problem-solver/storyline-disappears-for-too-long",
|
||||||
|
"/problem-solver/storylines-dont-connect",
|
||||||
|
"/problem-solver/one-storyline-is-taking-over",
|
||||||
|
"/problem-solver/scenes-with-no-clear-purpose",
|
||||||
|
"/problem-solver/setups-without-payoffs",
|
||||||
|
"/problem-solver/story-feels-like-unconnected-events",
|
||||||
|
"/problem-solver/too-many-characters-to-manage",
|
||||||
|
"/problem-solver/characters-doing-the-same-job",
|
||||||
|
"/problem-solver/character-disappears-for-too-long",
|
||||||
|
"/problem-solver/character-presence-is-unbalanced",
|
||||||
|
"/problem-solver/pov-characters-are-unbalanced",
|
||||||
|
"/problem-solver/character-details-dont-match",
|
||||||
|
"/problem-solver/losing-track-of-character-whereabouts",
|
||||||
|
"/problem-solver/too-many-character-relationships",
|
||||||
|
"/problem-solver/relationship-stage-is-unclear",
|
||||||
|
"/problem-solver/relationship-changes-too-quickly",
|
||||||
|
"/problem-solver/relationship-stops-developing",
|
||||||
|
"/problem-solver/characters-see-relationship-differently",
|
||||||
|
"/problem-solver/relationship-changes-have-too-many-consequences",
|
||||||
|
"/problem-solver/character-knows-something-too-early",
|
||||||
|
"/problem-solver/cant-remember-how-character-learned-something",
|
||||||
|
"/problem-solver/different-povs-know-different-things",
|
||||||
|
"/problem-solver/revelations-are-in-the-wrong-order",
|
||||||
|
"/problem-solver/too-many-clues-to-keep-track-of",
|
||||||
|
"/problem-solver/reveal-timing-doesnt-feel-right",
|
||||||
|
"/problem-solver/timeline-doesnt-add-up",
|
||||||
|
"/problem-solver/elapsed-time-doesnt-work",
|
||||||
|
"/problem-solver/character-age-doesnt-match-dates",
|
||||||
|
"/problem-solver/story-order-differs-from-chronology",
|
||||||
|
"/problem-solver/too-many-events-happening-at-once",
|
||||||
|
"/problem-solver/fiction-must-fit-real-dates",
|
||||||
|
"/problem-solver/too-many-scenes-to-organise",
|
||||||
|
"/problem-solver/dont-know-where-scene-belongs",
|
||||||
|
"/problem-solver/chapter-structure-feels-unbalanced",
|
||||||
|
"/problem-solver/scenes-repeat-the-same-job",
|
||||||
|
"/problem-solver/afraid-to-rearrange-the-story",
|
||||||
|
"/problem-solver/character-movement-doesnt-make-sense",
|
||||||
|
"/problem-solver/location-details-have-changed",
|
||||||
|
"/problem-solver/dont-know-where-important-object-is",
|
||||||
|
"/problem-solver/wrong-character-has-an-object",
|
||||||
|
"/problem-solver/object-history-contradicts-itself",
|
||||||
|
"/problem-solver/story-stops-moving",
|
||||||
|
"/problem-solver/pacing-is-uneven",
|
||||||
|
"/problem-solver/tension-is-uneven",
|
||||||
|
"/problem-solver/character-arc-stops-developing",
|
||||||
|
"/problem-solver/too-much-happens-near-the-end",
|
||||||
|
"/problem-solver/changes-have-unexpected-consequences",
|
||||||
|
"/problem-solver/comparing-different-story-versions",
|
||||||
|
"/problem-solver/series-continuity-is-too-big-to-remember",
|
||||||
|
"/problem-solver/storyline-spans-several-books",
|
||||||
|
"/problem-solver/novel-is-too-much-to-hold-in-your-head",
|
||||||
|
"/features/plot-lines",
|
||||||
|
"/features/timeline",
|
||||||
|
"/features/scenes-and-chapters",
|
||||||
|
"/features/characters",
|
||||||
|
"/features/relationships",
|
||||||
|
"/features/knowledge-and-revelations",
|
||||||
|
"/features/character-development",
|
||||||
|
"/features/locations",
|
||||||
|
"/features/important-objects",
|
||||||
|
"/features/continuity",
|
||||||
|
"/features/scenarios",
|
||||||
|
"/features/books-and-series",
|
||||||
|
"/features/manuscript-import",
|
||||||
|
"/features/story-organisation",
|
||||||
|
"/features/story-flow"
|
||||||
|
],
|
||||||
|
"routeTemplates": [
|
||||||
|
"GET /help?q={query}",
|
||||||
|
"GET /Help/Category/{category}",
|
||||||
|
"GET /Help/Article/{contextKey}",
|
||||||
|
"* /writing-problems/{**path} => 308 /problem-solver/{**path}",
|
||||||
|
"POST /problem-solver/answer",
|
||||||
|
"GET /problem-solver?state={protectedHistory}"
|
||||||
|
],
|
||||||
|
"crawlerFiles": [
|
||||||
|
"/robots.txt",
|
||||||
|
"/sitemap.xml",
|
||||||
|
"/llms.txt",
|
||||||
|
"/llms-full.txt"
|
||||||
|
]
|
||||||
|
}
|
||||||
48
Tests/test_deployment.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import hashlib,importlib.util,json,subprocess,sys,tarfile,tempfile,unittest
|
||||||
|
from pathlib import Path
|
||||||
|
ROOT=Path(__file__).resolve().parents[1]
|
||||||
|
sys.path.insert(0,str(ROOT/'Tools/Deployment'))
|
||||||
|
import website_release as release
|
||||||
|
|
||||||
|
class SignedReleaseTests(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.temp=tempfile.TemporaryDirectory();self.root=Path(self.temp.name);self.key=self.root/'key';self.public=self.root/'public'
|
||||||
|
subprocess.run(['openssl','genpkey','-algorithm','Ed25519','-out',str(self.key)],check=True,stderr=subprocess.DEVNULL)
|
||||||
|
subprocess.run(['openssl','pkey','-in',str(self.key),'-pubout','-out',str(self.public)],check=True,stderr=subprocess.DEVNULL)
|
||||||
|
def tearDown(self):self.temp.cleanup()
|
||||||
|
def bundle(self,product='PlotDirector.Website',extra=None):
|
||||||
|
raw=self.root/'raw';raw.mkdir();payload=self.root/'payload';(payload/'app').mkdir(parents=True)
|
||||||
|
(payload/'app/PlotDirector.Website.runtimeconfig.json').write_text('{"runtimeOptions":{"tfm":"net10.0"}}')
|
||||||
|
files={'app/PlotDirector.Website.runtimeconfig.json':release.file_digest(payload/'app/PlotDirector.Website.runtimeconfig.json')}
|
||||||
|
m={'format':1,'product':product,'release_id':'test-release','source_commit':'a'*40,'files':files};(payload/'manifest.json').write_bytes(release.canonical(m))
|
||||||
|
with tarfile.open(raw/'package.tar','w',format=tarfile.USTAR_FORMAT) as tar:
|
||||||
|
for name in ['manifest.json',*files]:tar.add(payload/name,arcname=name)
|
||||||
|
if extra:
|
||||||
|
import io
|
||||||
|
item=tarfile.TarInfo(extra);item.size=1;tar.addfile(item,io.BytesIO(b'x'))
|
||||||
|
auth={'format':1,'release_id':'test-release','source_commit':'a'*40,'package_sha256':release.file_digest(raw/'package.tar'),'manifest_sha256':release.file_digest(payload/'manifest.json')}
|
||||||
|
(raw/'authorization.json').write_bytes(release.canonical(auth));release.sign(raw/'authorization.json',self.key)
|
||||||
|
output=self.root/'bundle';release.compress_bundle(raw,output,self.key,self.public,verified=True);return output
|
||||||
|
def verify(self,bundle):
|
||||||
|
with tempfile.TemporaryDirectory() as temp:return release.verify(bundle,Path(temp),self.public)[0]
|
||||||
|
def test_valid_compressed_release(self):self.assertEqual(self.verify(self.bundle())['product'],'PlotDirector.Website')
|
||||||
|
def test_wrong_product(self):
|
||||||
|
with self.assertRaises(Exception):self.verify(self.bundle(product='PlotLine'))
|
||||||
|
def test_tampered_payload(self):
|
||||||
|
bundle=self.bundle();p=bundle/'package.tar.zst';p.write_bytes(p.read_bytes()+b'corrupt')
|
||||||
|
with self.assertRaises(Exception):self.verify(bundle)
|
||||||
|
def test_tampered_authorization(self):
|
||||||
|
bundle=self.bundle();p=bundle/'authorization.json';p.write_bytes(p.read_bytes()+b' ')
|
||||||
|
with self.assertRaises(Exception):self.verify(bundle)
|
||||||
|
def test_signed_path_traversal(self):
|
||||||
|
with self.assertRaises(Exception):self.verify(self.bundle(extra='../outside'))
|
||||||
|
def test_signed_unexpected_file(self):
|
||||||
|
with self.assertRaises(Exception):self.verify(self.bundle(extra='sql/migration.sql'))
|
||||||
|
def test_unknown_bundle_file(self):
|
||||||
|
bundle=self.bundle();(bundle/'extra').write_text('unexpected')
|
||||||
|
with self.assertRaises(Exception):self.verify(bundle)
|
||||||
|
def test_symlink_bundle_member(self):
|
||||||
|
bundle=self.bundle();p=bundle/'transport.json';p.rename(bundle/'saved');p.symlink_to(bundle/'saved')
|
||||||
|
with self.assertRaises(Exception):self.verify(bundle)
|
||||||
|
|
||||||
|
if __name__=='__main__':unittest.main()
|
||||||
69
Tests/verify.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Rendered HTTP compatibility and crawl validation against a running website."""
|
||||||
|
import argparse,concurrent.futures,json,sys,urllib.request,urllib.parse,xml.etree.ElementTree as ET
|
||||||
|
from html.parser import HTMLParser
|
||||||
|
from pathlib import Path
|
||||||
|
class Page(HTMLParser):
|
||||||
|
def __init__(self):super().__init__();self.links=[];self.assets=[];self.canonical=[];self.description=[];self.title='';self.in_title=False;self.ld=[];self.in_ld=False
|
||||||
|
def handle_starttag(self,tag,attrs):
|
||||||
|
a=dict(attrs)
|
||||||
|
if tag=='a' and a.get('href'):self.links.append(a['href'])
|
||||||
|
if tag=='img' and a.get('src'):self.assets.append(a['src'])
|
||||||
|
if tag=='script' and a.get('src'):self.assets.append(a['src'])
|
||||||
|
if tag=='link' and a.get('rel')=='stylesheet':self.assets.append(a['href'])
|
||||||
|
if tag=='link' and a.get('rel')=='canonical':self.canonical.append(a.get('href'))
|
||||||
|
if tag=='meta' and a.get('name')=='description':self.description.append(a.get('content'))
|
||||||
|
if tag=='title':self.in_title=True
|
||||||
|
if tag=='script' and a.get('type')=='application/ld+json':self.in_ld=True;self.ld.append('')
|
||||||
|
def handle_endtag(self,tag):
|
||||||
|
if tag=='title':self.in_title=False
|
||||||
|
if tag=='script':self.in_ld=False
|
||||||
|
def handle_data(self,data):
|
||||||
|
if self.in_title:self.title+=data
|
||||||
|
if self.in_ld:self.ld[-1]+=data
|
||||||
|
|
||||||
|
def run(origin,production=False):
|
||||||
|
root=Path(__file__).resolve().parents[1];public=json.loads((root/'Tests/public-urls.json').read_text())['urls']
|
||||||
|
graph=json.loads((root/'PlotDirector.Website/Content/solver.json').read_text());editorial=json.loads((root/'PlotDirector.Website/Content/WritingSolver/Editorial/pages-v1.json').read_text())
|
||||||
|
urls={urllib.parse.urlsplit(u).path for u in public}
|
||||||
|
urls|={'/problem-solver','/problem-solver/browse'}|{'/problem-solver/browse/'+a['id'] for a in editorial['areas']}
|
||||||
|
urls|={'/problem-solver/'+s['slug'] for s in graph['solutions'] if s['active']}
|
||||||
|
urls|={'/features/'+s['slug'] for s in graph['features'] if s['active']}
|
||||||
|
errors=[];pages={};assets=set();links=set()
|
||||||
|
def fetch(path):
|
||||||
|
with urllib.request.urlopen(origin+path,timeout=30) as r:return r.status,r.read(),dict(r.headers)
|
||||||
|
def check(path):
|
||||||
|
try:
|
||||||
|
status,data,headers=fetch(path);p=Page();p.feed(data.decode());return path,p,headers,None
|
||||||
|
except Exception as e:return path,None,{},str(e)
|
||||||
|
with concurrent.futures.ThreadPoolExecutor(max_workers=6) as pool:
|
||||||
|
for path,p,headers,error in pool.map(check,sorted(urls)):
|
||||||
|
if error:errors.append(path+': '+error);continue
|
||||||
|
pages[path]=p
|
||||||
|
if len(p.canonical)!=1 or p.canonical[0]!='https://plotdirector.com'+path:errors.append(path+': wrong canonical')
|
||||||
|
if not p.title.strip() or not p.description or not p.description[0]:errors.append(path+': missing metadata')
|
||||||
|
if not p.ld:errors.append(path+': missing JSON-LD')
|
||||||
|
for ld in p.ld:
|
||||||
|
try:json.loads(ld)
|
||||||
|
except ValueError:errors.append(path+': invalid JSON-LD')
|
||||||
|
robots=headers.get('X-Robots-Tag','')
|
||||||
|
if not production and 'noindex' not in robots:errors.append(path+': Development indexing exposure')
|
||||||
|
if production and path in {urllib.parse.urlsplit(u).path for u in public} and 'noindex' in robots:errors.append(path+': Production public page noindex')
|
||||||
|
for link in p.links:
|
||||||
|
if link.startswith('/') and not link.startswith('//') and not link.startswith('/Pricing/Checkout'):
|
||||||
|
parsed=urllib.parse.urlsplit(link);links.add(parsed.path)
|
||||||
|
assets.update(urllib.parse.urlsplit(a).path for a in p.assets if a.startswith('/'))
|
||||||
|
if 'service-worker' in ' '.join(p.assets) or any('site.webmanifest' in a for a in p.assets):errors.append(path+': application PWA asset')
|
||||||
|
for path in sorted((assets|links)-set(pages)):
|
||||||
|
try:fetch(path)
|
||||||
|
except Exception as e:errors.append(path+': broken internal link/asset '+str(e))
|
||||||
|
_,sitemap,_=fetch('/sitemap.xml');sitemap_urls={u.text for u in ET.fromstring(sitemap).findall('.//{*}loc')}
|
||||||
|
if sitemap_urls!=set(public):errors.append('Sitemap differs from approved Production URL inventory')
|
||||||
|
for path in ['/missing-page-acceptance','/help/missing/missing','/site.webmanifest','/service-worker.js','/hubs/word-companion-follow']:
|
||||||
|
try:fetch(path);errors.append(path+': expected 404')
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
if e.code!=404:errors.append(path+': expected 404 got '+str(e.code))
|
||||||
|
report={'origin':origin,'productionPolicy':production,'baselineUrls':len(public),'renderedPages':len(pages),'internalPaths':len(links),'assets':len(assets),'errors':errors,'passed':not errors}
|
||||||
|
print(json.dumps(report,indent=2));return bool(errors)
|
||||||
|
if __name__=='__main__':
|
||||||
|
p=argparse.ArgumentParser();p.add_argument('--origin',required=True);p.add_argument('--production',action='store_true');a=p.parse_args();sys.exit(run(a.origin.rstrip('/'),a.production))
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
exec /usr/bin/env -i PATH=/usr/bin:/bin LANG=C.UTF-8 PLOTDIRECTOR_WEBSITE_TARGET=Production /usr/bin/python3 -I /usr/local/lib/plotdirector-website-deployment/website_release.py "$@"
|
||||||
28
Tools/Deployment/production/nginx-application.conf
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# HTTP challenge preparation can precede TLS issuance only after approval.
|
||||||
|
server {
|
||||||
|
listen 80; listen [::]:80;
|
||||||
|
server_name app.plotdirector.com;
|
||||||
|
location ^~ /.well-known/acme-challenge/ { root /srv/plotdirector/acme; default_type text/plain; }
|
||||||
|
location / { return 301 https://app.plotdirector.com$request_uri; }
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 443 ssl; listen [::]:443 ssl;
|
||||||
|
server_name app.plotdirector.com;
|
||||||
|
ssl_certificate /etc/letsencrypt/live/app.plotdirector.com/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/app.plotdirector.com/privkey.pem;
|
||||||
|
access_log /var/log/nginx/plotdirector-app-access.log;
|
||||||
|
error_log /var/log/nginx/plotdirector-app-error.log;
|
||||||
|
client_max_body_size 100m;
|
||||||
|
add_header X-Robots-Tag "noindex, nofollow" always;
|
||||||
|
location ~* ^/_deployment(?:/|$) { return 404; }
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:5001;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $plotdirector_website_upgrade;
|
||||||
|
proxy_read_timeout 120s;
|
||||||
|
}
|
||||||
|
}
|
||||||
15
Tools/Deployment/production/nginx-development.conf
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Optional public HTTPS edge host on the existing Development reverse proxy.
|
||||||
|
# Requires website-dev.plotdirector.com DNS and a matching certificate.
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name website-dev.plotdirector.com;
|
||||||
|
ssl_certificate /etc/letsencrypt/live/website-dev.plotdirector.com/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/website-dev.plotdirector.com/privkey.pem;
|
||||||
|
add_header X-Robots-Tag "noindex, nofollow" always;
|
||||||
|
location / {
|
||||||
|
proxy_pass http://192.168.10.10:5051;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
52
Tools/Deployment/production/nginx-website.conf
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# Merge with the reviewed live PlotDirector configuration; do not enable two vhosts
|
||||||
|
# for the same host. Preserve existing maintenance, verification and ACME locations.
|
||||||
|
map $http_upgrade $plotdirector_website_upgrade { default upgrade; '' close; }
|
||||||
|
server {
|
||||||
|
listen 80; listen [::]:80;
|
||||||
|
server_name plotdirector.com www.plotdirector.com;
|
||||||
|
location ^~ /.well-known/acme-challenge/ { root /srv/plotdirector/acme; default_type text/plain; }
|
||||||
|
location / { return 301 https://plotdirector.com$request_uri; }
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 443 ssl; listen [::]:443 ssl;
|
||||||
|
server_name www.plotdirector.com;
|
||||||
|
ssl_certificate /etc/letsencrypt/live/plotdirector.com/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/plotdirector.com/privkey.pem;
|
||||||
|
return 301 https://plotdirector.com$request_uri;
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 443 ssl; listen [::]:443 ssl;
|
||||||
|
server_name plotdirector.com;
|
||||||
|
ssl_certificate /etc/letsencrypt/live/plotdirector.com/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/plotdirector.com/privkey.pem;
|
||||||
|
access_log /var/log/nginx/plotdirector-website-access.log;
|
||||||
|
error_log /var/log/nginx/plotdirector-website-error.log;
|
||||||
|
client_max_body_size 100m;
|
||||||
|
gzip on;
|
||||||
|
gzip_types text/plain text/css application/javascript application/json application/xml image/svg+xml;
|
||||||
|
location ~* ^/_deployment(?:/|$) { return 404; }
|
||||||
|
# Request bodies, bearer credentials and websocket upgrades must reach the app.
|
||||||
|
# Browser redirects are insufficient for these legacy integration clients.
|
||||||
|
location ~* ^/(api|hubs|native-companion|word-companion|uploads)(?:/|$) {
|
||||||
|
proxy_pass http://127.0.0.1:5001;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $plotdirector_website_upgrade;
|
||||||
|
proxy_read_timeout 120s;
|
||||||
|
add_header X-Robots-Tag "noindex, nofollow" always;
|
||||||
|
}
|
||||||
|
location ~* ^/(Acceptance|Account|Admin|Ai|AiAdministration|Analytics|Appearance|Archives|BookRecovery|Books|Chapters|CharacterAttributes|CharacterWorkspace|Characters|ContextNames|ContextNavigation|ContextRelationshipLenses|ContextTools|ContinuityExplorer|DeploymentHealth|Dynamics|Exports|FeatureRequests|FloorPlans|Geography|HelpDiagnostics|HelpDrawer|Imports|IntelligenceReview|IntentAssessment|InvestigationCompanion|LocationWorkspace|Locations|ManageAccount|ManuscriptReader|Maps|NameVerification|Names|NarrativeFocus|NativeChapterSync|NativeCompanion|NativeCompanionAuth|NativeCompanionWorkflow|NativeInstallation|NativeManuscriptCapture|NativePresence|NativeWorkspace|Onboarding|ParagraphManuscript|PlotLineWorkspace|PlotLines|PlotThreads|ProjectCollaborators|ProjectMetrics|ProjectRestorePoints|Projects|RelationshipMap|Scenarios|SceneMetrics|Scenes|SharedFocus|SpatialContext|StoryAssets|StoryBible|StoryCalendar|StoryPoint|StripeWebhook|Timeline|Toolbar|Warnings|WordCompanion|WordCompanionHost|Writer|WriterActivities|WriterAuthoring|WriterInvestigations|WriterPlanning|WriterReview|WriterWord|WriterWork|Writing|WritingActivity|WritingSolverAdmin|WritingSolverReview|WritingSolverWorkspace|Home|Pricing/(?:StartTrial|Checkout))(?:/|$) {
|
||||||
|
return 308 https://app.plotdirector.com$request_uri;
|
||||||
|
}
|
||||||
|
# Retain original public Help and solver URLs, including legacy help redirects.
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:5004;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
19
Tools/Deployment/production/plotdirector-website.service
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=PlotDirector public website
|
||||||
|
After=network.target
|
||||||
|
[Service]
|
||||||
|
User=plotdirector-website
|
||||||
|
Group=plotdirector-website
|
||||||
|
WorkingDirectory=/srv/plotdirector-website/current
|
||||||
|
ExecStart=/usr/bin/dotnet /srv/plotdirector-website/current/PlotDirector.Website.dll
|
||||||
|
EnvironmentFile=/etc/plotdirector-website-production/website.env
|
||||||
|
StateDirectory=plotdirector-website
|
||||||
|
NoNewPrivileges=true
|
||||||
|
PrivateTmp=true
|
||||||
|
ProtectSystem=strict
|
||||||
|
ProtectHome=true
|
||||||
|
ReadWritePaths=/srv/plotdirector-website/shared/keys /var/lib/plotdirector-website
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=3
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
11
Tools/Deployment/production/sshd-website.conf
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Match User plotdirector-website-deploy
|
||||||
|
AuthenticationMethods publickey
|
||||||
|
PasswordAuthentication no
|
||||||
|
KbdInteractiveAuthentication no
|
||||||
|
AllowTcpForwarding no
|
||||||
|
X11Forwarding no
|
||||||
|
PermitTTY no
|
||||||
|
PermitTunnel no
|
||||||
|
PermitUserRC no
|
||||||
|
ForceCommand /usr/bin/python3 -I /usr/local/lib/plotdirector-website-deployment/ssh_dispatch.py
|
||||||
|
Match all
|
||||||
1
Tools/Deployment/production/target.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"product":"PlotDirector.Website","root":"/srv/plotdirector-website","inbox":"/srv/plotdirector-website/incoming","service":"plotdirector-website.service","url":"http://127.0.0.1:5004/health","public_key":"/etc/plotdirector-website-production/public.pem"}
|
||||||
7
Tools/Deployment/production/website.env
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
ASPNETCORE_ENVIRONMENT=Production
|
||||||
|
ASPNETCORE_URLS=http://127.0.0.1:5004
|
||||||
|
AllowedHosts=plotdirector.com;www.plotdirector.com;127.0.0.1
|
||||||
|
Application__BaseUrl=https://app.plotdirector.com
|
||||||
|
WritingSolver__EnableIndexing=false
|
||||||
|
HelpContent__Path=/srv/plotdirector-website/shared/help/current
|
||||||
|
DataProtection__KeysPath=/srv/plotdirector-website/shared/keys
|
||||||
1
Tools/Deployment/production/website.sudoers
Normal file
@ -0,0 +1 @@
|
|||||||
|
plotdirector-website-deploy ALL=(root) NOPASSWD: /usr/local/sbin/deploy-plotdirector-website-production validate *, /usr/local/sbin/deploy-plotdirector-website-production activate *, /usr/local/sbin/deploy-plotdirector-website-production rollback *, /usr/local/sbin/deploy-plotdirector-website-production receipt *
|
||||||
59
Tools/Deployment/provision-development.sh
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Administrator-only, Atlas-only, no Production connections or database operations.
|
||||||
|
set -euo pipefail
|
||||||
|
[[ $(hostname -s) == atlas && $EUID == 0 ]] || { echo 'Atlas administrator required'; exit 1; }
|
||||||
|
repo=$(cd -- "$(dirname -- "$0")/../.." && pwd)
|
||||||
|
[[ ! -e /etc/plotdirector-website-development/target.json ]] || { echo 'Already provisioned; review changes separately'; exit 1; }
|
||||||
|
getent group plotdirector-website-deploy >/dev/null || groupadd --system plotdirector-website-deploy
|
||||||
|
id plotdirector-website >/dev/null 2>&1 || useradd --system --home-dir /var/lib/plotdirector-website --create-home --shell /usr/sbin/nologin plotdirector-website
|
||||||
|
usermod -a -G plotdirector-website-deploy nick
|
||||||
|
install -d -m 755 /opt/plotdirector-website-dev /opt/plotdirector-website-dev/releases /opt/plotdirector-website-dev/receipts /opt/plotdirector-website-dev/shared
|
||||||
|
install -d -m 730 -o root -g plotdirector-website-deploy /opt/plotdirector-website-dev/incoming
|
||||||
|
install -d -m 750 -o plotdirector-website -g plotdirector-website /opt/plotdirector-website-dev/shared/keys
|
||||||
|
install -d -m 755 /etc/plotdirector-website-development /usr/local/lib/plotdirector-website-deployment/vendor
|
||||||
|
install -m 644 "$repo/Tools/Deployment/website_release.py" /usr/local/lib/plotdirector-website-deployment/
|
||||||
|
install -m 644 "$repo/Tools/Deployment/vendor/"*.py /usr/local/lib/plotdirector-website-deployment/vendor/
|
||||||
|
install -m 644 /home/nick/.local/share/plotdirector-website-development/signing/public.pem /etc/plotdirector-website-development/public.pem
|
||||||
|
cat > /etc/plotdirector-website-development/target.json <<'JSON'
|
||||||
|
{"product":"PlotDirector.Website","root":"/opt/plotdirector-website-dev","inbox":"/opt/plotdirector-website-dev/incoming","service":"plotdirector-website-dev.service","url":"http://127.0.0.1:5051/health","public_key":"/etc/plotdirector-website-development/public.pem"}
|
||||||
|
JSON
|
||||||
|
chmod 644 /etc/plotdirector-website-development/target.json
|
||||||
|
cat > /usr/local/sbin/deploy-plotdirector-website-development <<'SH'
|
||||||
|
#!/bin/sh
|
||||||
|
exec /usr/bin/env -i PATH=/usr/bin:/bin LANG=C.UTF-8 /usr/bin/python3 -I /usr/local/lib/plotdirector-website-deployment/website_release.py "$@"
|
||||||
|
SH
|
||||||
|
chmod 755 /usr/local/sbin/deploy-plotdirector-website-development
|
||||||
|
# The installed helper's subcommands are constrained by this sudo rule.
|
||||||
|
cat > /etc/sudoers.d/plotdirector-website-development <<'SUDO'
|
||||||
|
%plotdirector-website-deploy ALL=(root) NOPASSWD: /usr/local/sbin/deploy-plotdirector-website-development validate *, /usr/local/sbin/deploy-plotdirector-website-development activate *, /usr/local/sbin/deploy-plotdirector-website-development rollback *
|
||||||
|
SUDO
|
||||||
|
chmod 440 /etc/sudoers.d/plotdirector-website-development
|
||||||
|
visudo -cf /etc/sudoers.d/plotdirector-website-development
|
||||||
|
cat > /etc/systemd/system/plotdirector-website-dev.service <<'UNIT'
|
||||||
|
[Unit]
|
||||||
|
Description=PlotDirector public website Development
|
||||||
|
After=network.target
|
||||||
|
[Service]
|
||||||
|
User=plotdirector-website
|
||||||
|
Group=plotdirector-website
|
||||||
|
WorkingDirectory=/opt/plotdirector-website-dev/current
|
||||||
|
ExecStart=/usr/bin/dotnet /opt/plotdirector-website-dev/current/PlotDirector.Website.dll
|
||||||
|
Environment=ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
Environment=ASPNETCORE_URLS=http://0.0.0.0:5051
|
||||||
|
Environment=Application__BaseUrl=https://dev.plotdirector.com
|
||||||
|
Environment=WritingSolver__EnableIndexing=false
|
||||||
|
Environment=HelpContent__Path=/opt/plotdirector-website-dev/shared/help/current
|
||||||
|
Environment=DataProtection__KeysPath=/opt/plotdirector-website-dev/shared/keys
|
||||||
|
StateDirectory=plotdirector-website
|
||||||
|
NoNewPrivileges=true
|
||||||
|
PrivateTmp=true
|
||||||
|
ProtectSystem=strict
|
||||||
|
ProtectHome=true
|
||||||
|
ReadWritePaths=/opt/plotdirector-website-dev/shared/keys /var/lib/plotdirector-website
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=3
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
UNIT
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable plotdirector-website-dev.service
|
||||||
80
Tools/Deployment/ssh_dispatch.py
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#!/usr/bin/python3 -I
|
||||||
|
"""Forced SSH command for plotdirector-deploy; no shell, SFTP or arbitrary paths."""
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tarfile
|
||||||
|
import fcntl
|
||||||
|
import resource
|
||||||
|
import signal
|
||||||
|
import shutil
|
||||||
|
import stat
|
||||||
|
import time
|
||||||
|
import json
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
INBOX=Path('/srv/plotdirector-website/incoming')
|
||||||
|
LIMIT=4*1024**3
|
||||||
|
UPLOAD_LOCK=Path('/srv/plotdirector-website/incoming-upload.lock')
|
||||||
|
FREE_FLOOR=10*1024**3
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
os.umask(0o077)
|
||||||
|
# sshd ForceCommand passes the requested text as data, never to a shell here.
|
||||||
|
original=os.environ.get('SSH_ORIGINAL_COMMAND','')
|
||||||
|
match=re.fullmatch(r'(upload|validate|activate|rollback|receipt) ([A-Za-z0-9][A-Za-z0-9_.-]{0,99})',original)
|
||||||
|
if not match or match[2] in ('.','..'):
|
||||||
|
raise ValueError('Unsupported deployment operation')
|
||||||
|
operation,release=match.groups()
|
||||||
|
if operation!='upload':
|
||||||
|
args=['/usr/bin/sudo','-n','/usr/local/sbin/deploy-plotdirector-website-production',operation,release]
|
||||||
|
raise SystemExit(subprocess.run(args,env={'PATH':'/usr/sbin:/usr/bin:/sbin:/bin','LANG':'C.UTF-8'},cwd='/').returncode)
|
||||||
|
# These limits apply only to unprivileged transfer, never to the activation
|
||||||
|
# worker/.NET subprocess. Serialize uploads and retain space for other sites.
|
||||||
|
resource.setrlimit(resource.RLIMIT_AS,(256*1024**2,256*1024**2))
|
||||||
|
resource.setrlimit(resource.RLIMIT_CPU,(120,120))
|
||||||
|
signal.alarm(1800)
|
||||||
|
os.nice(10)
|
||||||
|
lock=os.open(UPLOAD_LOCK,os.O_RDWR|os.O_NOFOLLOW)
|
||||||
|
info=os.fstat(lock)
|
||||||
|
if not stat.S_ISREG(info.st_mode) or info.st_uid!=0 or info.st_nlink!=1 or info.st_mode&0o007:
|
||||||
|
raise ValueError('Invalid protected upload lock')
|
||||||
|
fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB)
|
||||||
|
if shutil.disk_usage(INBOX).free<FREE_FLOOR+LIMIT:raise ValueError('Insufficient staging space')
|
||||||
|
destination=INBOX/release
|
||||||
|
destination.mkdir(mode=0o700) # Refuses replacement, including symlinks.
|
||||||
|
started=time.monotonic()
|
||||||
|
started_utc=datetime.now(timezone.utc).isoformat()
|
||||||
|
received=set()
|
||||||
|
total=0
|
||||||
|
with tarfile.open(fileobj=sys.stdin.buffer,mode='r|') as tar:
|
||||||
|
for member in tar:
|
||||||
|
if member.name not in ('package.tar','package.tar.zst','authorization.json','authorization.sig','transport.json','transport.sig') or member.name in received or not member.isfile() or member.linkname or member.pax_headers:
|
||||||
|
raise ValueError('Invalid transfer member')
|
||||||
|
received.add(member.name)
|
||||||
|
if member.name in ('package.tar','package.tar.zst') and received & ({'package.tar','package.tar.zst'}-{member.name}):
|
||||||
|
raise ValueError('Ambiguous transport')
|
||||||
|
limit=LIMIT if member.name in ('package.tar','package.tar.zst') else 16384
|
||||||
|
if not 0<=member.size<=limit:raise ValueError('Transfer size exceeded')
|
||||||
|
total+=member.size
|
||||||
|
if total>LIMIT+65536:raise ValueError('Transfer size exceeded')
|
||||||
|
with tar.extractfile(member) as source,(destination/member.name).open('xb') as target:
|
||||||
|
while block:=source.read(1024**2):
|
||||||
|
if shutil.disk_usage(INBOX).free<FREE_FLOOR+len(block):raise ValueError('Staging space floor reached')
|
||||||
|
target.write(block)
|
||||||
|
target.flush();os.fsync(target.fileno())
|
||||||
|
if received not in ({'package.tar','authorization.json','authorization.sig'},{'package.tar.zst','authorization.json','authorization.sig','transport.json','transport.sig'}):
|
||||||
|
raise ValueError('Incomplete transfer; administrator must remove the incomplete incoming directory before retry')
|
||||||
|
elapsed=time.monotonic()-started
|
||||||
|
(destination/'transfer-metrics.json').write_text(json.dumps({'source':'ssh-receiver-unprivileged','started_utc':started_utc,'completed_utc':datetime.now(timezone.utc).isoformat(),'bytes':total,'seconds':elapsed,'mib_per_second':total/elapsed/1024**2}))
|
||||||
|
print('UPLOADED '+release+'; activation has not been performed')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
try:main()
|
||||||
|
except Exception:
|
||||||
|
print('DEPLOYMENT REQUEST REFUSED; no command was shell-evaluated',file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
50
Tools/Deployment/transfer.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Atlas immutable transfer. No activation; strict existing SSH identity/host policy."""
|
||||||
|
import argparse
|
||||||
|
from contextlib import nullcontext
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import tarfile
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
sys.path.insert(0,str(Path(__file__).resolve().parent/'vendor'))
|
||||||
|
from release import load, safe_name, require
|
||||||
|
from transport import TRANSPORT_FILES, LEGACY_FILES
|
||||||
|
|
||||||
|
|
||||||
|
def ssh(identity, command, host='85.190.124.132'):
|
||||||
|
require(host=='85.190.124.132','Production transfer host must be web1')
|
||||||
|
return ['ssh','-F','/dev/null','-i',identity,'-o','IdentitiesOnly=yes','-o','HostKeyAlgorithms=ssh-ed25519',
|
||||||
|
'-o','StrictHostKeyChecking=yes','-o','UpdateHostKeys=no','plotdirector-website-deploy@'+host,command]
|
||||||
|
|
||||||
|
|
||||||
|
def transfer(bundle, identity, host='85.190.124.132', meter=None):
|
||||||
|
bundle=Path(bundle).resolve();release=safe_name(load(bundle/'authorization.json')['release_id'])
|
||||||
|
names=TRANSPORT_FILES if (bundle/'transport.json').exists() else LEGACY_FILES
|
||||||
|
start=time.monotonic();total=0
|
||||||
|
with meter.phase('transfer') if meter else nullcontext():
|
||||||
|
process=subprocess.Popen(ssh(identity,'upload '+release,host),stdin=subprocess.PIPE)
|
||||||
|
try:
|
||||||
|
with tarfile.open(fileobj=process.stdin,mode='w|',format=tarfile.USTAR_FORMAT) as tar:
|
||||||
|
for name in names:
|
||||||
|
path=bundle/name
|
||||||
|
require(path.is_file() and not path.is_symlink(),'Invalid transfer input')
|
||||||
|
entry=tarfile.TarInfo(name);entry.size=path.stat().st_size;entry.mode=0o600;total+=entry.size
|
||||||
|
with path.open('rb') as stream:tar.addfile(entry,stream)
|
||||||
|
process.stdin.close()
|
||||||
|
require(process.wait()==0,'Restricted upload failed; incomplete staging retained for review')
|
||||||
|
finally:
|
||||||
|
if process.poll() is None:process.kill();process.wait()
|
||||||
|
elapsed=time.monotonic()-start
|
||||||
|
result={'source':'atlas-sender','bytes':total,'seconds':elapsed,'mib_per_second':total/elapsed/1024**2}
|
||||||
|
if meter:meter.data['transfer']=result
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser=argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument('bundle');parser.add_argument('--identity',required=True)
|
||||||
|
parser.add_argument('--host',default='85.190.124.132');args=parser.parse_args()
|
||||||
|
transfer(args.bundle,args.identity,args.host)
|
||||||
|
|
||||||
|
if __name__=='__main__':main()
|
||||||
5
Tools/Deployment/vendor/PROVENANCE.md
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Versioned copies of PlotDirector Tools/Deployment release.py and transport.py,
|
||||||
|
source commit 9dcd29d423b20e373e49fb28180d993c40aa165d (unchanged since that release).
|
||||||
|
Only safe primitive helpers and compressed transport are reused. Application
|
||||||
|
manifest/SQL qualification and activation are never called by website deployment.
|
||||||
|
Keep these files unchanged; update as an explicitly reviewed vendor version.
|
||||||
405
Tools/Deployment/vendor/release.py
vendored
Normal file
@ -0,0 +1,405 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Immutable release preparation and validation. Standard library + OpenSSL only."""
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path, PurePosixPath
|
||||||
|
import re
|
||||||
|
import stat
|
||||||
|
import subprocess
|
||||||
|
import tarfile
|
||||||
|
import tempfile
|
||||||
|
import sys
|
||||||
|
from contextlib import nullcontext
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.modules.setdefault('release', sys.modules[__name__])
|
||||||
|
|
||||||
|
LIMIT_BYTES = 4 * 1024**3
|
||||||
|
LIMIT_FILES = 100000
|
||||||
|
ID = re.compile(r'[A-Za-z0-9][A-Za-z0-9_.-]{0,99}\Z')
|
||||||
|
HASH = re.compile(r'[a-f0-9]{64}\Z')
|
||||||
|
COMMIT = re.compile(r'[a-f0-9]{40}\Z')
|
||||||
|
|
||||||
|
|
||||||
|
class Refused(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def require(condition, message):
|
||||||
|
if not condition:
|
||||||
|
raise Refused(message)
|
||||||
|
|
||||||
|
|
||||||
|
def digest(data):
|
||||||
|
return hashlib.sha256(data).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def file_digest(path):
|
||||||
|
with Path(path).open('rb') as stream:
|
||||||
|
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def canonical(value):
|
||||||
|
return (json.dumps(value, sort_keys=True, separators=(',', ':'), ensure_ascii=True) + '\n').encode()
|
||||||
|
|
||||||
|
|
||||||
|
def load(path):
|
||||||
|
def unique(items):
|
||||||
|
result = {}
|
||||||
|
for key, value in items:
|
||||||
|
require(key not in result, 'Duplicate JSON key')
|
||||||
|
result[key] = value
|
||||||
|
return result
|
||||||
|
require(Path(path).stat().st_size <= 16 * 1024**2, 'Oversized JSON')
|
||||||
|
return json.loads(Path(path).read_text(), object_pairs_hook=unique)
|
||||||
|
|
||||||
|
|
||||||
|
def keys(value, required, optional=()):
|
||||||
|
require(isinstance(value, dict) and set(required) <= set(value) <= set(required) | set(optional), 'Invalid fields')
|
||||||
|
|
||||||
|
|
||||||
|
def safe_name(value):
|
||||||
|
require(isinstance(value, str) and ID.fullmatch(value) and value not in ('.', '..'), 'Invalid identifier')
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def safe_path(value):
|
||||||
|
require(isinstance(value, str) and value and '\\' not in value and not any(ord(c) < 32 or ord(c) == 127 for c in value), 'Invalid path')
|
||||||
|
p = PurePosixPath(value)
|
||||||
|
require(not p.is_absolute() and '..' not in p.parts and str(p) == value and value != '.', 'Unsafe path')
|
||||||
|
return p
|
||||||
|
|
||||||
|
|
||||||
|
def sha(value):
|
||||||
|
require(isinstance(value, str) and HASH.fullmatch(value), 'Invalid SHA256')
|
||||||
|
|
||||||
|
|
||||||
|
def conditions(items):
|
||||||
|
require(isinstance(items, list) and len(items) <= 10000, 'Invalid conditions')
|
||||||
|
for c in items:
|
||||||
|
require(isinstance(c, dict), 'Invalid condition')
|
||||||
|
kind = c.get('kind')
|
||||||
|
required = {'object': ('kind', 'name', 'type'), 'column': ('kind', 'name', 'column'), 'module_sha256': ('kind', 'name', 'sha256'), 'solver_graph': ('kind', 'version', 'sha256')}.get(kind)
|
||||||
|
require(required is not None, 'Unsupported condition')
|
||||||
|
keys(c, required)
|
||||||
|
if kind == 'solver_graph':
|
||||||
|
require(re.fullmatch(r'[A-Za-z0-9_.-]{1,100}', c['version']), 'Invalid solver version')
|
||||||
|
sha(c['sha256'])
|
||||||
|
continue
|
||||||
|
require(re.fullmatch(r'dbo\.[A-Za-z_][A-Za-z0-9_]{0,127}', c['name']), 'Invalid object name')
|
||||||
|
if kind == 'object':
|
||||||
|
require(c['type'] in ('U', 'P', 'FN', 'IF', 'TF', 'V', 'TR'), 'Invalid object type')
|
||||||
|
if kind == 'column':
|
||||||
|
require(re.fullmatch(r'[A-Za-z_][A-Za-z0-9_]{0,127}', c['column']), 'Invalid column')
|
||||||
|
if kind == 'module_sha256':
|
||||||
|
sha(c['sha256'])
|
||||||
|
|
||||||
|
|
||||||
|
def validate_manifest(m):
|
||||||
|
keys(m, ('format', 'release_id', 'source_commit', 'version', 'files', 'application_sha256',
|
||||||
|
'starting_schema_sha256', 'resulting_schema_sha256', 'migrations', 'omitted_migrations',
|
||||||
|
'prerequisites', 'postconditions', 'health', 'qualification'))
|
||||||
|
require(m['format'] == 1, 'Unsupported manifest format')
|
||||||
|
safe_name(m['release_id'])
|
||||||
|
require(COMMIT.fullmatch(m['source_commit']), 'Full source commit required')
|
||||||
|
require(isinstance(m['version'], str) and re.fullmatch(r'[A-Za-z0-9.+_-]{1,100}', m['version']), 'Invalid application version')
|
||||||
|
for field in ('application_sha256', 'starting_schema_sha256', 'resulting_schema_sha256'):
|
||||||
|
sha(m[field])
|
||||||
|
require(isinstance(m['files'], dict) and 3 <= len(m['files']) <= LIMIT_FILES, 'Invalid file index')
|
||||||
|
for name, checksum in m['files'].items():
|
||||||
|
p = safe_path(name)
|
||||||
|
require(p.parts[0] in ('app', 'sql', 'evidence'), 'Invalid package area')
|
||||||
|
require(not any(x.startswith('.') or x in ('App_Data', 'uploads', 'logs', 'Logs') for x in p.parts), 'Persistent/config path in package')
|
||||||
|
require(not (p.name.startswith('appsettings') and p.suffix == '.json') and p.name not in ('web.config', 'dotnet-tools.json'), 'Configuration in package')
|
||||||
|
sha(checksum)
|
||||||
|
for name in ('PlotLine.dll', 'PlotLine.deps.json', 'PlotLine.runtimeconfig.json'):
|
||||||
|
require('app/' + name in m['files'], 'Incomplete framework-dependent application')
|
||||||
|
app_index = {k: v for k, v in m['files'].items() if k.startswith('app/')}
|
||||||
|
require(digest(canonical(app_index)) == m['application_sha256'], 'Application index checksum mismatch')
|
||||||
|
conditions(m['prerequisites'])
|
||||||
|
conditions(m['postconditions'])
|
||||||
|
require(bool(m['postconditions']), 'Release database health checks required')
|
||||||
|
require(isinstance(m['migrations'], list), 'Invalid migrations')
|
||||||
|
known = set()
|
||||||
|
sql_files = set()
|
||||||
|
for step in m['migrations']:
|
||||||
|
keys(step, ('id', 'file', 'sha256', 'requires', 'mode', 'prerequisites', 'postconditions'), ('evidence',))
|
||||||
|
identity = step['id']
|
||||||
|
require(isinstance(identity, str) and re.fullmatch(r'[A-Za-z0-9][A-Za-z0-9_.-]{0,199}', identity), 'Invalid migration identity')
|
||||||
|
require(identity not in known, 'Duplicate migration identity')
|
||||||
|
require(isinstance(step['requires'], list) and len(set(step['requires'])) == len(step['requires']) and set(step['requires']) <= known, 'Missing or out-of-order migration dependency')
|
||||||
|
safe_path(step['file'])
|
||||||
|
require('/' not in step['file'] and step['file'].endswith('.sql') and step['file'] not in sql_files, 'Invalid migration filename')
|
||||||
|
sql_files.add(step['file'])
|
||||||
|
sha(step['sha256'])
|
||||||
|
require(m['files'].get('sql/' + step['file']) == step['sha256'], 'Migration absent from index or checksum mismatch')
|
||||||
|
require(step['mode'] in ('execute', 'baseline'), 'Non-transactional migration requires a separately reviewed recovery procedure')
|
||||||
|
if step['mode'] == 'baseline':
|
||||||
|
require(isinstance(step.get('evidence'), str) and step['evidence'].startswith('evidence/') and step['evidence'] in m['files'], 'Historical baseline evidence required')
|
||||||
|
else:
|
||||||
|
require('evidence' not in step, 'Execution cannot claim historical baseline evidence')
|
||||||
|
conditions(step['prerequisites'])
|
||||||
|
conditions(step['postconditions'])
|
||||||
|
require(bool(step['postconditions']), 'Migration postconditions required')
|
||||||
|
known.add(identity)
|
||||||
|
require({n[4:] for n in m['files'] if n.startswith('sql/')} == sql_files, 'Unapproved SQL file')
|
||||||
|
require(isinstance(m['omitted_migrations'], list), 'Invalid omitted migrations')
|
||||||
|
for omitted in m['omitted_migrations']:
|
||||||
|
keys(omitted, ('id', 'sha256', 'reason', 'evidence'))
|
||||||
|
require(omitted['id'] not in known and isinstance(omitted['reason'], str) and len(omitted['reason']) > 10, 'Invalid omitted migration')
|
||||||
|
sha(omitted['sha256'])
|
||||||
|
require(omitted['evidence'] in m['files'] and omitted['evidence'].startswith('evidence/'), 'Omission evidence missing')
|
||||||
|
known.add(omitted['id'])
|
||||||
|
require(m['health'] == ['http-root', 'http-login', 'http-deployment-identity', 'database-postconditions', 'binary-identity'], 'Unsupported health checks')
|
||||||
|
require(isinstance(m['qualification'], dict) and m['qualification'].get('status') == 'passed', 'Release is not qualified')
|
||||||
|
keys(m['qualification'], ('status', 'evidence'))
|
||||||
|
require(m['qualification']['evidence'] in m['files'] and m['qualification']['evidence'].startswith('evidence/'), 'Qualification evidence absent')
|
||||||
|
|
||||||
|
|
||||||
|
def qualification_identity(m, evidence):
|
||||||
|
require(evidence.get('status') == 'passed' and evidence.get('source_commit') == m['source_commit'], 'Qualification source identity mismatch')
|
||||||
|
require(evidence.get('application_dll_sha256') == m['files']['app/PlotLine.dll'], 'Qualification binary identity mismatch')
|
||||||
|
require(evidence.get('starting_schema_sha256') == m['starting_schema_sha256']
|
||||||
|
and evidence.get('resulting_schema_sha256') == m['resulting_schema_sha256'], 'Qualification database identity mismatch')
|
||||||
|
|
||||||
|
|
||||||
|
def extract(archive, destination):
|
||||||
|
"""Only called on a private, verified snapshot; never uses extractall."""
|
||||||
|
destination = Path(destination)
|
||||||
|
total = 0
|
||||||
|
names = set()
|
||||||
|
with tarfile.open(archive, 'r:') as tar:
|
||||||
|
for member in tar:
|
||||||
|
name = str(safe_path(member.name))
|
||||||
|
require(member.isfile() and not member.pax_headers and not member.linkname, 'Archive must contain plain regular files only')
|
||||||
|
require(name not in names and len(names) < LIMIT_FILES, 'Duplicate or excessive archive entries')
|
||||||
|
names.add(name)
|
||||||
|
total += member.size
|
||||||
|
require(0 <= member.size and total <= LIMIT_BYTES, 'Archive exceeds size limit')
|
||||||
|
require(name == 'manifest.json' or PurePosixPath(name).parts[0] in ('app', 'sql', 'evidence'), 'Unexpected archive path')
|
||||||
|
out = destination / name
|
||||||
|
out.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
|
||||||
|
with out.open('xb') as target, tar.extractfile(member) as source:
|
||||||
|
while block := source.read(1024**2):
|
||||||
|
target.write(block)
|
||||||
|
out.chmod(0o600)
|
||||||
|
require('manifest.json' in names, 'Missing manifest')
|
||||||
|
m = load(destination / 'manifest.json')
|
||||||
|
validate_manifest(m)
|
||||||
|
require(names == set(m['files']) | {'manifest.json'}, 'Package files differ from manifest')
|
||||||
|
for name, checksum in m['files'].items():
|
||||||
|
require(file_digest(destination / name) == checksum, 'File checksum mismatch')
|
||||||
|
runtime = load(destination / 'app/PlotLine.runtimeconfig.json')
|
||||||
|
require(runtime.get('runtimeOptions', {}).get('tfm') == 'net10.0', 'Unexpected application runtime')
|
||||||
|
deps = load(destination / 'app/PlotLine.deps.json')
|
||||||
|
require('PlotLine/' + m['version'] in deps.get('libraries', {}), 'Application package version mismatch')
|
||||||
|
require((m['version'] + '+' + m['source_commit']).encode() in (destination / 'app/PlotLine.dll').read_bytes(), 'Assembly source commit mismatch')
|
||||||
|
qualification_identity(m, load(destination / m['qualification']['evidence']))
|
||||||
|
return m
|
||||||
|
|
||||||
|
|
||||||
|
def snapshot(path, destination, max_bytes):
|
||||||
|
"""Descriptor-relative, no-follow input. A changing source cannot bypass signature."""
|
||||||
|
path = Path(path)
|
||||||
|
require(path.is_absolute(), 'Absolute source path required')
|
||||||
|
fd = os.open('/', os.O_RDONLY | os.O_DIRECTORY)
|
||||||
|
try:
|
||||||
|
for part in path.parts[1:-1]:
|
||||||
|
next_fd = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=fd)
|
||||||
|
os.close(fd)
|
||||||
|
fd = next_fd
|
||||||
|
source_fd = os.open(path.name, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=fd)
|
||||||
|
with os.fdopen(source_fd, 'rb') as source, Path(destination).open('xb') as out:
|
||||||
|
info = os.fstat(source.fileno())
|
||||||
|
require(stat.S_ISREG(info.st_mode) and info.st_nlink == 1 and info.st_size <= max_bytes, 'Unsafe input file')
|
||||||
|
count = 0
|
||||||
|
while data := source.read(1024**2):
|
||||||
|
count += len(data)
|
||||||
|
require(count <= max_bytes, 'Input size exceeded')
|
||||||
|
out.write(data)
|
||||||
|
finally:
|
||||||
|
os.close(fd)
|
||||||
|
|
||||||
|
|
||||||
|
def verify_bundle(source, work, public_key, meter=None):
|
||||||
|
source, work = Path(source), Path(work)
|
||||||
|
phase = meter.phase if meter else lambda name: nullcontext()
|
||||||
|
with phase('package_validation'):
|
||||||
|
for name in ('authorization.json', 'authorization.sig'):
|
||||||
|
snapshot(source / name, work / name, 16384)
|
||||||
|
result = subprocess.run(['/usr/bin/openssl', 'pkeyutl', '-verify', '-pubin', '-inkey', str(public_key), '-rawin',
|
||||||
|
'-in', str(work / 'authorization.json'), '-sigfile', str(work / 'authorization.sig')],
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
require(result.returncode == 0, 'Release signature invalid')
|
||||||
|
authorization = load(work / 'authorization.json')
|
||||||
|
keys(authorization, ('format', 'release_id', 'source_commit', 'package_sha256', 'manifest_sha256'))
|
||||||
|
require(authorization['format'] == 1, 'Invalid authorization format')
|
||||||
|
safe_name(authorization['release_id'])
|
||||||
|
sha(authorization['package_sha256'])
|
||||||
|
sha(authorization['manifest_sha256'])
|
||||||
|
compressed = (source / 'transport.json').exists() or (source / 'package.tar.zst').exists()
|
||||||
|
if compressed:
|
||||||
|
from transport import envelope
|
||||||
|
require(not (source / 'package.tar').exists(), 'Ambiguous raw/compressed bundle')
|
||||||
|
t = envelope(source, work, public_key)
|
||||||
|
require(t['original_sha256'] == authorization['package_sha256'] and
|
||||||
|
t['release_id'] == authorization['release_id'] and
|
||||||
|
t['source_commit'] == authorization['source_commit'], 'Transport identity mismatch')
|
||||||
|
else:
|
||||||
|
snapshot(source / 'package.tar', work / 'package.tar', LIMIT_BYTES)
|
||||||
|
size = (work / 'package.tar').stat().st_size
|
||||||
|
t = {'method':'none','original_bytes':size,'transferred_bytes':size,
|
||||||
|
'original_sha256':authorization['package_sha256'],'transferred_sha256':authorization['package_sha256']}
|
||||||
|
if meter:
|
||||||
|
meter.data['transport'] = {k:t[k] for k in ('method','original_bytes','transferred_bytes','original_sha256','transferred_sha256')}
|
||||||
|
meter.data['transport']['compression_ratio'] = round(t['transferred_bytes']/t['original_bytes'],6)
|
||||||
|
if compressed:
|
||||||
|
meter.data['transport']['compression_seconds_atlas'] = t['compression_seconds']
|
||||||
|
meter.data['transport']['settings'] = {'level':t['level'],'threads':t['threads']}
|
||||||
|
if compressed:
|
||||||
|
from transport import decompress
|
||||||
|
with phase('decompression'):
|
||||||
|
decompress(work,t)
|
||||||
|
with phase('package_validation'):
|
||||||
|
require(file_digest(work / 'package.tar') == authorization['package_sha256'], 'Package checksum mismatch')
|
||||||
|
payload = work / 'payload'
|
||||||
|
payload.mkdir(mode=0o700)
|
||||||
|
manifest = extract(work / 'package.tar', payload)
|
||||||
|
require(file_digest(payload / 'manifest.json') == authorization['manifest_sha256'], 'Manifest checksum mismatch')
|
||||||
|
require(manifest['release_id'] == authorization['release_id'] and manifest['source_commit'] == authorization['source_commit'], 'Authorization identity mismatch')
|
||||||
|
return manifest, authorization, payload
|
||||||
|
|
||||||
|
|
||||||
|
def prepare(args, meter=None):
|
||||||
|
from receipt import Receipt, write_local
|
||||||
|
meter = meter or Receipt('atlas-preparation')
|
||||||
|
repo = Path(args.source).resolve()
|
||||||
|
with meter.phase('scope_verification'):
|
||||||
|
commit = subprocess.check_output(['git', '-C', str(repo), 'rev-parse', 'HEAD'], text=True).strip()
|
||||||
|
require(not subprocess.check_output(['git', '-C', str(repo), 'status', '--porcelain'], text=True).strip(), 'Source must be a clean Git commit')
|
||||||
|
if getattr(args, 'scope_base', None):
|
||||||
|
base = subprocess.check_output(['git','-C',str(repo),'rev-parse','--verify','--end-of-options',args.scope_base+'^{commit}'],text=True).strip()
|
||||||
|
require(COMMIT.fullmatch(base), 'Invalid scope baseline')
|
||||||
|
meter.data['scope'] = {'base':base,'source':commit,'changed_paths':subprocess.check_output(
|
||||||
|
['git','-C',str(repo),'diff','--name-only',base,commit],text=True).splitlines()}
|
||||||
|
require(COMMIT.fullmatch(commit), 'Invalid source commit')
|
||||||
|
plan = load(args.plan)
|
||||||
|
# The plan is reviewed data; paths are only read on Atlas, never trusted as remote targets.
|
||||||
|
keys(plan, ('starting_schema_sha256', 'resulting_schema_sha256', 'migrations', 'omitted_migrations', 'prerequisites', 'postconditions', 'qualification'))
|
||||||
|
output = Path(args.output).resolve()
|
||||||
|
require(not output.exists(), 'Release destination already exists')
|
||||||
|
output.mkdir(mode=0o700, parents=True)
|
||||||
|
with tempfile.TemporaryDirectory(prefix='pd-release-', dir=str(output.parent)) as directory:
|
||||||
|
work = Path(directory)
|
||||||
|
publish = work / 'publish'
|
||||||
|
with meter.phase('build'):
|
||||||
|
subprocess.run(['dotnet', 'publish', str(repo / 'PlotLine/PlotLine.csproj'), '-c', 'Release', '-o', str(publish),
|
||||||
|
'-p:ContinuousIntegrationBuild=true', '-p:SourceRevisionId=' + commit], check=True,
|
||||||
|
stdout=(output / 'publish.log').open('w'), stderr=subprocess.STDOUT)
|
||||||
|
with meter.phase('packaging_signing'):
|
||||||
|
require(not subprocess.check_output(['git', '-C', str(repo), 'status', '--porcelain'], text=True).strip(), 'Build changed tracked source')
|
||||||
|
files = {}
|
||||||
|
sources = {}
|
||||||
|
for path in sorted(publish.rglob('*')):
|
||||||
|
require(not path.is_symlink(), 'Publish contains symlink')
|
||||||
|
if not path.is_file():
|
||||||
|
continue
|
||||||
|
rel = path.relative_to(publish)
|
||||||
|
if any(p.startswith('.') or p in ('App_Data', 'uploads', 'logs', 'Logs') for p in rel.parts):
|
||||||
|
continue
|
||||||
|
if (path.name.startswith('appsettings') and path.suffix == '.json') or path.name in ('web.config', 'dotnet-tools.json'):
|
||||||
|
continue
|
||||||
|
name = 'app/' + rel.as_posix()
|
||||||
|
files[name] = file_digest(path)
|
||||||
|
sources[name] = path
|
||||||
|
for migration in plan['migrations']:
|
||||||
|
filename = str(safe_path(migration['file']))
|
||||||
|
require('/' not in filename, 'Invalid SQL source name')
|
||||||
|
# Historical non-numeric release SQL may be staged separately in the reviewed SQL input directory.
|
||||||
|
path = Path(args.sql) / filename
|
||||||
|
require(path.is_file() and not path.is_symlink() and file_digest(path) == migration['sha256'], 'SQL source differs from reviewed plan')
|
||||||
|
name = 'sql/' + filename
|
||||||
|
files[name] = migration['sha256']
|
||||||
|
sources[name] = path
|
||||||
|
for path in sorted(Path(args.evidence).rglob('*')):
|
||||||
|
require(not path.is_symlink(), 'Evidence symlink')
|
||||||
|
if path.is_file():
|
||||||
|
name = 'evidence/' + path.relative_to(args.evidence).as_posix()
|
||||||
|
safe_path(name)
|
||||||
|
files[name] = file_digest(path)
|
||||||
|
sources[name] = path
|
||||||
|
deps = load(publish / 'PlotLine.deps.json')
|
||||||
|
versions = [x[9:] for x in deps['libraries'] if x.startswith('PlotLine/')]
|
||||||
|
require(len(versions) == 1, 'Application identity unavailable')
|
||||||
|
manifest = {'format': 1, 'release_id': safe_name(args.release_id), 'source_commit': commit, 'version': versions[0],
|
||||||
|
'files': files, 'application_sha256': digest(canonical({k:v for k,v in files.items() if k.startswith('app/')})),
|
||||||
|
'health': ['http-root', 'http-login', 'http-deployment-identity', 'database-postconditions', 'binary-identity'], **plan}
|
||||||
|
validate_manifest(manifest)
|
||||||
|
qualification_identity(manifest, load(Path(args.evidence) / PurePosixPath(plan['qualification']['evidence']).relative_to('evidence')))
|
||||||
|
manifest_bytes = canonical(manifest)
|
||||||
|
(work / 'manifest.json').write_bytes(manifest_bytes)
|
||||||
|
sources['manifest.json'] = work / 'manifest.json'
|
||||||
|
with tarfile.open(output / 'package.tar', 'w', format=tarfile.USTAR_FORMAT) as tar:
|
||||||
|
for name, path in sorted(sources.items()):
|
||||||
|
entry = tarfile.TarInfo(name)
|
||||||
|
entry.size = path.stat().st_size
|
||||||
|
entry.mode = 0o644
|
||||||
|
with path.open('rb') as stream:
|
||||||
|
tar.addfile(entry, stream)
|
||||||
|
authorization = {'format': 1, 'release_id': args.release_id, 'source_commit': commit,
|
||||||
|
'package_sha256': file_digest(output / 'package.tar'), 'manifest_sha256': digest(manifest_bytes)}
|
||||||
|
(output / 'authorization.json').write_bytes(canonical(authorization))
|
||||||
|
subprocess.run(['/usr/bin/openssl', 'pkeyutl', '-sign', '-inkey', args.signing_key, '-rawin',
|
||||||
|
'-in', str(output / 'authorization.json'), '-out', str(output / 'authorization.sig')], check=True,
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
meter.data['release'] = {'id':args.release_id,'source_commit':commit,'version':manifest['version'],
|
||||||
|
'package_sha256':authorization['package_sha256'],'application_sha256':manifest['application_sha256']}
|
||||||
|
if getattr(args, 'compression', 'none') == 'zstd':
|
||||||
|
from transport import compress_bundle
|
||||||
|
with meter.phase('compression'):
|
||||||
|
transport = compress_bundle(output,work/'transport',args.signing_key,None,verified=True)
|
||||||
|
for name in ('transport.json','transport.sig','package.tar.zst'):
|
||||||
|
(work/'transport'/name).rename(output/name)
|
||||||
|
(output/'package.tar').unlink() # Only this operation's newly built temporary tar.
|
||||||
|
meter.data['transport'] = transport
|
||||||
|
with meter.phase('receipt_generation'):
|
||||||
|
meter.finish('prepared')
|
||||||
|
write_local(output/'preparation-receipt.json',meter.data)
|
||||||
|
meter.finish('prepared');write_local(output/'preparation-receipt.json',meter.data)
|
||||||
|
print(json.dumps(authorization, sort_keys=True))
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
sub = parser.add_subparsers(dest='command', required=True)
|
||||||
|
p = sub.add_parser('prepare')
|
||||||
|
for field in ('source', 'plan', 'sql', 'evidence', 'output', 'release-id', 'signing-key'):
|
||||||
|
p.add_argument('--' + field, required=True)
|
||||||
|
p.add_argument('--compression',choices=('zstd','none'),default='zstd')
|
||||||
|
p.add_argument('--scope-base')
|
||||||
|
c = sub.add_parser('compress',help='Wrap an unchanged existing signed tar; no application build')
|
||||||
|
for field in ('bundle','output','signing-key','public-key'):c.add_argument('--'+field,required=True)
|
||||||
|
v = sub.add_parser('verify')
|
||||||
|
v.add_argument('bundle')
|
||||||
|
v.add_argument('--public-key', required=True)
|
||||||
|
args = parser.parse_args()
|
||||||
|
os.umask(0o077)
|
||||||
|
try:
|
||||||
|
if args.command == 'prepare':
|
||||||
|
prepare(args)
|
||||||
|
elif args.command == 'compress':
|
||||||
|
from transport import compress_bundle
|
||||||
|
print(json.dumps(compress_bundle(args.bundle,args.output,args.signing_key,args.public_key),sort_keys=True))
|
||||||
|
else:
|
||||||
|
with tempfile.TemporaryDirectory(prefix='pd-verify-') as work:
|
||||||
|
m, a, _ = verify_bundle(Path(args.bundle).resolve(), work, args.public_key)
|
||||||
|
print(json.dumps({'verified': True, 'release_id': m['release_id'], 'package_sha256': a['package_sha256']}))
|
||||||
|
except (Refused, ValueError, OSError, subprocess.CalledProcessError) as error:
|
||||||
|
print('RELEASE REFUSED: ' + (str(error) if isinstance(error, Refused) else type(error).__name__))
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
88
Tools/Deployment/vendor/transport.py
vendored
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
"""Signed Zstandard envelope around an unchanged, previously signed tar package."""
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
|
from release import LIMIT_BYTES, Refused, canonical, file_digest, keys, load, require, safe_name, sha, snapshot
|
||||||
|
|
||||||
|
TRANSPORT_FILES=('authorization.json','authorization.sig','transport.json','transport.sig','package.tar.zst')
|
||||||
|
LEGACY_FILES=('authorization.json','authorization.sig','package.tar')
|
||||||
|
MAX_WINDOW_MIB=128
|
||||||
|
|
||||||
|
|
||||||
|
def signed_json(path, signature, public_key):
|
||||||
|
p=subprocess.run(['/usr/bin/openssl','pkeyutl','-verify','-pubin','-inkey',str(public_key),'-rawin',
|
||||||
|
'-in',str(path),'-sigfile',str(signature)],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
||||||
|
require(p.returncode==0,'Transport signature invalid')
|
||||||
|
return load(path)
|
||||||
|
|
||||||
|
|
||||||
|
def envelope(source, work, public_key):
|
||||||
|
"""Private snapshots only. Verify compressed bytes BEFORE invoking the decoder."""
|
||||||
|
for name,limit in [('transport.json',16384),('transport.sig',16384),('package.tar.zst',LIMIT_BYTES)]:
|
||||||
|
snapshot(source/name,work/name,limit)
|
||||||
|
t=signed_json(work/'transport.json',work/'transport.sig',public_key)
|
||||||
|
keys(t,('format','method','level','threads','release_id','source_commit','authorization_sha256',
|
||||||
|
'original_sha256','original_bytes','transferred_sha256','transferred_bytes','compression_seconds'))
|
||||||
|
require(t['format']==1 and t['method']=='zstd','Unsupported transport')
|
||||||
|
safe_name(t['release_id'])
|
||||||
|
require(isinstance(t['source_commit'],str) and len(t['source_commit'])==40,'Invalid transport source')
|
||||||
|
for k in ['authorization_sha256','original_sha256','transferred_sha256']:sha(t[k])
|
||||||
|
for k in ['original_bytes','transferred_bytes']:
|
||||||
|
require(type(t[k]) is int and 0<t[k]<=LIMIT_BYTES,'Transport size exceeds limit')
|
||||||
|
require(type(t['level']) is int and t['level'] in (1,3,6) and type(t['threads']) is int and 1<=t['threads']<=8,'Unsupported compressor settings')
|
||||||
|
require(type(t['compression_seconds']) in (float,int) and 0<=t['compression_seconds']<=86400,'Invalid compression measurement')
|
||||||
|
require((work/'package.tar.zst').stat().st_size==t['transferred_bytes'] and file_digest(work/'package.tar.zst')==t['transferred_sha256'],'Compressed transport checksum/size mismatch')
|
||||||
|
require(file_digest(work/'authorization.json')==t['authorization_sha256'],'Transport authorization mismatch')
|
||||||
|
require(shutil.disk_usage(work).free>=1024**3+3*t['original_bytes'],'Insufficient decompression/extraction/installation space')
|
||||||
|
return t
|
||||||
|
|
||||||
|
|
||||||
|
def decompress(work, t):
|
||||||
|
"""Bound output, decoder memory, CPU and wall time; never invoke a shell."""
|
||||||
|
import resource
|
||||||
|
import signal
|
||||||
|
def limits():
|
||||||
|
resource.setrlimit(resource.RLIMIT_FSIZE,(t['original_bytes'],t['original_bytes']))
|
||||||
|
resource.setrlimit(resource.RLIMIT_CPU,(120,120))
|
||||||
|
signal.alarm(120)
|
||||||
|
output=work/'package.tar'
|
||||||
|
try:
|
||||||
|
with output.open('xb') as stream:
|
||||||
|
p=subprocess.run(['/usr/bin/zstd','--quiet','--decompress','--stdout',f'--memory={MAX_WINDOW_MIB}MB','--',str(work/'package.tar.zst')],
|
||||||
|
stdout=stream,stderr=subprocess.DEVNULL,timeout=125,preexec_fn=limits)
|
||||||
|
require(p.returncode==0 and output.stat().st_size==t['original_bytes'],'Decompression failed or size mismatch')
|
||||||
|
require(file_digest(output)==t['original_sha256'],'Reconstructed package checksum mismatch')
|
||||||
|
except BaseException:
|
||||||
|
output.unlink(missing_ok=True)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def compress_bundle(source, output, signing_key, public_key, *, level=6, threads=4, meter=None, verified=False):
|
||||||
|
source,output=Path(source).resolve(),Path(output).resolve()
|
||||||
|
require(not output.exists(),'Transport destination already exists')
|
||||||
|
require(level in (1,3,6) and 1<=threads<=8,'Unsupported compression settings')
|
||||||
|
if not verified:
|
||||||
|
import tempfile
|
||||||
|
from release import verify_bundle
|
||||||
|
with tempfile.TemporaryDirectory(prefix='pd-source-check-',dir=output.parent) as directory:
|
||||||
|
verify_bundle(source,Path(directory),public_key)
|
||||||
|
output.mkdir(mode=0o700)
|
||||||
|
for name in ['authorization.json','authorization.sig']:
|
||||||
|
snapshot(source/name,output/name,16384)
|
||||||
|
a=load(output/'authorization.json');require(file_digest(source/'package.tar')==a['package_sha256'],'Original signed package differs')
|
||||||
|
start=time.monotonic()
|
||||||
|
with (output/'package.tar.zst').open('xb') as stream:
|
||||||
|
p=subprocess.run(['/usr/bin/zstd','--quiet',f'-{level}',f'-T{threads}','--check','--stdout','--',str(source/'package.tar')],stdout=stream,stderr=subprocess.DEVNULL,timeout=180)
|
||||||
|
require(p.returncode==0,'Compression failed')
|
||||||
|
elapsed=time.monotonic()-start
|
||||||
|
size=(source/'package.tar').stat().st_size
|
||||||
|
require(0<size<=LIMIT_BYTES and (output/'package.tar.zst').stat().st_size<=LIMIT_BYTES,'Transport exceeds size limit')
|
||||||
|
t={'format':1,'method':'zstd','level':level,'threads':threads,'release_id':a['release_id'],'source_commit':a['source_commit'],
|
||||||
|
'authorization_sha256':file_digest(output/'authorization.json'),'original_sha256':a['package_sha256'],'original_bytes':size,
|
||||||
|
'transferred_sha256':file_digest(output/'package.tar.zst'),'transferred_bytes':(output/'package.tar.zst').stat().st_size,'compression_seconds':elapsed}
|
||||||
|
(output/'transport.json').write_bytes(canonical(t))
|
||||||
|
subprocess.run(['/usr/bin/openssl','pkeyutl','-sign','-inkey',str(signing_key),'-rawin','-in',str(output/'transport.json'),'-out',str(output/'transport.sig')],check=True,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
||||||
|
return t
|
||||||
142
Tools/Deployment/website_release.py
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Website-only signed releases. No database worker, application target or shell hooks."""
|
||||||
|
import argparse,fcntl,json,os,re,shutil,subprocess,sys,tarfile,tempfile,time,uuid
|
||||||
|
from pathlib import Path
|
||||||
|
from urllib.request import urlopen
|
||||||
|
sys.path.insert(0,str(Path(__file__).resolve().parent/'vendor'))
|
||||||
|
from release import canonical,file_digest,load,require,safe_name,safe_path,snapshot,LIMIT_BYTES,LIMIT_FILES
|
||||||
|
from transport import compress_bundle,envelope,decompress,signed_json
|
||||||
|
|
||||||
|
BUNDLE={'authorization.json','authorization.sig','transport.json','transport.sig','package.tar.zst'}
|
||||||
|
def sign(path,key):
|
||||||
|
subprocess.run(['/usr/bin/openssl','pkeyutl','-sign','-inkey',str(key),'-rawin','-in',str(path),'-out',str(Path(path).with_suffix('.sig'))],check=True,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
||||||
|
def prepare(source,output,release,key,public):
|
||||||
|
source,output=Path(source).resolve(),Path(output).resolve();safe_name(release)
|
||||||
|
require(not output.exists(),'Output exists')
|
||||||
|
require(not subprocess.check_output(['git','status','--porcelain'],cwd=source),'Use clean committed source')
|
||||||
|
commit=subprocess.check_output(['git','rev-parse','HEAD'],cwd=source,text=True).strip()
|
||||||
|
with tempfile.TemporaryDirectory(prefix='website-build-') as td:
|
||||||
|
td=Path(td);app=td/'payload/app';app.mkdir(parents=True)
|
||||||
|
subprocess.run(['dotnet','publish',str(source/'PlotDirector.Website/PlotDirector.Website.csproj'),'-c','Release','-o',str(app),'-p:SourceRevisionId='+commit],check=True)
|
||||||
|
for name in ['appsettings.json','appsettings.Development.json']: (app/name).unlink(missing_ok=True)
|
||||||
|
files={str(p.relative_to(td/'payload')):file_digest(p) for p in sorted(app.rglob('*')) if p.is_file()}
|
||||||
|
require(not any('/uploads/' in n or '/sql/' in n for n in files),'Unexpected persistent/database payload')
|
||||||
|
manifest={'format':1,'product':'PlotDirector.Website','release_id':release,'source_commit':commit,'files':files}
|
||||||
|
(td/'payload/manifest.json').write_bytes(canonical(manifest))
|
||||||
|
raw=td/'raw';raw.mkdir()
|
||||||
|
with tarfile.open(raw/'package.tar','w',format=tarfile.USTAR_FORMAT) as tar:
|
||||||
|
for p in sorted((td/'payload').rglob('*')):
|
||||||
|
if p.is_file():tar.add(p,arcname=str(p.relative_to(td/'payload')),recursive=False)
|
||||||
|
auth={'format':1,'release_id':release,'source_commit':commit,'package_sha256':file_digest(raw/'package.tar'),'manifest_sha256':file_digest(td/'payload/manifest.json')}
|
||||||
|
(raw/'authorization.json').write_bytes(canonical(auth));sign(raw/'authorization.json',key)
|
||||||
|
# transport.py retains the existing qualified Zstandard framing/signatures.
|
||||||
|
compress_bundle(raw,output,key,public,verified=True)
|
||||||
|
with tempfile.TemporaryDirectory() as td:verify(output,Path(td),public)
|
||||||
|
print(json.dumps(auth))
|
||||||
|
def verify(source,work,public):
|
||||||
|
source=Path(source).resolve();work=Path(work)
|
||||||
|
require({p.name for p in source.iterdir()}==BUNDLE,'Unexpected bundle members')
|
||||||
|
for name in ('authorization.json','authorization.sig'):snapshot(source/name,work/name,16384)
|
||||||
|
auth=signed_json(work/'authorization.json',work/'authorization.sig',public)
|
||||||
|
require(auth['format']==1 and re.fullmatch('[a-f0-9]{40}',auth['source_commit']),'Invalid authorization')
|
||||||
|
safe_name(auth['release_id'])
|
||||||
|
transport=envelope(source,work,public)
|
||||||
|
require(all(transport[k]==auth[v] for k,v in [('release_id','release_id'),('source_commit','source_commit'),('original_sha256','package_sha256')]),'Transport identity mismatch')
|
||||||
|
decompress(work,transport)
|
||||||
|
require(file_digest(work/'package.tar')==auth['package_sha256'],'Package checksum mismatch')
|
||||||
|
payload=work/'payload';payload.mkdir();names=set();total=0
|
||||||
|
with tarfile.open(work/'package.tar','r:') as tar:
|
||||||
|
for member in tar:
|
||||||
|
name=str(safe_path(member.name))
|
||||||
|
require(member.isfile() and not member.pax_headers and not member.linkname,'Only plain files allowed')
|
||||||
|
require(name=='manifest.json' or name.startswith('app/'),'Unexpected package member')
|
||||||
|
require(name not in names and len(names)<LIMIT_FILES,'Duplicate/excessive member')
|
||||||
|
total+=member.size;require(0<=member.size and total<=LIMIT_BYTES,'Package too large');names.add(name)
|
||||||
|
path=payload/name;path.parent.mkdir(parents=True,exist_ok=True)
|
||||||
|
with path.open('xb') as out,tar.extractfile(member) as stream:shutil.copyfileobj(stream,out)
|
||||||
|
require(file_digest(payload/'manifest.json')==auth['manifest_sha256'],'Manifest checksum mismatch')
|
||||||
|
m=load(payload/'manifest.json')
|
||||||
|
require(m['format']==1 and m['product']=='PlotDirector.Website','Wrong product')
|
||||||
|
require(m['release_id']==auth['release_id'] and m['source_commit']==auth['source_commit'],'Manifest identity mismatch')
|
||||||
|
require(names==set(m['files'])|{'manifest.json'},'File inventory mismatch')
|
||||||
|
for name,digest in m['files'].items():require(file_digest(payload/name)==digest,'File checksum mismatch')
|
||||||
|
require(load(payload/'app/PlotDirector.Website.runtimeconfig.json')['runtimeOptions']['tfm']=='net10.0','Wrong runtime')
|
||||||
|
require(not any(n.startswith('app/appsettings') or '/uploads/' in n or '/sql/' in n for n in names),'Forbidden payload')
|
||||||
|
return m,payload,auth
|
||||||
|
|
||||||
|
def protect(path):
|
||||||
|
path=Path(path)
|
||||||
|
while True:
|
||||||
|
st=path.lstat();require(st.st_uid==0 and not st.st_mode&0o022 and not path.is_symlink(),'Unprotected deployment configuration')
|
||||||
|
if path==path.parent:break
|
||||||
|
path=path.parent
|
||||||
|
|
||||||
|
def activate(release,validate=False,rollback=False):
|
||||||
|
require(os.geteuid()==0,'Use the fixed installed privileged helper');safe_name(release)
|
||||||
|
production=os.environ.get('PLOTDIRECTOR_WEBSITE_TARGET')=='Production'
|
||||||
|
config=Path('/etc/plotdirector-website-production/target.json' if production else '/etc/plotdirector-website-development/target.json');protect(config)
|
||||||
|
cfg=load(config)
|
||||||
|
expected=('plotdirector-website.service','/srv/plotdirector-website','http://127.0.0.1:5004/health') if production else ('plotdirector-website-dev.service','/opt/plotdirector-website-dev','http://127.0.0.1:5051/health')
|
||||||
|
require(cfg['product']=='PlotDirector.Website' and (cfg['service'],cfg['root'],cfg['url'])==expected,'Wrong fixed website target')
|
||||||
|
require(os.uname().nodename.split('.')[0]==('web1' if production else 'atlas'),'Wrong deployment host')
|
||||||
|
root=Path(cfg['root']);protect(root);protect(cfg['public_key'])
|
||||||
|
root.joinpath('receipts').mkdir(exist_ok=True)
|
||||||
|
with (root/'deployment.lock').open('a') as lock:
|
||||||
|
fcntl.flock(lock,fcntl.LOCK_EX)
|
||||||
|
receipt={'operation':str(uuid.uuid4()),'release':release,'kind':'validate' if validate else 'rollback' if rollback else 'deploy','startedUtc':time.strftime('%Y-%m-%dT%H:%M:%SZ',time.gmtime()),'status':'failed'}
|
||||||
|
previous=None;switched=False
|
||||||
|
try:
|
||||||
|
with tempfile.TemporaryDirectory(prefix='verify-',dir=root) as td:
|
||||||
|
m,payload,auth=verify(Path(cfg['inbox'])/release,Path(td),cfg['public_key']);require(m['release_id']==release,'Inbox identity mismatch')
|
||||||
|
receipt.update(sourceCommit=m['source_commit'],packageSha256=auth['package_sha256'],manifestSha256=auth['manifest_sha256'])
|
||||||
|
if not validate:
|
||||||
|
destination=root/'releases'/release/'app'
|
||||||
|
if destination.exists():
|
||||||
|
require(rollback,'Release already exists; rollback must be explicit')
|
||||||
|
for name,digest in m['files'].items():require(file_digest(destination/Path(name).relative_to('app'))==digest,'Retained release differs')
|
||||||
|
else:
|
||||||
|
destination.parent.mkdir(parents=True);shutil.copytree(payload/'app',destination)
|
||||||
|
for p in destination.rglob('*'):p.chmod(0o755 if p.is_dir() else 0o444)
|
||||||
|
destination.chmod(0o755);destination.parent.chmod(0o755)
|
||||||
|
previous=(root/'current').resolve() if (root/'current').exists() else None
|
||||||
|
receipt['previous']=str(previous) if previous else None
|
||||||
|
link=root/('.next-'+receipt['operation']);link.symlink_to(destination);os.replace(link,root/'current');switched=True
|
||||||
|
subprocess.run(['/usr/bin/systemctl','restart',cfg['service']],check=True,timeout=30)
|
||||||
|
ready=False
|
||||||
|
for _ in range(40):
|
||||||
|
try:
|
||||||
|
with urlopen(cfg['url'],timeout=2) as response:health=json.load(response)
|
||||||
|
if health.get('healthy') and health.get('product')=='PlotDirector.Website' and health.get('sourceCommit')==m['source_commit']:ready=True;break
|
||||||
|
except (OSError,ValueError):pass
|
||||||
|
time.sleep(.25)
|
||||||
|
require(ready,'Website health/source identity failed')
|
||||||
|
receipt['health']=health
|
||||||
|
(root/'active-deployment.json').write_bytes(canonical(receipt|{'status':'activated'}))
|
||||||
|
receipt['status']='validated' if validate else 'activated'
|
||||||
|
except Exception:
|
||||||
|
receipt['failure']='Deployment failed; review protected service logs'
|
||||||
|
if switched and previous:
|
||||||
|
link=root/('.recover-'+receipt['operation']);link.symlink_to(previous);os.replace(link,root/'current')
|
||||||
|
subprocess.run(['/usr/bin/systemctl','restart',cfg['service']],check=False,timeout=30)
|
||||||
|
receipt['recoveredPrevious']=True
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
receipt['completedUtc']=time.strftime('%Y-%m-%dT%H:%M:%SZ',time.gmtime())
|
||||||
|
(root/'receipts'/(receipt['operation']+'.json')).write_bytes(canonical(receipt))
|
||||||
|
print(json.dumps(receipt))
|
||||||
|
|
||||||
|
def main():
|
||||||
|
p=argparse.ArgumentParser();s=p.add_subparsers(dest='command',required=True)
|
||||||
|
q=s.add_parser('prepare');q.add_argument('--source',required=True);q.add_argument('--output',required=True);q.add_argument('--release-id',required=True);q.add_argument('--signing-key',required=True);q.add_argument('--public-key',required=True)
|
||||||
|
q=s.add_parser('verify');q.add_argument('bundle');q.add_argument('--public-key',required=True)
|
||||||
|
for c in ['validate','activate','rollback','receipt']:q=s.add_parser(c);q.add_argument('release')
|
||||||
|
a=p.parse_args()
|
||||||
|
if a.command=='prepare':prepare(a.source,a.output,a.release_id,a.signing_key,a.public_key)
|
||||||
|
elif a.command=='verify':
|
||||||
|
with tempfile.TemporaryDirectory() as td:m,_,_=verify(a.bundle,Path(td),a.public_key);print(json.dumps({'verified':True,'release':m['release_id']}))
|
||||||
|
elif a.command=='receipt':
|
||||||
|
require(re.fullmatch(r'[a-f0-9-]{36}',a.release),'Invalid receipt identifier')
|
||||||
|
root=Path('/srv/plotdirector-website' if os.environ.get('PLOTDIRECTOR_WEBSITE_TARGET')=='Production' else '/opt/plotdirector-website-dev')
|
||||||
|
path=root/'receipts'/(a.release+'.json');protect(path);print(path.read_text())
|
||||||
|
else:activate(a.release,validate=a.command=='validate',rollback=a.command=='rollback')
|
||||||
|
if __name__=='__main__':main()
|
||||||
30
Tools/brand_package.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Versioned public-brand exchange. Explicit consumption in a source checkout only."""
|
||||||
|
import argparse,hashlib,json,shutil,subprocess
|
||||||
|
from pathlib import Path,PurePosixPath
|
||||||
|
CSS={'css/public-site.css','css/public-art-direction.css','css/public-visual-system.css','favicon.svg'}
|
||||||
|
def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest()
|
||||||
|
def allowed(name):return name in CSS or name.startswith('images/public/')
|
||||||
|
p=argparse.ArgumentParser();s=p.add_subparsers(dest='command',required=True)
|
||||||
|
q=s.add_parser('publish');q.add_argument('--source',required=True);q.add_argument('--output',required=True);q.add_argument('--version',required=True)
|
||||||
|
q=s.add_parser('consume');q.add_argument('package');q.add_argument('--target-webroot',required=True);q.add_argument('--manifest-sha256',required=True)
|
||||||
|
a=p.parse_args()
|
||||||
|
if a.command=='publish':
|
||||||
|
root=Path(a.source).resolve();out=Path(a.output).resolve();out.mkdir(exist_ok=False);web=root/'PlotDirector.Website/wwwroot'
|
||||||
|
files={str(f.relative_to(web)):sha(f) for f in sorted(web.rglob('*')) if f.is_file() and allowed(str(f.relative_to(web)))}
|
||||||
|
for name in files:
|
||||||
|
dest=out/name;dest.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(web/name,dest)
|
||||||
|
manifest={'format':1,'version':a.version,'sourceCommit':subprocess.check_output(['git','rev-parse','HEAD'],cwd=root,text=True).strip(),'files':files}
|
||||||
|
(out/'manifest.json').write_text(json.dumps(manifest,indent=2)+'\n');print(sha(out/'manifest.json'))
|
||||||
|
else:
|
||||||
|
source=Path(a.package).resolve();target=Path(a.target_webroot).resolve()
|
||||||
|
if not (target.parent/'PlotLine.csproj').is_file():raise ValueError('Application source webroot required; deployed directories forbidden')
|
||||||
|
if sha(source/'manifest.json')!=a.manifest_sha256:raise ValueError('Approved manifest digest mismatch')
|
||||||
|
m=json.loads((source/'manifest.json').read_text())
|
||||||
|
if m['format']!=1:raise ValueError('Unsupported brand format')
|
||||||
|
for name,digest in m['files'].items():
|
||||||
|
path=PurePosixPath(name)
|
||||||
|
if path.is_absolute() or '..' in path.parts or '\\' in name or not allowed(name) or (source/name).is_symlink() or sha(source/name)!=digest:raise ValueError('Invalid brand member')
|
||||||
|
for name in m['files']:
|
||||||
|
dest=target/name;dest.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(source/name,dest)
|
||||||
|
print(json.dumps({'consumed':m['version'],'sourceCommit':m['sourceCommit'],'files':len(m['files'])}))
|
||||||
40
Tools/consume_help.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Verify and install an explicitly published help directory; never contacts the app."""
|
||||||
|
import argparse,hashlib,json,os,shutil,tempfile
|
||||||
|
from pathlib import Path,PurePosixPath
|
||||||
|
|
||||||
|
def consume(source,store,channel,expected):
|
||||||
|
source,store=Path(source).resolve(),Path(store).resolve()
|
||||||
|
manifest=(source/'manifest.json').read_bytes()
|
||||||
|
if hashlib.sha256(manifest).hexdigest()!=expected:raise ValueError('Approved manifest digest differs')
|
||||||
|
m=json.loads(manifest)
|
||||||
|
if m['format']!=1 or m['channel']!=channel:raise ValueError('Wrong content publication channel')
|
||||||
|
if not m['files'] or 'articles.json' not in m['files']:raise ValueError('Missing article inventory')
|
||||||
|
store.mkdir(parents=True,exist_ok=True)
|
||||||
|
version=store/expected
|
||||||
|
if version.exists():raise ValueError('Publication already installed; select its retained directory explicitly')
|
||||||
|
with tempfile.TemporaryDirectory(prefix='.incoming-',dir=store) as temp:
|
||||||
|
temp=Path(temp)
|
||||||
|
for name,digest in m['files'].items():
|
||||||
|
path=PurePosixPath(name)
|
||||||
|
if path.is_absolute() or '..' in path.parts or '\\' in name:raise ValueError('Unsafe package member')
|
||||||
|
src=source/name
|
||||||
|
if src.is_symlink() or not src.is_file() or not src.resolve().is_relative_to(source):raise ValueError('Unsafe publication file')
|
||||||
|
data=src.read_bytes()
|
||||||
|
if hashlib.sha256(data).hexdigest()!=digest:raise ValueError('Publication checksum mismatch')
|
||||||
|
out=temp/name;out.parent.mkdir(parents=True,exist_ok=True);out.write_bytes(data)
|
||||||
|
articles=json.loads((temp/'articles.json').read_text())
|
||||||
|
urls=[a['CategorySlug']+'/'+a['Slug'] for a in articles]
|
||||||
|
if len(urls)!=len(set(urls)) or any(a['Category'].lower()=='internal' for a in articles):raise ValueError('Invalid public articles')
|
||||||
|
(temp/'manifest.json').write_bytes(manifest)
|
||||||
|
for file in temp.rglob('*'):
|
||||||
|
file.chmod(0o755 if file.is_dir() else 0o444)
|
||||||
|
temp.chmod(0o755)
|
||||||
|
os.rename(temp,version)
|
||||||
|
# TemporaryDirectory cleanup tolerates the directory being atomically moved.
|
||||||
|
link=store/('.current-'+expected)
|
||||||
|
link.symlink_to(version)
|
||||||
|
os.replace(link,store/'current')
|
||||||
|
print(json.dumps({'channel':channel,'version':m['version'],'manifestSha256':expected,'articles':len(articles)}))
|
||||||
|
if __name__=='__main__':
|
||||||
|
p=argparse.ArgumentParser();p.add_argument('source');p.add_argument('--store',required=True);p.add_argument('--channel',choices=['Development','Production'],required=True);p.add_argument('--manifest-sha256',required=True);a=p.parse_args();consume(a.source,a.store,a.channel,a.manifest_sha256)
|
||||||
59
package-lock.json
generated
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
"name": "PlotDirector.Website",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"devDependencies": {
|
||||||
|
"playwright": "1.58.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/fsevents": {
|
||||||
|
"version": "2.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||||
|
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||||
|
"dev": true,
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/playwright": {
|
||||||
|
"version": "1.58.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.58.2.tgz",
|
||||||
|
"integrity": "sha512-vA30H8Nvkq/cPBnNw4Q8TWz1EJyqgpuinBcHET0YVJVFldr8JDNiU9LaWAE1KqSkRYazuaBhTpB5ZzShOezQ6A==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"playwright-core": "1.58.2"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"playwright": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"fsevents": "2.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/playwright-core": {
|
||||||
|
"version": "1.58.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.58.2.tgz",
|
||||||
|
"integrity": "sha512-yZkEtftgwS8CsfYo7nm0KE8jsvm6i/PTgVtB8DL726wNf6H2IMsDuxCpJj59KDaxCtSnrWan2AeDqM7JBaultg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"playwright-core": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
package.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"private":true,"scripts":{"test:browser":"node Tests/browser.cjs"},"devDependencies":{"playwright":"1.58.2"}}
|
||||||