Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ name: Build
on:
workflow_dispatch:
pull_request:
paths-ignore: ['*.md']
types: [opened, synchronize, reopened, ready_for_review]
branches: ['master']
paths-ignore: ['*.md']

permissions: {}

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
group: package-build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
if: github.event.pull_request.draft == false
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
permissions:
contents: read
uses: Start9Labs/start-technologies/.github/workflows/build.yml@master
secrets:
DEV_KEY: ${{ secrets.DEV_KEY }}
# No DEV_KEY — a PR build doesn't publish, so it doesn't need the signing key.
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@start9labs/start-sdk/prettier.config.json"
26 changes: 0 additions & 26 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,3 @@ This is a StartOS service-package repository — it builds a `.s9pk` for StartOS
Develop it inside a StartOS packaging workspace created by `start-cli s9pk init-workspace`,
which provides the packaging guide and agent context one level up. If you're reading this in a
bare clone with no workspace, the full guide is at <https://docs.start9.com/packaging>.

**Start every task at the recipe index** — `../start-technologies/projects/start-sdk/docs/src/recipes.md`
(or <https://docs.start9.com/packaging/recipes.html>). It maps an intent ("prompt the user to create
admin credentials", "expose a web UI") to the constructs, the reference pages, and a named production
package to copy. Find the recipe before you read this package's neighbours: a package you reach by
grepping may be non-conformant, and the recipe outranks it.

Freshly scaffolded? Work the
[New Package Checklist](../start-technologies/projects/start-sdk/docs/src/new-package-checklist.md)
(or <https://docs.start9.com/packaging/new-package-checklist.html>) from top to bottom. It is a
guide page, not a file in this repo — read it, don't copy it in.

Keep `README.md` (technical reference for an AI support or administering agent) and
`instructions.md` (end-user docs) in sync with your changes. This file restates neither:
whoever changes the package has both, so it carries only what they don't — repo mechanics,
a change that looks right and is not, where the next thing gets added, a naming trap, a
build or test invocation particular to this repo.

**Fix a defect you spot rather than reporting it** — you have the package open and the
context to be sure. File **a GitHub issue on this repo** only when the call isn't yours to
make: you can't pin the cause down, two defensible fixes exist, or it's too large to ride on
the work in hand. An open issue is a report, not a queue — implement one when you're asked
to or when it's labelled `Approved`, then close it with `Closes #<n>`.

Don't record work in the repo instead: no `TODO.md`, no `NOTES.md`, no `PLAN.md`. What you
verified, tried, and decided belongs in the commit message and the PR body.
65 changes: 35 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ the entrypoint's printout of both startup scripts.

The package has one small volume, and it holds no diagram.

| Volume | Mount point | Contents |
| --------- | ----------- | -------------------------------- |
| `startos` | not mounted | `store.json`: the primary URL |
| Volume | Mount point | Contents |
| --------- | ----------- | ----------------------------- |
| `startos` | not mounted | `store.json`: the primary URL |

Diagrams live wherever each user saves them: on their own device, in their browser's
storage for that address, or in Nextcloud when opened through its draw.io app. There
Expand All @@ -72,15 +72,19 @@ is no database, and the draw.io container mounts no volume at all.

One JSON file, written only by the package, never by draw.io.

**`store.json`** (`startos` volume) holds `primaryUrl`. Init sets it on install; the
Set Primary URL action rewrites it. It reaches draw.io as environment variables, read
on every start:
**`store.json`** (`startos` volume) holds `primaryUrl`, the address chosen with Set
Primary URL, empty until one is chosen. draw.io uses that address at its hostname's
current port and scheme. While the hostname is not one of the Web UI's addresses, or
nothing is chosen, it uses the preferred address instead: a public domain (HTTPS
first), else the `.local` address, else the first. The choice is kept, so draw.io
returns to it when the address does. Whenever the address in use changes, draw.io
restarts to pick it up. It reaches draw.io as environment variables:

| Variable | Value |
| --------------------- | -------------------------------------------------------------------------------------- |
| `DRAWIO_SERVER_URL` | Always `/`. Keeps the editor's own requests relative, so it works from every address |
| `DRAWIO_BASE_URL` | `primaryUrl`, trailing slash removed. Used in HTML exports, embed code and editor links |
| `DRAWIO_LIGHTBOX_URL` | `primaryUrl`. Used for viewer links (File → Publish → Link…) |
| Variable | Value |
| --------------------- | ------------------------------------------------------------------------------------ |
| `DRAWIO_SERVER_URL` | Always `/`. Keeps the editor's own requests relative, so it works from every address |
| `DRAWIO_BASE_URL` | The address in use. Used in HTML exports, embed code and editor links |
| `DRAWIO_LIGHTBOX_URL` | The address in use. Used for viewer links (File → Publish → Link…) |

`DRAWIO_SERVER_URL` must stay set: given only `DRAWIO_BASE_URL`, the upstream
entrypoint derives an absolute server URL from it, and the editor then sends its own
Expand All @@ -106,8 +110,8 @@ The package exposes one HTTP interface. The server has no login: anyone who can
reach an address can use the editor, though there is nothing stored for them to
read.

| Interface | ID | Type | Port | Protocol | Serves |
| --------- | ---- | ---- | ---- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Interface | ID | Type | Port | Protocol | Serves |
| --------- | ---- | ---- | ---- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Web UI | `ui` | `ui` | 8080 | HTTP | The editor; the viewer behind share links (`/?lightbox=1`); the viewer script HTML exports load (`/js/viewer-static.min.js`); the embed mode Nextcloud frames (`/?embed=1`) |

Tomcat's HTTPS port, 8443, is not exposed. Two upstream endpoints fetch URLs
Expand All @@ -118,31 +122,31 @@ private, loopback, link-local and `.local` ones.
## Installation and First-Run Flow

There is no setup wizard and no account to create; the editor is usable as soon as
the service starts. On install, init sets the primary URL to the interface's `.local`
address, or to its first off-box address when there is no `.local` one.
the service starts. Install stores no primary URL: draw.io uses the preferred address
(see File Models), and the Set Primary URL task asks the user to choose one.

## Actions

The package has one action. It can run while the service is running or stopped; a
running draw.io restarts to apply it, which takes a few seconds.

**Set Primary URL** (`set-primary-url`) — run it when people open exported files and
share links from somewhere the current address does not reach, typically over a VPN
or a domain rather than the LAN. It rewrites `primaryUrl` in `store.json`, which
restarts a running draw.io. Its form pre-fills the current address only while that
address still exists, so from the task it opens on the default instead. Links and
**Set Primary URL** (`set-primary-url`), built by `sdk.setupPrimaryUrl` — run it when
people open exported files and share links from somewhere the current address does not
reach, typically over a VPN or a domain rather than the LAN. It offers the Web UI's
off-box addresses, pre-selects the preferred one and pre-fills the stored choice. It
rewrites `primaryUrl` in `store.json`, which restarts a running draw.io. Links and
files exported earlier keep the address they were made with. Safe to repeat.

## Tasks

The package raises one task, and it never blocks the service.

**Set Primary URL**, severity `important`. Init raises it when the stored primary
URL is no longer one of the Web UI's addresses: the address was disabled, a domain
was removed, or a backup was restored onto a server with a different name. Running
Set Primary URL clears it, and so does the chosen address coming back. It returns
whenever the chosen address disappears again.
While it is raised, draw.io keeps running; exports simply carry the dead address.
**Set Primary URL**, severity `important`. Init raises it while no primary URL is
chosen, as after install, and while the chosen one's hostname is not one of the Web
UI's addresses: the address was disabled, a domain was removed, a backup was restored
onto a server with a different name, or an IP address's network link is down. Choosing
an address clears it, and so does the chosen address coming back. While it is raised,
draw.io keeps running on the preferred address.

## Health Checks

Expand All @@ -161,7 +165,8 @@ URL.
A backup contains no diagrams, because the server never has any. Users' diagrams
must be backed up wherever they save them — their devices, or Nextcloud. After a
restore onto a server with a different name, the stored primary URL no longer
matches any address and the task above asks for a new one.
matches any address: draw.io uses the preferred address, and the task above asks for
a new one.

## Limitations and Differences

Expand All @@ -187,8 +192,8 @@ listed because the hosted draw.io at app.diagrams.net behaves differently.
5. **No login.** Anyone who can reach one of its addresses can use the editor.
6. **A new primary URL can lag in an open browser.** The startup scripts are served
without cache headers, so a browser that loaded draw.io recently may keep
exporting with the old address after the action restarts the service. Reloading
the page fetches the new one.
exporting with the old address after it changes. Reloading the page fetches the
new one.
7. **URL proxy off.** With `/proxy` disabled, importing an image by URL from a site
that does not allow cross-origin requests fails; downloading it and inserting the
file works.
Expand Down Expand Up @@ -216,7 +221,7 @@ interfaces:
actions:
- set-primary-url
tasks:
- { action: set-primary-url, severity: important }
- { action: set-primary-url, severity: important } # while unset or not a Web UI address
health_checks:
- primary
```
19 changes: 11 additions & 8 deletions instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

## Getting set up

1. Open the **Web UI**. The editor starts on a blank diagram.
2. Before you rely on it, decide where your diagrams will live. Use **File → Save
1. Run the **Set Primary URL** task StartOS shows after install, to choose the address
that goes into share links and exported files (see **Sharing and exporting** below).
2. Open the **Web UI**. The editor starts on a blank diagram.
3. Before you rely on it, decide where your diagrams will live. Use **File → Save
as…** and pick a place under **Where**:
- **Device** saves a `.drawio` file to a folder you choose, and keeps saving to
it. Any folder your computer can see works, including a mounted network share.
Expand All @@ -32,10 +34,10 @@
### Sharing and exporting

**File → Publish → Link…**, **File → Export as → HTML…** and **File → Embed** all
produce links or files that load from your server's **primary URL** — the `.local`
address, unless you change it. People who open them need to reach that address. If
they open them over a VPN or through a domain instead, run **Set Primary URL** and
choose an address that works for them. Links and files you made earlier keep the
produce links or files that load from draw.io's **primary URL**, the address you
chose with **Set Primary URL**. People who open them need to reach that address. If
they open them over a VPN or through a domain instead, run **Set Primary URL** again
and choose an address that works for them. Links and files you made earlier keep the
address they were made with.

### Using it from Nextcloud
Expand All @@ -59,8 +61,9 @@ your device is in dark mode.
This action chooses which of draw.io's addresses goes into share links, HTML exports
and embed code. If draw.io is running, it restarts, which takes a few seconds; if a
browser that already had draw.io open still uses the old address, reload the page.
If the chosen address stops existing, for example after you disable it, StartOS asks
you to pick a new one, and draw.io keeps working meanwhile.
If the chosen address stops existing, for example after you disable it, draw.io uses
its public domain if it has one, otherwise its `.local` address, until the chosen one
returns, and StartOS asks you to pick a new one.

## Limitations

Expand Down
Loading
Loading