docs(variants): define the build process (new variant) and rebuild process (build_all.sh)
- New variants/build_all.sh: rebuilds ALL variants from their json definitions in one go (loops over <definitions-dir>/*.json, calls build.php per variant, aggregates failures, exits non-zero on any failure) and prints the owner follow-up actions (reset each variant theme in the LS admin, flushassets, Ctrl+F5). Generic tooling — no client names — so it ships in the public repo. - README.md: the variants workflow is now split into a 'Build process' (defining a NEW variant: json + assets in the private definitions repo, build.php, deploy + theme reset + flushassets) and a 'Rebuild process' (build_all.sh after a mother config.xml change or a definitions change). The preview section now documents the standing rules: variant preview must differ from the mother's, preview.svg is committed + synced publicly, added only at first creation and never overwritten. - AGENTS.md propagation rule now points at build_all.sh. Verified: bash -n clean; PHP_BIN=/usr/bin/php bash variants/build_all.sh variants -> '2 built, 0 failed', rc=0, both variants' preview.svg untouched (md5 before = after); export_public.sh exit 0 with build_all.sh in the zip. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
d288ac8197
commit
9cb0eb0723
2 changed files with 125 additions and 34 deletions
82
README.md
82
README.md
|
|
@ -351,28 +351,33 @@ its own font files and css:
|
||||||
House-style-specific values are ONLY: colors, fonts, and font
|
House-style-specific values are ONLY: colors, fonts, and font
|
||||||
sizes/colors/weights (plus logo files). Everything else lives once, here.
|
sizes/colors/weights (plus logo files). Everything else lives once, here.
|
||||||
|
|
||||||
### Theme preview image per variant (`files/preview.png`)
|
### Theme preview image per variant (`files/preview.png` + `files/preview.svg`)
|
||||||
|
|
||||||
The theme list shows `files/preview.png` of each theme (hard-coded in core,
|
The theme list shows `files/preview.png` of each theme (hard-coded in core,
|
||||||
`TemplateConfiguration::getPreview()` — `preview.svg` is NOT picked up; a feature
|
`TemplateConfiguration::getPreview()` — `preview.svg` is NOT picked up by core;
|
||||||
request for SVG support and starter-theme fallback has been prepared for the
|
a feature request for SVG support has been prepared for the LimeSurvey
|
||||||
LimeSurvey developers). The preview is read
|
developers). The preview is read from the theme's OWN files folder — there is no
|
||||||
from the theme's OWN files folder — there is no starter-theme fallback — so every
|
starter-theme fallback — so every variant must ship its own
|
||||||
variant should ship its own `files/preview.png`: put it in
|
`files/preview.png`. Standing rule: **a variant's preview must differ from the
|
||||||
`<client>/files/preview.png` in the private variants repo; `build.php` copies
|
mother theme's** — when defining a variant, create a variant-specific
|
||||||
the whole `<client>/` asset folder into the generated variant automatically.
|
`files/preview.svg` (the editable source, committed and synced publicly) and
|
||||||
A variant without its own preview shows "No preview available" in the theme
|
export `files/preview.png` from it (Inkscape → PNG export). `build.php` adds
|
||||||
list.
|
`files/preview.svg` to a variant only ONCE, at first creation (seeded from the
|
||||||
|
mother if the definitions dir has none), and NEVER overwrites it afterwards —
|
||||||
|
after that you edit it in the variant folder. `build.php` prints a WARNING when
|
||||||
|
the variant's `preview.png` is identical to the mother's.
|
||||||
|
|
||||||
Workflow:
|
### Build process (defining a NEW variant)
|
||||||
|
|
||||||
1. In `config.xml`, the house-style options are marked with `HOUSE-STYLE`
|
1. In `config.xml`, the house-style options are marked with `HOUSE-STYLE`
|
||||||
comments (colors, fonts, font sizes/weights, logo files, logo top margin,
|
comments (colors, fonts, font sizes/weights, logo files, logo top margin,
|
||||||
background image/color). Only those values belong in a variant json —
|
background image/color). Only those values belong in a variant json —
|
||||||
never hardcode house-style values in shared files (`views/`, `css/`,
|
never hardcode house-style values in shared files (`views/`, `css/`,
|
||||||
`scripts/`), because those are inherited by all variants.
|
`scripts/`), because those are inherited by all variants.
|
||||||
2. Create `variants/<client>.json` with the variant name/title/description and
|
2. In the private variants repo, create `variants/<client>.json` with the
|
||||||
only the house-style option keys with the client values:
|
variant name/title/description and only the house-style option keys with the
|
||||||
|
client values, plus a `<client>/` asset folder (logos, `files/fonts/`,
|
||||||
|
`css/variant.css`, `files/preview.svg`/`preview.png`):
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"name": "respondage_client",
|
"name": "respondage_client",
|
||||||
|
|
@ -380,7 +385,7 @@ Workflow:
|
||||||
"options": { "primarycolor": "#123456", "fontsize": "18px" }
|
"options": { "primarycolor": "#123456", "fontsize": "18px" }
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
2. Run `php variants/build.php <client>`. This generates
|
3. Run `php variants/build.php <client> <definitions-dir>`. This generates
|
||||||
`../<client>/config.xml`: a copy of this theme's config.xml with only those
|
`../<client>/config.xml`: a copy of this theme's config.xml with only those
|
||||||
option values replaced, `<extends>` set to this theme, and the `<engine>`
|
option values replaced, `<extends>` set to this theme, and the `<engine>`
|
||||||
section emptied except `<optionspage>` (same as LimeSurvey's own "extend
|
section emptied except `<optionspage>` (same as LimeSurvey's own "extend
|
||||||
|
|
@ -388,25 +393,36 @@ Workflow:
|
||||||
kept: LimeSurvey resolves each listed file in the variant first and then in
|
kept: LimeSurvey resolves each listed file in the variant first and then in
|
||||||
the starter theme, so the starter theme's css/js keep loading until a
|
the starter theme, so the starter theme's css/js keep loading until a
|
||||||
variant ships its own file with the same name. Unknown option keys make the build fail
|
variant ships its own file with the same name. Unknown option keys make the build fail
|
||||||
loudly, so drift is caught at build time.
|
loudly, so drift is caught at build time. The whole `<client>/` asset folder
|
||||||
3. The `<client>/` assets (logos, `files/fonts/`, `css/variant.css`,
|
is copied into `../<client>/` automatically.
|
||||||
`files/preview.png`) from the definitions dir are copied into `../<client>/`
|
4. Deploy and activate: upload `../<client>/` to `upload/themes/survey/` (the
|
||||||
automatically — every build OVERWRITES existing files there, so never edit the
|
mother theme `vanilla_respondage` must be present there too — the variant
|
||||||
generated folder by hand. Upload the folder to `upload/themes/survey/` and
|
extends it; the core theme `vanilla` ships with LimeSurvey itself), then
|
||||||
install/reset the theme in LimeSurvey, then FLUSH the LimeSurvey asset cache and
|
install/reset the variant theme in the LimeSurvey admin (Theme options →
|
||||||
hard-refresh the browser (Ctrl+F5) — after a rebuild the asset hash changes, and a
|
`<client>` → Reset, which imports the new config.xml into the DB), FLUSH the
|
||||||
stale cached css is exactly how an old placeholder font keeps showing.
|
asset cache (`php application/commands/console.php flushassets`) and
|
||||||
REBUILD RULE: after every change to `<client>.json` or `<client>/` in the
|
hard-refresh the browser (Ctrl+F5) — a stale cached css is exactly how an
|
||||||
private definitions repo, re-run `php variants/build.php <client>` and reset
|
old placeholder font keeps showing.
|
||||||
the variant theme in LimeSurvey — a variant folder that is not rebuilt after
|
|
||||||
a definitions change is stale (fonts/logo/css then don't match, e.g. an old
|
### Rebuild process (after a change in THIS mother theme or in a definitions file)
|
||||||
placeholder `css/variant.css` keeps loading instead of the client font).
|
|
||||||
IMPORTANT: a variant only works when the starter theme `vanilla_respondage`
|
- Views/css/js changes in this theme apply to all variants immediately via
|
||||||
is also present in `upload/themes/survey/` on the server — the variant
|
`<extends>` — no rebuild needed (but do flush assets + Ctrl+F5 on the server).
|
||||||
extends it and inherits all views/css/js/options from it. The core theme
|
- After a `config.xml` change (new/renamed options) or a change to a
|
||||||
`vanilla` (which this starter theme extends) ships with LimeSurvey itself,
|
`<client>.json` / `<client>/` in the definitions repo, rebuild ALL variants
|
||||||
so that one is always there. So deploy: `vanilla_respondage` + each
|
in one go:
|
||||||
`respondage_<client>` you use.
|
```
|
||||||
|
bash variants/build_all.sh <definitions-dir>
|
||||||
|
```
|
||||||
|
(`<definitions-dir>` defaults to `variants/` or `$RESPONDAGE_VARIANTS_DIR`;
|
||||||
|
set `PHP_BIN=/path/to/php` if `php` is not on PATH.) It loops over every
|
||||||
|
`*.json` in the definitions dir, calls `build.php` per variant, and fails
|
||||||
|
non-zero if any variant fails. Then, per rebuilt variant: reset the theme in
|
||||||
|
the LimeSurvey admin (Theme options → Reset), flush assets, Ctrl+F5.
|
||||||
|
Never edit the generated `../<client>/` folder by hand — every build
|
||||||
|
OVERWRITES its files from the definitions dir, EXCEPT `files/preview.svg`
|
||||||
|
(first-creation-only, see above). A variant folder that is not rebuilt after
|
||||||
|
a definitions change is stale (fonts/logo/css then don't match).
|
||||||
|
|
||||||
Because of the native `<extends>` mechanism:
|
Because of the native `<extends>` mechanism:
|
||||||
- changes to any file (twig/css/js) in this starter theme apply to all
|
- changes to any file (twig/css/js) in this starter theme apply to all
|
||||||
|
|
|
||||||
75
variants/build_all.sh
Normal file
75
variants/build_all.sh
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# REBUILD process: rebuild ALL variants of this theme from their json
|
||||||
|
# definitions in one go (see README.md, "Client variants (house styles)").
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# bash variants/build_all.sh [definitions-dir]
|
||||||
|
#
|
||||||
|
# definitions-dir defaults to the variants/ folder next to this script, or to
|
||||||
|
# $RESPONDAGE_VARIANTS_DIR (the private variants repository, which holds the
|
||||||
|
# confidential <client>.json files and <client>/ asset folders). Every
|
||||||
|
# <name>.json in that dir is built with variants/build.php <name> <dir>.
|
||||||
|
#
|
||||||
|
# Environment:
|
||||||
|
# PHP_BIN php binary to use (default: "php"; e.g. PHP_BIN=/usr/bin/php)
|
||||||
|
#
|
||||||
|
# Per-variant rules enforced by build.php itself:
|
||||||
|
# - unknown option keys fail the build loudly (drift check);
|
||||||
|
# - files/preview.svg is added only at FIRST creation and never overwritten
|
||||||
|
# (row 235) — edit it in the variant, not here;
|
||||||
|
# - a WARNING is printed when the variant's preview.png is identical to the
|
||||||
|
# mother's (standing rule: each variant has its own preview).
|
||||||
|
#
|
||||||
|
# After a successful run, the OWNER actions in the LimeSurvey admin UI are:
|
||||||
|
# 1. reset every rebuilt variant theme (Theme options -> <variant> -> Reset),
|
||||||
|
# so the new config.xml is imported into lime_template_configuration;
|
||||||
|
# 2. flush the asset cache: php application/commands/console.php flushassets
|
||||||
|
# (or the button in the admin UI);
|
||||||
|
# 3. hard-refresh the browser (Ctrl+F5).
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
set -u
|
||||||
|
|
||||||
|
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
DEFS="${1:-${RESPONDAGE_VARIANTS_DIR:-$HERE}}"
|
||||||
|
PHP_BIN="${PHP_BIN:-php}"
|
||||||
|
|
||||||
|
if [ ! -d "$DEFS" ]; then
|
||||||
|
echo "ERROR: definitions dir not found: $DEFS" >&2
|
||||||
|
echo "Usage: bash variants/build_all.sh [definitions-dir]" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
shopt -s nullglob
|
||||||
|
jsons=("$DEFS"/*.json)
|
||||||
|
if [ ${#jsons[@]} -eq 0 ]; then
|
||||||
|
echo "ERROR: no *.json variant definitions found in $DEFS" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
built=0
|
||||||
|
failed=0
|
||||||
|
for json in "${jsons[@]}"; do
|
||||||
|
name="$(basename "$json" .json)"
|
||||||
|
echo "=================================================================="
|
||||||
|
echo "=== building variant: $name (from $json)"
|
||||||
|
echo "=================================================================="
|
||||||
|
if "$PHP_BIN" "$HERE/build.php" "$name" "$DEFS"; then
|
||||||
|
built=$((built + 1))
|
||||||
|
else
|
||||||
|
failed=$((failed + 1))
|
||||||
|
echo "!!! BUILD FAILED: $name (see output above)" >&2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "=================================================================="
|
||||||
|
echo "Rebuild summary: $built built, $failed failed (definitions dir: $DEFS)"
|
||||||
|
if [ "$failed" -gt 0 ]; then
|
||||||
|
echo "Fix the failing definitions and re-run this script." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
echo "Next — owner actions in the LimeSurvey admin UI:"
|
||||||
|
echo " 1. reset every rebuilt variant theme (Theme options -> <variant> -> Reset)"
|
||||||
|
echo " 2. flush the asset cache (php application/commands/console.php flushassets)"
|
||||||
|
echo " 3. hard-refresh the browser (Ctrl+F5)"
|
||||||
Loading…
Reference in a new issue