Skip to main content

Module package

Module package 

Source
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.json and its templates, each as (path under templates/, 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.json value.
install
Apply a package’s theme.json to 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.json plus every file under templates_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 without theme.json.
read_seed
Read only the theme.json of a package file.
unpack
Read a package file, writing its templates under templates_dest (created if missing); returns the theme.json and how many templates were written. Same refusals as read_bytes.