some cleanup

This commit is contained in:
udo
2026-04-28 12:10:07 +00:00
parent 223cf4c6e1
commit cd445f3c9b
224 changed files with 1558 additions and 38907 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ RENDER(Request& context)
{
DTree card_props;
card_props["title"] = "Component Example";
card_props["body"] = "This card body comes from context.call and is rendered through component().";
card_props["body"] = "This card body comes from context.props and is rendered through component().";
DTree named_props;
named_props["title"] = "Named Render Example";
+4 -4
View File
@@ -3,8 +3,8 @@ COMPONENT(Request& context)
{
<>
<section style="border:1px solid #ccc;padding:1em;margin:1em 0;">
<? component_render(":TITLE", context.call, context); ?>
<? component_render(":BODY", context.call, context); ?>
<? component_render(":TITLE", context.props, context); ?>
<? component_render(":BODY", context.props, context); ?>
</section>
</>
}
@@ -12,13 +12,13 @@ COMPONENT(Request& context)
COMPONENT:TITLE(Request& context)
{
<>
<h3><?= first(context.call["title"].to_string(), "Component Title") ?></h3>
<h3><?= first(context.props["title"].to_string(), "Component Title") ?></h3>
</>
}
COMPONENT:BODY(Request& context)
{
<>
<p><?= first(context.call["body"].to_string(), "Component Body") ?></p>
<p><?= first(context.props["body"].to_string(), "Component Body") ?></p>
</>
}
+2 -2
View File
@@ -1,10 +1,10 @@
COMPONENT(Request& context)
{
String lang = first(context.call["lang"].to_string(), "plain");
String lang = first(context.props["lang"].to_string(), "plain");
<>
<section>
<p><strong>Code block:</strong> <?= lang ?></p>
<div><?: context.call["default_html"].to_string() ?></div>
<div><?: context.props["default_html"].to_string() ?></div>
</section>
</>
}
+3 -3
View File
@@ -1,15 +1,15 @@
COMPONENT(Request& context)
{
String title = first(
context.call["node"]["attrs"]["title"].to_string(),
context.call["argument"].to_string(),
context.props["node"]["attrs"]["title"].to_string(),
context.props["argument"].to_string(),
"Notice"
);
<>
<aside>
<p><strong><?= title ?></strong></p>
<div><?: context.call["children_html"].to_string() ?></div>
<div><?: context.props["children_html"].to_string() ?></div>
</aside>
</>
}
-2
View File
@@ -27,8 +27,6 @@ RENDER(Request& context)
<a class="docs-link" href="../doc/index.uce">API Docs &rarr;</a>
</h1>
<div class="test-grid">
<div class="grid-heading">Coverage</div>
<? render_card("../tests/index.uce", "Site Tests", "Grouped coverage pages for broad runtime and API validation"); ?>
<div class="grid-heading">Basics</div>
<? render_card("hello.uce", "Hello World", "Basic output and server time"); ?>
+7 -6
View File
@@ -13,9 +13,9 @@ DTree chat_event(Request& context, String type, String body)
DTree event;
event["type"] = type;
event["body"] = body;
event["connection_id"] = ws_connection_id();
event["scope"] = first(context.params["DOCUMENT_URI"], ws_scope());
event["online"] = (f64)ws_connection_count();
event["connection_id"] = context.params["WS_CONNECTION_ID"];
event["scope"] = first(context.params["WS_DOCUMENT_URI"], context.params["DOCUMENT_URI"]);
event["online"] = float_val(first(context.params["WS_CONNECTION_COUNT"], "0"));
event["at"] = time_format_utc("%H:%M:%S");
event["name"] = context.connection["name"].to_string();
event["message_count"] = context.connection["message_count"];
@@ -37,6 +37,7 @@ RENDER(Request& context)
<pre>Page scope: <?= ws_url ?>
Connected right now: <span id="online-count"><?= online ?></span>
Status: <span id="status">Connecting...</span></pre>
<p>This demo uses <code>context.in</code> for the current payload, <code>context.params["WS_..."]</code> for message metadata, and <code>context.connection</code> for per-client state.</p>
<form id="chat-form" action="?" method="post">
<div>
@@ -152,13 +153,13 @@ WS(Request& context)
if(ws_is_binary())
{
ws_send_to(
ws_connection_id(),
context.params["WS_CONNECTION_ID"],
json_encode(chat_event(context, "notice", "Binary messages are not handled by this demo"))
);
return;
}
DTree payload = json_decode(ws_message());
DTree payload = json_decode(context.in);
String type = clean_chat_field(payload["type"].to_string(), 24);
String name = clean_chat_field(payload["name"].to_string(), 32);
String body = clean_chat_field(payload["body"].to_string(), 500);
@@ -190,6 +191,6 @@ WS(Request& context)
if(type != "")
{
context.connection["last_type"] = type;
ws_send_to(ws_connection_id(), json_encode(chat_event(context, "notice", "Unknown message type: " + type)));
ws_send_to(context.params["WS_CONNECTION_ID"], json_encode(chat_event(context, "notice", "Unknown message type: " + type)));
}
}