Developers
Article format
How Terminus reads and writes articles: chained casts with format_version 1, as set out in the Cast Format and Chained Casts proposal.
Articles aren't a Terminus format. They come from the Farcaster proposal "Cast Format and Chained Casts", which both Farcaster's network and Hypersnap accept. This page describes how Terminus reads and writes them, so another app can produce articles Terminus shows properly, and show the ones Terminus writes.
The two fields
An article is a chain of ordinary casts by one author. Two fields on CastAddBody mark them:
message CastAddBody {
// … the existing fields …
uint32 format_version = 9; // 0 plain text, 1 article Markdown
ChainCast chain = 10; // set on every cast of a chain
}
message ChainCast {
CastId root = 1; // the chain's first cast; absent on that cast itself
uint32 index = 2; // position in the chain, from 0
uint32 count = 3; // how many casts the chain has; 0 while it's still growing
}
Rules a chain must follow
- At most 100 casts.
indexis less thancount, whencountisn't 0.- The cast at index 0 has no
root. Every later cast names aroot, and the root'sfidis the author's own. - Each later cast should be a reply (
parent_cast_id) to the cast before it in the chain. Terminus writes them this way and finds the parts by walking the first cast's replies, so it can't put together a chain that isn't.
How Terminus reads one
Telling what a cast is
| Cast | Shown as |
|---|---|
format_version 1, chain.index 0 | The article. In feeds it's a card; opened, it's the whole text. |
format_version 1 and chain.index above 0 | A part. Left out of feeds and out of the first cast's replies, and shown only inside the article. |
| Anything else | An ordinary post. |
Putting the parts together
There's no endpoint that returns a chain. Terminus walks the first cast's conversation, keeps the casts by the same author whose chain.root is that cast, and puts them in index order, stopping at the first missing index. The article is complete when it has count parts, or when count is 0.
Laying it out
- Title: the first non-empty line of the first cast, with any
#and**marks removed. - Cover: the first picture embedded in the first cast that no
[$N]line places. - Pictures in the text: a line holding only
[$N]places that cast's Nth embed there, counting from 1. A line holding onlyis read as a picture too. - Other embeds: any that no line places follow their cast's text.
- Text: Markdown, with every line its own paragraph.
How Terminus writes one
Writing is in the web app only.
- The first cast is the card: the title and the opening (a paragraph, or a heading and the paragraph after it), at most 1,024 bytes, with the cover as its only embed. If the two together run over, the card is the title alone. The body starts in the second cast, so apps that show only the first cast get a sensible preview.
- The body is split at paragraph breaks into casts of at most 10,000 bytes and four embeds each.
- The first cast is sent with
index0,countset to the number of parts, and noroot. - Each later cast is sent as a reply to the one before, with
rootset to the first cast.
Reading the fields from a node
A Hypersnap node's /v2 cast JSON carries format_version and chain. Search results leave them out, so look the cast up before deciding it isn't an article.
Account numbers at or above 4,294,967,296 are written as strings in a node's JSON, and smaller ones as numbers. Accept both. See accounts made on Hypersnap.