I think I need to change the documentation format
This commit is contained in:
+46
-7
@@ -18,7 +18,7 @@ RENDER(Request& context)
|
||||
t.set("String test");
|
||||
print("String: ", t.to_string(), "\n");
|
||||
|
||||
t.set(true);
|
||||
t.set_bool(true);
|
||||
print("bool: ", t.to_string(), "\n");
|
||||
|
||||
t.set(1234.5678);
|
||||
@@ -29,16 +29,55 @@ RENDER(Request& context)
|
||||
|
||||
?></pre>
|
||||
|
||||
<h2>Typed Conversions</h2>
|
||||
|
||||
<pre><?
|
||||
|
||||
DTree scalar_text;
|
||||
scalar_text = "42.75";
|
||||
print("text -> f64: ", scalar_text.to_f64(), "\n");
|
||||
print("text -> u64: ", scalar_text.to_u64(), "\n");
|
||||
print("text -> s64: ", scalar_text.to_s64(), "\n");
|
||||
|
||||
DTree bool_text;
|
||||
bool_text = "yes";
|
||||
print("yes -> bool: ", bool_text.to_bool() ? "true" : "false", "\n");
|
||||
|
||||
DTree single_value_map;
|
||||
single_value_map["value"] = "123";
|
||||
print("{value:123} -> u64: ", single_value_map.to_u64(), "\n");
|
||||
|
||||
DTree headers;
|
||||
headers["Content-Type"] = "text/plain";
|
||||
headers["X-Test"] = "123";
|
||||
print("map -> StringMap:\n", var_dump(headers.to_stringmap()), "\n");
|
||||
|
||||
?></pre>
|
||||
|
||||
<h2>Lookup Helpers</h2>
|
||||
|
||||
<pre><?
|
||||
|
||||
DTree lookup;
|
||||
print("has(user) before create: ", lookup.has("user") ? "true" : "false", "\n");
|
||||
print("key(user) before create: ", lookup.key("user") ? "present" : "missing", "\n");
|
||||
lookup.get_or_create("user")->set("Ada");
|
||||
print("has(user) after create: ", lookup.has("user") ? "true" : "false", "\n");
|
||||
if(DTree* user = lookup.key("user"))
|
||||
print("key(user) after create: ", user->to_string(), "\n");
|
||||
|
||||
?></pre>
|
||||
|
||||
<h2>Nested Tree</h2>
|
||||
|
||||
<pre><?
|
||||
|
||||
t.key("a")->set("valueA");
|
||||
t.key("b")->set("valueB");
|
||||
t.key("c")->key("c-d")->set("valueCD");
|
||||
t.key("c")->key("c-e")->set("valueCE");
|
||||
t.key("c")->key("c-f")->set(&t);
|
||||
t.key("g")->key("g-h")->key("h-i")->set("valueHI");
|
||||
t.get_or_create("a")->set("valueA");
|
||||
t.get_or_create("b")->set("valueB");
|
||||
t.get_or_create("c")->get_or_create("c-d")->set("valueCD");
|
||||
t.get_or_create("c")->get_or_create("c-e")->set("valueCE");
|
||||
t.get_or_create("c")->get_or_create("c-f")->set(&t);
|
||||
t.get_or_create("g")->get_or_create("g-h")->get_or_create("h-i")->set("valueHI");
|
||||
t["g"]["x"]["y1"] = "XYZ1";
|
||||
t["g"]["x"]["y2"] = &t;
|
||||
t["g"]["x"]["y3"] = time();
|
||||
|
||||
@@ -56,6 +56,7 @@ RENDER(Request& context)
|
||||
|
||||
<div class="grid-heading">Advanced</div>
|
||||
<? render_card("call_file.uce", "unit_call()", "Dynamic file inclusion"); ?>
|
||||
<? render_card("unit-browser.uce", "Unit Browser", "units_list(), unit_info(), unit_compile()"); ?>
|
||||
<? render_card("components.uce", "Components", "Reusable component system"); ?>
|
||||
<? render_card("markdown.uce", "Markdown", "Markdown parsing with components"); ?>
|
||||
<? render_card("script.uce", "Script", "UCE script integration"); ?>
|
||||
|
||||
+7
-7
@@ -15,13 +15,13 @@ RENDER(Request& context)
|
||||
|
||||
<pre style="white-space: pre-wrap"><?
|
||||
|
||||
t.key("a")->set("valueA");
|
||||
t.key("b")->set("valueB");
|
||||
t.key("c")->key("c-dt")->set_bool(true);
|
||||
t.key("c")->key("c-df")->set_bool(false);
|
||||
t.key("c")->key("c-e")->set("valueCE");
|
||||
t.key("c")->key("c-f")->set(&t);
|
||||
t.key("g")->key("g-h")->key("h-i")->set("valueHI");
|
||||
t.get_or_create("a")->set("valueA");
|
||||
t.get_or_create("b")->set("valueB");
|
||||
t.get_or_create("c")->get_or_create("c-dt")->set_bool(true);
|
||||
t.get_or_create("c")->get_or_create("c-df")->set_bool(false);
|
||||
t.get_or_create("c")->get_or_create("c-e")->set("valueCE");
|
||||
t.get_or_create("c")->get_or_create("c-f")->set(&t);
|
||||
t.get_or_create("g")->get_or_create("g-h")->get_or_create("h-i")->set("valueHI");
|
||||
t["g"]["x"]["y1"] = "XYZ1";
|
||||
t["g"]["x"]["y2"] = &t;
|
||||
t["g"]["x"]["y3"] = time();
|
||||
|
||||
@@ -3,6 +3,7 @@ RENDER(Request& context)
|
||||
{
|
||||
|
||||
String raw = first(context.post["raw"], "today");
|
||||
u64 parsed = time_parse(raw);
|
||||
|
||||
<>
|
||||
<link rel="stylesheet" href='style.css'></link>
|
||||
@@ -21,7 +22,9 @@ RENDER(Request& context)
|
||||
</form>
|
||||
<pre><?
|
||||
|
||||
print(time_format_local("%Y-%m-%d %H:%M", time_parse(raw)));
|
||||
print("local: ", time_format_local("%Y-%m-%d %H:%M", parsed), "\n");
|
||||
print("relative: ", time_format_relative(parsed), "\n");
|
||||
print("delta: ", time_format_local("%deltaHh %deltaMm %deltaSs", parsed), "\n");
|
||||
|
||||
?></pre>
|
||||
<pre><?= var_dump(context.params) ?></pre>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
RENDER(Request& context)
|
||||
{
|
||||
auto p = compiler_load_shared_unit(context, "post.uce");
|
||||
auto p = compiler_load_shared_unit(&context, "post.uce");
|
||||
if(p)
|
||||
print(to_string(p));
|
||||
}
|
||||
|
||||
+247
-2
@@ -1,5 +1,33 @@
|
||||
/* UCE Test Suite — Theme
|
||||
Color palette: deep blue gradient · warm gold accents · frosted glass surfaces */
|
||||
@font-face {
|
||||
font-family: 'default_sans';
|
||||
src: url('../examples/uce-starter/themes/common/fonts/b612/b612-regular.ttf') format('truetype');
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'default_sans';
|
||||
src: url('../examples/uce-starter/themes/common/fonts/b612/b612-bold.ttf') format('truetype');
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'default_mono';
|
||||
src: url('../examples/uce-starter/themes/common/fonts/b612/b612-mono-regular.ttf') format('truetype');
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'default_mono';
|
||||
src: url('../examples/uce-starter/themes/common/fonts/b612/b612-mono-bold.ttf') format('truetype');
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
:root {
|
||||
--bg: #113399;
|
||||
@@ -19,8 +47,8 @@
|
||||
--border-strong: rgba(255, 255, 255, 0.14);
|
||||
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||
--shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
|
||||
--font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
||||
--font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
|
||||
--font-sans: 'default_sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
||||
--font-mono: 'default_mono', 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
|
||||
--radius: 10px;
|
||||
--radius-lg: 16px;
|
||||
--ease: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
@@ -382,6 +410,223 @@ section h2 {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* ── Unit Browser ── */
|
||||
|
||||
.unit-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.unit-toolbar p {
|
||||
margin: 0;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
|
||||
.unit-count {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.82rem;
|
||||
color: var(--text-dim);
|
||||
padding: 6px 10px;
|
||||
background: var(--bg-code);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.72rem;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg-code);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.status-ok {
|
||||
color: #9ff0b3;
|
||||
border-color: rgba(159, 240, 179, 0.25);
|
||||
background: rgba(38, 105, 58, 0.22);
|
||||
}
|
||||
|
||||
.status-warn {
|
||||
color: #ffd97a;
|
||||
border-color: rgba(255, 217, 122, 0.26);
|
||||
background: rgba(120, 88, 22, 0.25);
|
||||
}
|
||||
|
||||
.status-error {
|
||||
color: #ff9e9e;
|
||||
border-color: rgba(255, 158, 158, 0.3);
|
||||
background: rgba(122, 34, 34, 0.28);
|
||||
}
|
||||
|
||||
.status-muted {
|
||||
color: var(--text-dim);
|
||||
border-color: var(--border);
|
||||
background: var(--bg-code);
|
||||
}
|
||||
|
||||
.unit-browser-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
|
||||
gap: 18px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.unit-sidebar,
|
||||
.unit-detail-pane {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.unit-sidebar-header,
|
||||
.unit-detail-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.unit-sidebar-header h2,
|
||||
.unit-detail-pane h2,
|
||||
.unit-detail-header h3 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.unit-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.unit-list-item {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.unit-list-item:hover {
|
||||
text-decoration: none;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
.unit-list-item.is-selected {
|
||||
border-color: rgba(240, 196, 48, 0.32);
|
||||
background: rgba(240, 196, 48, 0.08);
|
||||
box-shadow: 0 0 0 1px rgba(240, 196, 48, 0.08), var(--shadow-sm);
|
||||
}
|
||||
|
||||
.unit-list-title-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.unit-list-title-row strong {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.78rem;
|
||||
color: var(--text);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.unit-list-path {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.72rem;
|
||||
color: var(--text-muted);
|
||||
word-break: break-word;
|
||||
margin-bottom: 6px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.unit-list-meta {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
font-size: 0.74rem;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
|
||||
.unit-list-meta span {
|
||||
padding: 2px 6px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
.unit-list-error {
|
||||
margin-top: 8px;
|
||||
font-size: 0.74rem;
|
||||
color: #ffb7b7;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.unit-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.unit-actions a {
|
||||
font-size: 0.82rem;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.unit-detail-path {
|
||||
margin: 6px 0 0;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
|
||||
.detail-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.detail-card {
|
||||
padding: 16px 18px;
|
||||
background: var(--bg-code);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.detail-card strong {
|
||||
display: block;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.74rem;
|
||||
letter-spacing: 0.05em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.detail-card span,
|
||||
.detail-card code {
|
||||
font-size: 0.88rem;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
@media (max-width: 920px) {
|
||||
.unit-browser-layout {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.unit-sidebar-header,
|
||||
.unit-detail-header {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Scrollbar ── */
|
||||
|
||||
::-webkit-scrollbar {
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
String unit_query(String selected_path, String compile_path = "")
|
||||
{
|
||||
String result = "?";
|
||||
if(selected_path != "")
|
||||
result += "selected=" + uri_encode(selected_path);
|
||||
if(compile_path != "")
|
||||
{
|
||||
if(result.length() > 1)
|
||||
result += "&";
|
||||
result += "compile=" + uri_encode(compile_path);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
String unit_status_class(String compile_status, String error_status)
|
||||
{
|
||||
if(trim(error_status) != "")
|
||||
return("status-error");
|
||||
if(compile_status == "loaded" || compile_status == "compiled")
|
||||
return("status-ok");
|
||||
if(compile_status == "stale")
|
||||
return("status-warn");
|
||||
if(compile_status == "missing_source")
|
||||
return("status-error");
|
||||
return("status-muted");
|
||||
}
|
||||
|
||||
String unit_flag_label(DTree value)
|
||||
{
|
||||
return(value.to_string() == "(true)" ? "✅" : "❌");
|
||||
}
|
||||
|
||||
RENDER(Request& context)
|
||||
{
|
||||
String compile_target = first(context.get["compile"], "");
|
||||
String selected_path = first(context.get["selected"], "");
|
||||
String compile_message = "";
|
||||
String compile_message_class = "status-muted";
|
||||
|
||||
if(compile_target != "")
|
||||
{
|
||||
bool compile_ok = unit_compile(compile_target);
|
||||
selected_path = compile_target;
|
||||
compile_message = (compile_ok ? "Compile succeeded for " : "Compile failed for ") + compile_target;
|
||||
compile_message_class = compile_ok ? "status-ok" : "status-error";
|
||||
}
|
||||
|
||||
auto unit_paths = units_list();
|
||||
if(selected_path == "" && unit_paths.size() > 0)
|
||||
selected_path = unit_paths.front();
|
||||
|
||||
DTree selected_info = unit_info(selected_path);
|
||||
String selected_compile_status = selected_info["compile_status"].to_string();
|
||||
String selected_error_status = selected_info["error_status"].to_string();
|
||||
String selected_status_class = unit_status_class(selected_compile_status, selected_error_status);
|
||||
String selected_export_count = std::to_string(selected_info["exports"]._map.size());
|
||||
String selected_compile_link = unit_query(selected_path, selected_path);
|
||||
|
||||
<><html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
|
||||
<link rel="stylesheet" href='style.css?v=<?= time() ?>'></link>
|
||||
<title>UCE Test: Unit Browser</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
<a href="index.uce">UCE Test</a>:
|
||||
Unit Browser
|
||||
</h1>
|
||||
|
||||
<? if(compile_message != "") { ?>
|
||||
<section>
|
||||
<p><span class="status-badge <?= compile_message_class ?>"><?= compile_message ?></span></p>
|
||||
</section>
|
||||
<? } ?>
|
||||
|
||||
<section>
|
||||
<div class="unit-browser-layout">
|
||||
<aside class="unit-sidebar">
|
||||
<div class="unit-sidebar-header">
|
||||
<h2>Units</h2>
|
||||
<span class="unit-count"><?= std::to_string(unit_paths.size()) ?> total</span>
|
||||
</div>
|
||||
<div class="unit-list">
|
||||
<?
|
||||
for(auto& unit_path : unit_paths)
|
||||
{
|
||||
auto info = unit_info(unit_path);
|
||||
String compile_status = info["compile_status"].to_string();
|
||||
String error_status = info["error_status"].to_string();
|
||||
String status_class = unit_status_class(compile_status, error_status);
|
||||
String select_link = unit_query(unit_path);
|
||||
String title = first(info["src_file_name"].to_string(), unit_path);
|
||||
String meta_line = std::to_string(info["exports"]._map.size()) + " exports";
|
||||
bool is_selected = (selected_path == unit_path);
|
||||
?>
|
||||
<a class="unit-list-item <?= is_selected ? "is-selected" : "" ?>" href="<?= select_link ?>">
|
||||
<div class="unit-list-title-row" title="<?= unit_path ?>">
|
||||
<strong><?= title ?></strong>
|
||||
<span class="status-badge <?= status_class ?>"><?= compile_status ?></span>
|
||||
</div>
|
||||
|
||||
<? if(trim(error_status) != "") { ?>
|
||||
<div class="unit-list-error"><?= error_status ?></div>
|
||||
<? } ?>
|
||||
</a>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div class="unit-detail-pane">
|
||||
<h2>Unit Info</h2>
|
||||
<? if(selected_info["path"].to_string() == "") { ?>
|
||||
<p>No unit metadata is available for the current selection.</p>
|
||||
<? } else { ?>
|
||||
<div class="unit-detail-header">
|
||||
<div>
|
||||
<h3><?= first(selected_info["src_file_name"].to_string(), selected_info["path"].to_string()) ?></h3>
|
||||
<p class="unit-detail-path"><code><?= selected_info["path"].to_string() ?></code></p>
|
||||
</div>
|
||||
<div class="unit-actions">
|
||||
<span class="status-badge <?= selected_status_class ?>"><?= selected_compile_status ?></span>
|
||||
<a href="<?= selected_compile_link ?>">compile</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-grid">
|
||||
<div class="detail-card">
|
||||
<strong>Error Status</strong>
|
||||
<span><?= trim(selected_error_status) != "" ? selected_error_status : "none" ?></span>
|
||||
</div>
|
||||
<div class="detail-card">
|
||||
<strong>Exports</strong>
|
||||
<span><?= selected_export_count ?></span>
|
||||
</div>
|
||||
<div class="detail-card">
|
||||
<strong>Filesystem</strong>
|
||||
<span>source <?= unit_flag_label(selected_info["source_exists"]) ?>, compiled <?= unit_flag_label(selected_info["compiled_exists"]) ?>, metadata <?= unit_flag_label(selected_info["metadata_exists"]) ?></span>
|
||||
</div>
|
||||
<div class="detail-card">
|
||||
<strong>Runtime Flags</strong>
|
||||
<span>loaded <?= unit_flag_label(selected_info["loaded"]) ?>, stale <?= unit_flag_label(selected_info["stale"]) ?>, current <?= unit_flag_label(selected_info["current_unit"]) ?></span>
|
||||
</div>
|
||||
<div class="detail-card">
|
||||
<strong>Artifacts</strong>
|
||||
<code><?= selected_info["so_name"].to_string() ?></code>
|
||||
</div>
|
||||
<div class="detail-card">
|
||||
<strong>Timestamps</strong>
|
||||
<span>Source file: <?= time_format_relative(selected_info["source_mtime"].to_u64()) ?><br>
|
||||
Binary: <?= time_format_relative(selected_info["compiled_mtime"].to_u64()) ?><br>
|
||||
Meta info: <?= time_format_relative(selected_info["metadata_mtime"].to_u64()) ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<details open>
|
||||
<summary><code>unit_info()</code> payload</summary>
|
||||
<pre><?= var_dump(selected_info) ?></pre>
|
||||
</details>
|
||||
<? } ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html></>
|
||||
}
|
||||
Reference in New Issue
Block a user