mosaic-headless 1.34.0 → 1.34.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/SKILL.md +17 -1
- package/assets/templates/platforms/claude-ai.json +1 -1
- package/assets/templates/platforms/claude-code.json +1 -1
- package/assets/templates/platforms/codex-cli.json +1 -1
- package/assets/templates/platforms/copilot.json +1 -1
- package/assets/templates/platforms/gemini-cli.json +1 -1
- package/package.json +1 -1
- package/tools/build_page.py +36 -1
- package/tools/build_site.py +16 -2
- package/tools/fix_text_runs.py +140 -0
package/README.md
CHANGED
|
@@ -302,6 +302,7 @@ and heading level — and it earned its place at once: it caught the converter l
|
|
|
302
302
|
| `verify_intro.py` / `verify_loop.py` | a page-load sequence that ENDS; a perpetual one that loops, hides nothing, and opens |
|
|
303
303
|
| `theme_export.php` / `theme_import.php` | a whole theme as JSON rows over WP-CLI, ids intact |
|
|
304
304
|
| `prune_unbound.php` | clears the templates and masters that page rebuilds leave bound to nothing, with their nodes; dry run unless `--apply` |
|
|
305
|
+
| `fix_text_runs.py` | makes buttons built before v1.34.1 editable in the Mosaic editor by wrapping their text the way the editor does; dry run unless `--apply` |
|
|
305
306
|
| `theme_zip.py` / `theme_zip_compare.php` / `theme_delete.php` | Mosaic's own ZIP export/import from outside the editor, the copy held against the source, and a clean delete that refuses the live theme |
|
|
306
307
|
| `list_fields.php` | every `@VAR` / `@LOOP` name a post's custom fields register, with values |
|
|
307
308
|
| `verify_dialog.py` | the 1.0.9 modal, triggers, run rules and memory, driven in a browser |
|
package/SKILL.md
CHANGED
|
@@ -5,7 +5,7 @@ description: |
|
|
|
5
5
|
license: "MIT"
|
|
6
6
|
metadata:
|
|
7
7
|
author: "moksa (https://moksaweb.com)"
|
|
8
|
-
version: "1.34.
|
|
8
|
+
version: "1.34.2"
|
|
9
9
|
homepage: "https://github.com/Moksa1123/mosaic-headless"
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -849,6 +849,21 @@ with `tools/prune_unbound.php` (dry run by default) after a batch of rebuilds.
|
|
|
849
849
|
with `inactive:"1"` - the new integer-as-string property, the Badge variant's
|
|
850
850
|
default - it is a `<span>`, a label rather than a control. Measured all three.
|
|
851
851
|
`menu-link` and `wysiwyg-link` still render `<span>` without a `url`.
|
|
852
|
+
- **A button's words go in a `text` node, not straight under it.** The editor builds
|
|
853
|
+
`button > text (Inherited text variant, 6381b2f3…) > wysiwyg-text`, and the same
|
|
854
|
+
for menu-link, dropdown-toggle, tabs and submit labels. A `wysiwyg-text` placed
|
|
855
|
+
directly under a button renders identically but cannot be edited in the editor:
|
|
856
|
+
the navigator shows no child, and a double-click opens only the link settings.
|
|
857
|
+
Only `text`, `label`, `choice-label`, `choice-legend`, `fieldset-legend` and the
|
|
858
|
+
inline `wysiwyg-span` / `wysiwyg-link` hold runs directly. `build_page.py` wraps
|
|
859
|
+
runs under any other type itself (`wrap_text_runs`), so the `"text"` shorthand is
|
|
860
|
+
safe on a button, and a component's `text` override on a button follows the run
|
|
861
|
+
down into that wrapper (`build_site.py`). Output: `<a class="m-button"><div class="m-inherited-text
|
|
862
|
+
m-wysiwyg">…</div></a>` - the editor's own button carries the same `<div>`.
|
|
863
|
+
A site built before v1.34.1 is fixed in place by `tools/fix_text_runs.py`
|
|
864
|
+
(dry run, then `--apply`): measured on the test theme, 428 runs wrapped
|
|
865
|
+
across its masters and templates, every page unchanged in text, a component instance's
|
|
866
|
+
override still shown, and a second run finding nothing.
|
|
852
867
|
- **`text` renders as `<div>` by default** — set `tagName` for `<h1>`, `<p>` and so on.
|
|
853
868
|
- **A `wysiwyg-text` run prints no markup since 1.0.11.** Its `<` and `>` are escaped
|
|
854
869
|
on output, so `A<strong>B</strong>C<br>D` reaches the page as those literal
|
|
@@ -934,6 +949,7 @@ with `tools/prune_unbound.php` (dry run by default) after a batch of rebuilds.
|
|
|
934
949
|
| `theme_zip_compare.php` | hold an imported copy against its source, tree for tree - every scoped table, the (parentType, type) shape, which ids survive, and orphans named rather than counted |
|
|
935
950
|
| `prune_unbound.php` | delete the templates no post is bound to, the masters no kept template uses, their nodes, then orphan nodes pass after pass - one theme, dry run unless `--apply`, `assign="auto"` templates kept |
|
|
936
951
|
| `theme_delete.php` | remove a theme completely through the plugin's own routine; refuses the live one |
|
|
952
|
+
| `fix_text_runs.py` | wrap text runs that sit directly under a button, menu-link or other non-text element (built before v1.34.1) in an Inherited text `text` node, so the editor can edit them - every master, template and component, through each document's own commit; dry run unless `--apply`, idempotent, component overrides kept |
|
|
937
953
|
| `verify_slider.py` | the slider in a real browser: does it advance, do the arrows and bullets drive it, does the keyboard, does it stop when motion is not wanted - `--label`/`--append` put several sliders in one table, which is where a carousel and a plain slider can be held against each other |
|
|
938
954
|
| `verify_navigation.py` | a multi-page site: is every menu item a real `<a href>`, does every page answer 200 (a template that was never bound answers 406 with an empty body, which only a logged-out visitor sees), and with `--viewports` does any page scroll SIDEWAYS - the one question no per-page checker asks - and whether every in-page `#fragment` resolves ON THE PAGE THAT CARRIES IT, which an HTTP check cannot see: a bare `#services` in a SHARED header fetches the current page, answers 200 everywhere, and does nothing on every page but the one that has that section |
|
|
939
955
|
| `verify_dialog.py` | the modal in a real browser (1.0.9 and 1.0.10 alike: open is read as `:popover-open` or `dialog.open`): does it open, close, answer Esc, remember, cap - and does an OpenStreetMap carry the coordinates it was given |
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.34.
|
|
23
|
+
"version": "1.34.2"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "Upload via Settings -> Skills -> Upload. Claude.ai parses SKILL.md frontmatter and surfaces the skill in your library. The extraction tool (extract-block-schema.php) needs a live WP-CLI connection and won't run in the sandbox; use it from a local terminal against your own site instead.",
|
|
26
26
|
"uploadSteps": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.34.
|
|
23
|
+
"version": "1.34.2"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "Auto-loads on session start when SKILL.md frontmatter parses successfully.",
|
|
26
26
|
"verified": true,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.34.
|
|
23
|
+
"version": "1.34.2"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "Confirmed (2026-07-11): Codex CLI natively supports the SKILL.md spec. Place SKILL.md under .codex/skills/<name>/ (project) or ~/.codex/skills/<name>/ (personal) and Codex loads the name+description at session start, then the full body on demand. A parallel, broader convention .agents/skills/ (searched from cwd up to repo root, then ~/.agents/skills/) also exists across multiple tools - if your Codex CLI version prioritizes that path instead, mirror the same SKILL.md there.",
|
|
26
26
|
"verified": true,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.34.
|
|
23
|
+
"version": "1.34.2"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "CHANGED as of 2026-07-11: GitHub Copilot added a proper '.github/skills/' Agent Skills directory (December 2025), alongside the older single-file .github/copilot-instructions.md convention. This config targets the new skills-directory form. If your Copilot version predates this (pre Dec 2025), use the instructions-append fallback instead (see fallback below).",
|
|
26
26
|
"fallback": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.34.
|
|
23
|
+
"version": "1.34.2"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "CHANGED as of 2026-07-11: Gemini CLI now natively supports the same SKILL.md standard as Claude Code and Codex CLI - the same directory-based skill works unmodified. Gemini CLI discovers skills in this precedence order: built-in, extension skills, ~/.gemini/skills/ (personal), .gemini/skills/ (project, shared via version control). At session start Gemini injects each discovered skill's name+description into the system prompt and calls activate_skill when a task matches.",
|
|
26
26
|
"verified": true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mosaic-headless",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.2",
|
|
4
4
|
"description": "AI-agent skill: build Mosaic Pro (Nextend) WordPress sites by writing the underlying data model directly - 23 custom tables, no visual editor, no DOM. Every node type, style property and node property swept against a live install and asserted on the delivered HTML and compiled CSS. Installs into Claude Code, Cursor, Codex CLI, Gemini CLI, Copilot, Continue, Windsurf and Claude.ai.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wordpress",
|
package/tools/build_page.py
CHANGED
|
@@ -21,7 +21,9 @@ style-states.csv, and the commit sequence is the one in references/write-protoco
|
|
|
21
21
|
A node is:
|
|
22
22
|
|
|
23
23
|
{"type": "div",
|
|
24
|
-
"text": "hello", shorthand: adds a wysiwyg-text child
|
|
24
|
+
"text": "hello", shorthand: adds a wysiwyg-text child (inside an
|
|
25
|
+
Inherited text `text` node unless the type
|
|
26
|
+
holds runs itself - see wrap_text_runs)
|
|
25
27
|
"data": {"tagName": "h1"}, merged into the node's data
|
|
26
28
|
"style": {"_": {...}, "_m": {...}}, base state, per breakpoint
|
|
27
29
|
"hover": {"_": {...}}, any state name works as a key
|
|
@@ -430,12 +432,45 @@ def flatten(node, parent_id, master_id, surface, force, ordering="a0",
|
|
|
430
432
|
children = list(node.get("children") or [])
|
|
431
433
|
if node.get("text") is not None:
|
|
432
434
|
children.insert(0, {"type": "wysiwyg-text", "data": {"text": node["text"]}})
|
|
435
|
+
children = wrap_text_runs(node["type"], children)
|
|
433
436
|
for i, child in enumerate(children):
|
|
434
437
|
flatten(child, nid, master_id, surface, force, ordering_for(i),
|
|
435
438
|
node["type"], out, ancestors + (node["type"],))
|
|
436
439
|
return out
|
|
437
440
|
|
|
438
441
|
|
|
442
|
+
# Types the editor lets hold text runs directly (its own defaults put
|
|
443
|
+
# wysiwyg-text straight under these). Everything else - button, menu-link,
|
|
444
|
+
# dropdown-toggle, tab, submit-label... - gets its runs inside a `text` node on
|
|
445
|
+
# the Inherited text variant, and a run placed directly under one renders fine
|
|
446
|
+
# but cannot be edited in the editor: the navigator shows no child and a
|
|
447
|
+
# double-click opens only the link settings.
|
|
448
|
+
DIRECT_TEXT_HOSTS = {"text", "label", "choice-label", "choice-legend", "fieldset-legend",
|
|
449
|
+
"wysiwyg-span", "wysiwyg-link"}
|
|
450
|
+
INHERITED_TEXT_VARIANT = "6381b2f3-7a23-05db-87b9-c808a98a292b"
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
def wrap_text_runs(node_type, children):
|
|
454
|
+
"""Group consecutive wysiwyg-* children of a non-text host into one
|
|
455
|
+
`text` node on the Inherited text variant, the shape the editor builds."""
|
|
456
|
+
if node_type in DIRECT_TEXT_HOSTS:
|
|
457
|
+
return children
|
|
458
|
+
out, run = [], []
|
|
459
|
+
for child in children:
|
|
460
|
+
if str(child.get("type", "")).startswith("wysiwyg-"):
|
|
461
|
+
run.append(child)
|
|
462
|
+
continue
|
|
463
|
+
if run:
|
|
464
|
+
out.append({"type": "text", "data": {"style": {"variant": INHERITED_TEXT_VARIANT}},
|
|
465
|
+
"children": run})
|
|
466
|
+
run = []
|
|
467
|
+
out.append(child)
|
|
468
|
+
if run:
|
|
469
|
+
out.append({"type": "text", "data": {"style": {"variant": INHERITED_TEXT_VARIANT}},
|
|
470
|
+
"children": run})
|
|
471
|
+
return out
|
|
472
|
+
|
|
473
|
+
|
|
439
474
|
def ordering_for(index):
|
|
440
475
|
"""Siblings order by a fractional-index STRING, never by number."""
|
|
441
476
|
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
package/tools/build_site.py
CHANGED
|
@@ -40,6 +40,7 @@ import uuid
|
|
|
40
40
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
41
41
|
from build_page import (refresh_node_ids, # noqa: E402
|
|
42
42
|
COMPONENT_USES,
|
|
43
|
+
INHERITED_TEXT_VARIANT,
|
|
43
44
|
VAR_IDS,
|
|
44
45
|
Surface,
|
|
45
46
|
flatten,
|
|
@@ -240,9 +241,22 @@ def ensure_components(client, cfg, site, surface):
|
|
|
240
241
|
by_parent = {}
|
|
241
242
|
for node in doc2[key]:
|
|
242
243
|
by_parent.setdefault(node.get("parentID"), []).append(node)
|
|
244
|
+
def text_child(nid):
|
|
245
|
+
kids = by_parent.get(nid, [])
|
|
246
|
+
run = next((c for c in kids if c["type"].startswith("wysiwyg-")), None)
|
|
247
|
+
if run:
|
|
248
|
+
return run
|
|
249
|
+
# a button's runs sit one level down, in the Inherited text `text`
|
|
250
|
+
# node build_page wraps them in (wrap_text_runs)
|
|
251
|
+
wrap = next((c for c in kids if c["type"] == "text" and not
|
|
252
|
+
(c.get("data") or {}).get("attrID") and
|
|
253
|
+
((c.get("data") or {}).get("style") or {}).get("variant")
|
|
254
|
+
== INHERITED_TEXT_VARIANT), None)
|
|
255
|
+
return wrap and next((c for c in by_parent.get(wrap["ID"], [])
|
|
256
|
+
if c["type"].startswith("wysiwyg-")), None)
|
|
257
|
+
|
|
243
258
|
for attr, nid in nodes.items():
|
|
244
|
-
child =
|
|
245
|
-
if c["type"].startswith("wysiwyg-")), None)
|
|
259
|
+
child = text_child(nid)
|
|
246
260
|
if child:
|
|
247
261
|
texts[attr] = child["ID"]
|
|
248
262
|
out[name] = {"id": cid, "nodes": nodes, "texts": texts}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Put text runs that sit directly under a button (or any non-text element) into
|
|
3
|
+
an Inherited text `text` node, so the Mosaic editor can edit them.
|
|
4
|
+
|
|
5
|
+
python fix_text_runs.py --config site.json # dry run: lists what it would move
|
|
6
|
+
python fix_text_runs.py --config site.json --apply # commit, document by document
|
|
7
|
+
|
|
8
|
+
Why this exists
|
|
9
|
+
---------------
|
|
10
|
+
Through v1.34.0, build_page.py's `"text"` shorthand wrote a button as
|
|
11
|
+
`button > wysiwyg-text`. That renders exactly like the editor's own button, but
|
|
12
|
+
the editor builds `button > text (Inherited text variant) > wysiwyg-text`, and
|
|
13
|
+
without the middle node it has nothing to edit: the navigator shows the button
|
|
14
|
+
with no child, and a double-click opens only the link settings. The same holds
|
|
15
|
+
for menu-link, dropdown-toggle, tabs-tab, list-item, submit labels, pagination
|
|
16
|
+
and multi-step buttons. Only the types in DIRECT_TEXT_HOSTS hold runs directly.
|
|
17
|
+
|
|
18
|
+
A rebuild with v1.34.1+ fixes a page; this fixes a site in place without one.
|
|
19
|
+
For each run of consecutive wysiwyg-* children under a non-host element it writes
|
|
20
|
+
one new `text` node in the run's place and moves the runs into it. The runs keep
|
|
21
|
+
their ids, so a component instance's override of a run still points at it.
|
|
22
|
+
|
|
23
|
+
Every document on the theme is covered: masters, templates and components. The
|
|
24
|
+
changes go through each document's own commit, the same path the editor uses,
|
|
25
|
+
never SQL. Back up the wp_mosaic_* tables first all the same.
|
|
26
|
+
"""
|
|
27
|
+
import mosaic_config
|
|
28
|
+
import argparse
|
|
29
|
+
import os
|
|
30
|
+
import sys
|
|
31
|
+
import uuid
|
|
32
|
+
|
|
33
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
34
|
+
from build_page import DIRECT_TEXT_HOSTS, INHERITED_TEXT_VARIANT # noqa: E402
|
|
35
|
+
from sweep_node_types import Client, envelopes, exceptions_of, unwrap # noqa: E402
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def documents(client):
|
|
39
|
+
"""(instance, key, label) for every document on the theme that holds nodes."""
|
|
40
|
+
out, seen = [], set()
|
|
41
|
+
tei = unwrap(client.get("adminTemplateEditorInstance"), "adminTemplateEditorInstance")
|
|
42
|
+
for tpl in tei.get("template", []):
|
|
43
|
+
master = tpl["masterID"]
|
|
44
|
+
if master not in seen:
|
|
45
|
+
seen.add(master)
|
|
46
|
+
out.append(("masterDocumentInstance/%s" % master, "node/master/%s" % master,
|
|
47
|
+
"master %s" % master[:8]))
|
|
48
|
+
out.append(("templateDocumentInstance/%s/%s" % (master, tpl["ID"]),
|
|
49
|
+
"node/template/%s" % tpl["ID"],
|
|
50
|
+
"template %s %s" % (tpl["ID"][:8], (tpl.get("data") or {}).get("name") or "")))
|
|
51
|
+
comps = unwrap(client.get("adminComponentsEditorInstance"), "adminComponentsEditorInstance")
|
|
52
|
+
for c in comps.get("component", []):
|
|
53
|
+
if c.get("status") == "delete":
|
|
54
|
+
continue
|
|
55
|
+
out.append(("componentDocumentInstance/%s" % c["ID"], "node/component/%s" % c["ID"],
|
|
56
|
+
"component %s %s" % (c["ID"][:8], c.get("name") or "")))
|
|
57
|
+
return out
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def plan(nodes):
|
|
61
|
+
"""Revision records that wrap every misplaced run, and a count per parent type."""
|
|
62
|
+
live = [n for n in nodes if n.get("status") != "delete"]
|
|
63
|
+
kids = {}
|
|
64
|
+
for n in live:
|
|
65
|
+
kids.setdefault(n.get("parentID"), []).append(n)
|
|
66
|
+
records, counts = [], {}
|
|
67
|
+
for parent in live:
|
|
68
|
+
ptype = parent["type"]
|
|
69
|
+
if (ptype in DIRECT_TEXT_HOSTS or ptype.startswith("wysiwyg-")
|
|
70
|
+
or ptype.startswith("component-instance")):
|
|
71
|
+
continue
|
|
72
|
+
children = sorted((c for c in kids.get(parent["ID"], [])
|
|
73
|
+
if c.get("parentType") == "node"),
|
|
74
|
+
key=lambda c: c.get("ordering") or "")
|
|
75
|
+
groups, run = [], []
|
|
76
|
+
for c in children:
|
|
77
|
+
if c["type"].startswith("wysiwyg-"):
|
|
78
|
+
run.append(c)
|
|
79
|
+
elif run:
|
|
80
|
+
groups.append(run)
|
|
81
|
+
run = []
|
|
82
|
+
if run:
|
|
83
|
+
groups.append(run)
|
|
84
|
+
for run in groups:
|
|
85
|
+
wrap_id = str(uuid.uuid4())
|
|
86
|
+
first = run[0]
|
|
87
|
+
records.append({"newRevisionRecord": {
|
|
88
|
+
"ID": wrap_id, "parentType": "node", "parentID": parent["ID"],
|
|
89
|
+
"ordering": first.get("ordering") or "a0", "status": "publish",
|
|
90
|
+
"revision": "", "version": "", "type": "text",
|
|
91
|
+
"data": {"style": {"variant": INHERITED_TEXT_VARIANT}},
|
|
92
|
+
"documentType": first.get("documentType"),
|
|
93
|
+
"documentID": first.get("documentID")},
|
|
94
|
+
"originalRevisionRecord": None})
|
|
95
|
+
for c in run:
|
|
96
|
+
records.append({"newRevisionRecord": dict(c, parentID=wrap_id),
|
|
97
|
+
"originalRevisionRecord": c})
|
|
98
|
+
counts[ptype] = counts.get(ptype, 0) + 1
|
|
99
|
+
return records, counts
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def main():
|
|
103
|
+
ap = argparse.ArgumentParser()
|
|
104
|
+
ap.add_argument("--config",
|
|
105
|
+
help="JSON with base/cookie/nonce/themeID; omit it and the MOSAIC_* environment variables supply them")
|
|
106
|
+
ap.add_argument("--apply", action="store_true", help="commit; without it nothing is written")
|
|
107
|
+
a = ap.parse_args()
|
|
108
|
+
client = Client(mosaic_config.load(a.config))
|
|
109
|
+
|
|
110
|
+
total, totals = 0, {}
|
|
111
|
+
for instance, key, label in documents(client):
|
|
112
|
+
resp = client.get(instance)
|
|
113
|
+
if "_httperror" in resp or "response" not in resp:
|
|
114
|
+
print(" skip %-40s (could not read)" % label)
|
|
115
|
+
continue
|
|
116
|
+
doc = resp["response"]
|
|
117
|
+
records, counts = plan(doc.get(key) or [])
|
|
118
|
+
if not counts:
|
|
119
|
+
continue
|
|
120
|
+
n = sum(counts.values())
|
|
121
|
+
total += n
|
|
122
|
+
for k, v in counts.items():
|
|
123
|
+
totals[k] = totals.get(k, 0) + v
|
|
124
|
+
print(" %-40s %3d run(s): %s" % (label, n,
|
|
125
|
+
", ".join("%s %d" % kv for kv in sorted(counts.items()))))
|
|
126
|
+
if a.apply:
|
|
127
|
+
err = exceptions_of(client.commit(instance, envelopes(doc), {key: records}))
|
|
128
|
+
if err:
|
|
129
|
+
sys.exit("commit failed on %s: %s" % (label, err[:400]))
|
|
130
|
+
|
|
131
|
+
print("%s %d run(s) under %s" % ("wrapped" if a.apply else "would wrap", total,
|
|
132
|
+
", ".join("%s %d" % kv for kv in sorted(totals.items())) or "nothing"))
|
|
133
|
+
if total and not a.apply:
|
|
134
|
+
print("dry run - nothing written. Add --apply to commit.")
|
|
135
|
+
elif total:
|
|
136
|
+
print("purge the page cache, then open a page in the editor and double-click a button.")
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
if __name__ == "__main__":
|
|
140
|
+
main()
|