diff --git a/app/entities/users/page.mdx b/app/entities/users/page.mdx index 39b7594..16331c6 100644 --- a/app/entities/users/page.mdx +++ b/app/entities/users/page.mdx @@ -13,10 +13,10 @@ The `User` entity represents an account on a Lysand instance. Users can post [No - + The user's avatar. Must be an image format (`image/*`). - + Short description of the user. Must be text format (`text/*`). @@ -37,7 +37,7 @@ The `User` entity represents an account on a Lysand instance. Users can post [No Can only contain the following characters: `a-z` (lowercase), `0-9`, `_` and `-`. Should be limited to reasonable lengths. - + A header image for the user's profile. Also known as a cover photo or a banner. Must be an image format (`image/*`). @@ -65,19 +65,19 @@ The `User` entity represents an account on a Lysand instance. Users can post [No The user's federation outbox. Refer to the [federation documentation](/federation). - User's followers. URI must resolve to a [Collection](/structures/collections) of [User](/entities/users) entities. + User's followers. URI must resolve to a [Collection](/structures/collection) of [User](/entities/users) entities. - Users that the user follows. URI must resolve to a [Collection](/structures/collections) of [User](/entities/users) entities. + Users that the user follows. URI must resolve to a [Collection](/structures/collection) of [User](/entities/users) entities. - User's likes. URI must resolve to a [Collection](/structures/collections) of [Like](/entities/likes) entities. + User's likes. URI must resolve to a [Collection](/structures/collection) of [Like](/entities/likes) entities. - User's dislikes. URI must resolve to a [Collection](/structures/collections) of [Dislike](/entities/dislikes) entities. + User's dislikes. URI must resolve to a [Collection](/structures/collection) of [Dislike](/entities/dislikes) entities. - [Notes](/entities/notes) that the user wants to feature (also known as "pin") on their profile. URI must resolve to a [Collection](/structures/collections) of [Note](/entities/notes) entities. + [Notes](/entities/notes) that the user wants to feature (also known as "pin") on their profile. URI must resolve to a [Collection](/structures/collection) of [Note](/entities/notes) entities. diff --git a/app/structures/content-format/page.mdx b/app/structures/content-format/page.mdx new file mode 100644 index 0000000..b182f3b --- /dev/null +++ b/app/structures/content-format/page.mdx @@ -0,0 +1,153 @@ +export const metadata = { + title: 'ContentFormat', + description: 'Definition of the ContentFormat structure', +} + +# ContentFormat + +The `ContentFormat` structure is used to represent content with metadata. It supports multiple content types for the same file, such as a PNG image and a WebP image. {{ className: 'lead' }} + +A `ContentFormat` structure is defined as follows: + +```typescript +type ContentType = `${string}/${string}`; + +type ContentFormat = { + [key: ContentType]: { + ... + }; +} +``` + + +Each piece of data in the `ContentFormat` structure is meant to be a different representation of the same content. For example, a PNG image and its WebP version are different representations of the same image. Do not mix unrelated files or data in the same `ContentFormat` structure. + +**Good:** +```json +{ + "image/png": { + ... + }, + "image/webp": { + ... + } +} +``` + +**Bad:** +```json +{ + "image/png": { + ... + }, + "application/json": { + ... + } +} +``` + + +## Implementation Guidelines + +### Text + +Implementations should always process text content with the richest format available, such as HTML. However, they should also provide other formats like plain text and Markdown for compatibility with other systems. + +HTML is the recommended content type for text content, and as such every text content should have an HTML representation. If the content is not HTML, it should be converted to HTML using appropriate conversion rules. + +Rich formats include: +- `text/html` +- `text/markdown` +- `text/x.misskeymarkdown` (Misskey Flavoured Markdown, common on ActivityPub + +Clients should display the richest possible format available. If the client does not support the richest format, it should fall back to the next richest format. + +### Images + +It is a good idea to provide at least two versions of an image (if possible): one in the original format and another in a more efficient format like WebP/AVIF. This allows clients to choose the most suitable format based on their capabilities. + +## Entity Definition + + + + + + + Structure data. If `Content-Type` is a binary format, this field should be a URI to the binary data. Otherwise, it should be the content itself. Refer to the `remote` property for more information. + + + If `true`, the content is hosted remotely and should be fetched by the client. If `false`, the content is embedded in the entity. + + + A human-readable description of the content. Also known as `alt` text. + + + Size of the content in bytes. + + + Hash of the content. + + ```typescript + type HashNames = "sha256" | "sha512" | "sha3-256" | "sha3-512" | "blake2b-256" | "blake2b-512" | "blake3-256" | "blake3-512" | "md5" | "sha1" | "sha224" | "sha384" | "sha3-224" | "sha3-384" | "blake2s-256" | "blake2s-512" | "blake3-224" | "blake3-384"; + + type Hash = { + [key in HashNames]: string; + } + ``` + + + Image in [BlurHash](https://blurha.sh/) format. + + + Width of the content in pixels. Only applicable to content types that have a width. + + + Height of the content in pixels. Only applicable to content types that have a height. + + + Frames per second. Only applicable to video content. + + + Duration of the content in seconds. Only applicable to content types that have a duration. + + + + + + + ```jsonc {{ 'title': 'Images' }} + { + "image/png": { + "content": "https://cdn.example.com/attachments/ece2f9d9-27d7-457d-b657-4ce9172bdcf8.png", + "remote": true, + "description": "A jolly horse running through mountains", + "size": 453933, + "hash": { + "sha256": "91714fc336210d459d4f9d9233de663be2b87ffe923f1cfd76ece9d06f7c965d" + }, + "blurhash": "UUKJ^v~q9G%L~qRj9GofRjofRjof", + "width": 1920, + "height": 1080 + } + } + ``` + + ```jsonc {{ 'title': 'Text Formats' }} + { + "text/plain": { + "content": "The consequences of today are determined by the actions of the past. To change your future, alter your decisions today.", + "remote": false + }, + "text/markdown": { + "content": "> The consequences of today are determined by the actions of the past.\n> To change your future, alter your decisions today.", + "remote": false + }, + "text/html": { + "content": "

The consequences of today are determined by the actions of the past.

To change your future, alter your decisions today.

", + "remote": false + } + } + ``` + + +
diff --git a/components/Navigation.tsx b/components/Navigation.tsx index 3727bb9..1b3cea3 100644 --- a/components/Navigation.tsx +++ b/components/Navigation.tsx @@ -255,20 +255,17 @@ export const navigation: NavGroup[] = [ { title: "Webhooks", href: "/webhooks" }, */ ], }, + { + title: "Structures", + links: [ + { title: "ContentFormat", href: "/structures/content-format" }, + { title: "Collection", href: "/structures/collection" }, + ], + }, { title: "Entities", links: [{ title: "Users", href: "/entities/users" }], }, - /* { - title: "Resources", - links: [ - { title: "Contacts", href: "/contacts" }, - { title: "Conversations", href: "/conversations" }, - { title: "Messages", href: "/messages" }, - { title: "Groups", href: "/groups" }, - { title: "Attachments", href: "/attachments" }, - ], - }, */ ]; export function Navigation(props: ComponentPropsWithoutRef<"nav">) { diff --git a/components/mdx.tsx b/components/mdx.tsx index 3dbda38..6a7cd0b 100644 --- a/components/mdx.tsx +++ b/components/mdx.tsx @@ -92,17 +92,25 @@ export function Properties({ children }: { children: ReactNode }) { ); } +const numberTypeTooltips = { + f64: "64-bit floating-point number", + i64: "64-bit signed integer", + u64: "64-bit unsigned integer", +}; + export function Property({ name, children, type, typeLink, + numberType, required, }: { name: string; children: ReactNode; type?: string; typeLink?: string; + numberType?: "f64" | "i64" | "u64"; required?: boolean; }) { return ( @@ -120,6 +128,17 @@ export function Property({ )} + {numberType && ( + <> +
Type
+
+ {numberType} +
+ + )} {type && ( <>
Type