thumbtypes

package
v1.132.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package thumbtypes names the content families a browser can rasterize into a tile, and which of them are drawn on a forced background and so need a second capture for dark mode.

It exists because the rule was written out four times -- once per store, once for the browser gate, once for the capturer's dispatch -- and the four copies stopped agreeing: a JSX resource was never offered although the capturer renders JSX, and an image asset was never offered although the capturer downscales images (#1568). This is the one Go definition; the one TypeScript definition is ui/src/lib/thumbnailSupport.ts, and TestGoAndBrowserAgree holds the two to each other.

A thumbnail is a property of a piece of content rather than of a kind, so nothing here knows whether the row it is asked about is a portal asset or a managed resource.

Index

Constants

This section is empty.

Variables

View Source
var Capturable = []string{
	"html", "jsx", "svg", "markdown", "csv", "tab-separated", "json",
	"yaml", "xml", "sql", "python", "javascript", "css", "text/plain",
	"image/png", "image/jpeg", "image/gif", "image/webp",
	"image/avif", "image/bmp", "image/x-icon", "image/vnd.microsoft.icon",
}

Capturable are the content families a browser can draw into a tile, as fragments of the media type rather than exact types: a stored type carries parameters and vendor prefixes ("text/markdown; charset=utf-8", "application/vnd.acme+json"), and every spelling of a family contains its fragment.

"json" covers both JSON families at once, newline-delimited included ("application/x-ndjson", "application/jsonl"); which of the two is drawn is a question only the capturer asks. "text/plain" is spelled in full because the bare word is a substring of "text/html", "text/csv" and "text/markdown", each of which is drawn differently.

The code families -- YAML, XML, SQL, Python, JavaScript, CSS -- and TSV are here because the viewer renders every one of them and a browser that can render it can draw a tile of it; they were absent, and each kept a content-type icon forever (#1754). Order carries the two overlaps: "svg" takes image/svg+xml before "xml" is reached, and "jsx" takes text/jsx before "javascript" is.

The raster families are named one by one rather than as "image/", which is what a bare prefix would have cost: a capture DOWNSCALES a raster image by decoding it in the browser, and TIFF, HEIC and PSD are images a browser cannot decode at all. Offering one is offering work that fails every time, and the pending query is an ORDER BY ... LIMIT window, so a bulk upload of them would fill it and starve the documents behind them of a capture they could actually complete -- the same failure the PDF exclusion exists to prevent. These eight are the families every current browser decodes.

Everything else -- PDF, spreadsheets, archives, binaries -- has no renderer, keeps its content-type icon, and is never offered for capture.

View Source
var Themeable = []string{
	"markdown", "csv", "tab-separated", "json",
	"yaml", "xml", "sql", "python", "javascript", "css", "text/plain",
}

Themeable are the families drawn on a forced background, which are captured twice, once per color scheme. HTML, JSX, SVG and a raster image carry their own colors: they store a single image and serve it in both modes, so reading their empty dark key as "pending" would offer them forever.

In Capturable's order, which is what the parity test compares.

Functions

func ILikePatterns

func ILikePatterns(fragments []string) []string

ILikePatterns wraps content-type fragments as SQL ILIKE patterns, which is how the substring test the browser applies is asked of a column.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL