Add Site Studio themes and Theme Manager
Support categorized fragments, theme presets, block widths, and server-backed theme editing with onboarding and preview. Include Site Studio, design sources, specification and verification reports; remove the legacy studio-site example.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Install a wheel and smoke real FastAPI outside the checkout, without design/."""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
@@ -11,6 +12,9 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--site", type=Path, default=ROOT / "examples/studio-site")
|
||||
args = parser.parse_args()
|
||||
with tempfile.TemporaryDirectory(prefix="cms-installed-001-") as tmp:
|
||||
work = Path(tmp)
|
||||
project = work / "project"
|
||||
@@ -54,7 +58,7 @@ def main():
|
||||
check=True,
|
||||
)
|
||||
shutil.copytree(
|
||||
ROOT / "examples/studio-site", work / "site", ignore=shutil.ignore_patterns(".engine")
|
||||
args.site, work / "site", ignore=shutil.ignore_patterns(".engine")
|
||||
)
|
||||
env = dict(
|
||||
os.environ,
|
||||
@@ -76,6 +80,15 @@ from site_engine.web.app import create_app
|
||||
from site_engine.web.preview_app import create_preview_app
|
||||
import site_engine
|
||||
assert str(Path(site_engine.__file__).resolve()).startswith(os.environ['PYTHONPATH'])
|
||||
from site_engine.core.theme import preset_catalog, resolve_theme
|
||||
from site_engine.errors import Report
|
||||
for name, preset in preset_catalog().items():
|
||||
overrides={k:preset[k] for k in ('colors','type','ui')} if name=='custom' else {}
|
||||
report=Report()
|
||||
theme=resolve_theme(dict(schema=1,preset=name,preset_version=1,overrides=overrides), report)
|
||||
assert theme and report.ok,(name,report)
|
||||
from site_engine.build.pipeline import build_site
|
||||
build_site(Path(os.environ['SITE_ROOT']),Path(os.environ['SITE_DIST']))
|
||||
os.environ['SITE_ADMIN_PASSWORD_HASH']=hash_password('installed wheel password',n=2**10)
|
||||
os.environ['SITE_ADMIN_LOGIN']='admin'
|
||||
app=create_app()
|
||||
@@ -84,7 +97,7 @@ with TestClient(app) as client:
|
||||
assert response.status_code==200
|
||||
response=client.get('/admin/pages/index')
|
||||
assert response.status_code==200 and 'document-editor' in response.text
|
||||
for name in ('antirion-rework.css','shell.css','pages.css','pages.js','admin.css','admin.js','editor.js','builder.css','builder-adapter.css','builder.js','htmx.min.js'):
|
||||
for name in ('antirion-rework.css','shell.css','pages.css','pages.js','admin.css','admin.js','editor.js','builder.css','builder-adapter.css','builder.js','htmx.min.js','theme-studio.css','theme-studio.js'):
|
||||
assert client.get('/admin/static/'+name).status_code==200,name
|
||||
assert 'pages-screen' in client.get('/admin/pages').text
|
||||
cookie=client.cookies.get('se_session')
|
||||
@@ -99,8 +112,20 @@ with TestClient(app) as client:
|
||||
result=preview.get(url)
|
||||
assert result.status_code==200,result.text
|
||||
assert 'preview:ready' in result.text and 'data-preview-id' in result.text
|
||||
assert 'data-section-width' in result.text and '--container-max:' in result.text
|
||||
assert 'theme-bootstrap' in client.get('/admin/theme').text
|
||||
import json
|
||||
document={'schema':1,'preset':'dark','preset_version':1,'overrides':{}}
|
||||
result=client.post('/admin/theme/validate',data={'csrf':csrf,'payload':json.dumps({'document':document,'revision':17})},headers={'Origin':'http://testserver','HX-Request':'true'})
|
||||
assert result.status_code==200 and result.json()['revision']==17,result.text
|
||||
result=client.post('/admin/theme/preview',data={'csrf':csrf,'payload':json.dumps({'document':document,'revision':17})},headers={'Origin':'http://testserver','HX-Request':'true'})
|
||||
assert result.status_code==200,result.text
|
||||
with TestClient(create_preview_app()) as preview:
|
||||
result=preview.get(result.json()['url'])
|
||||
assert result.status_code==200 and 'sample-site' in result.text,result.text
|
||||
assert '--color-primary: #a48bfa' in result.text
|
||||
assert app.state.api_calls>0
|
||||
print('installed wheel: static, templates, API, bridge, separate preview OK; design/ absent')
|
||||
print('installed wheel: all theme presets, build, widths, static, templates, Theme Manager, API, bridge, separate preview OK; design/ absent')
|
||||
"""
|
||||
subprocess.run([sys.executable, "-c", program], cwd=work, env=env, check=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user