module

ContributorMural::AvatarSalvage

The faces already on the wall, taken back off the file this run is about to replace.

An avatar host that throttles, blips, or answers 404 for a minute takes people off the mural, and the run then commits that — so the picture regresses over a failure which has usually fixed itself by the time anyone looks at it. Retrying is not the answer here; the retries already happened and the fetcher gave up.

The previous output is the cache. Every avatar in it is base64 in the document, inside the link of the person it belongs to, so a wall that has been rendered once already holds everything needed to redraw it. Nothing extra is written, nothing has to be restored between runs, and a face is only ever reused for someone this run has already decided belongs on the wall — a person dropped by exclude or limit is never read back in.

Constants

DATA_OPEN = "href=\"data:image/"

Narrower than href="data: on purpose: the only data URI this program emits is an image, and anything else under that prefix is not ours.

HREF_OPEN = "href=\""
LINK_OPEN = "<a href=\""
MAX_URI = (12 * 1024) * 1024

A data URI longer than this is not one we wrote — the fetcher caps a single avatar at 8 MB before it is base64-encoded.

MAX_WALL = (256 * 1024) * 1024

A previous wall larger than this is not read back: a few thousand faces at the largest size any style fetches stay well under it, and it is held twice while it is scanned.

QUOTE = '"'
SYMBOL_CLOSE = "</symbol>"
SYMBOL_OPEN = "<symbol id=\""

A face drawn in more than one section is written once into <defs> and referenced from each of them, so for those people the link holds a reference rather than the bytes.

USE_OPEN = "<use href=\"#"
VALID_URI = /\Adata:image\/[a-z0-9.+-]+;base64,[A-Za-z0-9+\/=]*\z/

Exactly the shape Embedder#fetch_missing builds, and nothing else.

What comes back from here is written into an href attribute verbatim, the way a freshly encoded one is — which is safe only because base64 and a known content type cannot carry &, < or a quote. A previous wall is a file on disk, though: hand-edited, merge-mangled, or left half-written by a killed job, it can hold anything between those two quotes, and one bare & costs the whole document rather than one label. Salvage is a new route into the markup, so it is checked at the door instead of trusted for having been ours once.

Class methods

read(workspace : String, paths : Array(String)) : Hash(String, String)

Link (as it appears in the markup) => data URI, for every person the given outputs already carry.

Source