Add get_preview and get_preview_image for link unfurling - #121
Merged
Merged
Conversation
Slack, Bluesky, Teams and the rest build a link card from the og:* tags in a page's raw HTML, and none of them run JavaScript. The viewer sets those tags per term from JS only, so a pasted term link previews as the site logo whatever the term. get_preview?id=<id> renders the same tags server-side from get_term_info -- title, description, thumbnail, canonical to /reports/<id> -- with a meta-refresh into the viewer so a human landing here still arrives where the link pointed. Intended for an IRI-routing branch that hands unfurler user-agents this instead of the redirect. get_preview_image?id=<id> redirects to the term's thumbnail, or the logo when it has none: a stable id-keyed image URL for og:image, cards and the MCP. Both reuse the term_info:<id> cache key, so a preview costs no extra term lookup and a burst of unfurlers for one link coalesces to one query; the HTML is a 2KB response v3-cached stores like any other. Title and description logic mirrors pageMetadata.js in geppetto-vfb so a term reads the same wherever its preview is built -- except that ';' in Types becomes ', ' rather than ',', which reads as a list; the JS wants the same fix on its next release. Ontology text is HTML-escaped, and ids are validated against the VFB id shape before any lookup.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slack, Bluesky, Teams and the rest build a link card from the og:* tags in
a page's raw HTML, and none of them run JavaScript. The viewer sets those
tags per term from JS only, so a pasted term link previews as the site logo
whatever the term.
get_preview?id= renders the same tags server-side from get_term_info --
title, description, thumbnail, canonical to /reports/ -- with a
meta-refresh into the viewer so a human landing here still arrives where the
link pointed. Intended for an IRI-routing branch that hands unfurler
user-agents this instead of the redirect.
get_preview_image?id= redirects to the term's thumbnail, or the logo
when it has none: a stable id-keyed image URL for og:image, cards and the MCP.
Both reuse the term_info: cache key, so a preview costs no extra term
lookup and a burst of unfurlers for one link coalesces to one query; the
HTML is a 2KB response v3-cached stores like any other.
Title and description logic mirrors pageMetadata.js in geppetto-vfb so a term
reads the same wherever its preview is built -- except that ';' in Types
becomes ', ' rather than ',', which reads as a list; the JS wants the same fix
on its next release.
Ontology text is HTML-escaped, and ids are validated against the VFB id shape
before any lookup.