Move SX docs rendering from sx_components.py to sxc/pages (phase 8)
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 33s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 33s
Consolidate 86 component rendering functions into sxc/pages/__init__.py, update 37 import sites in routes.py, remove app.py side-effect imports, and delete sx/sxc/sx_components.py. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
from __future__ import annotations
|
||||
import path_setup # noqa: F401
|
||||
import sxc.sx_components as sx_components # noqa: F401
|
||||
|
||||
from shared.infrastructure.factory import create_base_app
|
||||
|
||||
from bp import register_pages
|
||||
@@ -48,8 +46,6 @@ def create_app() -> "Quart":
|
||||
domain_services_fn=register_domain_services,
|
||||
)
|
||||
|
||||
import sxc.sx_components # noqa: F401
|
||||
|
||||
from sxc.pages import setup_sx_pages
|
||||
setup_sx_pages()
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/click")
|
||||
async def api_click():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
sx_src = f'(~click-result :time "{now}")'
|
||||
comp_text = _component_source_text("click-result")
|
||||
@@ -38,7 +38,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.post("/examples/api/form")
|
||||
async def api_form():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
form = await request.form
|
||||
name = form.get("name", "")
|
||||
escaped = name.replace('"', '\\"')
|
||||
@@ -54,7 +54,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/poll")
|
||||
async def api_poll():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
_poll_count["n"] += 1
|
||||
now = datetime.now().strftime("%H:%M:%S")
|
||||
count = min(_poll_count["n"], 10)
|
||||
@@ -69,7 +69,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.delete("/examples/api/delete/<item_id>")
|
||||
async def api_delete(item_id: str):
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
# Empty primary response — outerHTML swap removes the row
|
||||
# But send OOB swaps to show what happened
|
||||
wire_text = _full_wire_text(f'(empty — row #{item_id} removed by outerHTML swap)')
|
||||
@@ -81,7 +81,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/edit")
|
||||
async def api_edit_form():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
value = request.args.get("value", "")
|
||||
escaped = value.replace('"', '\\"')
|
||||
sx_src = f'(~inline-edit-form :value "{escaped}")'
|
||||
@@ -95,7 +95,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.post("/examples/api/edit")
|
||||
async def api_edit_save():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
form = await request.form
|
||||
value = form.get("value", "")
|
||||
escaped = value.replace('"', '\\"')
|
||||
@@ -109,7 +109,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/edit/cancel")
|
||||
async def api_edit_cancel():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
value = request.args.get("value", "")
|
||||
escaped = value.replace('"', '\\"')
|
||||
sx_src = f'(~inline-view :value "{escaped}")'
|
||||
@@ -122,7 +122,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/oob")
|
||||
async def api_oob():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _full_wire_text
|
||||
from sxc.pages import _oob_code, _full_wire_text
|
||||
now = datetime.now().strftime("%H:%M:%S")
|
||||
sx_src = (
|
||||
f'(<>'
|
||||
@@ -141,7 +141,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/lazy")
|
||||
async def api_lazy():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
now = datetime.now().strftime("%H:%M:%S")
|
||||
sx_src = f'(~lazy-result :time "{now}")'
|
||||
comp_text = _component_source_text("lazy-result")
|
||||
@@ -155,7 +155,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/scroll")
|
||||
async def api_scroll():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _full_wire_text
|
||||
from sxc.pages import _oob_code, _full_wire_text
|
||||
page = int(request.args.get("page", 2))
|
||||
start = (page - 1) * 5 + 1
|
||||
next_page = page + 1
|
||||
@@ -191,7 +191,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.post("/examples/api/progress/start")
|
||||
async def api_progress_start():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
job_id = str(uuid4())[:8]
|
||||
_jobs[job_id] = 0
|
||||
sx_src = f'(~progress-status :percent 0 :job-id "{job_id}")'
|
||||
@@ -204,7 +204,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/progress/status")
|
||||
async def api_progress_status():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
job_id = request.args.get("job", "")
|
||||
current = _jobs.get(job_id, 0)
|
||||
current = min(current + random.randint(15, 30), 100)
|
||||
@@ -221,7 +221,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/search")
|
||||
async def api_search():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
from content.pages import SEARCH_LANGUAGES
|
||||
q = request.args.get("q", "").strip().lower()
|
||||
if not q:
|
||||
@@ -244,7 +244,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/validate")
|
||||
async def api_validate():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
email = request.args.get("email", "").strip()
|
||||
if not email:
|
||||
sx_src = '(~validation-error :message "Email is required")'
|
||||
@@ -282,7 +282,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/values")
|
||||
async def api_values():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _full_wire_text
|
||||
from sxc.pages import _oob_code, _full_wire_text
|
||||
from content.pages import VALUE_SELECT_DATA
|
||||
cat = request.args.get("category", "")
|
||||
items = VALUE_SELECT_DATA.get(cat, [])
|
||||
@@ -300,7 +300,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.post("/examples/api/reset-submit")
|
||||
async def api_reset_submit():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
form = await request.form
|
||||
msg = form.get("message", "").strip() or "(empty)"
|
||||
escaped = msg.replace('"', '\\"')
|
||||
@@ -326,7 +326,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/editrow/<row_id>")
|
||||
async def api_editrow_form(row_id: str):
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
rows = _get_edit_rows()
|
||||
row = rows.get(row_id, {"id": row_id, "name": "", "price": "0", "stock": "0"})
|
||||
sx_src = (f'(~edit-row-form :id "{row["id"]}" :name "{row["name"]}"'
|
||||
@@ -341,7 +341,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.post("/examples/api/editrow/<row_id>")
|
||||
async def api_editrow_save(row_id: str):
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
form = await request.form
|
||||
rows = _get_edit_rows()
|
||||
rows[row_id] = {
|
||||
@@ -362,7 +362,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/editrow/<row_id>/cancel")
|
||||
async def api_editrow_cancel(row_id: str):
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
rows = _get_edit_rows()
|
||||
row = rows.get(row_id, {"id": row_id, "name": "", "price": "0", "stock": "0"})
|
||||
sx_src = (f'(~edit-row-view :id "{row["id"]}" :name "{row["name"]}"'
|
||||
@@ -388,7 +388,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.post("/examples/api/bulk")
|
||||
async def api_bulk():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
action = request.args.get("action", "activate")
|
||||
form = await request.form
|
||||
ids = form.getlist("ids")
|
||||
@@ -418,7 +418,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.post("/examples/api/swap-log")
|
||||
async def api_swap_log():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _full_wire_text
|
||||
from sxc.pages import _oob_code, _full_wire_text
|
||||
mode = request.args.get("mode", "beforeend")
|
||||
_swap_count["n"] += 1
|
||||
now = datetime.now().strftime("%H:%M:%S")
|
||||
@@ -438,7 +438,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/dashboard")
|
||||
async def api_dashboard():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _full_wire_text
|
||||
from sxc.pages import _oob_code, _full_wire_text
|
||||
now = datetime.now().strftime("%H:%M:%S")
|
||||
sx_src = (
|
||||
f'(<>'
|
||||
@@ -483,7 +483,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/tabs/<tab>")
|
||||
async def api_tabs(tab: str):
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _full_wire_text
|
||||
from sxc.pages import _oob_code, _full_wire_text
|
||||
sx_src = _TAB_CONTENT.get(tab, _TAB_CONTENT["tab1"])
|
||||
buttons = []
|
||||
for t, label in [("tab1", "Overview"), ("tab2", "Details"), ("tab3", "History")]:
|
||||
@@ -503,7 +503,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/animate")
|
||||
async def api_animate():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
colors = ["bg-violet-100", "bg-emerald-100", "bg-blue-100", "bg-amber-100", "bg-rose-100"]
|
||||
color = random.choice(colors)
|
||||
now = datetime.now().strftime("%H:%M:%S")
|
||||
@@ -519,7 +519,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/dialog")
|
||||
async def api_dialog():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
sx_src = '(~dialog-modal :title "Confirm Action" :message "Are you sure you want to proceed? This is a demo dialog rendered entirely with sx components.")'
|
||||
comp_text = _component_source_text("dialog-modal")
|
||||
wire_text = _full_wire_text(sx_src, "dialog-modal")
|
||||
@@ -530,7 +530,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/dialog/close")
|
||||
async def api_dialog_close():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _full_wire_text
|
||||
from sxc.pages import _oob_code, _full_wire_text
|
||||
wire_text = _full_wire_text("(empty — dialog closed)")
|
||||
oob_wire = _oob_code("dialog-wire", wire_text)
|
||||
return sx_response(f'(<> {oob_wire})')
|
||||
@@ -546,7 +546,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/keyboard")
|
||||
async def api_keyboard():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
key = request.args.get("key", "")
|
||||
action = _KBD_ACTIONS.get(key, f"Unknown key: {key}")
|
||||
escaped_action = action.replace('"', '\\"')
|
||||
@@ -571,7 +571,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/putpatch/edit-all")
|
||||
async def api_pp_edit_all():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
p = _get_profile()
|
||||
sx_src = f'(~pp-form-full :name "{p["name"]}" :email "{p["email"]}" :role "{p["role"]}")'
|
||||
comp_text = _component_source_text("pp-form-full")
|
||||
@@ -584,7 +584,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.put("/examples/api/putpatch")
|
||||
async def api_pp_put():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
form = await request.form
|
||||
p = _get_profile()
|
||||
p["name"] = form.get("name", p["name"])
|
||||
@@ -600,7 +600,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/putpatch/cancel")
|
||||
async def api_pp_cancel():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
p = _get_profile()
|
||||
sx_src = f'(~pp-view :name "{p["name"]}" :email "{p["email"]}" :role "{p["role"]}")'
|
||||
comp_text = _component_source_text("pp-view")
|
||||
@@ -615,7 +615,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.post("/examples/api/json-echo")
|
||||
async def api_json_echo():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
data = await request.get_json(silent=True) or {}
|
||||
body = json.dumps(data, indent=2)
|
||||
ct = request.content_type or "unknown"
|
||||
@@ -633,7 +633,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/echo-vals")
|
||||
async def api_echo_vals():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
vals = {k: v for k, v in request.args.items()
|
||||
if k not in ("_", "sx-request")}
|
||||
items_sx = " ".join(f'"{k}: {v}"' for k, v in vals.items())
|
||||
@@ -647,7 +647,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/echo-headers")
|
||||
async def api_echo_headers():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
custom = {k: v for k, v in request.headers if k.lower().startswith("x-")}
|
||||
items_sx = " ".join(f'"{k}: {v}"' for k, v in custom.items())
|
||||
sx_src = f'(~echo-result :label "headers" :items (list {items_sx}))'
|
||||
@@ -662,7 +662,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/slow")
|
||||
async def api_slow():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
await asyncio.sleep(2)
|
||||
now = datetime.now().strftime("%H:%M:%S")
|
||||
sx_src = f'(~loading-result :time "{now}")'
|
||||
@@ -677,7 +677,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/slow-search")
|
||||
async def api_slow_search():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
delay = random.uniform(0.5, 2.0)
|
||||
await asyncio.sleep(delay)
|
||||
q = request.args.get("q", "").strip()
|
||||
@@ -697,7 +697,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
@bp.get("/examples/api/flaky")
|
||||
async def api_flaky():
|
||||
from shared.sx.helpers import sx_response
|
||||
from sxc.sx_components import _oob_code, _component_source_text, _full_wire_text
|
||||
from sxc.pages import _oob_code, _component_source_text, _full_wire_text
|
||||
_flaky["n"] += 1
|
||||
n = _flaky["n"]
|
||||
if n % 3 != 0:
|
||||
@@ -715,7 +715,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
||||
|
||||
def _ref_wire(wire_id: str, sx_src: str) -> str:
|
||||
"""Build OOB swap showing the wire response text."""
|
||||
from sxc.sx_components import _oob_code
|
||||
from sxc.pages import _oob_code
|
||||
return _oob_code(f"ref-wire-{wire_id}", sx_src)
|
||||
|
||||
@bp.get("/reference/api/time")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user