Documentation
¶
Index ¶
Constants ¶
const DefaultCountry = "us"
DefaultCountry is the country a site is made for when the caller names none.
const MaxPhotos = 8
MaxPhotos is how many slots one site asks for at most.
Variables ¶
var ( // ErrUnknownCountry is the refusal of a country that has no data file. ErrUnknownCountry = errors.New("decoy: unknown country") // ErrNotInCountry is the refusal of a kind that has no text in the language of the country. ErrNotInCountry = errors.New("decoy: the kind has no texts for this country") )
var ErrUnknownKind = errors.New("decoy: unknown site kind")
ErrUnknownKind is Generate's refusal of a kind that has no folder of templates.
Functions ¶
This section is empty.
Types ¶
type CountryInfo ¶
type CountryInfo struct {
Code string
Lang string
// Kinds are the kinds that have texts in the country's language.
Kinds []string
}
CountryInfo is a country the generator knows.
func Countries ¶
func Countries() []CountryInfo
Countries lists the countries in the order of their "order" field, then by code.
type File ¶
File is a file of a generated site, the type FromFiles takes.
func Generate ¶
Generate makes the files of a site of the given kind for DefaultCountry. The same kind and seed always give the same files, byte for byte; the result is meant for FromFiles.
func GenerateNamed ¶
GenerateNamed is Generate that also returns the brand the pages print (the site's own name, for naming it in the library).
type KindInfo ¶
type KindInfo struct {
ID string `json:"id"`
NameEN string `json:"name_en"`
NameRU string `json:"name_ru"`
// Countries are the codes of the countries the kind can be made for (it has texts in their language), in the order of Countries().
Countries []string `json:"countries"`
}
KindInfo describes a kind of generated site for the admin's list.
type Options ¶
type Options struct {
// Country is the code of the country the site is made for ("" is DefaultCountry): its language, cities, money and formats.
Country string
// Photos maps Slot.Name to a JPEG that already has the shape of its slot. Nil keeps every picture drawn; an empty map does
// the same, a slot missing from it stays drawn.
Photos map[string][]byte
}
Options are what Generate may be given besides a kind and a seed.
type Slot ¶
type Slot struct {
Name string // the place: "hero", "t3"; the key of Options.Photos
Query string // what to search for, from the vocabulary of the site's bundle
W, H int // the shape of the box the photo fills (the aspect matters, not the units)
MaxW int // the widest file worth having, in pixels
}
Slot is a place in a site that may hold a photo.
func Plan ¶
Plan lists the photos a site of this kind and seed would like for DefaultCountry; see PlanFor.