Skip to content

Theme packages

A theme can come as a package. Then a new look for one site needs no engine release. Building a theme says what goes in it.

The package

A package is a zip of at most 20 MB. Its root holds these files:

  • THEME is JSON, such as {"key": "example", "version": "1.0.0", "engine": ">=1.2.0"}.
    • key uses only [a-z0-9_-]. It is unique across Lightbolt: a key another organisation has is refused.
    • version is MAJOR.MINOR.PATCH.
    • engine is optional. It takes >=, >, =, ^ or ~.
  • MANIFEST.sha256 holds a hash of every file.

THEME can also hold two optional keys:

  • presets are the choices that the admin offers in the field Classes. They are per kind: menu_item, section, row and page. Each has a label per language, and classes per slot.
  • display says what the theme has a place for. It is per kind and per column. The kind is blog, records for every module, or the key of a module. The column is list or item. An example is {"blog": {"item": ["image", "date", "author"]}, "records": {"item": ["image", "f:*"]}}.
    • The keys are the same as display in GET entries. f:* and r:* mean every field or every relation.
    • Under What it shows, the admin greys out the rest, and says why. What someone chose there stays.
    • A kind or column that is not named shows everything.

Uploading

Upload it in Lightbolt under Organisation → Themes, or from a pipeline:

POST /delivery/v1/themes
Authorization: Bearer lbt_…
(the zip as the body, or as the form field "theme")
Answer What it means
201 It worked. The answer has key, version, engine, sha256 and bytes.
422 with error THEME or MANIFEST.sha256 is missing, the version exists with other files, or the zip is wrong.

The very same zip again gives back the version that is there. So a pipeline can run again safely.

You can also choose it in the same call. Add ?site=<id>&environment=<name>. Then the version is also chosen for that environment, when the token may do that. That is a token made under Repositories, or a token for those environments.

  • Then 201 also has chosen: {site, environment}.
  • When it could not be chosen, you get 409 with error, such as Uploaded, but not chosen: …. So the pipeline turns red.

Themes from Bitbucket gives a whole setup per site.

Your own pipeline, with tags

The usual way is a repository that Lightbolt makes or links. Every push to a branch builds the theme, and puts it on the environment of that branch. See Themes from Bitbucket or GitHub.

A pipeline of your own can work differently. The example of the frontend, tools/bitbucket-pipelines.example.yml, works like this:

  • You push a tag like theme-sunrise-1.0.1. That builds the package with php tools/build-theme.php <theme folder> <version> "<engine rule>". Then it posts the package to POST /delivery/v1/themes, without site and environment.
  • It needs two secured repository variables:
    • LIGHTBOLT_CMS is the address of Lightbolt.
    • LIGHTBOLT_UPLOAD_TOKEN is a pipeline key, lbt_…, from Organisation → Themes → Pipeline keys. Never put the token in the repository.
  • Such an upload only stores the version. Choose it under Theme → Theme version of the site. Choose it for staging first, check it, and then choose it for live.
  • The engine rule of the example, ">=1.5.0", is a placeholder. Set your own.
  • Outside the repository of the frontend, build-theme.php needs the parent themes, to merge in their presets. Add --parents=<folder with theme folders>, such as engine/themes of the dev kit. Without them, it builds anyway, and says that the presets of the parents are missing.

The engine rule is engine in THEME. It is the oldest engine that the theme works with, such as ">=1.137.0". A frontend on an older engine refuses the package. The site then keeps what it had. Choose the version that you tested with in the dev kit. That is in engine/VERSION.

Using it

  • You choose a package per site and per environment, under Theme → Theme version of the site.
  • site.theme.package is then {key, version, sha256, bytes, engine, parent}. parent comes from its THEME. When it is missing, it is base. The signal carries theme.
  • GET /delivery/v1/theme/<key>/<version> gives the zip, with X-Theme-SHA256. Switch only when the hash matches.
  • The own themes of an agency run only on a frontend that the agency owns.

New engine versions

The platform moves every frontend to the newest engine at once. Semver is the rule:

  • A patch or a minor, such as 1.4.0 → 1.5.0, goes everywhere that the engine of your theme allows it.
  • A new major, such as 2.0.0, goes only where the rule names that major, such as ^2.0.0 or >=2.0.0. >=1.118.0 alone does not allow 2.x.
  • An environment whose theme does not allow the new version stays on what it runs. You see it under Organisation → Themes. Your managers get one mail per major.
  • Once your theme works on the new version, change engine in its THEME, and upload it. The next upgrade then moves it.
  • After a term, a held environment moves anyway. The platform sets that term, per agency.

Also called: theme deployment, template package, CI/CD, design system, engine upgrade.

Last changed