From f6ea4bbc58d303c1f4e828831f29cc1a4c9a876a Mon Sep 17 00:00:00 2001 From: philmillman Date: Tue, 24 Nov 2026 16:22:54 -0500 Subject: [PATCH] Allow usernames in contact.social entries contact.social values previously had to be http(s) URLs, so cards that listed a Discord username (04_BYO_Benjolin, 669_Computer_Tracker) got schema warnings. Every platform now accepts either a profile URL or a handle: an optional leading @, letters/digits/_/./-, and an optional @instance.domain suffix for fediverse handles. --- documentation/info.yaml.md | 5 ++-- .../sitegen/src/schema/infoYamlJsonSchema.js | 10 ++++++- tools/sitegen/src/validate/rules/index.js | 2 +- tools/sitegen/test/validate.test.js | 29 +++++++++++++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/documentation/info.yaml.md b/documentation/info.yaml.md index 6303fd0fc..39c523ec8 100644 --- a/documentation/info.yaml.md +++ b/documentation/info.yaml.md @@ -48,7 +48,7 @@ Optional creator/maintainer contact details. Not rendered on detail pages yet; p |-------|----------|------|-------------| | `contact.email` | no | string | Contact email address. | | `contact.website` | no | string (URL) | Personal or project website. | -| `contact.social` | no | object | Map of platform name → profile URL (keys normalized to lowercase, no spaces). | +| `contact.social` | no | object | Map of platform name → profile URL or username/handle (e.g. `@username`, `name.bsky.social`, `@user@mastodon.social`). Keys normalized to lowercase, no spaces. | ```yaml contact: @@ -57,7 +57,8 @@ contact: social: instagram: https://instagram.com/username github: https://github.com/username - mastodon: https://mastodon.social/@username + mastodon: "@username@mastodon.social" + discord: "@username" ``` ## Web editor diff --git a/tools/sitegen/src/schema/infoYamlJsonSchema.js b/tools/sitegen/src/schema/infoYamlJsonSchema.js index 9c7c6dfad..82c94cb11 100644 --- a/tools/sitegen/src/schema/infoYamlJsonSchema.js +++ b/tools/sitegen/src/schema/infoYamlJsonSchema.js @@ -16,6 +16,14 @@ const urlText = { pattern: '^https?://\\S+$', }; +// Social contacts may be a profile URL or a bare handle: "@name", "name", +// "name.bsky.social", or a fediverse "@name@instance.social". A single pattern +// (rather than anyOf) keeps invalid values to one diagnostic. +const socialContact = { + type: 'string', + pattern: '^(https?://\\S+|@?[A-Za-z0-9_.-]{1,64}(@[A-Za-z0-9.-]+\\.[A-Za-z]{2,})?)$', +}; + const nonBlankText = { type: 'string', minLength: 1 }; const description = { type: 'string' }; const panelWhen = { @@ -138,7 +146,7 @@ export const infoYamlJsonSchema = { website: urlText, social: { type: 'object', - additionalProperties: urlText, + additionalProperties: socialContact, }, }, additionalProperties: false, diff --git a/tools/sitegen/src/validate/rules/index.js b/tools/sitegen/src/validate/rules/index.js index 683cd059a..213a06c0d 100644 --- a/tools/sitegen/src/validate/rules/index.js +++ b/tools/sitegen/src/validate/rules/index.js @@ -112,7 +112,7 @@ export const contactShape = { } if (contact.social !== undefined && !isPlainObject(contact.social)) { out.push({ severity: 'warning', path: 'contact.social', key: 'contact', - message: 'contact.social should be a map of platform → profile URL.' }); + message: 'contact.social should be a map of platform → profile URL or username.' }); } return out; }, diff --git a/tools/sitegen/test/validate.test.js b/tools/sitegen/test/validate.test.js index a0e9a861d..1f2659c05 100644 --- a/tools/sitegen/test/validate.test.js +++ b/tools/sitegen/test/validate.test.js @@ -168,6 +168,35 @@ panel: assert.equal(result.errorCount, 0); }); +test('contact.social entries accept a profile URL or a username/handle', () => { + const socialDiagnostics = social => validate(` +Name: Test Card +Creator: Someone +Language: C++ +Version: "1.0" +Status: Released +contact: + social: +${Object.entries(social).map(([k, v]) => ` ${k}: ${JSON.stringify(v)}`).join('\n')} +`).diagnostics.filter(d => d.path.startsWith('contact.social')); + + assert.deepEqual(socialDiagnostics({ discord: '@dessertplanet' }), []); + assert.deepEqual(socialDiagnostics({ discord: 'chrischn52' }), []); + assert.deepEqual(socialDiagnostics({ discord: 'some.user_name' }), []); + assert.deepEqual(socialDiagnostics({ discord: 'https://discord.com/channels/1/2' }), []); + assert.deepEqual(socialDiagnostics({ + github: 'some-user', + instagram: '@plus.minus.audio', + bluesky: 'name.bsky.social', + mastodon: '@user@mastodon.social', + youtube: 'https://www.youtube.com/@someone', + }), []); + assert.ok(socialDiagnostics({ discord: 'not a username' }).length > 0); + assert.ok(socialDiagnostics({ github: 'ftp://github.com/x' }).length > 0); + assert.ok(socialDiagnostics({ mastodon: '@user@nodomain' }).length > 0); + assert.equal(socialDiagnostics({ instagram: 'has spaces in it' }).length, 1); +}); + test('missing Name is an error, legacy Title satisfies it', () => { const missing = validate(`Creator: Someone\nLanguage: C\nVersion: "1"\nStatus: WIP\n`); assert.ok(missing.diagnostics.some(d =>