Expand description
Theme packages: a site’s look (and optionally its pages) as one .zip
that another site installs.
A package holds theme.json (the StarterSeed
format) and the site’s templates/. export builds the seed from a
live site, pack / unpack write and read the archive, and
install applies it:
- on an empty site, everything: page types, pages, menus, site settings and colours, exactly like a starter theme;
- on a site with content, only the look: missing page types are added, existing ones point at the package’s templates, its colours become the default, and its error pages fill in any status the site has none for. Other pages, menus and settings are left as they are.
Structs§
- Package
- A package read into memory: its
theme.jsonand its templates, each as (path undertemplates/, body).
Constants§
- MAX_
ENTRIES - The most entries and the most unpacked bytes a package may hold. A theme is a few dozen small text files; anything far beyond that is refused before it is unpacked, so a hostile archive cannot fill the disk.
- MAX_
UNPACKED_ BYTES - SEED_
ENTRY - The archive entry holding the seed.
- TEMPLATES_
DIR - The archive folder holding the templates.
Functions§
- export
- The site’s look, and optionally its pages, as a
theme.jsonvalue. - install
- Apply a package’s
theme.jsonto a site: everything on an empty site, only the look on a site with content (see the module docs). - pack
- Write a package file:
theme.jsonplus every file undertemplates_dir. - pack_
bytes - Build a package in memory.
- read_
bytes - Read a package from memory. Refuses an archive with too many entries
or too many unpacked bytes, an entry outside
templates/, a path that would escape its folder, a template that is not UTF-8 text, and an archive withouttheme.json. - read_
seed - Read only the
theme.jsonof a package file. - unpack
- Read a package file, writing its templates under
templates_dest(created if missing); returns thetheme.jsonand how many templates were written. Same refusals asread_bytes.