#451 Related timelines below a timeline on the website (#447)
–
- github
- github/openchronology/timeline-app
- github/openchronology/timeline-app#451
- pull request
- state:merged
Closes #447. Below a timeline on the website, **Related timelines** now shows up to six other timelines about the same things, as cards that open their pages. **How they're chosen** (`relatedTimelines` in `server/collaboration.mjs`): - **Matching:** up to 24 words that best describe the timeline, taken from its title and tags first, then its description, using the weighted `search_document` it already has. They become one OR query, matched only against the title, tags and description of other timelines (weights A and B). Moment text isn't used, because it would match nearly anything. - **Shared tags:** a timeline that shares a tag is a candidate even with no shared words. Each shared tag adds half a point. - **Score:** `ts_rank_cd` on a small vector of just the title, tags and description, built on the fly, so large stored vectors aren't read. Stars break near-ties. - **Who can appear:** the same rules as browsing, since nobody searched for these. Public timelines of established accounts or featured ones; labelled timelines only for signed-in adults; never the timeline itself, its copies or comparisons; at most two from any one owner. At most 400 candidates are ranked. **Where they show:** - `GET /api/timelines/{id}/related` returns `{ timelines }` as search results, with shapes. The reader must be able to read the timeline; otherwise it returns 404. It's documented in the OpenAPI spec. - The editor (`src/related-timelines.ts`) shows them below the timeline when it's open on the website, but not for drafts, comparisons, embeds or the desktop app. The cards open the timeline's page in the whole window, not in the editor's frame. A labelled timeline's card shows its warning and no image. If loading fails, the section simply doesn't appear. - The page's text summary (`TimelineSummary`), which screen readers and search engines read, lists them as links. - Docs: a new section in `docs/browsing.md`. **Tests:** - New `related-postgres.mjs` (added to CI) checks: - the closest timeline comes first; - a shared word or a shared tag is enough; - at most two per owner; - private, newcomer, labelled, copied, unrelated and moment-only matches are left out; - a featured newcomer appears; - labelled timelines appear only for an adult; - a private timeline's related list returns 404 to others; - a timeline with nothing in common gets an empty list. - `sharing-postgres.mjs` checks the card in the live editor, its link and `target="_top"`, and the summary link. - Locally both pass, 30 of 30 browser tests pass, and the unit tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/openchronology/timeline-app/pull/451
Related
Open #451 Related timelines below a timeline on the website (#447) in the timeline