clone

an offline map explorer where each world, from a game map to a city's open data, ships as one .atlas file

main
atlas / internal / workbench / sources.go
sources.go 2.9K
1package workbench23// The source registry, as data.4//5// A source card says what a volume owes the people whose work it carries: the6// licence, the attribution, the id space its numbers live in, and -- where a7// crawler exists for it -- what a fetch may be pointed at. Those facts are the8// generate lane's own: they ride each source's registry entry9// (internal/generate/sources, doc.Provenance) and are copied verbatim into10// every document the source emits.11//12// The workbench may not import the generate lane (issue #5 ยง3.2), so the13// entries reach it as **data, handed over by whoever mounted the handler**.14// `atlas workbench` is that whoever, and cmd/ is the one place allowed to wire15// every lane: it reads the sources' own Describe() and the crawl registry's own16// Usage(), and hands the result to [New].17//18// The alternative shapes were a subcommand emitting the registry as JSON for19// the workbench to shell out for, and a curation file restating it. Both were20// refused for the same reason: they put a second copy of a licence somewhere,21// either on a wire or in a file, and a licence that exists twice is a licence22// that can be wrong in one of them. Wiring passes the registry entry itself,23// once, at construction -- the lane matrix stays intact, no subprocess stands24// between a page and a fact, and a source added to the lane appears on the card25// wall with no second edit anywhere.2627// Source is one capture source as its registry entry describes it.28type Source struct {29 // Name is the registry name -- the slug a merge ledger line and this card30 // agree on.31 Name string32 // Label is the same source spelled for a person.33 Label string34 // License and Attribution are what a volume owes the people whose work it35 // carries. Either may be empty: a source that imposes no terms says so by36 // saying nothing, and the card says that plainly rather than inventing a37 // licence.38 License string39 Attribution string40 // IDSpace is "native" or "derived": whether the source's captures carried41 // their own numbers or the translator minted them from stable names.42 IDSpace string43 // Crawlable reports that a crawler is registered under this source's name,44 // so the operations page may offer a fetch. The game sources' endpoints are45 // somebody else's editorial work and their crawlers are kept complete46 // rather than run from here, which is exactly what this being false means.47 Crawlable bool48 // TargetHint is the crawler's own line about what a target means, printed49 // on the form that asks for one.50 TargetHint string51 // Pair marks a source addressed as two slugs joined by a slash, which is52 // the one thing target validation has to be told.53 Pair bool54}5556// sourceByName finds one registered source.57func sourceByName(sources []Source, name string) (Source, bool) {58 for _, source := range sources {59 if source.Name == name {60 return source, true61 }62 }63 return Source{}, false64}