diff --git a/.changeset/admin-nav-title.md b/.changeset/admin-nav-title.md new file mode 100644 index 0000000..c042090 --- /dev/null +++ b/.changeset/admin-nav-title.md @@ -0,0 +1,7 @@ +--- +'@goto/web': patch +'@goto/cli': patch +'@goto/worker': patch +--- + +Fix the admin and sign-in title to GoTo and remove the `site` config section. Show the app icon beside the title, link the pair to Overview only from other pages, and move Health next to the theme switcher. diff --git a/README.md b/README.md index 9a09e10..7a96885 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,11 @@ The shared `@goto/config` package validates the YAML contract; the web runtime d not load it yet. See [the example](examples/goto.yaml) and [the package API](packages/config/README.md). -Configuration is a single `config/goto.yaml` with `site`, `appearance`, `auth`, -`database`, `analytics`, `defaults`, and `domains` sections. Unknown fields and -null values fail validation. Auth declares exactly one OIDC or shared-credentials -provider; `auth.secret` is optional and is not generated by the loader. +Configuration is a single `config/goto.yaml` with top-level keys `version`, +`url`, `appearance`, `auth`, `database`, `analytics`, `link_defaults`, `fallback`, +and `domains`. Unknown fields and null values fail validation. Auth declares +exactly one OIDC or shared-credentials provider; `auth.secret` is optional and +is not generated by the loader. Redirect status and query forwarding inherit built-in → global → domain → link. Fallback inherits only through domain scope. Defaults are 302, forwarding off, diff --git a/apps/cli/src/cli.test.ts b/apps/cli/src/cli.test.ts index d67faa9..97d5ed2 100644 --- a/apps/cli/src/cli.test.ts +++ b/apps/cli/src/cli.test.ts @@ -176,11 +176,12 @@ describe('goto-cli config validate', () => { environment: env }, { - name: 'actual error alongside dropped tags', - source: `${validYaml} tags: [., ""]\nsite: {title: null}\n`, - environment: env + name: 'invalid appearance alongside dropped tags', + source: `${validYaml} tags: [., ""]\nappearance: false\n`, + environment: env, + issue: '\n /appearance: Expected object\n' } - ])('reports $name without disclosing configuration', async ({ source, environment }) => { + ])('reports $name without disclosing configuration', async ({ source, environment, issue }) => { await writeConfiguration('config/goto.yaml', source); const output = createOutput(); @@ -190,6 +191,7 @@ describe('goto-cli config validate', () => { expect.stringMatching(/^Configuration validation failed\.\n/) ); const diagnostic = output.stderr.mock.calls[0]?.[0]; + if (issue !== undefined) expect(diagnostic).toContain(issue); for (const sensitive of [...Object.values(env), ...Object.values(environment)]) { if (sensitive !== undefined) expect(diagnostic).not.toContain(sensitive); } @@ -198,17 +200,19 @@ describe('goto-cli config validate', () => { expect(diagnostic).not.toContain('config/goto.yaml'); }); - it('reports the site section for an unsupported site.url without printing its value', async () => { - const oldSiteUrl = 'https://old.example.test/private-do-not-print'; - await writeConfiguration('config/goto.yaml', `${validYaml}site:\n url: ${oldSiteUrl}\n`); + it('rejects the removed site section without printing its custom title', async () => { + const oldTitle = 'Private title not for diagnostics'; + await writeConfiguration('config/goto.yaml', `${validYaml}site:\n title: ${oldTitle}\n`); const output = createOutput(); expect(await runCli(['config', 'validate'], output, { cwd, env })).toBe(1); expect(output.stdout).not.toHaveBeenCalled(); expect(output.stderr).toHaveBeenCalledExactlyOnceWith( - expect.stringMatching(/^Configuration validation failed\.\n {2}\/site: \S[^\n]*\n$/) + expect.stringMatching( + /^Configuration validation failed\.\n {2}\/: Unexpected property\.[^\n]*\n$/ + ) ); - expect(output.stderr.mock.calls[0]?.[0]).not.toContain(oldSiteUrl); + expect(output.stderr.mock.calls[0]?.[0]).not.toContain(oldTitle); }); it('reports a missing file without disclosing the path', async () => { diff --git a/apps/web/e2e/auth.e2e.ts b/apps/web/e2e/auth.e2e.ts index 9a3604e..bc2f8a3 100644 --- a/apps/web/e2e/auth.e2e.ts +++ b/apps/web/e2e/auth.e2e.ts @@ -32,6 +32,8 @@ test('shared credentials protect admin pages and sign-out removes access', async const signInPage = await page.goto(`${appServer.origin}/admin`); await expect(page).toHaveURL(/\/signin\?/); expect(signInPage?.headers()['cache-control']).toBe('private, no-store'); + await expect(page).toHaveTitle('Sign in — GoTo'); + await expect(page.getByRole('heading', { name: 'Sign in to GoTo', exact: true })).toBeVisible(); await page.getByLabel('Username', { exact: true }).fill('example'); await page.getByLabel('Password', { exact: true }).fill('incorrect'); const failedSignIn = page.waitForResponse(`${appServer.origin}/auth/sign-in/credentials`); @@ -145,11 +147,15 @@ test('shared credentials protect admin pages and sign-out removes access', async await expect(visitsValue).toHaveText('4'); await expect(graph).toHaveAccessibleName(/^Visits by week\. Total: 4\./); expect(navigationWarnings).toEqual([]); + const adminNav = page.getByRole('navigation', { name: 'Administration', exact: true }); + const overviewLink = adminNav.getByRole('link', { name: 'GoTo', exact: true }); + await expect(adminNav.getByText('GoTo', { exact: true })).toBeVisible(); + await expect(overviewLink).toHaveCount(0); await domainLink.click(); await expect(page.getByRole('heading', { name: 'Domain', exact: true })).toBeVisible(); const context = page.locator('.admin-context'); await expect(context).toHaveCount(0); - await expect(page).toHaveTitle('Domain — go.example.org — Goto'); + await expect(page).toHaveTitle('Domain — go.example.org — GoTo'); await expect(acceptedLanguages).toBeVisible(); await expect(browsers.getByRole('columnheader')).toHaveText(['Browser', 'Visits', 'Share']); await expect(operatingSystems.getByRole('columnheader')).toHaveText([ @@ -158,10 +164,12 @@ test('shared credentials protect admin pages and sign-out removes access', async 'Share' ]); await expect(browsers.getByRole('rowheader', { name: 'Other', exact: true })).toBeVisible(); - const overviewLink = page - .getByRole('navigation', { name: 'Administration', exact: true }) - .getByRole('link', { name: 'Goto', exact: true }); await expect(overviewLink).toHaveAttribute('href', '/admin?period=all'); + const appIcon = overviewLink.locator('img[src="/@static/favicon.svg"]'); + await expect(appIcon).toBeVisible(); + await expect + .poll(() => appIcon.evaluate((image: HTMLImageElement) => image.naturalWidth)) + .toBeGreaterThan(0); await expect(page.getByRole('link', { name: 'Overview', exact: true })).toHaveCount(0); await expect(graph).toHaveAttribute('aria-busy', 'false'); await expect(graph).toHaveAccessibleName(/^Visits by week\. Total: 3\./); @@ -297,7 +305,7 @@ test('shared credentials protect admin pages and sign-out removes access', async await expect(redirectCard.locator('dd').nth(1)).toHaveText('/docs'); await expect(page.locator('.admin-cards .admin-stat-label')).toHaveText(['Visits', 'Status']); await expect(page.getByRole('region', { name: 'Status', exact: true })).toContainText('Active'); - await expect(page).toHaveTitle('Link — go.example.org/docs — Goto'); + await expect(page).toHaveTitle('Link — go.example.org/docs — GoTo'); await expect(graph).toHaveAttribute('aria-busy', 'false'); await expect(chartTable).toHaveAccessibleName('Visits'); await expect(graph).toHaveAccessibleName(/^Visits by week\. Total: 1\./); @@ -343,7 +351,7 @@ test('shared credentials protect admin pages and sign-out removes access', async const tagHeading = page.getByRole('heading', { name: `Tag: ${sharedTag}`, exact: true }); await expect(tagHeading).toBeVisible(); await expect(tagHeading).toHaveAttribute('title', `Tag: ${sharedTag}`); - await expect(page).toHaveTitle(`Tag: ${sharedTag} — Goto`); + await expect(page).toHaveTitle(`Tag: ${sharedTag} — GoTo`); await expect(page.getByRole('region', { name: 'Tag details', exact: true })).toHaveCount(0); const taggedLinks = page.getByRole('region', { name: `Links tagged ${sharedTag}`, exact: true }); await expect(taggedLinks.getByRole('link')).toHaveCount(2); @@ -373,7 +381,7 @@ test('shared credentials protect admin pages and sign-out removes access', async await domainLink.click(); await page.getByRole('link', { name: '/a%2Fb', exact: true }).click(); await expect(page.getByRole('heading', { name: 'Link', exact: true })).toBeVisible(); - await expect(page).toHaveTitle('Link — go.example.org/a%2Fb — Goto'); + await expect(page).toHaveTitle('Link — go.example.org/a%2Fb — GoTo'); await expect(redirectCard.getByText('Title', { exact: true })).toHaveCount(0); await expect(page).toHaveURL( `${appServer.origin}/admin/domains/go.example.org/links/a%252Fb?period=all` @@ -385,14 +393,14 @@ test('shared credentials protect admin pages and sign-out removes access', async `${appServer.origin}/admin/domains/go.example.org/links/a/b?period=all` ); await expect(page.getByRole('heading', { name: 'Link', exact: true })).toBeVisible(); - await expect(page).toHaveTitle('Link — go.example.org/a/b — Goto'); + await expect(page).toHaveTitle('Link — go.example.org/a/b — GoTo'); await expect(visitsValue).toHaveText('0'); await page.goBack(); await rootLink.click(); await expect(page).toHaveURL(`${appServer.origin}/admin/domains/go.example.org/links?period=all`); await expect(page.getByRole('heading', { name: 'Root', exact: true })).toBeVisible(); - await expect(page).toHaveTitle('Root — go.example.org — Goto'); + await expect(page).toHaveTitle('Root — go.example.org — GoTo'); await expect(acceptedLanguages).toBeVisible(); await expect(visitsValue).toHaveText('1'); await expect(page.getByRole('region', { name: 'Status', exact: true })).toHaveCount(0); diff --git a/apps/web/src/lib/components/admin/AdminNav.svelte b/apps/web/src/lib/components/admin/AdminNav.svelte index 916d96f..765766a 100644 --- a/apps/web/src/lib/components/admin/AdminNav.svelte +++ b/apps/web/src/lib/components/admin/AdminNav.svelte @@ -5,9 +5,10 @@ import { authClient } from '#lib/auth-client.js'; import ThemeToggle from '../ThemeToggle.svelte'; - let { title, overviewHref }: { title: string; overviewHref: string } = $props(); + let { overviewHref }: { overviewHref: string } = $props(); let currentPath = $derived(page.url.pathname + page.url.search); + let onOverview = $derived(page.url.pathname === '/admin'); let pending = $state(false); let signoutError = $state<'rate' | 'network' | 'auth' | null>(null); @@ -47,12 +48,19 @@ }} /> +{#snippet titleWithIcon()} + + GoTo +{/snippet} + - - - {title} + + {#if onOverview} + {@render titleWithIcon()} + {:else} + {@render titleWithIcon()} + {/if} + - - - + {#if signoutError} {#if signoutError === 'rate'} @@ -106,14 +112,10 @@ gap: var(--space-5); } - nav { - display: flex; - flex-wrap: wrap; + .nav-title { + display: inline-flex; align-items: center; - gap: var(--space-5); - } - - a { + gap: var(--space-4); color: var(--color-text); font-weight: 600; text-decoration: none; diff --git a/apps/web/src/lib/components/admin/AdminPage.svelte b/apps/web/src/lib/components/admin/AdminPage.svelte index 5a93fe7..614a1cc 100644 --- a/apps/web/src/lib/components/admin/AdminPage.svelte +++ b/apps/web/src/lib/components/admin/AdminPage.svelte @@ -5,7 +5,6 @@ import '#lib/styles/admin.css'; let { - siteTitle, title: heading, documentTitle, context, @@ -14,7 +13,6 @@ actions, children }: { - siteTitle: string; title: string; documentTitle?: string; context?: Snippet; @@ -28,8 +26,8 @@ let compactActivityText = $derived(formatLastVisitCompact(lastActivityAt)); -{documentTitle ?? heading} — {siteTitle} - +{documentTitle ?? heading} — GoTo + diff --git a/apps/web/src/lib/server/request-context.test.ts b/apps/web/src/lib/server/request-context.test.ts index 4a91c54..8e99d0b 100644 --- a/apps/web/src/lib/server/request-context.test.ts +++ b/apps/web/src/lib/server/request-context.test.ts @@ -111,8 +111,7 @@ test('an existing request retains its snapshot when the application publishes an current = prepareSnapshot( loadConfig( { - url: { app: 'https://admin.example.org' }, - site: { title: 'Updated' }, + url: { app: 'https://updated-admin.example.org' }, auth: { credentials: { username: 'example', password: 'test-password' } }, domains: {} }, @@ -124,7 +123,7 @@ test('an existing request retains its snapshot when the application publishes an expect(requestSnapshot(first)).toBe(initial); expect(requestSnapshot(second)).toBe(current); - expect(requestSnapshot(first)?.configuration.site.title).toBe('Goto'); + expect(requestSnapshot(first)?.configuration.url.app).toBe('https://admin.example.org'); }); test('binding neither consumes the request body nor serializes private configuration', async () => { diff --git a/apps/web/src/routes/(admin)/(auth)/admin/+page.svelte b/apps/web/src/routes/(admin)/(auth)/admin/+page.svelte index f22cf9e..3a7bb6f 100644 --- a/apps/web/src/routes/(admin)/(auth)/admin/+page.svelte +++ b/apps/web/src/routes/(admin)/(auth)/admin/+page.svelte @@ -26,7 +26,7 @@ let acceptedLanguageVisits = $derived(data.acceptedLanguageVisitsByTimeframe[timeframe] ?? null); - + {#snippet actions()} {#if data.available && data.timeframes.length > 0} - + Application diff --git a/apps/web/src/routes/(admin)/(auth)/admin/tags/[tag]/+page.svelte b/apps/web/src/routes/(admin)/(auth)/admin/tags/[tag]/+page.svelte index 7415a23..9e2e62e 100644 --- a/apps/web/src/routes/(admin)/(auth)/admin/tags/[tag]/+page.svelte +++ b/apps/web/src/routes/(admin)/(auth)/admin/tags/[tag]/+page.svelte @@ -28,7 +28,6 @@ - Sign in — {data.title} + Sign in — GoTo - Sign in to {data.title} + Sign in to GoTo {#if errorCode} diff --git a/apps/web/src/routes/(admin)/+layout.server.ts b/apps/web/src/routes/(admin)/+layout.server.ts deleted file mode 100644 index 20ebc1f..0000000 --- a/apps/web/src/routes/(admin)/+layout.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { LayoutServerLoad } from './$types'; - -export const load: LayoutServerLoad = ({ locals }) => { - return { title: locals.snapshot.configuration.site.title }; -}; diff --git a/examples/goto.yaml b/examples/goto.yaml index 389f552..a015150 100644 --- a/examples/goto.yaml +++ b/examples/goto.yaml @@ -5,9 +5,6 @@ url: app: https://goto.example.net worker: http://goto-worker:9000 -site: - title: Goto - appearance: primary_light_color: '#0f766e' primary_dark_color: '#5eead4' diff --git a/packages/config/src/config.schema.json b/packages/config/src/config.schema.json index 8bd1a45..7627317 100644 --- a/packages/config/src/config.schema.json +++ b/packages/config/src/config.schema.json @@ -6,7 +6,6 @@ "properties": { "version": { "default": 1, "const": 1, "type": "number" }, "url": { "default": {}, "$ref": "#/$defs/Url" }, - "site": { "default": {}, "$ref": "#/$defs/Site" }, "appearance": { "default": {}, "$ref": "#/$defs/Appearance" }, "auth": { "$ref": "#/$defs/Auth" }, "database": { "default": {}, "$ref": "#/$defs/Database" }, @@ -107,20 +106,6 @@ } ] }, - "LocalImagePath": { - "description": "A decoded /public/ SVG, PNG, JPEG, GIF or WebP image path without dot segments, percent escapes, backslashes, queries or fragments.", - "type": "string", - "anyOf": [ - { - "type": "string", - "pattern": "^/public/(?:(?!\\.{1,2}(?:/|$))[^/%\\\\?#\\x00-\\x1f\\x7f]+/)*(?!\\.{1,2}(?:/|$))[^/%\\\\?#\\x00-\\x1f\\x7f]+\\.(?:[sS][vV][gG]|[pP][nN][gG]|[jJ][pP][eE]?[gG]|[gG][iI][fF]|[wW][eE][bB][pP])(?![\\s\\S])" - }, - { - "type": "string", - "pattern": "(?:^|[^$])(?:\\$\\$)*\\$\\{[A-Z_][A-Z0-9_]*(?::-[^}]*)?\\}" - } - ] - }, "HexColor": { "type": "string", "anyOf": [ @@ -175,25 +160,6 @@ "worker": { "default": "http://goto-worker:9000", "$ref": "#/$defs/BaseUrl" } } }, - "Site": { - "additionalProperties": false, - "type": "object", - "properties": { - "title": { - "default": "Goto", - "type": "string", - "anyOf": [ - { "type": "string", "pattern": "\\S", "minLength": 1 }, - { - "type": "string", - "pattern": "(?:^|[^$])(?:\\$\\$)*\\$\\{[A-Z_][A-Z0-9_]*(?::-[^}]*)?\\}" - } - ] - }, - "logo_path": { "$ref": "#/$defs/LocalImagePath" }, - "favicon_path": { "$ref": "#/$defs/LocalImagePath" } - } - }, "Appearance": { "additionalProperties": false, "type": "object", diff --git a/packages/config/src/diagnostics.test.ts b/packages/config/src/diagnostics.test.ts index 1e56848..0b490d4 100644 --- a/packages/config/src/diagnostics.test.ts +++ b/packages/config/src/diagnostics.test.ts @@ -24,15 +24,15 @@ function captureConfigError(action: () => unknown): ConfigError { describe('configuration diagnostics', () => { it('keeps the error message generic and formats issues only when requested', () => { - const issues = [{ path: '/site', message: 'Expected object' }]; + const issues = [{ path: '/url', message: 'Expected object' }]; const error = new ConfigError(issues); expect(error.message).toBe('Invalid configuration'); expect(String(error)).toBe('ConfigError: Invalid configuration'); expect(error.issues).toEqual(issues); expect(error).not.toHaveProperty('cause'); - expect(formatConfigError(error)).toBe('Invalid configuration\n /site: Expected object'); + expect(formatConfigError(error)).toBe('Invalid configuration\n /url: Expected object'); expect(formatConfigError(error, 'Configuration validation failed.')).toBe( - 'Configuration validation failed.\n /site: Expected object' + 'Configuration validation failed.\n /url: Expected object' ); expect(new ConfigError().issues).toEqual([]); expect(formatConfigError(new ConfigError())).toBe('Invalid configuration'); @@ -76,12 +76,12 @@ describe('configuration diagnostics', () => { } }); - it('identifies the site section and its allowed fields without echoing the old URL', () => { + it('identifies the URL section and its allowed fields without echoing the value', () => { const error = captureConfigError(() => loadConfig( { ...configurationInput(), - site: { url: `https://${privateValue}.example.com` } + url: { origin: `https://${privateValue}.example.com` } }, options ) @@ -89,8 +89,8 @@ describe('configuration diagnostics', () => { expect(error.message).toBe('Invalid configuration'); expect(error.issues).toEqual([ { - path: '/site', - message: 'Unexpected property. Allowed fields: title, logo_path, favicon_path' + path: '/url', + message: 'Unexpected property. Allowed fields: app, worker' } ]); expect(JSON.stringify(error)).not.toContain(privateValue); @@ -99,7 +99,7 @@ describe('configuration diagnostics', () => { it.each([ { override: { [privateKey]: privateValue }, path: '/' }, - { override: { site: { [privateKey]: privateValue } }, path: '/site' } + { override: { url: { [privateKey]: privateValue } }, path: '/url' } ])('omits unknown property names and values at $path', ({ override, path }) => { const error = captureConfigError(() => loadConfig({ ...configurationInput(), ...override }, options) diff --git a/packages/config/src/editor-schema.test.ts b/packages/config/src/editor-schema.test.ts index 6cde18e..bc1c5c4 100644 --- a/packages/config/src/editor-schema.test.ts +++ b/packages/config/src/editor-schema.test.ts @@ -23,11 +23,10 @@ describe('Goto editor schema', () => { it('relaxes defaulted fields while keeping authentication, domain links and destinations required', () => { const editor = createEditorSchema(); expect(editor.required).toEqual(['auth', 'domains']); - for (const name of ['Url', 'Site', 'Appearance', 'Database', 'Analytics', 'LinkDefaults']) { + for (const name of ['Url', 'Appearance', 'Database', 'Analytics', 'LinkDefaults']) { expect(definition(editor, name).required).toBeUndefined(); } - expect(property(editor, 'site')).toEqual({ $ref: '#/$defs/Site', default: {} }); - expect(object(definition(editor, 'Site').properties)).not.toHaveProperty('url'); + expect(object(editor.properties)).not.toHaveProperty('site'); expect(property(editor, 'url')).toEqual({ $ref: '#/$defs/Url', default: {} }); expect(property(definition(editor, 'Url'), 'app')).toEqual({ $ref: '#/$defs/AppUrl', diff --git a/packages/config/src/load.test.ts b/packages/config/src/load.test.ts index b3f94fa..141a827 100644 --- a/packages/config/src/load.test.ts +++ b/packages/config/src/load.test.ts @@ -12,10 +12,7 @@ const yaml = 'auth: {credentials: {username: admin, password: test-password}}\nd const authoredKeyMarker = 'dummy-authored-key-marker'; describe('configuration loading', () => { - it('parses YAML and applies configuration defaults without mutating the input', () => { - expect(parseConfig(`${yaml}\nsite: {title: yes}`, options).configuration.site.title).toBe( - 'yes' - ); + it('applies configuration defaults without mutating the input', () => { const input = configurationInput(); const original = structuredClone(input); const { configuration, warnings } = loadConfig(input, options); @@ -23,7 +20,6 @@ describe('configuration loading', () => { expect(configuration).toMatchObject({ version: 1, url: { app: 'http://localhost:3000', worker: 'http://goto-worker:9000' }, - site: { title: 'Goto' }, database: { path: './data/goto.sqlite', worker_path: './data/worker.sqlite' }, analytics: { retention_months: 3 }, link_defaults: { @@ -225,7 +221,9 @@ domains: } ]); expect(() => loadConfig(input, options)).toThrow(ConfigError); - expect(() => loadConfig({ ...input, site: null }, { env: { TAG: '.' } })).toThrow(ConfigError); + expect(() => loadConfig({ ...input, appearance: false }, { env: { TAG: '.' } })).toThrow( + expect.objectContaining({ issues: [{ path: '/appearance', message: 'Expected object' }] }) + ); }); it.each([null, {}, 'work', ['work', 42], [false], [null], [{}]])( @@ -348,19 +346,8 @@ domains: ); }); - it('rejects the old site URL key without accepting it as an app URL', () => { - for (const url of [undefined, { app: 'https://admin.example.com' }]) { - expect(() => - loadConfig( - { - ...configurationInput(), - ...(url === undefined ? {} : { url }), - site: { url: 'https://old.example.com', title: 'Custom title' } - }, - options - ) - ).toThrow(ConfigError); - } + it('rejects the removed site section even when empty', () => { + expect(() => parseConfig(`${yaml}\nsite: {}`, options)).toThrow(ConfigError); }); it('defaults the OIDC name after resolving authentication placeholders', () => { @@ -470,8 +457,6 @@ domains: it.each([ { unknown: 'private-value' }, - { site: null }, - { site: [] }, { url: null }, { url: [] }, { version: Infinity }, @@ -541,8 +526,7 @@ domains: it.each([ `${yaml}\nversion: 1\nversion: 1`, `${yaml}\n<<: {version: 1}`, - `${yaml}\n---\n${yaml}`, - `${yaml}\nsite: &cycle {title: *cycle}` + `${yaml}\n---\n${yaml}` ])('rejects non-strict YAML', (source) => { expect(() => parseConfig(source, options)).toThrow(ConfigError); }); @@ -585,7 +569,7 @@ domains: let calls = 0; const getter = { ...configurationInput(), - get site() { + get appearance() { calls++; return {}; } @@ -593,7 +577,7 @@ domains: expect(() => loadConfig(getter, options)).toThrow(ConfigError); expect(calls).toBe(0); const cycle = configurationInput(); - Object.assign(cycle, { site: cycle }); + Object.assign(cycle, { appearance: cycle }); for (const input of [ cycle, Object.create(configurationInput()), diff --git a/packages/config/src/schema.ts b/packages/config/src/schema.ts index bc0a0d7..a22f1fe 100644 --- a/packages/config/src/schema.ts +++ b/packages/config/src/schema.ts @@ -68,7 +68,6 @@ FormatRegistry.Set('goto-instant', (value) => { }); const nonBlankText = { minLength: 1, pattern: '\\S' }; -const imageSegment = '(?!\\.{1,2}(?:/|$))[^/%\\\\?#\\x00-\\x1f\\x7f]+'; const HttpUrlSchema = Type.String({ $id: 'HttpUrl', @@ -114,13 +113,6 @@ const AuthSecretSchema = Type.String({ minLength: 32 }); -const LocalImagePathSchema = Type.String({ - $id: 'LocalImagePath', - pattern: `^/public/(?:${imageSegment}/)*${imageSegment}\\.(?:[sS][vV][gG]|[pP][nN][gG]|[jJ][pP][eE]?[gG]|[gG][iI][fF]|[wW][eE][bB][pP])${end}`, - description: - 'A decoded /public/ SVG, PNG, JPEG, GIF or WebP image path without dot segments, percent escapes, backslashes, queries or fragments.' -}); - const HexColorSchema = Type.String({ $id: 'HexColor', pattern: `^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})${end}` @@ -163,15 +155,6 @@ const UrlSchema = Type.Object( { $id: 'Url', additionalProperties: false } ); -const SiteSchema = Type.Object( - { - title: Type.String({ ...nonBlankText, default: 'Goto' }), - logo_path: Type.Optional(ref(LocalImagePathSchema)), - favicon_path: Type.Optional(ref(LocalImagePathSchema)) - }, - { $id: 'Site', additionalProperties: false } -); - const AppearanceSchema = Type.Object( { primary_light_color: ref(HexColorSchema, { default: '#0f766e' }), @@ -346,7 +329,6 @@ export const GotoConfigurationSchema = Type.Object( { version: Type.Literal(1, { default: 1 }), url: ref(UrlSchema, { default: {} }), - site: ref(SiteSchema, { default: {} }), appearance: ref(AppearanceSchema, { default: {} }), auth: ref(AuthSchema), database: ref(DatabaseSchema, { default: {} }), @@ -369,13 +351,11 @@ export const configurationReferences: TSchema[] = [ AppUrlSchema, InstantSchema, AuthSecretSchema, - LocalImagePathSchema, HexColorSchema, TagsSchema, RedirectStatusSchema, RedirectResponseSchema, UrlSchema, - SiteSchema, AppearanceSchema, OidcAuthSchema, CredentialsAuthSchema,
{#if signoutError === 'rate'} @@ -106,14 +112,10 @@ gap: var(--space-5); } - nav { - display: flex; - flex-wrap: wrap; + .nav-title { + display: inline-flex; align-items: center; - gap: var(--space-5); - } - - a { + gap: var(--space-4); color: var(--color-text); font-weight: 600; text-decoration: none; diff --git a/apps/web/src/lib/components/admin/AdminPage.svelte b/apps/web/src/lib/components/admin/AdminPage.svelte index 5a93fe7..614a1cc 100644 --- a/apps/web/src/lib/components/admin/AdminPage.svelte +++ b/apps/web/src/lib/components/admin/AdminPage.svelte @@ -5,7 +5,6 @@ import '#lib/styles/admin.css'; let { - siteTitle, title: heading, documentTitle, context, @@ -14,7 +13,6 @@ actions, children }: { - siteTitle: string; title: string; documentTitle?: string; context?: Snippet; @@ -28,8 +26,8 @@ let compactActivityText = $derived(formatLastVisitCompact(lastActivityAt)); -{documentTitle ?? heading} — {siteTitle} - +{documentTitle ?? heading} — GoTo + diff --git a/apps/web/src/lib/server/request-context.test.ts b/apps/web/src/lib/server/request-context.test.ts index 4a91c54..8e99d0b 100644 --- a/apps/web/src/lib/server/request-context.test.ts +++ b/apps/web/src/lib/server/request-context.test.ts @@ -111,8 +111,7 @@ test('an existing request retains its snapshot when the application publishes an current = prepareSnapshot( loadConfig( { - url: { app: 'https://admin.example.org' }, - site: { title: 'Updated' }, + url: { app: 'https://updated-admin.example.org' }, auth: { credentials: { username: 'example', password: 'test-password' } }, domains: {} }, @@ -124,7 +123,7 @@ test('an existing request retains its snapshot when the application publishes an expect(requestSnapshot(first)).toBe(initial); expect(requestSnapshot(second)).toBe(current); - expect(requestSnapshot(first)?.configuration.site.title).toBe('Goto'); + expect(requestSnapshot(first)?.configuration.url.app).toBe('https://admin.example.org'); }); test('binding neither consumes the request body nor serializes private configuration', async () => { diff --git a/apps/web/src/routes/(admin)/(auth)/admin/+page.svelte b/apps/web/src/routes/(admin)/(auth)/admin/+page.svelte index f22cf9e..3a7bb6f 100644 --- a/apps/web/src/routes/(admin)/(auth)/admin/+page.svelte +++ b/apps/web/src/routes/(admin)/(auth)/admin/+page.svelte @@ -26,7 +26,7 @@ let acceptedLanguageVisits = $derived(data.acceptedLanguageVisitsByTimeframe[timeframe] ?? null); - + {#snippet actions()} {#if data.available && data.timeframes.length > 0} - + Application diff --git a/apps/web/src/routes/(admin)/(auth)/admin/tags/[tag]/+page.svelte b/apps/web/src/routes/(admin)/(auth)/admin/tags/[tag]/+page.svelte index 7415a23..9e2e62e 100644 --- a/apps/web/src/routes/(admin)/(auth)/admin/tags/[tag]/+page.svelte +++ b/apps/web/src/routes/(admin)/(auth)/admin/tags/[tag]/+page.svelte @@ -28,7 +28,6 @@ - Sign in — {data.title} + Sign in — GoTo - Sign in to {data.title} + Sign in to GoTo {#if errorCode} diff --git a/apps/web/src/routes/(admin)/+layout.server.ts b/apps/web/src/routes/(admin)/+layout.server.ts deleted file mode 100644 index 20ebc1f..0000000 --- a/apps/web/src/routes/(admin)/+layout.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { LayoutServerLoad } from './$types'; - -export const load: LayoutServerLoad = ({ locals }) => { - return { title: locals.snapshot.configuration.site.title }; -}; diff --git a/examples/goto.yaml b/examples/goto.yaml index 389f552..a015150 100644 --- a/examples/goto.yaml +++ b/examples/goto.yaml @@ -5,9 +5,6 @@ url: app: https://goto.example.net worker: http://goto-worker:9000 -site: - title: Goto - appearance: primary_light_color: '#0f766e' primary_dark_color: '#5eead4' diff --git a/packages/config/src/config.schema.json b/packages/config/src/config.schema.json index 8bd1a45..7627317 100644 --- a/packages/config/src/config.schema.json +++ b/packages/config/src/config.schema.json @@ -6,7 +6,6 @@ "properties": { "version": { "default": 1, "const": 1, "type": "number" }, "url": { "default": {}, "$ref": "#/$defs/Url" }, - "site": { "default": {}, "$ref": "#/$defs/Site" }, "appearance": { "default": {}, "$ref": "#/$defs/Appearance" }, "auth": { "$ref": "#/$defs/Auth" }, "database": { "default": {}, "$ref": "#/$defs/Database" }, @@ -107,20 +106,6 @@ } ] }, - "LocalImagePath": { - "description": "A decoded /public/ SVG, PNG, JPEG, GIF or WebP image path without dot segments, percent escapes, backslashes, queries or fragments.", - "type": "string", - "anyOf": [ - { - "type": "string", - "pattern": "^/public/(?:(?!\\.{1,2}(?:/|$))[^/%\\\\?#\\x00-\\x1f\\x7f]+/)*(?!\\.{1,2}(?:/|$))[^/%\\\\?#\\x00-\\x1f\\x7f]+\\.(?:[sS][vV][gG]|[pP][nN][gG]|[jJ][pP][eE]?[gG]|[gG][iI][fF]|[wW][eE][bB][pP])(?![\\s\\S])" - }, - { - "type": "string", - "pattern": "(?:^|[^$])(?:\\$\\$)*\\$\\{[A-Z_][A-Z0-9_]*(?::-[^}]*)?\\}" - } - ] - }, "HexColor": { "type": "string", "anyOf": [ @@ -175,25 +160,6 @@ "worker": { "default": "http://goto-worker:9000", "$ref": "#/$defs/BaseUrl" } } }, - "Site": { - "additionalProperties": false, - "type": "object", - "properties": { - "title": { - "default": "Goto", - "type": "string", - "anyOf": [ - { "type": "string", "pattern": "\\S", "minLength": 1 }, - { - "type": "string", - "pattern": "(?:^|[^$])(?:\\$\\$)*\\$\\{[A-Z_][A-Z0-9_]*(?::-[^}]*)?\\}" - } - ] - }, - "logo_path": { "$ref": "#/$defs/LocalImagePath" }, - "favicon_path": { "$ref": "#/$defs/LocalImagePath" } - } - }, "Appearance": { "additionalProperties": false, "type": "object", diff --git a/packages/config/src/diagnostics.test.ts b/packages/config/src/diagnostics.test.ts index 1e56848..0b490d4 100644 --- a/packages/config/src/diagnostics.test.ts +++ b/packages/config/src/diagnostics.test.ts @@ -24,15 +24,15 @@ function captureConfigError(action: () => unknown): ConfigError { describe('configuration diagnostics', () => { it('keeps the error message generic and formats issues only when requested', () => { - const issues = [{ path: '/site', message: 'Expected object' }]; + const issues = [{ path: '/url', message: 'Expected object' }]; const error = new ConfigError(issues); expect(error.message).toBe('Invalid configuration'); expect(String(error)).toBe('ConfigError: Invalid configuration'); expect(error.issues).toEqual(issues); expect(error).not.toHaveProperty('cause'); - expect(formatConfigError(error)).toBe('Invalid configuration\n /site: Expected object'); + expect(formatConfigError(error)).toBe('Invalid configuration\n /url: Expected object'); expect(formatConfigError(error, 'Configuration validation failed.')).toBe( - 'Configuration validation failed.\n /site: Expected object' + 'Configuration validation failed.\n /url: Expected object' ); expect(new ConfigError().issues).toEqual([]); expect(formatConfigError(new ConfigError())).toBe('Invalid configuration'); @@ -76,12 +76,12 @@ describe('configuration diagnostics', () => { } }); - it('identifies the site section and its allowed fields without echoing the old URL', () => { + it('identifies the URL section and its allowed fields without echoing the value', () => { const error = captureConfigError(() => loadConfig( { ...configurationInput(), - site: { url: `https://${privateValue}.example.com` } + url: { origin: `https://${privateValue}.example.com` } }, options ) @@ -89,8 +89,8 @@ describe('configuration diagnostics', () => { expect(error.message).toBe('Invalid configuration'); expect(error.issues).toEqual([ { - path: '/site', - message: 'Unexpected property. Allowed fields: title, logo_path, favicon_path' + path: '/url', + message: 'Unexpected property. Allowed fields: app, worker' } ]); expect(JSON.stringify(error)).not.toContain(privateValue); @@ -99,7 +99,7 @@ describe('configuration diagnostics', () => { it.each([ { override: { [privateKey]: privateValue }, path: '/' }, - { override: { site: { [privateKey]: privateValue } }, path: '/site' } + { override: { url: { [privateKey]: privateValue } }, path: '/url' } ])('omits unknown property names and values at $path', ({ override, path }) => { const error = captureConfigError(() => loadConfig({ ...configurationInput(), ...override }, options) diff --git a/packages/config/src/editor-schema.test.ts b/packages/config/src/editor-schema.test.ts index 6cde18e..bc1c5c4 100644 --- a/packages/config/src/editor-schema.test.ts +++ b/packages/config/src/editor-schema.test.ts @@ -23,11 +23,10 @@ describe('Goto editor schema', () => { it('relaxes defaulted fields while keeping authentication, domain links and destinations required', () => { const editor = createEditorSchema(); expect(editor.required).toEqual(['auth', 'domains']); - for (const name of ['Url', 'Site', 'Appearance', 'Database', 'Analytics', 'LinkDefaults']) { + for (const name of ['Url', 'Appearance', 'Database', 'Analytics', 'LinkDefaults']) { expect(definition(editor, name).required).toBeUndefined(); } - expect(property(editor, 'site')).toEqual({ $ref: '#/$defs/Site', default: {} }); - expect(object(definition(editor, 'Site').properties)).not.toHaveProperty('url'); + expect(object(editor.properties)).not.toHaveProperty('site'); expect(property(editor, 'url')).toEqual({ $ref: '#/$defs/Url', default: {} }); expect(property(definition(editor, 'Url'), 'app')).toEqual({ $ref: '#/$defs/AppUrl', diff --git a/packages/config/src/load.test.ts b/packages/config/src/load.test.ts index b3f94fa..141a827 100644 --- a/packages/config/src/load.test.ts +++ b/packages/config/src/load.test.ts @@ -12,10 +12,7 @@ const yaml = 'auth: {credentials: {username: admin, password: test-password}}\nd const authoredKeyMarker = 'dummy-authored-key-marker'; describe('configuration loading', () => { - it('parses YAML and applies configuration defaults without mutating the input', () => { - expect(parseConfig(`${yaml}\nsite: {title: yes}`, options).configuration.site.title).toBe( - 'yes' - ); + it('applies configuration defaults without mutating the input', () => { const input = configurationInput(); const original = structuredClone(input); const { configuration, warnings } = loadConfig(input, options); @@ -23,7 +20,6 @@ describe('configuration loading', () => { expect(configuration).toMatchObject({ version: 1, url: { app: 'http://localhost:3000', worker: 'http://goto-worker:9000' }, - site: { title: 'Goto' }, database: { path: './data/goto.sqlite', worker_path: './data/worker.sqlite' }, analytics: { retention_months: 3 }, link_defaults: { @@ -225,7 +221,9 @@ domains: } ]); expect(() => loadConfig(input, options)).toThrow(ConfigError); - expect(() => loadConfig({ ...input, site: null }, { env: { TAG: '.' } })).toThrow(ConfigError); + expect(() => loadConfig({ ...input, appearance: false }, { env: { TAG: '.' } })).toThrow( + expect.objectContaining({ issues: [{ path: '/appearance', message: 'Expected object' }] }) + ); }); it.each([null, {}, 'work', ['work', 42], [false], [null], [{}]])( @@ -348,19 +346,8 @@ domains: ); }); - it('rejects the old site URL key without accepting it as an app URL', () => { - for (const url of [undefined, { app: 'https://admin.example.com' }]) { - expect(() => - loadConfig( - { - ...configurationInput(), - ...(url === undefined ? {} : { url }), - site: { url: 'https://old.example.com', title: 'Custom title' } - }, - options - ) - ).toThrow(ConfigError); - } + it('rejects the removed site section even when empty', () => { + expect(() => parseConfig(`${yaml}\nsite: {}`, options)).toThrow(ConfigError); }); it('defaults the OIDC name after resolving authentication placeholders', () => { @@ -470,8 +457,6 @@ domains: it.each([ { unknown: 'private-value' }, - { site: null }, - { site: [] }, { url: null }, { url: [] }, { version: Infinity }, @@ -541,8 +526,7 @@ domains: it.each([ `${yaml}\nversion: 1\nversion: 1`, `${yaml}\n<<: {version: 1}`, - `${yaml}\n---\n${yaml}`, - `${yaml}\nsite: &cycle {title: *cycle}` + `${yaml}\n---\n${yaml}` ])('rejects non-strict YAML', (source) => { expect(() => parseConfig(source, options)).toThrow(ConfigError); }); @@ -585,7 +569,7 @@ domains: let calls = 0; const getter = { ...configurationInput(), - get site() { + get appearance() { calls++; return {}; } @@ -593,7 +577,7 @@ domains: expect(() => loadConfig(getter, options)).toThrow(ConfigError); expect(calls).toBe(0); const cycle = configurationInput(); - Object.assign(cycle, { site: cycle }); + Object.assign(cycle, { appearance: cycle }); for (const input of [ cycle, Object.create(configurationInput()), diff --git a/packages/config/src/schema.ts b/packages/config/src/schema.ts index bc0a0d7..a22f1fe 100644 --- a/packages/config/src/schema.ts +++ b/packages/config/src/schema.ts @@ -68,7 +68,6 @@ FormatRegistry.Set('goto-instant', (value) => { }); const nonBlankText = { minLength: 1, pattern: '\\S' }; -const imageSegment = '(?!\\.{1,2}(?:/|$))[^/%\\\\?#\\x00-\\x1f\\x7f]+'; const HttpUrlSchema = Type.String({ $id: 'HttpUrl', @@ -114,13 +113,6 @@ const AuthSecretSchema = Type.String({ minLength: 32 }); -const LocalImagePathSchema = Type.String({ - $id: 'LocalImagePath', - pattern: `^/public/(?:${imageSegment}/)*${imageSegment}\\.(?:[sS][vV][gG]|[pP][nN][gG]|[jJ][pP][eE]?[gG]|[gG][iI][fF]|[wW][eE][bB][pP])${end}`, - description: - 'A decoded /public/ SVG, PNG, JPEG, GIF or WebP image path without dot segments, percent escapes, backslashes, queries or fragments.' -}); - const HexColorSchema = Type.String({ $id: 'HexColor', pattern: `^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})${end}` @@ -163,15 +155,6 @@ const UrlSchema = Type.Object( { $id: 'Url', additionalProperties: false } ); -const SiteSchema = Type.Object( - { - title: Type.String({ ...nonBlankText, default: 'Goto' }), - logo_path: Type.Optional(ref(LocalImagePathSchema)), - favicon_path: Type.Optional(ref(LocalImagePathSchema)) - }, - { $id: 'Site', additionalProperties: false } -); - const AppearanceSchema = Type.Object( { primary_light_color: ref(HexColorSchema, { default: '#0f766e' }), @@ -346,7 +329,6 @@ export const GotoConfigurationSchema = Type.Object( { version: Type.Literal(1, { default: 1 }), url: ref(UrlSchema, { default: {} }), - site: ref(SiteSchema, { default: {} }), appearance: ref(AppearanceSchema, { default: {} }), auth: ref(AuthSchema), database: ref(DatabaseSchema, { default: {} }), @@ -369,13 +351,11 @@ export const configurationReferences: TSchema[] = [ AppUrlSchema, InstantSchema, AuthSecretSchema, - LocalImagePathSchema, HexColorSchema, TagsSchema, RedirectStatusSchema, RedirectResponseSchema, UrlSchema, - SiteSchema, AppearanceSchema, OidcAuthSchema, CredentialsAuthSchema,