Integrate Antirion admin with FastAPI and htmx
Add the shared document API, constructor and expert editors, isolated preview, and fragment catalog metadata with typed block IDs. Include design references, specification 001, QA scripts, project guidance, and cached Docker dependency installation. Leave example sites for a separate commit.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
"""Transfer designer CSS/SVG verbatim, isolating its document reset from the shared shell."""
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from css_scope import scope_css
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def main():
|
||||
def emit(path, content):
|
||||
if "--check" in sys.argv:
|
||||
if not path.exists() or path.read_text() != content:
|
||||
raise SystemExit(f"Designer transfer out of date: {path}")
|
||||
else:
|
||||
path.write_text(content)
|
||||
|
||||
static = ROOT / "src/site_engine/web/admin/static"
|
||||
source = (ROOT / "design/assets/builder.css").read_text()
|
||||
emit(static / "builder-design.css", source)
|
||||
# All component declarations and media queries remain designer-owned. Only the
|
||||
# document root becomes the embedded editor root. Ordinary prefixed selectors
|
||||
# isolate the shell, including in browsers that do not implement CSS @scope.
|
||||
embedded = re.sub(r"(?<![-\w])(?:html|body)(?![-\w])", ":scope", source)
|
||||
embedded = embedded.replace(":root", ":scope")
|
||||
emit(
|
||||
static / "builder.css",
|
||||
"/* Generated by scripts/sync_builder_design.py. Do not hand-edit. */\n"
|
||||
+ scope_css(
|
||||
embedded, "#document-editor.page-builder", ":where(#document-editor).page-builder"
|
||||
),
|
||||
)
|
||||
js = (ROOT / "design/assets/builder.js").read_text()
|
||||
icons = dict(re.findall(r"(\w+):'([^']*)'", js.split("const I={", 1)[1].split("};", 1)[0]))
|
||||
macro = "{% macro bi(name) -%}{% set paths = " + json.dumps(icons, ensure_ascii=False) + " %}"
|
||||
macro += "<svg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round' aria-hidden='true'><path d='{{ paths.get(name, paths.blocks) }}'/></svg>{%- endmacro %}\n"
|
||||
emit(static.parent / "templates/_builder_icons.html.j2", macro)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user