Integrate Content Editor and Publication workflow

This commit is contained in:
2026-11-17 11:43:53 +03:00
parent f18bc9a4fd
commit c3938f24d8
55 changed files with 6207 additions and 203 deletions
+48
View File
@@ -0,0 +1,48 @@
"""Transfer original Content CSS and SVGs; only isolate selectors from the 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"Content design out of date: {path}")
else:
path.write_text(content)
target = ROOT / "src/site_engine/web/admin"
css = (
(ROOT / "design/assets/builder.css").read_text()
+ "\n"
+ (ROOT / "design/assets/content-editor.css").read_text()
)
css = re.sub(r"(?<![-\w])(?:html|body)(?![-\w])", ":scope", css).replace(":root", ":scope")
css = css.replace(':scope[data-theme="antirion"]', ":scope").replace(
':scope[data-theme="rose"]', ":scope[data-unused-rose]"
)
emit(
target / "static/content-editor.css",
"/* Generated by scripts/sync_content_design.py; original declarations unchanged. */\n"
+ scope_css(css, ".entry-content-editor", ":where(.entry-content-editor)"),
)
js = (ROOT / "design/assets/content-editor.js").read_text()
data = js.split("function icon(name){const p={", 1)[1].split("}[name]||", 1)[0]
icons = dict(re.findall(r"(\w+):'([^']*)'", data))
emit(
target / "templates/_content_icons.html.j2",
"{% macro ci(name) -%}{% set paths = "
+ json.dumps(icons)
+ ' %}<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.file) }}"/></svg>{%- endmacro %}\n',
)
if __name__ == "__main__":
main()