sitegen

package
v0.2.0-dev.13 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultCountry = "us"

DefaultCountry is the country a site is made for when the caller names none.

View Source
const MaxPhotos = 8

MaxPhotos is how many slots one site asks for at most.

Variables

View Source
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")
)
View Source
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

type File = decoy.File

File is a file of a generated site, the type FromFiles takes.

func Generate

func Generate(kind string, seed []byte) ([]File, error)

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

func GenerateNamed(kind string, seed []byte) ([]File, string, error)

GenerateNamed is Generate that also returns the brand the pages print (the site's own name, for naming it in the library).

func GenerateWith

func GenerateWith(kind string, seed []byte, o Options) ([]File, string, error)

GenerateWith is GenerateNamed with Options.

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.

func Kinds

func Kinds() []KindInfo

Kinds lists the kinds of generated site, sorted by id.

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

func Plan(kind string, seed []byte) ([]Slot, error)

Plan lists the photos a site of this kind and seed would like for DefaultCountry; see PlanFor.

func PlanFor

func PlanFor(kind string, seed []byte, country string) ([]Slot, error)

PlanFor lists the photos a site of this kind, seed and country would like, in the order its pages ask for them, at most MaxPhotos. It is empty when the kind or the variant the seed chose shows none (a docs site, a status page, an illustrator's portfolio).

Jump to

Keyboard shortcuts

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