sandcms 0.7.0 → 0.8.0
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 +4 -4
- package/dist/admin/Admin.svelte +7 -5
- package/dist/admin/AssetAttachment.svelte +8 -3
- package/dist/admin/AssetAttachment.svelte.d.ts +3 -0
- package/dist/admin/Editor.svelte +5 -9
- package/dist/admin/Fields.svelte +2 -1
- package/dist/admin/Gallery.svelte +221 -76
- package/dist/admin/Inbox.svelte +3 -2
- package/dist/admin/MediaPicker.svelte +36 -20
- package/dist/admin/Navigation.svelte +13 -2
- package/dist/admin/Pages.svelte +195 -0
- package/dist/admin/Pages.svelte.d.ts +7 -0
- package/dist/admin/Shell.svelte +27 -5
- package/dist/admin/SortableList.svelte +82 -61
- package/dist/admin/SortableList.svelte.d.ts +3 -1
- package/dist/admin/Users.svelte +8 -3
- package/dist/admin/generated/admin.css +300 -20
- package/dist/admin/navigation.d.ts +9 -0
- package/dist/admin/navigation.js +20 -1
- package/dist/admin/types.d.ts +1 -0
- package/dist/blueprints/labels.d.ts +6 -0
- package/dist/blueprints/labels.js +14 -0
- package/dist/blueprints/load.js +11 -2
- package/dist/blueprints/types.d.ts +2 -2
- package/dist/cli/admin.d.ts +39 -0
- package/dist/cli/admin.js +95 -0
- package/dist/cli/backup.js +4 -4
- package/dist/cli/doctor.d.ts +8 -1
- package/dist/cli/doctor.js +19 -9
- package/dist/cli/email-test.d.ts +3 -0
- package/dist/cli/email-test.js +20 -0
- package/dist/cli/files.js +2 -1
- package/dist/cli/index.js +373 -135
- package/dist/cli/rebaseline.d.ts +10 -0
- package/dist/cli/rebaseline.js +117 -0
- package/dist/cli/upgrade.js +17 -9
- package/dist/env.d.ts +0 -8
- package/dist/env.js +0 -8
- package/dist/notification-fields.js +2 -1
- package/dist/server/admin-load.d.ts +72 -0
- package/dist/server/admin-load.js +20 -0
- package/dist/server/api-keys.d.ts +96 -0
- package/dist/server/api-keys.js +115 -0
- package/dist/server/api.js +16 -61
- package/dist/server/cms.d.ts +0 -5
- package/dist/server/cms.js +4 -3
- package/dist/server/db/auto-migrate.d.ts +0 -4
- package/dist/server/db/auto-migrate.js +12 -3
- package/dist/server/db/legacy.d.ts +13 -0
- package/dist/server/db/legacy.js +60 -0
- package/dist/server/db/migration-data.js +2 -38
- package/dist/server/db/migrations/{0000_foundation.sql → 0000_baseline.sql} +120 -4
- package/dist/server/db/migrations/meta/0000_snapshot.json +578 -3
- package/dist/server/db/migrations/meta/_journal.json +2 -65
- package/dist/server/db/schema.js +8 -6
- package/dist/server/db/store.d.ts +25 -2
- package/dist/server/db/store.js +90 -26
- package/dist/server/forms.js +2 -1
- package/dist/server/media/runner.d.ts +1 -1
- package/dist/server/media/runner.js +1 -1
- package/dist/server/media/service.d.ts +0 -4
- package/dist/server/media/service.js +0 -2
- package/dist/server/media/verify.d.ts +28 -0
- package/dist/server/media/verify.js +94 -2
- package/dist/server/platform/snapshots.js +3 -3
- package/docs/acceptance.md +2 -2
- package/docs/api.md +15 -1
- package/docs/cloudflare.md +9 -41
- package/docs/content.md +18 -3
- package/docs/deployment.md +97 -34
- package/docs/email.md +6 -0
- package/docs/forms.md +1 -1
- package/docs/media.md +10 -1
- package/docs/package.md +4 -4
- package/docs/releases.md +21 -1
- package/docs/upgrades.md +41 -7
- package/package.json +4 -10
- package/templates/Dockerfile +6 -2
- package/templates/integration.ts +10 -5
- package/templates/openship.json +9 -0
- package/templates/sandcms/config.yaml +1 -0
- package/dist/server/db/migrations/0001_independent_password_resets.sql +0 -3
- package/dist/server/db/migrations/0002_email_failure_reason.sql +0 -1
- package/dist/server/db/migrations/0003_direct_r2_uploads.sql +0 -10
- package/dist/server/db/migrations/0004_agent_api_keys.sql +0 -38
- package/dist/server/db/migrations/0005_api_retention_and_pagination.sql +0 -3
- package/dist/server/db/migrations/0006_durable_media_deletion.sql +0 -7
- package/dist/server/db/migrations/0007_content_and_job_indexes.sql +0 -2
- package/dist/server/db/migrations/0008_search_text_cache.sql +0 -45
- package/dist/server/db/migrations/0009_local_media.sql +0 -9
- package/dist/server/db/migrations/meta/0001_snapshot.json +0 -1197
- package/dist/server/db/migrations/meta/0002_snapshot.json +0 -1204
- package/dist/server/db/migrations/meta/0003_snapshot.json +0 -1281
- package/dist/server/db/migrations/meta/0004_snapshot.json +0 -1546
- package/dist/server/db/migrations/meta/0005_snapshot.json +0 -1572
- package/dist/server/db/migrations/meta/0006_snapshot.json +0 -1627
- package/dist/server/db/migrations/meta/0007_snapshot.json +0 -1643
- package/dist/server/db/migrations/meta/0008_snapshot.json +0 -1711
- package/dist/server/db/migrations/meta/0009_snapshot.json +0 -1763
- package/dist/server/media/import-r2.d.ts +0 -56
- package/dist/server/media/import-r2.js +0 -342
- package/dist/worker/index.d.ts +0 -10
- package/dist/worker/index.js +0 -460
- package/dist/worker/local.d.ts +0 -5
- package/dist/worker/local.js +0 -57
- package/dist/worker/source.d.ts +0 -2
- package/dist/worker/source.js +0 -31
- package/dist/worker/svg.d.ts +0 -1
- package/dist/worker/svg.js +0 -2
- package/dist/worker/uploads.d.ts +0 -22
- package/dist/worker/uploads.js +0 -48
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SandCMS
|
|
2
2
|
|
|
3
|
-
**0.
|
|
3
|
+
**0.8.0** lets a SandCMS site deploy by overlap on OpenShip, Dokploy and Coolify: the new release migrates and passes its health check while the previous one still serves, and every later migration keeps the previous release working. The 0.7 migration history is replaced by one frozen baseline; existing 0.7.x databases are converted once with `sandcms rebaseline`. The release also adds operator commands for the server shell, a Pages screen and the site favicon or logo in the admin. See the [0.8.0 release notes](docs/releases.md#080), [upgrade checklist](docs/upgrades.md#080-upgrade-checklist) and [agent instructions](AGENTS.md).
|
|
4
4
|
|
|
5
5
|
SandCMS embeds a content workspace into a SvelteKit website. Developers own YAML blueprints and public routes; editors manage drafts, publication, images, and form submissions at `/admin`.
|
|
6
6
|
|
|
@@ -35,7 +35,7 @@ Open `https://10.123.59.34:5443/admin` and accept the local certificate prompt.
|
|
|
35
35
|
|
|
36
36
|
## Hosting
|
|
37
37
|
|
|
38
|
-
A site runs as one container built from its `Dockerfile`, with one persistent volume mounted at `/data`, behind any reverse proxy with default settings.
|
|
38
|
+
A site runs as one container built from its `Dockerfile`, with one persistent volume mounted at `/data`, behind any reverse proxy with default settings. Deploys overlap the old and new container with no downtime: the new one migrates on its first health check and takes traffic only once it is healthy. The volume should be backed up on a schedule. [OpenShip](https://openship.io), [Dokploy](https://dokploy.com) and [Coolify](https://coolify.io) are documented with the settings each needs; nothing in the package depends on any of them. See [deployment](docs/deployment.md) for the requirements, environment and backup workflow.
|
|
39
39
|
|
|
40
40
|
## Included
|
|
41
41
|
|
|
@@ -62,7 +62,7 @@ For a reproducible local archive installation, use the explicit commands in the
|
|
|
62
62
|
|
|
63
63
|
```sh
|
|
64
64
|
bun run check
|
|
65
|
-
bun test
|
|
65
|
+
bun run test
|
|
66
66
|
bun run build
|
|
67
67
|
bun x playwright install chromium
|
|
68
68
|
bun run test:e2e
|
|
@@ -76,7 +76,7 @@ Stop the dev server before building. Browser tests use the production Bun server
|
|
|
76
76
|
- [Installation and private packaging](docs/package.md)
|
|
77
77
|
- [Blueprints and runtime API](docs/content.md)
|
|
78
78
|
- [Media, publication, and images](docs/media.md)
|
|
79
|
-
- [Cloudflare:
|
|
79
|
+
- [Cloudflare: retired Worker and optional CDN](docs/cloudflare.md)
|
|
80
80
|
- [Forms and submissions](docs/forms.md)
|
|
81
81
|
- [Deployment, backups, and recovery](docs/deployment.md)
|
|
82
82
|
- [Updates and file ownership](docs/upgrades.md)
|
package/dist/admin/Admin.svelte
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import Shell from './Shell.svelte';
|
|
7
7
|
import Dashboard from './Dashboard.svelte';
|
|
8
8
|
import Collection from './Collection.svelte';
|
|
9
|
+
import Pages from './Pages.svelte';
|
|
9
10
|
import Editor from './Editor.svelte';
|
|
10
11
|
import MediaLibrary from './MediaLibrary.svelte';
|
|
11
12
|
import Inbox from './Inbox.svelte';
|
|
@@ -28,10 +29,9 @@
|
|
|
28
29
|
</script>
|
|
29
30
|
|
|
30
31
|
<svelte:head
|
|
31
|
-
><title
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/></svelte:head
|
|
32
|
+
><title
|
|
33
|
+
>{data.blueprint?.label ?? (data.screen === 'pages' ? 'Pages' : 'Workspace')} · SandCMS</title
|
|
34
|
+
><meta name="robots" content="noindex,nofollow" /></svelte:head
|
|
35
35
|
>
|
|
36
36
|
<div class="sandcms-admin" data-theme={theme}>
|
|
37
37
|
<a class="cms-skip" href="#cms-main">Skip to content</a>{#if data.screen === 'login'}<Login
|
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
/>{:else}<Shell {data}
|
|
43
43
|
>{#key data.screen + ':' + (data.blueprint?.id ?? '') + ':' + (data.entry?.id ?? '') + ':' + String(data.editing)}{#if data.screen === 'content'}{#if data.editing}<Editor
|
|
44
44
|
{data}
|
|
45
|
-
/>{:else}<Collection {data} />{/if}{:else if data.screen === '
|
|
45
|
+
/>{:else}<Collection {data} />{/if}{:else if data.screen === 'pages'}<Pages
|
|
46
|
+
{data}
|
|
47
|
+
/>{:else if data.screen === 'media'}<MediaLibrary
|
|
46
48
|
{data}
|
|
47
49
|
/>{:else if data.screen === 'forms'}<Inbox
|
|
48
50
|
{data}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import Image from '@lucide/svelte/icons/image';
|
|
3
3
|
import X from '@lucide/svelte/icons/x';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
4
5
|
import { assetUrl } from './client.js';
|
|
5
6
|
import type { Asset } from './types.js';
|
|
6
7
|
import * as Attachment from './components/ui/attachment/index.js';
|
|
@@ -12,6 +13,7 @@
|
|
|
12
13
|
visibility,
|
|
13
14
|
onopen,
|
|
14
15
|
onremove,
|
|
16
|
+
actions,
|
|
15
17
|
class: className
|
|
16
18
|
}: {
|
|
17
19
|
asset: Asset;
|
|
@@ -20,6 +22,8 @@
|
|
|
20
22
|
visibility?: 'Public' | 'Private';
|
|
21
23
|
onopen?: () => void;
|
|
22
24
|
onremove?: () => void;
|
|
25
|
+
/** Extra actions rendered before the remove button. */
|
|
26
|
+
actions?: Snippet;
|
|
23
27
|
class?: string;
|
|
24
28
|
} = $props();
|
|
25
29
|
const src = $derived(assetUrl(asset));
|
|
@@ -60,11 +64,12 @@
|
|
|
60
64
|
: 'Processing image'}
|
|
61
65
|
</Attachment.Description>{/if}
|
|
62
66
|
</Attachment.Content>
|
|
63
|
-
{#if onremove}
|
|
67
|
+
{#if onremove || actions}
|
|
64
68
|
<Attachment.Actions>
|
|
65
|
-
|
|
69
|
+
{@render actions?.()}
|
|
70
|
+
{#if onremove}<Attachment.Action aria-label={'Remove ' + asset.filename} onclick={onremove}
|
|
66
71
|
><X /></Attachment.Action
|
|
67
|
-
|
|
72
|
+
>{/if}
|
|
68
73
|
</Attachment.Actions>
|
|
69
74
|
{/if}
|
|
70
75
|
{#if onopen}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
1
2
|
import type { Asset } from './types.js';
|
|
2
3
|
import * as Attachment from './components/ui/attachment/index.js';
|
|
3
4
|
type $$ComponentProps = {
|
|
@@ -7,6 +8,8 @@ type $$ComponentProps = {
|
|
|
7
8
|
visibility?: 'Public' | 'Private';
|
|
8
9
|
onopen?: () => void;
|
|
9
10
|
onremove?: () => void;
|
|
11
|
+
/** Extra actions rendered before the remove button. */
|
|
12
|
+
actions?: Snippet;
|
|
10
13
|
class?: string;
|
|
11
14
|
};
|
|
12
15
|
declare const AssetAttachment: import("svelte").Component<$$ComponentProps, {}, "">;
|
package/dist/admin/Editor.svelte
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import HoverHint from './HoverHint.svelte';
|
|
17
17
|
import * as DropdownMenu from './components/ui/dropdown-menu/index.js';
|
|
18
18
|
import RowMenu from './RowMenu.svelte';
|
|
19
|
+
import { previewPath } from './navigation.js';
|
|
19
20
|
import ArrowUpRight from '@lucide/svelte/icons/arrow-up-right';
|
|
20
21
|
import Copy from '@lucide/svelte/icons/copy';
|
|
21
22
|
import EyeOff from '@lucide/svelte/icons/eye-off';
|
|
@@ -139,15 +140,10 @@
|
|
|
139
140
|
busy = false;
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
|
-
const preview = $derived(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
.replace('{id}', entry.id) +
|
|
147
|
-
'?cmsPreview=' +
|
|
148
|
-
entry.id
|
|
149
|
-
: null
|
|
150
|
-
);
|
|
143
|
+
const preview = $derived.by(() => {
|
|
144
|
+
const path = previewPath(data.blueprint, entry);
|
|
145
|
+
return path && entry ? path + '?cmsPreview=' + entry.id : null;
|
|
146
|
+
});
|
|
151
147
|
</script>
|
|
152
148
|
|
|
153
149
|
<UnsavedChanges {dirty} />
|
package/dist/admin/Fields.svelte
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Field, FileBlueprint, Json, Payload } from '../blueprints/types.js';
|
|
3
3
|
import { fieldVisible } from '../blueprints/conditions.js';
|
|
4
4
|
import { widthSpan } from '../blueprints/layout.js';
|
|
5
|
+
import { fieldLabel } from '../blueprints/labels.js';
|
|
5
6
|
import type { Asset, Relations } from './types.js';
|
|
6
7
|
import { Input } from './components/ui/input/index.js';
|
|
7
8
|
import { Textarea } from './components/ui/textarea/index.js';
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
{#each Object.entries(fields) as [key, field]}
|
|
58
59
|
{#if fieldVisible(field, value)}
|
|
59
60
|
{@const id = prefix + '-' + key}{@const label =
|
|
60
|
-
|
|
61
|
+
fieldLabel(key, field)}
|
|
61
62
|
{@const length = String(value[key] ?? '').length}
|
|
62
63
|
{@const outsideLength =
|
|
63
64
|
(field.minLength !== undefined && length < field.minLength) ||
|
|
@@ -3,14 +3,20 @@
|
|
|
3
3
|
import { selectGalleryImages } from '../blueprints/gallery.js';
|
|
4
4
|
import { fieldVisible } from '../blueprints/conditions.js';
|
|
5
5
|
import { effectiveMetadata } from '../blueprints/files.js';
|
|
6
|
+
import { fieldLabel } from '../blueprints/labels.js';
|
|
6
7
|
import type { Asset, Relations } from './types.js';
|
|
7
8
|
import { assetUrl } from './client.js';
|
|
8
9
|
import Fields from './Fields.svelte';
|
|
9
10
|
import MediaPicker from './MediaPicker.svelte';
|
|
10
11
|
import SortableList from './SortableList.svelte';
|
|
11
|
-
import
|
|
12
|
+
import * as Dialog from './components/ui/dialog/index.js';
|
|
12
13
|
import { Button } from './components/ui/button/index.js';
|
|
13
|
-
import
|
|
14
|
+
import X from '@lucide/svelte/icons/x';
|
|
15
|
+
import Pencil from '@lucide/svelte/icons/pencil';
|
|
16
|
+
import RotateCcw from '@lucide/svelte/icons/rotate-ccw';
|
|
17
|
+
import ImageOff from '@lucide/svelte/icons/image-off';
|
|
18
|
+
import Trash2 from '@lucide/svelte/icons/trash-2';
|
|
19
|
+
import TriangleAlert from '@lucide/svelte/icons/triangle-exclamation-point';
|
|
14
20
|
let {
|
|
15
21
|
value,
|
|
16
22
|
onchange,
|
|
@@ -32,6 +38,8 @@
|
|
|
32
38
|
} = $props();
|
|
33
39
|
let extra = $state<Asset[]>([]);
|
|
34
40
|
let all = $derived([...assets, ...extra.filter((a) => !assets.some((x) => x.id === a.id))]);
|
|
41
|
+
let editing = $state<number | null>(null);
|
|
42
|
+
let fields = $derived(Object.entries(field.fields ?? {}));
|
|
35
43
|
function empty(field: Field): Json {
|
|
36
44
|
if (field.type === 'boolean') return false;
|
|
37
45
|
if (['repeatable', 'multiselect'].includes(field.type)) return [];
|
|
@@ -48,84 +56,221 @@
|
|
|
48
56
|
}
|
|
49
57
|
function inherited(field: Field, value: Json | undefined) {
|
|
50
58
|
if (field.type === 'relation')
|
|
51
|
-
return relations[field.collection!]?.find((p) => p.id === value)?.label ??
|
|
52
|
-
if (value === undefined || value === null || value === '') return
|
|
59
|
+
return relations[field.collection!]?.find((p) => p.id === value)?.label ?? null;
|
|
60
|
+
if (value === undefined || value === null || value === '') return null;
|
|
53
61
|
if (Array.isArray(value)) return `${value.length} items`;
|
|
62
|
+
if (typeof value === 'boolean') return value ? 'Yes' : 'No';
|
|
54
63
|
return typeof value === 'object' ? 'Using saved file details' : String(value);
|
|
55
64
|
}
|
|
65
|
+
function rowErrors(i: number) {
|
|
66
|
+
return Object.fromEntries(
|
|
67
|
+
Object.entries(errors)
|
|
68
|
+
.filter(([path]) => path.startsWith(`${i}.`))
|
|
69
|
+
.map(([path, error]) => [path.slice(String(i).length + 1), error])
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
/** A caption or other text detail, so each tile says something useful at a glance. */
|
|
73
|
+
function summary(effective: Payload) {
|
|
74
|
+
const text = fields.filter(([, definition]) => ['text', 'textarea'].includes(definition.type));
|
|
75
|
+
const preferred = [...text.filter(([key]) => ['caption', 'title'].includes(key)), ...text];
|
|
76
|
+
for (const [key] of preferred) {
|
|
77
|
+
const v = effective[key];
|
|
78
|
+
if (typeof v === 'string' && v.trim()) return v;
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
/** Screen readers and search engines rely on alt text, so flag images without it. */
|
|
83
|
+
function missingAlt(effective: Payload) {
|
|
84
|
+
if (!field.fields?.alt) return false;
|
|
85
|
+
const alt = effective.alt;
|
|
86
|
+
return typeof alt !== 'string' || !alt.trim();
|
|
87
|
+
}
|
|
88
|
+
function overrides(row: Payload) {
|
|
89
|
+
return fields.filter(([key]) => row[key] != null).length;
|
|
90
|
+
}
|
|
91
|
+
function remove(i: number) {
|
|
92
|
+
if (editing === i) editing = null;
|
|
93
|
+
onchange(value.filter((_, n) => n !== i));
|
|
94
|
+
}
|
|
95
|
+
let current = $derived(editing === null ? undefined : value[editing]);
|
|
96
|
+
let currentAsset = $derived(current && all.find((a) => a.id === current.image));
|
|
56
97
|
</script>
|
|
57
98
|
|
|
58
|
-
<
|
|
59
|
-
{
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
{assets}
|
|
103
|
-
{relations}
|
|
104
|
-
{fileBlueprints}
|
|
105
|
-
prefix={`${id}-${i}`}
|
|
106
|
-
errors={Object.fromEntries(
|
|
107
|
-
Object.entries(errors)
|
|
108
|
-
.filter(([path]) => path.startsWith(`${i}.`))
|
|
109
|
-
.map(([path, error]) => [path.slice(String(i).length + 1), error])
|
|
110
|
-
)}
|
|
111
|
-
onchange={(next) => set(i, key, next[key] ?? empty(definition))}
|
|
112
|
-
/>
|
|
113
|
-
{/if}
|
|
99
|
+
<div class="cms-gallery">
|
|
100
|
+
<SortableList items={value} {onchange} layout="grid">
|
|
101
|
+
{#snippet children(row, i, handle)}
|
|
102
|
+
{@const asset = all.find((a) => a.id === row.image)}
|
|
103
|
+
{@const metadata = asset ? asset.metadata : {}}
|
|
104
|
+
{@const effective = effectiveMetadata(metadata, row, field.fields ?? {})}
|
|
105
|
+
{@const text = summary(effective)}
|
|
106
|
+
{@const custom = overrides(row)}
|
|
107
|
+
{@const invalid = Object.keys(errors).some(
|
|
108
|
+
(path) => path.startsWith(`${i}.`) && path !== `${i}.image`
|
|
109
|
+
)}
|
|
110
|
+
<div class="cms-gallery-tile" data-invalid={invalid || undefined}>
|
|
111
|
+
<div class="cms-gallery-media">
|
|
112
|
+
{#if asset && assetUrl(asset)}<img
|
|
113
|
+
class="cms-gallery-backdrop"
|
|
114
|
+
src={assetUrl(asset)}
|
|
115
|
+
alt=""
|
|
116
|
+
aria-hidden="true"
|
|
117
|
+
draggable="false"
|
|
118
|
+
loading="lazy"
|
|
119
|
+
/><img
|
|
120
|
+
src={assetUrl(asset)}
|
|
121
|
+
alt={String(effective.alt ?? '')}
|
|
122
|
+
draggable="false"
|
|
123
|
+
loading="lazy"
|
|
124
|
+
/>{:else}<span class="cms-gallery-missing"><ImageOff size={22} />Unavailable</span>{/if}
|
|
125
|
+
<div class="cms-gallery-handle">{@render handle(i)}</div>
|
|
126
|
+
<div class="cms-gallery-corner">
|
|
127
|
+
<Button
|
|
128
|
+
variant="secondary"
|
|
129
|
+
size="icon-sm"
|
|
130
|
+
class="cms-gallery-remove"
|
|
131
|
+
aria-label={'Remove image ' + (i + 1)}
|
|
132
|
+
title="Remove from gallery"
|
|
133
|
+
onclick={() => remove(i)}><X /></Button
|
|
134
|
+
>
|
|
135
|
+
{#if asset && missingAlt(effective)}<Button
|
|
136
|
+
variant="secondary"
|
|
137
|
+
size="icon-sm"
|
|
138
|
+
class="cms-gallery-alt-warning"
|
|
139
|
+
aria-label={'Add alternative text for image ' + (i + 1)}
|
|
140
|
+
title="Alternative text is missing"
|
|
141
|
+
onclick={() => (editing = i)}><TriangleAlert /></Button
|
|
142
|
+
>{/if}
|
|
114
143
|
</div>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
<
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
144
|
+
{#if asset && asset.status !== 'ready'}<span class="cms-gallery-status"
|
|
145
|
+
>{asset.status}</span
|
|
146
|
+
>{/if}
|
|
147
|
+
</div>
|
|
148
|
+
<div class="cms-gallery-meta">
|
|
149
|
+
<div class="min-w-0 flex-1">
|
|
150
|
+
<p class="cms-gallery-filename" title={asset?.filename}>
|
|
151
|
+
{asset?.filename ?? 'Unavailable image'}
|
|
152
|
+
</p>
|
|
153
|
+
{#if fields.length}<p class="cms-gallery-summary">
|
|
154
|
+
{#if invalid}<TriangleAlert size={12} />Needs attention{:else}{#if custom}<span
|
|
155
|
+
class="cms-gallery-dot"
|
|
156
|
+
title="{custom} customized for this gallery"
|
|
157
|
+
></span>{/if}<span class="cms-gallery-summary-text">{text ?? 'No details'}</span
|
|
158
|
+
>{#if custom}<span class="sr-only">, {custom} customized</span>{/if}{/if}
|
|
159
|
+
</p>{/if}
|
|
160
|
+
</div>
|
|
161
|
+
{#if fields.length}<Button
|
|
162
|
+
variant="ghost"
|
|
163
|
+
size="icon-sm"
|
|
164
|
+
aria-label={'Edit details for image ' + (i + 1)}
|
|
165
|
+
title={custom ? `Edit details (${custom} customized)` : 'Edit details'}
|
|
166
|
+
onclick={() => (editing = i)}><Pencil /></Button
|
|
167
|
+
>{/if}
|
|
168
|
+
</div>
|
|
169
|
+
{#if errors[i + '.image']}<p class="cms-error" role="alert">{errors[i + '.image']}</p>{/if}
|
|
170
|
+
</div>
|
|
171
|
+
{/snippet}
|
|
172
|
+
</SortableList>
|
|
173
|
+
<MediaPicker
|
|
174
|
+
{id}
|
|
175
|
+
assets={all}
|
|
176
|
+
multiple
|
|
177
|
+
hideSelection
|
|
178
|
+
fileBlueprint={fileBlueprints.find((b) => b.id === field.fileBlueprint)}
|
|
179
|
+
value={value.map((row) => row.image).filter((v): v is string => typeof v === 'string')}
|
|
180
|
+
onasset={(asset) => {
|
|
181
|
+
extra = [...extra, asset];
|
|
182
|
+
}}
|
|
183
|
+
onchange={(ids) => onchange(selectGalleryImages(value, Array.isArray(ids) ? ids : []))}
|
|
184
|
+
/>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<Dialog.Root
|
|
188
|
+
open={current !== undefined}
|
|
189
|
+
onOpenChange={(open) => {
|
|
190
|
+
if (!open) editing = null;
|
|
129
191
|
}}
|
|
130
|
-
|
|
131
|
-
|
|
192
|
+
>
|
|
193
|
+
<Dialog.Content portalProps={{ disabled: true }} class="cms-gallery-dialog">
|
|
194
|
+
{#if current !== undefined && editing !== null}
|
|
195
|
+
{@const i = editing}
|
|
196
|
+
{@const metadata = currentAsset ? currentAsset.metadata : {}}
|
|
197
|
+
{@const effective = effectiveMetadata(metadata, current, field.fields ?? {})}
|
|
198
|
+
<Dialog.Header>
|
|
199
|
+
<Dialog.Title class="cms-gallery-dialog-title"
|
|
200
|
+
>{currentAsset?.filename ?? 'Unavailable image'}</Dialog.Title
|
|
201
|
+
>
|
|
202
|
+
<Dialog.Description>
|
|
203
|
+
Image {i + 1} of {value.length}. Details come from the media library unless you customize
|
|
204
|
+
them here.
|
|
205
|
+
</Dialog.Description>
|
|
206
|
+
</Dialog.Header>
|
|
207
|
+
<div class="cms-gallery-dialog-body">
|
|
208
|
+
<div class="cms-gallery-preview">
|
|
209
|
+
{#if currentAsset && assetUrl(currentAsset)}<img
|
|
210
|
+
src={assetUrl(currentAsset)}
|
|
211
|
+
alt={String(effective.alt ?? '')}
|
|
212
|
+
/>{:else}<span class="cms-gallery-missing"><ImageOff size={22} />Unavailable</span>{/if}
|
|
213
|
+
</div>
|
|
214
|
+
<div class="cms-gallery-details">
|
|
215
|
+
{#each fields as [key, definition] (key)}
|
|
216
|
+
{#if fieldVisible(definition, effective)}
|
|
217
|
+
{@const label = fieldLabel(key, definition)}
|
|
218
|
+
{#if current[key] == null}
|
|
219
|
+
{@const shown = inherited(definition, metadata[key])}
|
|
220
|
+
<div class="cms-gallery-detail">
|
|
221
|
+
<div class="cms-gallery-detail-head">
|
|
222
|
+
<span class="cms-gallery-detail-label">{label}</span>
|
|
223
|
+
<Button
|
|
224
|
+
variant="ghost"
|
|
225
|
+
size="xs"
|
|
226
|
+
aria-label={'Customize ' + label.toLowerCase()}
|
|
227
|
+
onclick={() =>
|
|
228
|
+
set(i, key, structuredClone(metadata[key] ?? empty(definition)))}
|
|
229
|
+
><Pencil />Customize</Button
|
|
230
|
+
>
|
|
231
|
+
</div>
|
|
232
|
+
<p
|
|
233
|
+
class="cms-gallery-inherited"
|
|
234
|
+
class:cms-gallery-inherited-empty={!shown}
|
|
235
|
+
class:cms-gallery-inherited-warning={!shown && key === 'alt'}
|
|
236
|
+
>
|
|
237
|
+
{#if !shown && key === 'alt'}<TriangleAlert size={13} />Missing. Describe the
|
|
238
|
+
image for people using screen readers.{:else}{shown ??
|
|
239
|
+
'Not set in the media library'}{/if}
|
|
240
|
+
</p>
|
|
241
|
+
</div>
|
|
242
|
+
{:else}
|
|
243
|
+
<div class="cms-gallery-detail">
|
|
244
|
+
<Button
|
|
245
|
+
variant="ghost"
|
|
246
|
+
size="xs"
|
|
247
|
+
class="cms-gallery-reset"
|
|
248
|
+
aria-label={'Use media library ' + label.toLowerCase()}
|
|
249
|
+
title="Use the media library value"
|
|
250
|
+
onclick={() => set(i, key, undefined)}><RotateCcw />Reset</Button
|
|
251
|
+
>
|
|
252
|
+
<Fields
|
|
253
|
+
fields={{ [key]: definition }}
|
|
254
|
+
value={effective}
|
|
255
|
+
{assets}
|
|
256
|
+
{relations}
|
|
257
|
+
{fileBlueprints}
|
|
258
|
+
prefix={`${id}-${i}`}
|
|
259
|
+
errors={rowErrors(i)}
|
|
260
|
+
onchange={(next) => set(i, key, next[key] ?? empty(definition))}
|
|
261
|
+
/>
|
|
262
|
+
</div>
|
|
263
|
+
{/if}
|
|
264
|
+
{/if}
|
|
265
|
+
{/each}
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
<Dialog.Footer class="sm:justify-between">
|
|
269
|
+
<Button variant="ghost" class="text-destructive" onclick={() => remove(i)}
|
|
270
|
+
><Trash2 />Remove from gallery</Button
|
|
271
|
+
>
|
|
272
|
+
<Button onclick={() => (editing = null)}>Done</Button>
|
|
273
|
+
</Dialog.Footer>
|
|
274
|
+
{/if}
|
|
275
|
+
</Dialog.Content>
|
|
276
|
+
</Dialog.Root>
|
package/dist/admin/Inbox.svelte
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { emailFailureMessage } from '../email-failure.js';
|
|
3
|
+
import { fieldLabel } from '../blueprints/labels.js';
|
|
3
4
|
import NotificationSettings from './NotificationSettings.svelte';
|
|
4
5
|
import { onMount } from 'svelte';
|
|
5
6
|
import * as Table from './components/ui/table/index.js';
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
<Table.Header
|
|
68
69
|
><Table.Row
|
|
69
70
|
><Table.Head>Received</Table.Head>{#each data.blueprint?.columns ?? [] as col}<Table.Head
|
|
70
|
-
>{data.blueprint?.fields[col]
|
|
71
|
+
>{fieldLabel(col, data.blueprint?.fields[col])}</Table.Head
|
|
71
72
|
>{/each}<Table.Head>State</Table.Head></Table.Row
|
|
72
73
|
></Table.Header
|
|
73
74
|
><Table.Body
|
|
@@ -100,7 +101,7 @@
|
|
|
100
101
|
></Dialog.Header
|
|
101
102
|
>{#if active}<dl class="cms-answers">
|
|
102
103
|
{#each Object.entries(active.schema.fields) as [key, field]}<div>
|
|
103
|
-
<dt>{field
|
|
104
|
+
<dt>{fieldLabel(key, field)}</dt>
|
|
104
105
|
<dd>{display(active.data[key])}</dd>
|
|
105
106
|
</div>{/each}
|
|
106
107
|
</dl>
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import SearchList from './SearchList.svelte';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
3
4
|
import type { FileBlueprint } from '../blueprints/types.js';
|
|
4
5
|
import type { Asset } from './types.js';
|
|
5
6
|
import * as Dialog from './components/ui/dialog/index.js';
|
|
6
7
|
import { Button } from './components/ui/button/index.js';
|
|
7
8
|
import Image from '@lucide/svelte/icons/image';
|
|
8
9
|
import Upload from '@lucide/svelte/icons/upload';
|
|
10
|
+
import RefreshCw from '@lucide/svelte/icons/refresh-cw';
|
|
11
|
+
import * as Attachment from './components/ui/attachment/index.js';
|
|
9
12
|
import { uploadImages, type UploadItem, type UploadFailure } from './uploads.js';
|
|
10
13
|
import UploadQueue from './UploadQueue.svelte';
|
|
11
14
|
import UploadProgress from './UploadProgress.svelte';
|
|
@@ -175,16 +178,17 @@
|
|
|
175
178
|
}
|
|
176
179
|
</script>
|
|
177
180
|
|
|
178
|
-
{#snippet selectedImage(asset: Asset)}
|
|
181
|
+
{#snippet selectedImage(asset: Asset, replace?: Snippet)}
|
|
179
182
|
<AssetAttachment
|
|
180
183
|
{asset}
|
|
181
184
|
orientation="horizontal"
|
|
182
185
|
class="w-full"
|
|
186
|
+
actions={replace}
|
|
183
187
|
onremove={() => onchange(multiple ? (value as string[]).filter((id) => id !== asset.id) : null)}
|
|
184
188
|
/>
|
|
185
189
|
{/snippet}
|
|
186
|
-
|
|
187
|
-
{#if multiple}
|
|
190
|
+
<Dialog.Root bind:open>
|
|
191
|
+
{#if !hideSelection && multiple}
|
|
188
192
|
<SortableList items={Array.isArray(value) ? value : []} onchange={(ids) => onchange(ids)}>
|
|
189
193
|
{#snippet children(assetId)}
|
|
190
194
|
{@const asset = all.find((a) => a.id === assetId)}
|
|
@@ -195,25 +199,37 @@
|
|
|
195
199
|
>{/if}
|
|
196
200
|
{/snippet}
|
|
197
201
|
</SortableList>
|
|
202
|
+
{/if}
|
|
203
|
+
{#if !hideSelection && !multiple && selected[0]}
|
|
204
|
+
<!-- A single selection replaces the image in place instead of adding a second wide row. -->
|
|
205
|
+
{#snippet replace()}
|
|
206
|
+
<Dialog.Trigger>
|
|
207
|
+
{#snippet child({ props })}<Attachment.Action
|
|
208
|
+
{...props}
|
|
209
|
+
{id}
|
|
210
|
+
aria-label={'Replace ' + selected[0].filename}
|
|
211
|
+
title="Replace image"><RefreshCw /></Attachment.Action
|
|
212
|
+
>{/snippet}
|
|
213
|
+
</Dialog.Trigger>
|
|
214
|
+
{/snippet}
|
|
215
|
+
{@render selectedImage(selected[0], replace)}
|
|
198
216
|
{:else}
|
|
199
|
-
|
|
217
|
+
<Dialog.Trigger>
|
|
218
|
+
{#snippet child({ props })}<Button
|
|
219
|
+
{...props}
|
|
220
|
+
{id}
|
|
221
|
+
variant="outline"
|
|
222
|
+
class="h-auto w-full border-dashed p-5"
|
|
223
|
+
>
|
|
224
|
+
<Image size={18} />{multiple
|
|
225
|
+
? 'Add images'
|
|
226
|
+
: selected.length
|
|
227
|
+
? 'Choose another image'
|
|
228
|
+
: 'Choose an image'}
|
|
229
|
+
</Button>{/snippet}
|
|
230
|
+
</Dialog.Trigger>
|
|
200
231
|
{/if}
|
|
201
|
-
{
|
|
202
|
-
<Dialog.Root bind:open
|
|
203
|
-
><Dialog.Trigger>
|
|
204
|
-
{#snippet child({ props })}<Button
|
|
205
|
-
{...props}
|
|
206
|
-
{id}
|
|
207
|
-
variant="outline"
|
|
208
|
-
class="h-auto w-full border-dashed p-5"
|
|
209
|
-
>
|
|
210
|
-
<Image size={18} />{multiple
|
|
211
|
-
? 'Add images'
|
|
212
|
-
: selected.length
|
|
213
|
-
? 'Choose another image'
|
|
214
|
-
: 'Choose an image'}
|
|
215
|
-
</Button>{/snippet}</Dialog.Trigger
|
|
216
|
-
><Dialog.Content portalProps={{ disabled: true }} class="cms-media-dialog"
|
|
232
|
+
<Dialog.Content portalProps={{ disabled: true }} class="cms-media-dialog"
|
|
217
233
|
><Dialog.Header><Dialog.Title>Media library</Dialog.Title></Dialog.Header><UploadQueue
|
|
218
234
|
items={uploads}
|
|
219
235
|
/><UploadProgress items={uploads} />
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { Icon } from '@lucide/svelte';
|
|
5
5
|
import Folder from '@lucide/svelte/icons/folder';
|
|
6
6
|
import ChevronRight from '@lucide/svelte/icons/chevron-right';
|
|
7
|
+
import Files from '@lucide/svelte/icons/files';
|
|
7
8
|
import type { AdminData } from './types.js';
|
|
8
9
|
import { blueprintHref, navigationGroups, navigationSelected } from './navigation.js';
|
|
9
10
|
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
navigationSelected(page.url.pathname, blueprintHref(b));
|
|
16
17
|
afterNavigate(() => {
|
|
17
18
|
for (const item of items) {
|
|
18
|
-
if (item.group !== false && item.blueprints.some(active)) {
|
|
19
|
+
if (item.group !== false && !item.href && item.blueprints.some(active)) {
|
|
19
20
|
expanded = new Map(expanded).set(item.group, true);
|
|
20
21
|
}
|
|
21
22
|
}
|
|
@@ -35,7 +36,17 @@
|
|
|
35
36
|
{/snippet}
|
|
36
37
|
|
|
37
38
|
{#each items as item, index}
|
|
38
|
-
{#if item.
|
|
39
|
+
{#if item.href}
|
|
40
|
+
{@const isActive =
|
|
41
|
+
navigationSelected(page.url.pathname, item.href) || item.blueprints.some(active)}
|
|
42
|
+
<a
|
|
43
|
+
href={item.href}
|
|
44
|
+
class:active={isActive}
|
|
45
|
+
aria-current={navigationSelected(page.url.pathname, item.href) ? 'page' : undefined}
|
|
46
|
+
>
|
|
47
|
+
<Files size={17} />{item.group}
|
|
48
|
+
</a>
|
|
49
|
+
{:else if item.group === false}
|
|
39
50
|
{@render links(item.blueprints)}
|
|
40
51
|
{:else}
|
|
41
52
|
{@const group = item.group}
|