Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions documentation/info.yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
10 changes: 9 additions & 1 deletion tools/sitegen/src/schema/infoYamlJsonSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -138,7 +146,7 @@ export const infoYamlJsonSchema = {
website: urlText,
social: {
type: 'object',
additionalProperties: urlText,
additionalProperties: socialContact,
},
},
additionalProperties: false,
Expand Down
2 changes: 1 addition & 1 deletion tools/sitegen/src/validate/rules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down
29 changes: 29 additions & 0 deletions tools/sitegen/test/validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down