Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

feat(site): align home layout, social links and typography

Timothy Yin76362819b7bb
diff --git a/apps/cloud/app/assets/cloud.css b/apps/cloud/app/assets/cloud.css
index 2ecb86fa..94c226ad 100644
--- a/apps/cloud/app/assets/cloud.css
+++ b/apps/cloud/app/assets/cloud.css
@@ -2792,3 +2792,51 @@ a.cf-domain-address:hover {
white-space: normal;
margin-top: 4px;
}
+
+.cf-gallery-presentation {
+ border-top: 1px solid var(--border);
+ padding-top: 20px;
+ display: grid;
+ gap: 12px;
+}
+.cf-gallery-presentation h3 {
+ font-size: 14px;
+ font-weight: 600;
+ margin: 0;
+}
+.cf-gallery-presentation fieldset {
+ display: flex;
+ gap: 12px;
+ flex-wrap: wrap;
+ border: 0;
+ padding: 0;
+ margin: 0;
+}
+.cf-layout-option {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ padding: 10px 12px;
+ cursor: pointer;
+ font-size: 13px;
+}
+.cf-layout-option:has(input:checked) {
+ border-color: var(--primary);
+ background: var(--secondary);
+}
+.cf-layout-option input {
+ width: 16px;
+ height: 16px;
+ accent-color: var(--primary);
+}
+.cf-social-input-row {
+ display: flex;
+ gap: 8px;
+ align-items: center;
+}
+.cf-social-input-row > input {
+ min-width: 0;
+ flex: 1;
+}
diff --git a/apps/cloud/app/components/CloudSiteSettings.vue b/apps/cloud/app/components/CloudSiteSettings.vue
index f4b631ab..e352d187 100644
--- a/apps/cloud/app/components/CloudSiteSettings.vue
+++ b/apps/cloud/app/components/CloudSiteSettings.vue
@@ -1,4 +1,10 @@
<script setup lang="ts">
+import {
+ MAX_SOCIAL_LINKS,
+ parseSocialLinks,
+ socialLinkIdentity,
+ resolveSocialPlatform,
+} from '@chronoframe/contracts/social-links'
const { t } = useI18n()
const props = defineProps<{ siteId: number }>()
@@ -17,6 +23,36 @@ const profile = reactive({
author: data.value?.site.author ?? '',
avatarUrl: data.value?.site.avatarUrl ?? '',
})
+const homeHeaderLayout = ref<'embedded' | 'fixed'>(
+ data.value?.site.presentation.homeHeaderLayout ?? 'embedded',
+)
+const socialDraft = ref(
+ Array.from(
+ { length: MAX_SOCIAL_LINKS },
+ (_, i) => data.value?.site.presentation.socialLinks.links[i] ?? '',
+ ),
+)
+const socialErrors = computed(() => {
+ const seen = new Set<string>()
+ return socialDraft.value.map((value) => {
+ if (!value.trim()) return ''
+ try {
+ const identity = socialLinkIdentity(value.trim())
+ if (seen.has(identity)) return t('cloud.presentation.duplicate')
+ seen.add(identity)
+ return ''
+ } catch {
+ return t('cloud.presentation.invalid')
+ }
+ })
+})
+function socialLabel(value: string) {
+ try {
+ return resolveSocialPlatform(value.trim()).label
+ } catch {
+ return ''
+ }
+}
const iconError = ref(''),
iconBusy = ref(false)
async function chooseIcon(event: Event) {
@@ -77,10 +113,22 @@ async function reload() {
author: data.value?.site.author ?? '',
avatarUrl: data.value?.site.avatarUrl ?? '',
})
+ homeHeaderLayout.value =
+ data.value?.site.presentation.homeHeaderLayout ?? 'embedded'
+ socialDraft.value = Array.from(
+ { length: MAX_SOCIAL_LINKS },
+ (_, i) => data.value?.site.presentation.socialLinks.links[i] ?? '',
+ )
message.value = ''
}
async function save() {
- if (!data.value || busy.value || iconBusy.value) return
+ if (
+ !data.value ||
+ busy.value ||
+ iconBusy.value ||
+ socialErrors.value.some(Boolean)
+ )
+ return
busy.value = true
message.value = ''
failed.value = false
@@ -92,6 +140,14 @@ async function save() {
revision: data.value.site.revision,
published: !!data.value.site.published,
profile: { ...profile },
+ presentation: {
+ homeHeaderLayout: homeHeaderLayout.value,
+ socialLinks: {
+ links: parseSocialLinks({
+ links: socialDraft.value.map((v) => v.trim()).filter(Boolean),
+ }),
+ },
+ },
},
})
data.value = { site: { ...result.site, role: data.value.site.role } }
@@ -223,10 +279,85 @@ async function save() {
{{ iconError }}
</p>
</div>
+ <section class="cf-gallery-presentation">
+ <h3>{{ $t('cloud.presentation.layout') }}</h3>
+ <p class="cf-field-hint">
+ {{ $t('cloud.presentation.layoutHelp') }}
+ </p>
+ <fieldset :disabled="busy">
+ <legend class="sr-only">
+ {{ $t('cloud.presentation.layout') }}
+ </legend>
+ <label
+ v-for="option in ['embedded', 'fixed'] as const"
+ :key="option"
+ class="cf-layout-option"
+ ><input
+ v-model="homeHeaderLayout"
+ type="radio"
+ name="home-header-layout"
+ :value="option"
+ /><span>{{ $t('cloud.presentation.' + option) }}</span></label
+ >
+ </fieldset>
+ </section>
+ <section class="cf-gallery-presentation">
+ <h3>{{ $t('cloud.presentation.social') }}</h3>
+ <p class="cf-field-hint">
+ {{
+ $t('cloud.presentation.socialHelp', { max: MAX_SOCIAL_LINKS })
+ }}
+ </p>
+ <div
+ v-for="(_, index) in socialDraft"
+ :key="index"
+ class="cf-field"
+ >
+ <label :for="'social-link-' + index"
+ >{{ $t('cloud.presentation.slot', { number: index + 1 })
+ }}<small v-if="socialDraft[index] && !socialErrors[index]">
+ · {{ socialLabel(socialDraft[index]!) }}</small
+ ></label
+ >
+ <div class="cf-social-input-row">
+ <CloudInput
+ :id="'social-link-' + index"
+ v-model="socialDraft[index]"
+ type="url"
+ placeholder="https://…"
+ maxlength="2048"
+ :disabled="busy"
+ :aria-invalid="!!socialErrors[index]"
+ :aria-describedby="
+ socialErrors[index] ? 'social-error-' + index : undefined
+ "
+ /><CloudButton
+ type="button"
+ variant="ghost"
+ :disabled="busy || !socialDraft[index]"
+ :aria-label="
+ $t('cloud.presentation.clear', { number: index + 1 })
+ "
+ @click="socialDraft[index] = ''"
+ >×</CloudButton
+ >
+ </div>
+ <p
+ v-if="socialErrors[index]"
+ :id="'social-error-' + index"
+ role="alert"
+ class="cf-error-message"
+ >
+ {{ socialErrors[index] }}
+ </p>
+ </div>
+ </section>
<div class="cf-site-actions">
<CloudButton
type="submit"
- :disabled="busy || iconBusy || !name.trim()"
+ :disabled="
+ busy || iconBusy || !name.trim() || socialErrors.some(Boolean)
+ "
>{{
busy
? $t('cloud.messages.saving')
diff --git a/apps/cloud/i18n/locales/en.json b/apps/cloud/i18n/locales/en.json
index 2754f76a..56645ccb 100644
--- a/apps/cloud/i18n/locales/en.json
+++ b/apps/cloud/i18n/locales/en.json
@@ -584,6 +584,18 @@
"holdSite": "This site is suspended. Its hosted domain service will be removed.",
"holdAccount": "Workspace account access is suspended. Its hosted domain service will be removed.",
"cleanup": "Domain resources are being removed. This record remains until cleanup completes and will retry automatically."
+ },
+ "presentation": {
+ "layout": "Home header layout",
+ "layoutHelp": "Choose how your identity appears on the photo wall.",
+ "embedded": "Embedded in photo wall",
+ "fixed": "Fixed at top",
+ "social": "Social links",
+ "socialHelp": "Add up to {max} HTTPS profile links. Icons are detected automatically; empty slots stay hidden.",
+ "slot": "Link {number}",
+ "clear": "Clear link {number}",
+ "invalid": "Enter a valid HTTPS profile URL.",
+ "duplicate": "This profile is already listed."
}
}
}
diff --git a/apps/cloud/i18n/locales/zh-Hans.json b/apps/cloud/i18n/locales/zh-Hans.json
index b136e255..5505ac34 100644
--- a/apps/cloud/i18n/locales/zh-Hans.json
+++ b/apps/cloud/i18n/locales/zh-Hans.json
@@ -584,6 +584,18 @@
"holdSite": "站点访问已暂停,域服务将停用。",
"holdAccount": "工作空间账号已暂停,域服务将停用。",
"cleanup": "正在清理域服务;完成前将保留此记录并自动重试。"
+ },
+ "presentation": {
+ "layout": "首页头部布局",
+ "layoutHelp": "选择个人信息在照片墙中的展示方式。",
+ "embedded": "嵌入照片墙",
+ "fixed": "固定在顶部",
+ "social": "社交链接",
+ "socialHelp": "最多添加 {max} 个 HTTPS 个人主页链接,自动识别图标,空白项不显示。",
+ "slot": "链接 {number}",
+ "clear": "清空链接 {number}",
+ "invalid": "请输入有效的 HTTPS 个人主页链接。",
+ "duplicate": "该个人主页已添加。"
}
}
}
diff --git a/apps/cloud/server/api/sites/[siteId]/settings.patch.ts b/apps/cloud/server/api/sites/[siteId]/settings.patch.ts
index 4e813055..bd7bcfc7 100644
--- a/apps/cloud/server/api/sites/[siteId]/settings.patch.ts
+++ b/apps/cloud/server/api/sites/[siteId]/settings.patch.ts
@@ -13,6 +13,7 @@ export default definePlatformHandler(async (event) => {
revision: body.revision,
published: body.published,
profile: body.profile,
+ presentation: body.presentation,
}),
}
})
diff --git a/apps/nuxt.shared.ts b/apps/nuxt.shared.ts
index 0f33f8f8..70747cba 100644
--- a/apps/nuxt.shared.ts
+++ b/apps/nuxt.shared.ts
@@ -1,3 +1,4 @@
+import { SOCIAL_LINK_ICONS } from '../packages/contracts/src/social-links'
import type { NuxtConfig } from 'nuxt/schema'
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
@@ -54,6 +55,7 @@ export const sharedUi = {
ui: { fonts: false },
icon: {
clientBundle: {
+ icons: SOCIAL_LINK_ICONS,
scan: {
globInclude: [
fileURLToPath(
diff --git a/apps/self-hosted/nuxt.config.ts b/apps/self-hosted/nuxt.config.ts
index e85f7fa9..a9e38b62 100644
--- a/apps/self-hosted/nuxt.config.ts
+++ b/apps/self-hosted/nuxt.config.ts
@@ -1,3 +1,4 @@
+import { galleryFontFamilies } from '../../packages/gallery/fonts'
import { SELF_HOSTED_CAPABILITIES } from '../../packages/contracts/src/entry'
import pkg from '../../package.json'
import type { AnalyticsConfig } from './shared/types/config'
@@ -256,10 +257,7 @@ export default defineNuxtConfig({
},
fonts: {
- families: [
- { name: 'Rubik', weights: [400, 500, 600, 700], global: true },
- { name: 'Noto Sans SC', weights: [400, 500, 600, 700], global: true },
- ],
+ families: galleryFontFamilies,
},
dayjs: {
diff --git a/apps/site/nuxt.config.ts b/apps/site/nuxt.config.ts
index 86d9bac7..c154141a 100644
--- a/apps/site/nuxt.config.ts
+++ b/apps/site/nuxt.config.ts
@@ -1,7 +1,10 @@
+import { galleryFontFamilies } from '../../packages/gallery/fonts'
import { SITE_CAPABILITIES } from '../../packages/contracts/src/entry'
import { sharedUi } from '../nuxt.shared'
export default defineNuxtConfig({
...sharedUi,
+ modules: [...sharedUi.modules, '@nuxt/fonts'],
+ fonts: { families: galleryFontFamilies },
devServer: { port: 3002 },
app: { head: { htmlAttrs: { lang: 'en' } } },
nitro: {
diff --git a/apps/site/package.json b/apps/site/package.json
index 0fa10c84..672bfc65 100644
--- a/apps/site/package.json
+++ b/apps/site/package.json
@@ -37,6 +37,7 @@
"@chronoframe/database": "workspace:*",
"@chronoframe/storage": "workspace:*",
"@chronoframe/contracts": "workspace:*",
- "nuxt-gtag": "4.1.0"
+ "nuxt-gtag": "4.1.0",
+ "@nuxt/fonts": "0.14.0"
}
}
diff --git a/apps/site/server/api/public/system/settings/all.get.ts b/apps/site/server/api/public/system/settings/all.get.ts
index eb6e6d1a..d5a5a3e1 100644
--- a/apps/site/server/api/public/system/settings/all.get.ts
+++ b/apps/site/server/api/public/system/settings/all.get.ts
@@ -1,4 +1,7 @@
-import { PUBLIC_GALLERY_DEFAULTS } from '@chronoframe/contracts/gallery-settings'
+import {
+ PUBLIC_GALLERY_DEFAULTS,
+ parseGalleryPresentation,
+} from '@chronoframe/contracts/gallery-settings'
import {
platformDatabase,
definePlatformHandler,
@@ -15,7 +18,7 @@ export default definePlatformHandler(async (event) => {
>
const profile = await platformDatabase(event)
.prepare(
- 'SELECT gallery_title AS title, gallery_slogan AS slogan, gallery_author AS author, gallery_avatar AS avatarUrl FROM platform_sites WHERE id = ?',
+ 'SELECT gallery_title AS title, gallery_slogan AS slogan, gallery_author AS author, gallery_avatar AS avatarUrl, gallery_presentation AS presentation FROM platform_sites WHERE id = ?',
)
.bind(context.siteId)
.first<{
@@ -23,10 +26,18 @@ export default definePlatformHandler(async (event) => {
slogan: string
author: string
avatarUrl: string
+ presentation: string
}>()
data.app!.title = profile?.title || context.name
data.app!.slogan = profile?.slogan || ''
data.app!.author = profile?.author || ''
data.app!.avatarUrl = profile?.avatarUrl || ''
+ if (profile) {
+ const presentation = parseGalleryPresentation(
+ JSON.parse(profile.presentation),
+ )
+ data.app!['appearance.homeHeaderLayout'] = presentation.homeHeaderLayout
+ data.app!.socialLinks = presentation.socialLinks
+ }
return { timestamp: Date.now(), data }
})
diff --git a/packages/contracts/src/gallery-settings.ts b/packages/contracts/src/gallery-settings.ts
index 34098304..6064694d 100644
--- a/packages/contracts/src/gallery-settings.ts
+++ b/packages/contracts/src/gallery-settings.ts
@@ -1,3 +1,4 @@
+import { parseSocialLinks } from './social-links.ts'
/** Shared public defaults for both gallery editions. Never includes credentials or private settings. */
export const PUBLIC_GALLERY_DEFAULTS = {
app: {
@@ -39,3 +40,25 @@ export const PUBLIC_GALLERY_DEFAULTS = {
bodyScripts: '',
},
} as const
+
+export interface GalleryPresentation {
+ homeHeaderLayout: 'embedded' | 'fixed'
+ socialLinks: { links: string[] }
+}
+export function parseGalleryPresentation(value: unknown): GalleryPresentation {
+ if (!value || typeof value !== 'object' || Array.isArray(value))
+ throw new Error('Invalid gallery presentation')
+ const data = value as Record<string, unknown>
+ if (
+ Object.keys(data).some(
+ (k) => !['homeHeaderLayout', 'socialLinks'].includes(k),
+ ) ||
+ !['embedded', 'fixed'].includes(String(data.homeHeaderLayout))
+ )
+ throw new Error('Invalid home header layout')
+ return {
+ homeHeaderLayout:
+ data.homeHeaderLayout as GalleryPresentation['homeHeaderLayout'],
+ socialLinks: { links: parseSocialLinks(data.socialLinks) },
+ }
+}
diff --git a/packages/contracts/src/social-links.ts b/packages/contracts/src/social-links.ts
index 4feab83b..6f2c08aa 100644
--- a/packages/contracts/src/social-links.ts
+++ b/packages/contracts/src/social-links.ts
@@ -208,3 +208,8 @@ export function resolveSocialPlatform(value: string): {
? { label: platform.label, icon: platform.icon }
: { label: hostname.replace(/^www\./, ''), icon: 'tabler:link' }
}
+
+/** Icons used by profile links, available for static gallery bundles. */
+export const SOCIAL_LINK_ICONS = [
+ ...new Set([...platforms.map((platform) => platform.icon), 'tabler:link']),
+]
diff --git a/packages/gallery/fonts.ts b/packages/gallery/fonts.ts
new file mode 100644
index 00000000..85d9cf6e
--- /dev/null
+++ b/packages/gallery/fonts.ts
@@ -0,0 +1,5 @@
+/** Gallery typography is shared by both deployment editions. */
+export const galleryFontFamilies = [
+ { name: 'Rubik', weights: [400, 500, 600, 700], global: true },
+ { name: 'Noto Sans SC', weights: [400, 500, 600, 700], global: true },
+]
diff --git a/packages/platform/migrations/0016_gallery_presentation.sql b/packages/platform/migrations/0016_gallery_presentation.sql
new file mode 100644
index 00000000..08bbc9a7
--- /dev/null
+++ b/packages/platform/migrations/0016_gallery_presentation.sql
@@ -0,0 +1 @@
+ALTER TABLE platform_sites ADD COLUMN gallery_presentation TEXT NOT NULL DEFAULT '{"homeHeaderLayout":"embedded","socialLinks":{"links":[]}}' CHECK(json_valid(gallery_presentation));
diff --git a/packages/platform/src/provisioning.ts b/packages/platform/src/provisioning.ts
index 647b3d03..669c91bf 100644
--- a/packages/platform/src/provisioning.ts
+++ b/packages/platform/src/provisioning.ts
@@ -1,3 +1,7 @@
+import {
+ parseGalleryPresentation,
+ type GalleryPresentation,
+} from '@chronoframe/contracts/gallery-settings'
import { workspaceEntitlements } from './entitlements.ts'
import { validSiteSlug, defaultSiteHost } from '@chronoframe/contracts/domains'
import type { PlatformD1 } from './index.ts'
@@ -56,6 +60,7 @@ export function siteProfile(value: unknown) {
}
}
export interface ManagedSite {
+ presentation: GalleryPresentation
siteId: number
workspaceId: number
name: string
@@ -68,7 +73,18 @@ export interface ManagedSite {
avatarUrl: string
}
const fields =
- 's.id AS siteId, s.workspace_id AS workspaceId, s.name, s.slug, s.published, s.revision, s.gallery_title AS title, s.gallery_slogan AS slogan, s.gallery_author AS author, s.gallery_avatar AS avatarUrl'
+ 's.id AS siteId, s.workspace_id AS workspaceId, s.name, s.slug, s.published, s.revision, s.gallery_title AS title, s.gallery_slogan AS slogan, s.gallery_author AS author, s.gallery_avatar AS avatarUrl, s.gallery_presentation AS presentation'
+type StoredManagedSite = Omit<ManagedSite, 'presentation'> & {
+ presentation: string
+}
+function decodedSite<T extends { presentation: string }>(
+ row: T,
+): Omit<T, 'presentation'> & { presentation: GalleryPresentation } {
+ return {
+ ...row,
+ presentation: parseGalleryPresentation(JSON.parse(row.presentation)),
+ }
+}
/** Transactional D1 writes retain live membership checks, including during retries. */
export function createD1Provisioning(
db: PlatformD1,
@@ -104,9 +120,9 @@ export function createD1Provisioning(
JOIN platform_memberships m ON m.workspace_id = s.workspace_id
WHERE s.id = ? AND s.suspended=0 AND m.user_id = ? AND m.role IN ('admin','member')`)
.bind(siteId, userId)
- .first<ManagedSite & { role: string }>()
+ .first<StoredManagedSite & { role: string }>()
if (!site) throw new ProvisioningError(404, 'Site not found')
- return site
+ return decodedSite(site)
}
return {
defaultWorkspace,
@@ -127,11 +143,11 @@ export function createD1Provisioning(
JOIN platform_memberships m ON m.workspace_id = s.workspace_id
WHERE s.workspace_id = ? AND s.provision_key = ? AND m.user_id = ? AND m.role = 'admin'`)
.bind(workspace.id, input.requestId, userId)
- .first<ManagedSite>()
+ .first<StoredManagedSite>()
if (existing) {
if (existing.name !== identity.name || existing.slug !== identity.slug)
throw new ProvisioningError(409, 'Request identifier already used')
- return existing
+ return decodedSite(existing)
}
const entitlement = await workspaceEntitlements(db, workspace.id)
try {
@@ -173,7 +189,7 @@ export function createD1Provisioning(
`SELECT ${fields} FROM platform_sites s WHERE workspace_id=? AND provision_key=?`,
)
.bind(workspace.id, input.requestId)
- .first<ManagedSite>()
+ .first<StoredManagedSite>()
if (!site)
throw new ProvisioningError(
403,
@@ -181,7 +197,7 @@ export function createD1Provisioning(
)
if (site.name !== identity.name || site.slug !== identity.slug)
throw new ProvisioningError(409, 'Request identifier already used')
- return site
+ return decodedSite(site)
} catch (error) {
if (
String(error).includes(
@@ -203,6 +219,7 @@ export function createD1Provisioning(
revision: unknown
published: unknown
profile?: unknown
+ presentation?: unknown
},
) {
const current = await get(userId, siteId)
@@ -211,15 +228,23 @@ export function createD1Provisioning(
const name = siteIdentity(input.name, current.slug ?? 'legacy-site').name
const profile =
input.profile === undefined ? current : siteProfile(input.profile)
+ let presentation = current.presentation
+ if (input.presentation !== undefined) {
+ try {
+ presentation = parseGalleryPresentation(input.presentation)
+ } catch {
+ throw new ProvisioningError(400, 'Invalid gallery presentation')
+ }
+ }
if (
!Number.isSafeInteger(input.revision) ||
typeof input.published !== 'boolean'
)
throw new ProvisioningError(400, 'Invalid site settings')
const result = await db
- .prepare(`UPDATE platform_sites SET name = ?, published = ?, gallery_title = ?, gallery_slogan = ?, gallery_author = ?, gallery_avatar = ?, revision = revision + 1
+ .prepare(`UPDATE platform_sites SET name = ?, published = ?, gallery_title = ?, gallery_slogan = ?, gallery_author = ?, gallery_avatar = ?, gallery_presentation = ?, revision = revision + 1
WHERE id = ? AND revision = ? AND EXISTS(SELECT 1 FROM platform_memberships WHERE workspace_id = platform_sites.workspace_id AND user_id = ? AND role = 'admin')
- RETURNING id AS siteId, workspace_id AS workspaceId, name, slug, published, revision, gallery_title AS title, gallery_slogan AS slogan, gallery_author AS author, gallery_avatar AS avatarUrl`)
+ RETURNING id AS siteId, workspace_id AS workspaceId, name, slug, published, revision, gallery_title AS title, gallery_slogan AS slogan, gallery_author AS author, gallery_avatar AS avatarUrl, gallery_presentation AS presentation`)
.bind(
name,
input.published ? 1 : 0,
@@ -227,14 +252,15 @@ export function createD1Provisioning(
profile.slogan,
profile.author,
profile.avatarUrl,
+ JSON.stringify(presentation),
siteId,
input.revision as number,
userId,
)
- .first<ManagedSite>()
+ .first<StoredManagedSite>()
if (!result)
throw new ProvisioningError(409, 'Site changed; reload before saving')
- return result
+ return decodedSite(result)
},
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d7eda0dd..d0d26a59 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -866,6 +866,9 @@ importers:
apps/site:
dependencies:
+ '@nuxt/fonts':
+ specifier: 0.14.0
'@chronoframe/contracts':
specifier: workspace:*
version: link:../../packages/contracts
diff --git a/tests/platform-provisioning.test.ts b/tests/platform-provisioning.test.ts
index b35770e9..2f89a2aa 100644
--- a/tests/platform-provisioning.test.ts
+++ b/tests/platform-provisioning.test.ts
@@ -88,6 +88,7 @@ test('Real D1 provisioning preserves old tenants, serializes defaults and enforc
'0009_cloud_usage_events.sql',
'0014_entitlements.sql',
'0015_lifecycle.sql',
+ '0016_gallery_presentation.sql',
])
await migrate(migration)
await db
@@ -220,6 +221,21 @@ test('Real D1 provisioning preserves old tenants, serializes defaults and enforc
published: false,
revision: 3,
profile,
+ presentation: {
+ homeHeaderLayout: 'fixed',
+ socialLinks: {
+ links: [
+ 'https://github.com/example',
+ 'https://example.com/portfolio',
+ ],
+ },
+ },
+ })
+ assert.deepEqual(profiled.presentation, {
+ homeHeaderLayout: 'fixed',
+ socialLinks: {
+ links: ['https://github.com/example', 'https://example.com/portfolio'],
+ },
})
assert.equal(profiled.title, profile.title)
assert.equal((await store.get(42, 8)).avatarUrl, profile.avatarUrl)
@@ -233,6 +249,40 @@ test('Real D1 provisioning preserves old tenants, serializes defaults and enforc
profile.title,
'legacy clients preserve public profile',
)
+ assert.deepEqual(
+ preserved.presentation,
+ profiled.presentation,
+ 'legacy updates retain gallery presentation',
+ )
+ for (const presentation of [
+ { homeHeaderLayout: 'invalid', socialLinks: { links: [] } },
+ {
+ homeHeaderLayout: 'fixed',
+ socialLinks: { links: ['javascript:alert(1)'] },
+ },
+ {
+ homeHeaderLayout: 'fixed',
+ socialLinks: {
+ links: ['https://github.com/example', 'https://github.com/example/'],
+ },
+ },
+ {
+ homeHeaderLayout: 'fixed',
+ socialLinks: { links: Array(5).fill('https://example.com') },
+ },
+ ]) {
+ await assert.rejects(
+ store.update(42, 8, {
+ name: 'Must not change',
+ published: true,
+ revision: 5,
+ presentation,
+ }),
+ { statusCode: 400 },
+ )
+ }
+ assert.equal((await store.get(42, 8)).name, preserved.name)
+
await assert.rejects(
store.update(42, 8, {
name: 'Stale',