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
|
from __future__ import annotations
|
||||||
import path_setup # noqa: F401
|
import path_setup # noqa: F401
|
||||||
import sxc.sx_components as sx_components # noqa: F401
|
|
||||||
|
|
||||||
from shared.infrastructure.factory import create_base_app
|
from shared.infrastructure.factory import create_base_app
|
||||||
|
|
||||||
from bp import register_pages
|
from bp import register_pages
|
||||||
@@ -48,8 +46,6 @@ def create_app() -> "Quart":
|
|||||||
domain_services_fn=register_domain_services,
|
domain_services_fn=register_domain_services,
|
||||||
)
|
)
|
||||||
|
|
||||||
import sxc.sx_components # noqa: F401
|
|
||||||
|
|
||||||
from sxc.pages import setup_sx_pages
|
from sxc.pages import setup_sx_pages
|
||||||
setup_sx_pages()
|
setup_sx_pages()
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/click")
|
@bp.get("/examples/api/click")
|
||||||
async def api_click():
|
async def api_click():
|
||||||
from shared.sx.helpers import sx_response
|
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")
|
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
sx_src = f'(~click-result :time "{now}")'
|
sx_src = f'(~click-result :time "{now}")'
|
||||||
comp_text = _component_source_text("click-result")
|
comp_text = _component_source_text("click-result")
|
||||||
@@ -38,7 +38,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.post("/examples/api/form")
|
@bp.post("/examples/api/form")
|
||||||
async def api_form():
|
async def api_form():
|
||||||
from shared.sx.helpers import sx_response
|
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
|
form = await request.form
|
||||||
name = form.get("name", "")
|
name = form.get("name", "")
|
||||||
escaped = name.replace('"', '\\"')
|
escaped = name.replace('"', '\\"')
|
||||||
@@ -54,7 +54,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/poll")
|
@bp.get("/examples/api/poll")
|
||||||
async def api_poll():
|
async def api_poll():
|
||||||
from shared.sx.helpers import sx_response
|
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
|
_poll_count["n"] += 1
|
||||||
now = datetime.now().strftime("%H:%M:%S")
|
now = datetime.now().strftime("%H:%M:%S")
|
||||||
count = min(_poll_count["n"], 10)
|
count = min(_poll_count["n"], 10)
|
||||||
@@ -69,7 +69,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.delete("/examples/api/delete/<item_id>")
|
@bp.delete("/examples/api/delete/<item_id>")
|
||||||
async def api_delete(item_id: str):
|
async def api_delete(item_id: str):
|
||||||
from shared.sx.helpers import sx_response
|
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
|
# Empty primary response — outerHTML swap removes the row
|
||||||
# But send OOB swaps to show what happened
|
# But send OOB swaps to show what happened
|
||||||
wire_text = _full_wire_text(f'(empty — row #{item_id} removed by outerHTML swap)')
|
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")
|
@bp.get("/examples/api/edit")
|
||||||
async def api_edit_form():
|
async def api_edit_form():
|
||||||
from shared.sx.helpers import sx_response
|
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", "")
|
value = request.args.get("value", "")
|
||||||
escaped = value.replace('"', '\\"')
|
escaped = value.replace('"', '\\"')
|
||||||
sx_src = f'(~inline-edit-form :value "{escaped}")'
|
sx_src = f'(~inline-edit-form :value "{escaped}")'
|
||||||
@@ -95,7 +95,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.post("/examples/api/edit")
|
@bp.post("/examples/api/edit")
|
||||||
async def api_edit_save():
|
async def api_edit_save():
|
||||||
from shared.sx.helpers import sx_response
|
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
|
form = await request.form
|
||||||
value = form.get("value", "")
|
value = form.get("value", "")
|
||||||
escaped = value.replace('"', '\\"')
|
escaped = value.replace('"', '\\"')
|
||||||
@@ -109,7 +109,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/edit/cancel")
|
@bp.get("/examples/api/edit/cancel")
|
||||||
async def api_edit_cancel():
|
async def api_edit_cancel():
|
||||||
from shared.sx.helpers import sx_response
|
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", "")
|
value = request.args.get("value", "")
|
||||||
escaped = value.replace('"', '\\"')
|
escaped = value.replace('"', '\\"')
|
||||||
sx_src = f'(~inline-view :value "{escaped}")'
|
sx_src = f'(~inline-view :value "{escaped}")'
|
||||||
@@ -122,7 +122,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/oob")
|
@bp.get("/examples/api/oob")
|
||||||
async def api_oob():
|
async def api_oob():
|
||||||
from shared.sx.helpers import sx_response
|
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")
|
now = datetime.now().strftime("%H:%M:%S")
|
||||||
sx_src = (
|
sx_src = (
|
||||||
f'(<>'
|
f'(<>'
|
||||||
@@ -141,7 +141,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/lazy")
|
@bp.get("/examples/api/lazy")
|
||||||
async def api_lazy():
|
async def api_lazy():
|
||||||
from shared.sx.helpers import sx_response
|
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")
|
now = datetime.now().strftime("%H:%M:%S")
|
||||||
sx_src = f'(~lazy-result :time "{now}")'
|
sx_src = f'(~lazy-result :time "{now}")'
|
||||||
comp_text = _component_source_text("lazy-result")
|
comp_text = _component_source_text("lazy-result")
|
||||||
@@ -155,7 +155,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/scroll")
|
@bp.get("/examples/api/scroll")
|
||||||
async def api_scroll():
|
async def api_scroll():
|
||||||
from shared.sx.helpers import sx_response
|
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))
|
page = int(request.args.get("page", 2))
|
||||||
start = (page - 1) * 5 + 1
|
start = (page - 1) * 5 + 1
|
||||||
next_page = page + 1
|
next_page = page + 1
|
||||||
@@ -191,7 +191,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.post("/examples/api/progress/start")
|
@bp.post("/examples/api/progress/start")
|
||||||
async def api_progress_start():
|
async def api_progress_start():
|
||||||
from shared.sx.helpers import sx_response
|
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]
|
job_id = str(uuid4())[:8]
|
||||||
_jobs[job_id] = 0
|
_jobs[job_id] = 0
|
||||||
sx_src = f'(~progress-status :percent 0 :job-id "{job_id}")'
|
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")
|
@bp.get("/examples/api/progress/status")
|
||||||
async def api_progress_status():
|
async def api_progress_status():
|
||||||
from shared.sx.helpers import sx_response
|
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", "")
|
job_id = request.args.get("job", "")
|
||||||
current = _jobs.get(job_id, 0)
|
current = _jobs.get(job_id, 0)
|
||||||
current = min(current + random.randint(15, 30), 100)
|
current = min(current + random.randint(15, 30), 100)
|
||||||
@@ -221,7 +221,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/search")
|
@bp.get("/examples/api/search")
|
||||||
async def api_search():
|
async def api_search():
|
||||||
from shared.sx.helpers import sx_response
|
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
|
from content.pages import SEARCH_LANGUAGES
|
||||||
q = request.args.get("q", "").strip().lower()
|
q = request.args.get("q", "").strip().lower()
|
||||||
if not q:
|
if not q:
|
||||||
@@ -244,7 +244,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/validate")
|
@bp.get("/examples/api/validate")
|
||||||
async def api_validate():
|
async def api_validate():
|
||||||
from shared.sx.helpers import sx_response
|
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()
|
email = request.args.get("email", "").strip()
|
||||||
if not email:
|
if not email:
|
||||||
sx_src = '(~validation-error :message "Email is required")'
|
sx_src = '(~validation-error :message "Email is required")'
|
||||||
@@ -282,7 +282,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/values")
|
@bp.get("/examples/api/values")
|
||||||
async def api_values():
|
async def api_values():
|
||||||
from shared.sx.helpers import sx_response
|
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
|
from content.pages import VALUE_SELECT_DATA
|
||||||
cat = request.args.get("category", "")
|
cat = request.args.get("category", "")
|
||||||
items = VALUE_SELECT_DATA.get(cat, [])
|
items = VALUE_SELECT_DATA.get(cat, [])
|
||||||
@@ -300,7 +300,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.post("/examples/api/reset-submit")
|
@bp.post("/examples/api/reset-submit")
|
||||||
async def api_reset_submit():
|
async def api_reset_submit():
|
||||||
from shared.sx.helpers import sx_response
|
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
|
form = await request.form
|
||||||
msg = form.get("message", "").strip() or "(empty)"
|
msg = form.get("message", "").strip() or "(empty)"
|
||||||
escaped = msg.replace('"', '\\"')
|
escaped = msg.replace('"', '\\"')
|
||||||
@@ -326,7 +326,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/editrow/<row_id>")
|
@bp.get("/examples/api/editrow/<row_id>")
|
||||||
async def api_editrow_form(row_id: str):
|
async def api_editrow_form(row_id: str):
|
||||||
from shared.sx.helpers import sx_response
|
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()
|
rows = _get_edit_rows()
|
||||||
row = rows.get(row_id, {"id": row_id, "name": "", "price": "0", "stock": "0"})
|
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"]}"'
|
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>")
|
@bp.post("/examples/api/editrow/<row_id>")
|
||||||
async def api_editrow_save(row_id: str):
|
async def api_editrow_save(row_id: str):
|
||||||
from shared.sx.helpers import sx_response
|
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
|
form = await request.form
|
||||||
rows = _get_edit_rows()
|
rows = _get_edit_rows()
|
||||||
rows[row_id] = {
|
rows[row_id] = {
|
||||||
@@ -362,7 +362,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/editrow/<row_id>/cancel")
|
@bp.get("/examples/api/editrow/<row_id>/cancel")
|
||||||
async def api_editrow_cancel(row_id: str):
|
async def api_editrow_cancel(row_id: str):
|
||||||
from shared.sx.helpers import sx_response
|
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()
|
rows = _get_edit_rows()
|
||||||
row = rows.get(row_id, {"id": row_id, "name": "", "price": "0", "stock": "0"})
|
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"]}"'
|
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")
|
@bp.post("/examples/api/bulk")
|
||||||
async def api_bulk():
|
async def api_bulk():
|
||||||
from shared.sx.helpers import sx_response
|
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")
|
action = request.args.get("action", "activate")
|
||||||
form = await request.form
|
form = await request.form
|
||||||
ids = form.getlist("ids")
|
ids = form.getlist("ids")
|
||||||
@@ -418,7 +418,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.post("/examples/api/swap-log")
|
@bp.post("/examples/api/swap-log")
|
||||||
async def api_swap_log():
|
async def api_swap_log():
|
||||||
from shared.sx.helpers import sx_response
|
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")
|
mode = request.args.get("mode", "beforeend")
|
||||||
_swap_count["n"] += 1
|
_swap_count["n"] += 1
|
||||||
now = datetime.now().strftime("%H:%M:%S")
|
now = datetime.now().strftime("%H:%M:%S")
|
||||||
@@ -438,7 +438,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/dashboard")
|
@bp.get("/examples/api/dashboard")
|
||||||
async def api_dashboard():
|
async def api_dashboard():
|
||||||
from shared.sx.helpers import sx_response
|
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")
|
now = datetime.now().strftime("%H:%M:%S")
|
||||||
sx_src = (
|
sx_src = (
|
||||||
f'(<>'
|
f'(<>'
|
||||||
@@ -483,7 +483,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/tabs/<tab>")
|
@bp.get("/examples/api/tabs/<tab>")
|
||||||
async def api_tabs(tab: str):
|
async def api_tabs(tab: str):
|
||||||
from shared.sx.helpers import sx_response
|
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"])
|
sx_src = _TAB_CONTENT.get(tab, _TAB_CONTENT["tab1"])
|
||||||
buttons = []
|
buttons = []
|
||||||
for t, label in [("tab1", "Overview"), ("tab2", "Details"), ("tab3", "History")]:
|
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")
|
@bp.get("/examples/api/animate")
|
||||||
async def api_animate():
|
async def api_animate():
|
||||||
from shared.sx.helpers import sx_response
|
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"]
|
colors = ["bg-violet-100", "bg-emerald-100", "bg-blue-100", "bg-amber-100", "bg-rose-100"]
|
||||||
color = random.choice(colors)
|
color = random.choice(colors)
|
||||||
now = datetime.now().strftime("%H:%M:%S")
|
now = datetime.now().strftime("%H:%M:%S")
|
||||||
@@ -519,7 +519,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/dialog")
|
@bp.get("/examples/api/dialog")
|
||||||
async def api_dialog():
|
async def api_dialog():
|
||||||
from shared.sx.helpers import sx_response
|
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.")'
|
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")
|
comp_text = _component_source_text("dialog-modal")
|
||||||
wire_text = _full_wire_text(sx_src, "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")
|
@bp.get("/examples/api/dialog/close")
|
||||||
async def api_dialog_close():
|
async def api_dialog_close():
|
||||||
from shared.sx.helpers import sx_response
|
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)")
|
wire_text = _full_wire_text("(empty — dialog closed)")
|
||||||
oob_wire = _oob_code("dialog-wire", wire_text)
|
oob_wire = _oob_code("dialog-wire", wire_text)
|
||||||
return sx_response(f'(<> {oob_wire})')
|
return sx_response(f'(<> {oob_wire})')
|
||||||
@@ -546,7 +546,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/keyboard")
|
@bp.get("/examples/api/keyboard")
|
||||||
async def api_keyboard():
|
async def api_keyboard():
|
||||||
from shared.sx.helpers import sx_response
|
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", "")
|
key = request.args.get("key", "")
|
||||||
action = _KBD_ACTIONS.get(key, f"Unknown key: {key}")
|
action = _KBD_ACTIONS.get(key, f"Unknown key: {key}")
|
||||||
escaped_action = action.replace('"', '\\"')
|
escaped_action = action.replace('"', '\\"')
|
||||||
@@ -571,7 +571,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/putpatch/edit-all")
|
@bp.get("/examples/api/putpatch/edit-all")
|
||||||
async def api_pp_edit_all():
|
async def api_pp_edit_all():
|
||||||
from shared.sx.helpers import sx_response
|
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()
|
p = _get_profile()
|
||||||
sx_src = f'(~pp-form-full :name "{p["name"]}" :email "{p["email"]}" :role "{p["role"]}")'
|
sx_src = f'(~pp-form-full :name "{p["name"]}" :email "{p["email"]}" :role "{p["role"]}")'
|
||||||
comp_text = _component_source_text("pp-form-full")
|
comp_text = _component_source_text("pp-form-full")
|
||||||
@@ -584,7 +584,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.put("/examples/api/putpatch")
|
@bp.put("/examples/api/putpatch")
|
||||||
async def api_pp_put():
|
async def api_pp_put():
|
||||||
from shared.sx.helpers import sx_response
|
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
|
form = await request.form
|
||||||
p = _get_profile()
|
p = _get_profile()
|
||||||
p["name"] = form.get("name", p["name"])
|
p["name"] = form.get("name", p["name"])
|
||||||
@@ -600,7 +600,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/putpatch/cancel")
|
@bp.get("/examples/api/putpatch/cancel")
|
||||||
async def api_pp_cancel():
|
async def api_pp_cancel():
|
||||||
from shared.sx.helpers import sx_response
|
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()
|
p = _get_profile()
|
||||||
sx_src = f'(~pp-view :name "{p["name"]}" :email "{p["email"]}" :role "{p["role"]}")'
|
sx_src = f'(~pp-view :name "{p["name"]}" :email "{p["email"]}" :role "{p["role"]}")'
|
||||||
comp_text = _component_source_text("pp-view")
|
comp_text = _component_source_text("pp-view")
|
||||||
@@ -615,7 +615,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.post("/examples/api/json-echo")
|
@bp.post("/examples/api/json-echo")
|
||||||
async def api_json_echo():
|
async def api_json_echo():
|
||||||
from shared.sx.helpers import sx_response
|
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 {}
|
data = await request.get_json(silent=True) or {}
|
||||||
body = json.dumps(data, indent=2)
|
body = json.dumps(data, indent=2)
|
||||||
ct = request.content_type or "unknown"
|
ct = request.content_type or "unknown"
|
||||||
@@ -633,7 +633,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/echo-vals")
|
@bp.get("/examples/api/echo-vals")
|
||||||
async def api_echo_vals():
|
async def api_echo_vals():
|
||||||
from shared.sx.helpers import sx_response
|
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()
|
vals = {k: v for k, v in request.args.items()
|
||||||
if k not in ("_", "sx-request")}
|
if k not in ("_", "sx-request")}
|
||||||
items_sx = " ".join(f'"{k}: {v}"' for k, v in vals.items())
|
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")
|
@bp.get("/examples/api/echo-headers")
|
||||||
async def api_echo_headers():
|
async def api_echo_headers():
|
||||||
from shared.sx.helpers import sx_response
|
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-")}
|
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())
|
items_sx = " ".join(f'"{k}: {v}"' for k, v in custom.items())
|
||||||
sx_src = f'(~echo-result :label "headers" :items (list {items_sx}))'
|
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")
|
@bp.get("/examples/api/slow")
|
||||||
async def api_slow():
|
async def api_slow():
|
||||||
from shared.sx.helpers import sx_response
|
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)
|
await asyncio.sleep(2)
|
||||||
now = datetime.now().strftime("%H:%M:%S")
|
now = datetime.now().strftime("%H:%M:%S")
|
||||||
sx_src = f'(~loading-result :time "{now}")'
|
sx_src = f'(~loading-result :time "{now}")'
|
||||||
@@ -677,7 +677,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/slow-search")
|
@bp.get("/examples/api/slow-search")
|
||||||
async def api_slow_search():
|
async def api_slow_search():
|
||||||
from shared.sx.helpers import sx_response
|
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)
|
delay = random.uniform(0.5, 2.0)
|
||||||
await asyncio.sleep(delay)
|
await asyncio.sleep(delay)
|
||||||
q = request.args.get("q", "").strip()
|
q = request.args.get("q", "").strip()
|
||||||
@@ -697,7 +697,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
@bp.get("/examples/api/flaky")
|
@bp.get("/examples/api/flaky")
|
||||||
async def api_flaky():
|
async def api_flaky():
|
||||||
from shared.sx.helpers import sx_response
|
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
|
_flaky["n"] += 1
|
||||||
n = _flaky["n"]
|
n = _flaky["n"]
|
||||||
if n % 3 != 0:
|
if n % 3 != 0:
|
||||||
@@ -715,7 +715,7 @@ def register(url_prefix: str = "/") -> Blueprint:
|
|||||||
|
|
||||||
def _ref_wire(wire_id: str, sx_src: str) -> str:
|
def _ref_wire(wire_id: str, sx_src: str) -> str:
|
||||||
"""Build OOB swap showing the wire response text."""
|
"""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)
|
return _oob_code(f"ref-wire-{wire_id}", sx_src)
|
||||||
|
|
||||||
@bp.get("/reference/api/time")
|
@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