@nickpaustian/tela 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/index.js +1 -0
- package/lib/vite.js +7 -5
- package/package.json +5 -1
- package/scripts/check-components.ts +9 -0
- package/scripts/create-user.ts +50 -0
- package/scripts/media-words.ts +79 -0
- package/scripts/set-password.ts +72 -0
- package/src/config/types.ts +6 -0
- package/src/project.ts +9 -6
- package/src/vite.ts +1 -1
- package/src/collections/exhibitions/StatusSummary.lsp +0 -76
- package/src/collections/exhibitions/panels.ts +0 -53
- package/src/collections/exhibitions/schema.ts +0 -203
- package/src/collections/index.ts +0 -20
- package/src/collections/people/schema.ts +0 -16
- package/src/collections/users/schema.ts +0 -18
- package/src/collections/venues/schema.ts +0 -37
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ bunx tela build # checks components, builds the admin into ./dist
|
|
|
23
23
|
bunx tela create-user you@example.com # or open the admin: a fresh database offers to create the first admin
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
A project component with the same name as one of Tela's fails the build unless the project names it in `overrides`, which is how a project replaces an input on purpose.
|
|
26
|
+
A project component with the same name as one of Tela's fails the build unless the project names it in `overrides`, which is how a project replaces an input on purpose. Components are scanned from the project's `src`; `components: ["…"]` in the config adds other folders.
|
|
27
27
|
|
|
28
28
|
`tela dev` and `tela build` run Vite under Node 22.6 or later. The two entry points Vite's config loads (`@nickpaustian/tela` and `/vite`) ship compiled to `lib/`, since Node will not load TypeScript from `node_modules`; Bun reads the source. `bun run build:lib` rebuilds them, and packing does it first.
|
|
29
29
|
|
|
@@ -40,7 +40,7 @@ Bun's `file:` protocol copies rather than links, so it is not what you want here
|
|
|
40
40
|
|
|
41
41
|
## Developing Tela itself
|
|
42
42
|
|
|
43
|
-
This repo is also a valid project: its `tela.config.ts` and `
|
|
43
|
+
This repo is also a valid project: its `tela.config.ts` and `example/` (collections and a component, named in the config's `components` so they are scanned like a project's `src`) are the example the tests run against. `example/` is not in the package.
|
|
44
44
|
|
|
45
45
|
```sh
|
|
46
46
|
docker compose up -d
|
package/lib/index.js
CHANGED
|
@@ -440,6 +440,7 @@ function defineConfig(config) {
|
|
|
440
440
|
navigation: config.navigation,
|
|
441
441
|
media: config.media,
|
|
442
442
|
...config.overrides ? { overrides: config.overrides } : {},
|
|
443
|
+
...config.components ? { components: config.components } : {},
|
|
443
444
|
...config.site ? { site: config.site } : {},
|
|
444
445
|
...config.siteName ? { siteName: config.siteName } : {},
|
|
445
446
|
...config.userNames ? { userNames: true } : {}
|
package/lib/vite.js
CHANGED
|
@@ -14,11 +14,13 @@ if (!existsSync(CONFIG_PATH)) {
|
|
|
14
14
|
}
|
|
15
15
|
var PROJECT_ROOT = dirname(CONFIG_PATH);
|
|
16
16
|
var DIST = resolve(PROJECT_ROOT, "dist");
|
|
17
|
-
function componentRoots() {
|
|
17
|
+
function componentRoots(extra = []) {
|
|
18
18
|
const roots = [resolve(TELA_ROOT, "src")];
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
roots.
|
|
19
|
+
for (const dir of ["src", ...extra]) {
|
|
20
|
+
const project = resolve(PROJECT_ROOT, dir);
|
|
21
|
+
if (!roots.includes(project))
|
|
22
|
+
roots.push(project);
|
|
23
|
+
}
|
|
22
24
|
return roots;
|
|
23
25
|
}
|
|
24
26
|
|
|
@@ -26,7 +28,7 @@ function componentRoots() {
|
|
|
26
28
|
var require2 = createRequire(import.meta.url);
|
|
27
29
|
var MEDIA_LIBRARY = dirname2(require2.resolve("@pseudolux-ui/media-library"));
|
|
28
30
|
function telaVite(config) {
|
|
29
|
-
const projectComponents = componentRoots().slice(1);
|
|
31
|
+
const projectComponents = componentRoots(config.components).slice(1);
|
|
30
32
|
return {
|
|
31
33
|
root: TELA_ROOT,
|
|
32
34
|
base: "/",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nickpaustian/tela",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A Git-backed headless CMS: collections of fields in TypeScript, edited in a Lightspeed admin, published as JSON commits to a content repo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nick Paustian",
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"src",
|
|
31
31
|
"routes",
|
|
32
32
|
"lib",
|
|
33
|
+
"scripts/check-components.ts",
|
|
34
|
+
"scripts/create-user.ts",
|
|
35
|
+
"scripts/set-password.ts",
|
|
36
|
+
"scripts/media-words.ts",
|
|
33
37
|
"LICENSE",
|
|
34
38
|
"README.md"
|
|
35
39
|
],
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { config } from "../src/config/load.ts"
|
|
2
|
+
import { checkProject, reportCheck } from "../src/config/check.ts"
|
|
3
|
+
import { componentRoots } from "../src/project.ts"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The pre-build check, runnable on its own. `tela check` is the same call.
|
|
7
|
+
*/
|
|
8
|
+
const ok = reportCheck(checkProject(config.collections, componentRoots(config.components), config.overrides))
|
|
9
|
+
if (!ok) process.exit(1)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create an account. There is no sign-up route by design: an admin panel with
|
|
3
|
+
* open registration is a way to lose a site. The one exception is the first
|
|
4
|
+
* account, which the sign-in page offers to create while no account exists.
|
|
5
|
+
*
|
|
6
|
+
* bun run scripts/create-user.ts alice@example.com
|
|
7
|
+
* bun run scripts/create-user.ts alice@example.com --editor
|
|
8
|
+
*
|
|
9
|
+
* The first account is an **admin**, because otherwise nobody is: the deleted
|
|
10
|
+
* view and permanent deletion would be behind a role no account holds. After
|
|
11
|
+
* that the default stays admin - the script is run by whoever administers this
|
|
12
|
+
* CMS - and `--editor` is how to make one that is not.
|
|
13
|
+
*/
|
|
14
|
+
import { createUser } from "../src/auth/login.ts"
|
|
15
|
+
import { countUsers } from "../src/content/users.ts"
|
|
16
|
+
import { sql } from "../src/db/client.ts"
|
|
17
|
+
|
|
18
|
+
const email = process.argv[2]
|
|
19
|
+
const role = process.argv.includes("--editor") ? "editor" : "admin"
|
|
20
|
+
|
|
21
|
+
if (!email) {
|
|
22
|
+
console.error("usage: bun run scripts/create-user.ts <email>")
|
|
23
|
+
process.exit(1)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const password = process.env.TELA_PASSWORD ?? prompt("password:")
|
|
27
|
+
|
|
28
|
+
if (!password || password.length < 10) {
|
|
29
|
+
console.error("A password of at least 10 characters is required.")
|
|
30
|
+
process.exit(1)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const first = (await countUsers()) === 0
|
|
35
|
+
const id = await createUser(email, password, { role })
|
|
36
|
+
|
|
37
|
+
console.log(
|
|
38
|
+
`created ${email} (${id}) as ${role}` + (first ? " - the first account" : ""),
|
|
39
|
+
)
|
|
40
|
+
} catch (error) {
|
|
41
|
+
// Unique violation on email is the common case and worth saying plainly.
|
|
42
|
+
console.error(
|
|
43
|
+
String(error).includes("unique")
|
|
44
|
+
? `${email} already exists.`
|
|
45
|
+
: `Could not create user: ${error}`,
|
|
46
|
+
)
|
|
47
|
+
process.exit(1)
|
|
48
|
+
} finally {
|
|
49
|
+
await sql.end()
|
|
50
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Move words kept on media records into the media library.
|
|
3
|
+
*
|
|
4
|
+
* Over a library, a media record holds no alt text or credit of its own: the
|
|
5
|
+
* library keeps a picture's words, shared and per group, and publishing reads
|
|
6
|
+
* them there. Records written before that still carry words that nothing
|
|
7
|
+
* reads any more. This moves each one into the picture's words for this
|
|
8
|
+
* instance's group - what the record meant, "how this site describes it" -
|
|
9
|
+
* and clears the record.
|
|
10
|
+
*
|
|
11
|
+
* Shows what it would do unless given --apply. A picture that is not in this
|
|
12
|
+
* instance's group cannot hold words for it; those are listed and left, since
|
|
13
|
+
* moving them into the shared words would change every other site's text.
|
|
14
|
+
*
|
|
15
|
+
* tela media-words what would move
|
|
16
|
+
* tela media-words --apply move it
|
|
17
|
+
*/
|
|
18
|
+
import { sql } from "../src/db/client.ts"
|
|
19
|
+
import { media } from "../src/media/index.ts"
|
|
20
|
+
|
|
21
|
+
const apply = process.argv.includes("--apply")
|
|
22
|
+
const library = media().library
|
|
23
|
+
|
|
24
|
+
if (!library) {
|
|
25
|
+
console.log("This project's media store is not a library: its records keep their own words, and nothing needs moving.")
|
|
26
|
+
await sql.end()
|
|
27
|
+
process.exit(0)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!library.tag) {
|
|
31
|
+
console.error("This instance has no group (TELA_PSEUDOLUX_TAG), so there is no group's words to move into.")
|
|
32
|
+
await sql.end()
|
|
33
|
+
process.exit(1)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const rows = await sql`
|
|
37
|
+
select id, data from entries
|
|
38
|
+
where collection = 'media' and deleted_at is null
|
|
39
|
+
and (coalesce(data ->> 'alt', '') <> '' or coalesce(data ->> 'credit', '') <> '')
|
|
40
|
+
order by updated_at
|
|
41
|
+
`
|
|
42
|
+
|
|
43
|
+
let moved = 0
|
|
44
|
+
let left = 0
|
|
45
|
+
|
|
46
|
+
for (const row of rows) {
|
|
47
|
+
const data = row.data as { file?: string; title?: string; alt?: string; credit?: string }
|
|
48
|
+
const name = data.title || data.file || row.id
|
|
49
|
+
const words = {
|
|
50
|
+
...(data.alt ? { altText: data.alt } : {}),
|
|
51
|
+
...(data.credit ? { credit: data.credit } : {}),
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const asset = data.file ? await library.client.inspect(data.file).catch(() => null) : null
|
|
55
|
+
if (!asset || !(asset.tags ?? []).includes(library.tag)) {
|
|
56
|
+
console.log(`left ${name}: ${asset ? `not in ${library.tag}` : "not in the library"}`)
|
|
57
|
+
left++
|
|
58
|
+
continue
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// What the group already says wins; the record only fills a gap.
|
|
62
|
+
const has = asset.views?.[library.tag] ?? {}
|
|
63
|
+
const fill = Object.fromEntries(
|
|
64
|
+
Object.entries(words).filter(([word]) => !has[word as keyof typeof has]),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
console.log(`${apply ? "moved " : "move "} ${name}: ${Object.keys(fill).join(" and ") || "nothing new"} to ${library.tag}`)
|
|
68
|
+
if (apply) {
|
|
69
|
+
if (Object.keys(fill).length) await library.client.describeView(asset.pid, library.tag, fill)
|
|
70
|
+
await sql`update entries set data = data - 'alt' - 'credit' where id = ${row.id}`
|
|
71
|
+
}
|
|
72
|
+
moved++
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
console.log(
|
|
76
|
+
`\n${rows.length} record${rows.length === 1 ? "" : "s"} with words: ${moved} ${apply ? "moved" : "to move"}, ${left} left.` +
|
|
77
|
+
(apply || !moved ? "" : " Run again with --apply to move them."),
|
|
78
|
+
)
|
|
79
|
+
await sql.end()
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Change an account's password.
|
|
3
|
+
*
|
|
4
|
+
* The companion to `create-user.ts`, and the way back in when somebody is
|
|
5
|
+
* locked out: there is no reset email and no sign-up route, deliberately, so
|
|
6
|
+
* this is the door - and it is a door that needs a shell on the server.
|
|
7
|
+
*
|
|
8
|
+
* bun run scripts/set-password.ts alice@example.com
|
|
9
|
+
* TELA_PASSWORD=… bun run scripts/set-password.ts alice@example.com
|
|
10
|
+
*/
|
|
11
|
+
import { sql } from "../src/db/client.ts"
|
|
12
|
+
|
|
13
|
+
const email = process.argv[2]?.toLowerCase()
|
|
14
|
+
|
|
15
|
+
if (!email) {
|
|
16
|
+
console.error("usage: bun run scripts/set-password.ts <email>")
|
|
17
|
+
process.exit(1)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Checked before asking for a password. Being prompted, typing carefully, and
|
|
21
|
+
// then being told the account does not exist is a small insult.
|
|
22
|
+
const [account] = await sql`select id from users where email = ${email}`
|
|
23
|
+
|
|
24
|
+
if (!account) {
|
|
25
|
+
console.error(`No account for ${email}.`)
|
|
26
|
+
|
|
27
|
+
const others = await sql`select email from users order by email`
|
|
28
|
+
if (others.length) {
|
|
29
|
+
console.error(`Accounts: ${others.map((one: any) => one.email).join(", ")}`)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await sql.end()
|
|
33
|
+
process.exit(1)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const password = process.env.TELA_PASSWORD ?? prompt("new password:")
|
|
37
|
+
|
|
38
|
+
// The same floor `createUser` applies. A script that quietly accepts a weaker
|
|
39
|
+
// password than the form does is a hole in the form.
|
|
40
|
+
if (!password || password.length < 10) {
|
|
41
|
+
console.error("A password of at least 10 characters is required.")
|
|
42
|
+
await sql.end()
|
|
43
|
+
process.exit(1)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
await sql`
|
|
48
|
+
update users
|
|
49
|
+
set password_hash = ${await Bun.password.hash(password)},
|
|
50
|
+
updated_at = now()
|
|
51
|
+
where id = ${account.id}
|
|
52
|
+
`
|
|
53
|
+
|
|
54
|
+
// Every session for this account goes. Changing a password because it may
|
|
55
|
+
// have been seen is the main reason to change one, and leaving the existing
|
|
56
|
+
// sessions alive would defeat exactly that.
|
|
57
|
+
const gone = await sql`
|
|
58
|
+
delete from sessions where user_id = ${account.id} returning id
|
|
59
|
+
`
|
|
60
|
+
|
|
61
|
+
console.log(
|
|
62
|
+
`password set for ${email}` +
|
|
63
|
+
(gone.length
|
|
64
|
+
? ` — ${gone.length} session${gone.length === 1 ? "" : "s"} signed out`
|
|
65
|
+
: ""),
|
|
66
|
+
)
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error(`Could not set the password: ${error}`)
|
|
69
|
+
process.exit(1)
|
|
70
|
+
} finally {
|
|
71
|
+
await sql.end()
|
|
72
|
+
}
|
package/src/config/types.ts
CHANGED
|
@@ -653,6 +653,11 @@ export interface TelaConfig {
|
|
|
653
653
|
* the one the admin should use.
|
|
654
654
|
*/
|
|
655
655
|
overrides?: string[]
|
|
656
|
+
/**
|
|
657
|
+
* Folders of the project's own components outside its `src`, relative to
|
|
658
|
+
* the project. `src` is always scanned.
|
|
659
|
+
*/
|
|
660
|
+
components?: string[]
|
|
656
661
|
}
|
|
657
662
|
|
|
658
663
|
export interface NavSection {
|
|
@@ -1044,6 +1049,7 @@ export function defineConfig(config: TelaConfig): TelaConfig {
|
|
|
1044
1049
|
navigation: config.navigation,
|
|
1045
1050
|
media: config.media,
|
|
1046
1051
|
...(config.overrides ? { overrides: config.overrides } : {}),
|
|
1052
|
+
...(config.components ? { components: config.components } : {}),
|
|
1047
1053
|
...(config.site ? { site: config.site } : {}),
|
|
1048
1054
|
...(config.siteName ? { siteName: config.siteName } : {}),
|
|
1049
1055
|
...(config.userNames ? { userNames: true } : {}),
|
package/src/project.ts
CHANGED
|
@@ -34,13 +34,16 @@ export const PROJECT_ROOT = dirname(CONFIG_PATH)
|
|
|
34
34
|
export const DIST = resolve(PROJECT_ROOT, "dist")
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* Where components come from: Tela's `src`,
|
|
38
|
-
* somewhere else
|
|
39
|
-
* collection that uses
|
|
37
|
+
* Where components come from: Tela's `src`, the project's when that is
|
|
38
|
+
* somewhere else, and any other folders the project's config names. All
|
|
39
|
+
* scanned whole, so a project's input can sit beside the collection that uses
|
|
40
|
+
* it.
|
|
40
41
|
*/
|
|
41
|
-
export function componentRoots(): string[] {
|
|
42
|
+
export function componentRoots(extra: string[] = []): string[] {
|
|
42
43
|
const roots = [resolve(TELA_ROOT, "src")]
|
|
43
|
-
const
|
|
44
|
-
|
|
44
|
+
for (const dir of ["src", ...extra]) {
|
|
45
|
+
const project = resolve(PROJECT_ROOT, dir)
|
|
46
|
+
if (!roots.includes(project)) roots.push(project)
|
|
47
|
+
}
|
|
45
48
|
return roots
|
|
46
49
|
}
|
package/src/vite.ts
CHANGED
|
@@ -30,7 +30,7 @@ const MEDIA_LIBRARY = dirname(require.resolve("@pseudolux-ui/media-library"))
|
|
|
30
30
|
* this bundles the whole thing statically and runs under Node too.
|
|
31
31
|
*/
|
|
32
32
|
export function telaVite(config: TelaConfig): UserConfig {
|
|
33
|
-
const projectComponents = componentRoots().slice(1)
|
|
33
|
+
const projectComponents = componentRoots(config.components).slice(1)
|
|
34
34
|
|
|
35
35
|
return {
|
|
36
36
|
root: TELA_ROOT,
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
<view>
|
|
2
|
-
<span class="status" $class="state.tone">{{ state.label }}</span>
|
|
3
|
-
</view>
|
|
4
|
-
|
|
5
|
-
<logic lang="ts">
|
|
6
|
-
import { defineProps, reactive } from '@lightspeed-js/core'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Whether a dated thing is on, over, or still to come.
|
|
10
|
-
*
|
|
11
|
-
* The summary-component contract: `value` is whatever the part named - the
|
|
12
|
-
* whole entry when it named nothing, which is this case. A status is not one
|
|
13
|
-
* field. It is an opening date and a closing one read together, which is
|
|
14
|
-
* exactly why a summary part is declared where it is consumed rather than on a
|
|
15
|
-
* field that could only ever know half of it.
|
|
16
|
-
*/
|
|
17
|
-
const props = defineProps({
|
|
18
|
-
value: { default: {} },
|
|
19
|
-
options: { default: {} },
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Compared as ISO text.
|
|
24
|
-
*
|
|
25
|
-
* Dates are `YYYY-MM-DD`, so string comparison is date comparison - no parsing,
|
|
26
|
-
* and no timezone deciding that a show closing today closed yesterday.
|
|
27
|
-
*/
|
|
28
|
-
function today() {
|
|
29
|
-
return new Date().toISOString().slice(0, 10)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function status() {
|
|
33
|
-
const opens = props.value?.[props.options?.opens || 'opens']
|
|
34
|
-
const closes = props.value?.[props.options?.closes || 'closes']
|
|
35
|
-
const now = today()
|
|
36
|
-
|
|
37
|
-
if (!opens) return { label: '', tone: '' }
|
|
38
|
-
if (opens > now) return { label: 'Upcoming', tone: 'upcoming' }
|
|
39
|
-
if (closes && closes < now) return { label: 'Closed', tone: 'closed' }
|
|
40
|
-
return { label: 'On now', tone: 'now' }
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const state = reactive(status())
|
|
44
|
-
</logic>
|
|
45
|
-
|
|
46
|
-
<style>
|
|
47
|
-
.status {
|
|
48
|
-
padding: 0.1rem 0.5rem;
|
|
49
|
-
border-radius: 999px;
|
|
50
|
-
font-size: 0.72rem;
|
|
51
|
-
font-weight: 600;
|
|
52
|
-
letter-spacing: 0.02em;
|
|
53
|
-
white-space: nowrap;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/* Empty when there is no opening date - nothing to say, and a blank pill says
|
|
57
|
-
something. */
|
|
58
|
-
.status:empty {
|
|
59
|
-
display: none;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.status.now {
|
|
63
|
-
background: #e4f6ea;
|
|
64
|
-
color: #1d6b3a;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.status.upcoming {
|
|
68
|
-
background: #e8effc;
|
|
69
|
-
color: #24518f;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.status.closed {
|
|
73
|
-
background: #f1f3f5;
|
|
74
|
-
color: #6b7683;
|
|
75
|
-
}
|
|
76
|
-
</style>
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { Block } from "../../config/types.ts"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* What a panel can be.
|
|
5
|
-
*
|
|
6
|
-
* Declared once and shared by both slots - a block is data, so offering the
|
|
7
|
-
* same set in two places is a reference rather than a copy. "Copy" and "Copy
|
|
8
|
-
* with a link" are two shapes rather than one with a conditional: the editor
|
|
9
|
-
* picks a thing, and what is required stays honest.
|
|
10
|
-
*/
|
|
11
|
-
export const PANELS: Block[] = [
|
|
12
|
-
{
|
|
13
|
-
name: "image",
|
|
14
|
-
label: "Image",
|
|
15
|
-
description: "A single picture.",
|
|
16
|
-
fields: [
|
|
17
|
-
// A reference to the library, not a typed path. Alt text travels with
|
|
18
|
-
// the picture rather than being retyped at every use - which is how it
|
|
19
|
-
// ends up missing on the third one.
|
|
20
|
-
{
|
|
21
|
-
name: "image",
|
|
22
|
-
type: "reference",
|
|
23
|
-
to: "media",
|
|
24
|
-
// Stored as a reference like any other; drawn as the library. Type and
|
|
25
|
-
// component are separate for exactly this - the shape in the database
|
|
26
|
-
// does not change because the way of choosing did.
|
|
27
|
-
component: "mediaPicker",
|
|
28
|
-
label: "Image",
|
|
29
|
-
required: true,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: "copy",
|
|
35
|
-
label: "Copy",
|
|
36
|
-
description: "A heading and some text.",
|
|
37
|
-
fields: [
|
|
38
|
-
{ name: "heading", type: "text", label: "Heading" },
|
|
39
|
-
{ name: "body", type: "markdown", label: "Body" },
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: "copyCta",
|
|
44
|
-
label: "Copy with a link",
|
|
45
|
-
description: "Text, and a button that goes somewhere.",
|
|
46
|
-
fields: [
|
|
47
|
-
{ name: "heading", type: "text", label: "Heading" },
|
|
48
|
-
{ name: "body", type: "markdown", label: "Body" },
|
|
49
|
-
{ name: "label", type: "text", label: "Link text", required: true },
|
|
50
|
-
{ name: "href", type: "text", label: "Link target", required: true },
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
]
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { dateRange, splitBlock, type Collection } from "../../config/types.ts"
|
|
2
|
-
import { slugField } from "../../config/fields.ts"
|
|
3
|
-
import { PANELS } from "./panels.ts"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Exhibition landing pages.
|
|
7
|
-
*
|
|
8
|
-
* A real content model rather than an invented one, so the gaps show up
|
|
9
|
-
* honestly: `image` has no field component yet, and the editor says so rather
|
|
10
|
-
* than pretending.
|
|
11
|
-
*
|
|
12
|
-
* Everything this collection needs lives beside this file - the panels it
|
|
13
|
-
* offers, and `StatusSummary.lsp`, which draws its "on now" pill. A component
|
|
14
|
-
* that only one collection uses belongs with that collection; the registry
|
|
15
|
-
* scans the whole source tree, so where a `.lsp` file sits is an organising
|
|
16
|
-
* decision rather than a technical one.
|
|
17
|
-
*/
|
|
18
|
-
export const exhibitions: Collection = {
|
|
19
|
-
name: "exhibitions",
|
|
20
|
-
label: "Exhibitions",
|
|
21
|
-
titleField: "title",
|
|
22
|
-
// How an exhibition is represented wherever something else has to show one:
|
|
23
|
-
// the listing, a reference picker, a chip on a chosen reference. Declared
|
|
24
|
-
// once, because four screens deciding for themselves is four screens that
|
|
25
|
-
// disagree.
|
|
26
|
-
summary: {
|
|
27
|
-
subtitle: "{subtitle}",
|
|
28
|
-
// A template, exactly like `derive` - and it drops the dash along with a
|
|
29
|
-
// closing date that is not there.
|
|
30
|
-
meta: ["{opens} - {closes}", { component: "status" }],
|
|
31
|
-
},
|
|
32
|
-
fields: [
|
|
33
|
-
{
|
|
34
|
-
name: "title",
|
|
35
|
-
type: "text",
|
|
36
|
-
label: "Title",
|
|
37
|
-
required: true,
|
|
38
|
-
maxLength: 120,
|
|
39
|
-
sortable: true,
|
|
40
|
-
searchable: true,
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
slugField(),
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
name: "subtitle",
|
|
47
|
-
type: "text",
|
|
48
|
-
label: "Subtitle",
|
|
49
|
-
maxLength: 160,
|
|
50
|
-
// Searchable, not filterable: nobody narrows a listing *to* a subtitle,
|
|
51
|
-
// but half of what somebody remembers about a show is in one.
|
|
52
|
-
searchable: true,
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
// Admin furniture: it says something useful and stores nothing.
|
|
56
|
-
{
|
|
57
|
-
name: "datesNote",
|
|
58
|
-
type: "note",
|
|
59
|
-
text: "Dates drive the listing order and the “on now” badge, so fill them in even for a show that has closed.",
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
// Sugar that expands to exactly two ordinary date fields - see `dateRange`.
|
|
63
|
-
...dateRange({
|
|
64
|
-
legend: "Dates",
|
|
65
|
-
duration: true,
|
|
66
|
-
start: {
|
|
67
|
-
name: "opens",
|
|
68
|
-
label: "Opens",
|
|
69
|
-
required: true,
|
|
70
|
-
sortable: true,
|
|
71
|
-
filterable: true,
|
|
72
|
-
},
|
|
73
|
-
end: { name: "closes", label: "Closes", sortable: true },
|
|
74
|
-
}),
|
|
75
|
-
|
|
76
|
-
// A composite: one object with a fixed shape, addressed as
|
|
77
|
-
// `credit.photographer` - and `credit.full` written beside the parts when
|
|
78
|
-
// it publishes, so every template that shows a credit shows the same thing
|
|
79
|
-
// without joining it itself.
|
|
80
|
-
{
|
|
81
|
-
name: "credit",
|
|
82
|
-
type: "block",
|
|
83
|
-
label: "Image credit",
|
|
84
|
-
fields: [
|
|
85
|
-
{ name: "photographer", type: "text", label: "Photographer" },
|
|
86
|
-
{ name: "year", type: "text", label: "Year" },
|
|
87
|
-
{ name: "collection", type: "text", label: "Collection" },
|
|
88
|
-
],
|
|
89
|
-
derive: {
|
|
90
|
-
full: "{photographer}, {year}. {collection}",
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
// A group arranges the form; these still store exactly where they did
|
|
95
|
-
// before it existed.
|
|
96
|
-
{
|
|
97
|
-
name: "details",
|
|
98
|
-
type: "group",
|
|
99
|
-
label: "Details",
|
|
100
|
-
collapsed: true,
|
|
101
|
-
// What it shows while it is shut. `reference` is a summary component,
|
|
102
|
-
// the same one a listing would use - and it is handed `to` from the
|
|
103
|
-
// field it previews, so this does not repeat what the field already
|
|
104
|
-
// says.
|
|
105
|
-
peek: [
|
|
106
|
-
{ component: "reference", from: "venue" },
|
|
107
|
-
{ component: "reference", from: "artists" },
|
|
108
|
-
],
|
|
109
|
-
fields: [
|
|
110
|
-
// Stored as the venue's id, published as its slug. The one-to-many side
|
|
111
|
-
// of the relationship: a venue holds no list of exhibitions, because a
|
|
112
|
-
// relationship recorded at both ends is one that can come to disagree
|
|
113
|
-
// with itself.
|
|
114
|
-
{
|
|
115
|
-
name: "venue",
|
|
116
|
-
type: "reference",
|
|
117
|
-
to: "venues",
|
|
118
|
-
label: "Venue",
|
|
119
|
-
filterable: true,
|
|
120
|
-
},
|
|
121
|
-
// And the many-to-many: an exhibition has artists, an artist has
|
|
122
|
-
// exhibitions, and neither field knows about the other.
|
|
123
|
-
{
|
|
124
|
-
name: "artists",
|
|
125
|
-
type: "reference",
|
|
126
|
-
to: "people",
|
|
127
|
-
many: true,
|
|
128
|
-
label: "Artists",
|
|
129
|
-
filterable: true,
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
// The block editor: a list whose rows each choose a shape. Each row records
|
|
135
|
-
// which one under `block`, so the content is legible without this file.
|
|
136
|
-
{
|
|
137
|
-
name: "sections",
|
|
138
|
-
type: "repeater",
|
|
139
|
-
label: "Sections",
|
|
140
|
-
blocks: [
|
|
141
|
-
{
|
|
142
|
-
name: "slider",
|
|
143
|
-
label: "Slider",
|
|
144
|
-
description: "A row of images that scrolls.",
|
|
145
|
-
fields: [
|
|
146
|
-
{ name: "title", type: "text", label: "Title" },
|
|
147
|
-
// A list inside a shape - and it is an ordinary repeater, rendered
|
|
148
|
-
// by the same registry one level further down.
|
|
149
|
-
{
|
|
150
|
-
name: "items",
|
|
151
|
-
type: "repeater",
|
|
152
|
-
label: "Slides",
|
|
153
|
-
of: [
|
|
154
|
-
{ name: "image", type: "reference", to: "media", label: "Image" },
|
|
155
|
-
{ name: "caption", type: "text", label: "Caption" },
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
},
|
|
160
|
-
// Two panels today, because the config says two. The same block with
|
|
161
|
-
// `cells: { min: 1 }` would be an open-ended grid.
|
|
162
|
-
splitBlock({
|
|
163
|
-
name: "twoPanel",
|
|
164
|
-
label: "Two panel",
|
|
165
|
-
description: "Two side-by-side panels, each a block of its own.",
|
|
166
|
-
cells: { min: 1, max: 5 },
|
|
167
|
-
of: PANELS,
|
|
168
|
-
layouts: [
|
|
169
|
-
{ value: "50-50", label: "Equal" },
|
|
170
|
-
{ value: "60-40", label: "Wider left" },
|
|
171
|
-
{ value: "40-60", label: "Wider right" },
|
|
172
|
-
],
|
|
173
|
-
}),
|
|
174
|
-
{
|
|
175
|
-
name: "content",
|
|
176
|
-
label: "Content",
|
|
177
|
-
description: "A heading and a body of text.",
|
|
178
|
-
fields: [
|
|
179
|
-
{ name: "heading", type: "text", label: "Heading" },
|
|
180
|
-
{
|
|
181
|
-
name: "body",
|
|
182
|
-
type: "markdown",
|
|
183
|
-
label: "Body",
|
|
184
|
-
tools: ["bold", "italic", "link"],
|
|
185
|
-
},
|
|
186
|
-
],
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
{
|
|
192
|
-
name: "body",
|
|
193
|
-
type: "markdown",
|
|
194
|
-
label: "About the exhibition",
|
|
195
|
-
// The long-form field, so it gets the long-form tools. Everything else on
|
|
196
|
-
// this model keeps the default two.
|
|
197
|
-
tools: ["bold", "italic", "heading", "link", "bullet", "quote"],
|
|
198
|
-
searchable: true,
|
|
199
|
-
},
|
|
200
|
-
],
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export default exhibitions
|
package/src/collections/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Collection } from "../config/types.ts"
|
|
2
|
-
import exhibitions from "./exhibitions/schema.ts"
|
|
3
|
-
import venues from "./venues/schema.ts"
|
|
4
|
-
import people from "./people/schema.ts"
|
|
5
|
-
import users from "./users/schema.ts"
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Every collection this CMS holds.
|
|
9
|
-
*
|
|
10
|
-
* One import for anything that needs the whole model, and a named one for
|
|
11
|
-
* anything that needs a particular collection - a test that wants `venues`
|
|
12
|
-
* should not have to know which folder it lives in.
|
|
13
|
-
*
|
|
14
|
-
* Listed rather than discovered from the filesystem. The order is the order of
|
|
15
|
-
* the admin's navigation, and a collection that exists because a file exists
|
|
16
|
-
* is a collection nobody decided to add.
|
|
17
|
-
*/
|
|
18
|
-
export const collections: Collection[] = [exhibitions, venues, people, users]
|
|
19
|
-
|
|
20
|
-
export { exhibitions, venues, people, users }
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Collection } from "../../config/types.ts"
|
|
2
|
-
import { slugField } from "../../config/fields.ts"
|
|
3
|
-
|
|
4
|
-
/** Artists, and anyone else an entry needs to name. */
|
|
5
|
-
export const people: Collection = {
|
|
6
|
-
name: "people",
|
|
7
|
-
label: "People",
|
|
8
|
-
titleField: "title",
|
|
9
|
-
fields: [
|
|
10
|
-
{ name: "title", type: "text", label: "Name", required: true, searchable: true },
|
|
11
|
-
slugField(),
|
|
12
|
-
{ name: "bio", type: "markdown", label: "Biography", searchable: true },
|
|
13
|
-
],
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default people
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Collection } from "../../config/types.ts"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Extending the built-in users collection.
|
|
5
|
-
*
|
|
6
|
-
* The same operation as adding a field to any other type. The base is an
|
|
7
|
-
* address, a password and a role: a name is useful *here*, because this CMS
|
|
8
|
-
* shows who edited what, and it is added like any other field.
|
|
9
|
-
*/
|
|
10
|
-
export const users: Collection = {
|
|
11
|
-
name: "users",
|
|
12
|
-
titleField: "name",
|
|
13
|
-
fields: [
|
|
14
|
-
{ name: "name", type: "text", label: "Name", required: true, searchable: true },
|
|
15
|
-
],
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default users
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Collection } from "../../config/types.ts"
|
|
2
|
-
import { slugField } from "../../config/fields.ts"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Somewhere an exhibition happens.
|
|
6
|
-
*
|
|
7
|
-
* Small on purpose. It exists to be pointed at, and what a venue *is* can grow
|
|
8
|
-
* without any of the entries referring to it changing.
|
|
9
|
-
*/
|
|
10
|
-
export const venues: Collection = {
|
|
11
|
-
name: "venues",
|
|
12
|
-
label: "Venues",
|
|
13
|
-
titleField: "title",
|
|
14
|
-
// Two venues can share a name; where they are is what tells them apart,
|
|
15
|
-
// which matters most in the picker where the name is all there is.
|
|
16
|
-
summary: { subtitle: "{address.suburb} {address.state}" },
|
|
17
|
-
fields: [
|
|
18
|
-
{ name: "title", type: "text", label: "Name", required: true, searchable: true },
|
|
19
|
-
slugField(),
|
|
20
|
-
{
|
|
21
|
-
name: "address",
|
|
22
|
-
type: "block",
|
|
23
|
-
label: "Address",
|
|
24
|
-
fields: [
|
|
25
|
-
{ name: "line1", type: "text", label: "Street" },
|
|
26
|
-
{ name: "suburb", type: "text", label: "Suburb", searchable: true },
|
|
27
|
-
{ name: "state", type: "text", label: "State" },
|
|
28
|
-
{ name: "postcode", type: "text", label: "Postcode" },
|
|
29
|
-
],
|
|
30
|
-
derive: {
|
|
31
|
-
full: "{line1}, {suburb} {state} {postcode}",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default venues
|