docs(variants): README for the variants tooling and json format
variants/README.md documents the scripts (build.php, build_all.sh, export_options.php, document_options.php, option_formats.php, export_public.sh, example/) and the variant definition json structure with a full annotated example: name/title/description/_note, options with "" = inherit, the _formats hint map, files_add and fontOptions, plus the build/deploy/rebuild workflow. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
c996b27cd1
commit
aac20b729d
1 changed files with 89 additions and 0 deletions
89
variants/README.md
Normal file
89
variants/README.md
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
# variants/ — client variant tooling
|
||||
|
||||
This folder holds the GENERIC, public tooling for building thin client
|
||||
variants of this theme (see the main `README.md`, section "Client variants
|
||||
(house styles) without code duplication" for the full concepts). Only the
|
||||
confidential parts are gitignored and stay in the private variants repo:
|
||||
`variants/*.json` (client definitions), `variants/leak-patterns.txt`,
|
||||
`variants/tests/`.
|
||||
|
||||
## Files
|
||||
|
||||
- `build.php` — build ONE variant: `php variants/build.php <client> <definitions-dir>`.
|
||||
Generates `../<client>/config.xml` from the mother `config.xml` + the
|
||||
client json (see the header comment of `build.php` for all rules: unknown
|
||||
option keys fail loudly, `files/preview.svg` is added only at first
|
||||
creation and never overwritten, warning when preview.png equals the
|
||||
mother's, NEW mother option keys are auto-added to the json as `""` with
|
||||
a `_formats` hint).
|
||||
- `build_all.sh` — build/rebuild ALL variants in one go:
|
||||
`bash variants/build_all.sh <definitions-dir>` builds only jsons with NO
|
||||
variant folder yet; `bash variants/build_all.sh --rebuild <definitions-dir>`
|
||||
rebuilds only existing ones; skipped jsons are listed at the end.
|
||||
- `export_options.php` — generate a client json from the CURRENTLY SAVED
|
||||
theme options in the LimeSurvey UI (global or per survey):
|
||||
`php variants/export_options.php <client> --global|--sid <id> [--title ...] [--definitions-dir ...] [--force]`.
|
||||
- `document_options.php` — refresh the `_formats` hints in every json after a
|
||||
mother config.xml change: `php variants/document_options.php <definitions-dir> [--check]`.
|
||||
- `option_formats.php` — shared helper (option key → value-format hint),
|
||||
used by `build.php` and `document_options.php`.
|
||||
- `export_public.sh` — build the checked public zip (leak check + external-host
|
||||
check + stale-css check); aborts on any violation.
|
||||
- `example/` — public example output of a variant build (`respondage_respondage`).
|
||||
|
||||
## The variant definition json (`<client>.json`)
|
||||
|
||||
Reference structure (all 109 option keys of the mother config.xml are listed,
|
||||
so it is visible what CAN be set per variant):
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "respondage_client",
|
||||
"title": "Client LimeSurvey theme",
|
||||
"description": "<strong>Client theme, based on Vanilla Respondage</strong><br>Thin variant of vanilla_respondage: only the house-style option values (colors, fonts, font sizes/weights/colors, logo files) differ. All views, CSS and JS are inherited from the mother theme.",
|
||||
"_note": "All option keys of the mother config.xml are listed. An empty value (\"\") means: inherit the default from vanilla_respondage (build.php skips empty values). Keys marked HOUSE-STYLE in config.xml are the per-client house-style values; the rest are structural and normally left empty.",
|
||||
"options": {
|
||||
"font": "my_custom_font",
|
||||
"fontsize": "18px",
|
||||
"primarycolor": "#123456",
|
||||
"navbarfontcolor": "other",
|
||||
"navbarfontcolorcustom": "#123456",
|
||||
"brandlogofile": "./files/client-logo.png",
|
||||
"...": ""
|
||||
},
|
||||
"_formats": {
|
||||
"font": "font value slug, e.g. \"inter\"",
|
||||
"primarycolor": "hex color, e.g. #123456",
|
||||
"navbarfontcolor": "chooser mode: one of default|defaultbackgroundcolor|color1|color2|color3|other — when 'other', put the hex in navbarfontcolorcustom",
|
||||
"...": ""
|
||||
},
|
||||
"files_add": { "css": ["css/variant.css"], "js": [] },
|
||||
"fontOptions": [ { "value": "my_custom_font", "label": "My Custom Font" } ]
|
||||
}
|
||||
```
|
||||
|
||||
- `name` must equal the file name and the generated folder (`respondage_<client>`).
|
||||
- `options`: an **empty value (`""`) means "inherit the mother default"** and is
|
||||
skipped by the build. Fill in the house-style values you know; leave the
|
||||
rest empty. Legacy keys (e.g. `logotopmargin`, `<pos>logo`, raw hex in a
|
||||
chooser option, `400|700` font weights) are still accepted and migrated by
|
||||
`build.php`. Value formats per key are documented in `_formats`
|
||||
(regenerate with `document_options.php`).
|
||||
- `_formats`: documentation only — never read by the build or the drift check.
|
||||
- `files_add`: extra files the variant ships (appended to the `<files>` list).
|
||||
- `fontOptions`: custom fonts appended to the "Custom (this theme)" optgroup;
|
||||
the font files + `@font-face` + generic `.font-<value>` rule live in the
|
||||
`<client>/` asset folder (`files/fonts/`, `css/variant.css`).
|
||||
- The whole `<definitions-dir>/<client>/` asset folder (logos, fonts, css,
|
||||
`files/preview.svg`) is copied into the generated theme by `build.php`.
|
||||
|
||||
## Workflow
|
||||
|
||||
1. Create/edit `<client>.json` + `<client>/` assets (or generate the json from
|
||||
saved UI options with `export_options.php`).
|
||||
2. Build: `php variants/build.php <client> <definitions-dir>` (or
|
||||
`bash variants/build_all.sh ...` for all).
|
||||
3. Deploy `../<client>/` to `upload/themes/survey/` and reset the theme in the
|
||||
LimeSurvey admin (Theme options → Reset), then `flushassets` + Ctrl+F5.
|
||||
4. Rebuild after every json/config.xml change (`build_all.sh --rebuild`);
|
||||
a stale variant folder does not match its definitions.
|
||||
Loading…
Reference in a new issue