getting closer to full port of web app starter

This commit is contained in:
udo
2026-04-19 19:09:21 +00:00
parent 2b5586d7df
commit d1167aec3b
96 changed files with 3395 additions and 1027 deletions
@@ -7,9 +7,9 @@ COMPONENT(Request& context)
DTree user = users.current();
bool signed_in = user["email"].to_string() != "";
String theme_key = context.cfg.get_by_path("theme/key").to_string();
String wrapper_class = theme_key == "localfirst" ? "admin-account-card" : "nav-account nav-menu";
String links_class = theme_key == "localfirst" ? "admin-account-links" : "";
String name_class = theme_key == "localfirst" ? "admin-account-name" : "account-name";
String wrapper_class = first(context.call["wrapper_class"].to_string(), theme_key == "localfirst" ? "admin-account-card" : "nav-account nav-menu");
String links_class = first(context.call["links_wrapper_class"].to_string(), theme_key == "localfirst" ? "admin-account-links" : "");
String name_class = first(context.call["name_class"].to_string(), theme_key == "localfirst" ? "admin-account-name" : "account-name");
<>
<div class="<?= wrapper_class ?>">
@@ -3,18 +3,19 @@
COMPONENT(Request& context)
{
starter_boot(context);
if(context.var["starter"]["embed_mode"].to_string() != "")
bool embed_mode = starter_page_embed_mode(context);
if(embed_mode)
return;
String text = first(context.cfg.get_by_path("theme/footer_text").to_string(), context.cfg.get_by_path("site/name").to_string());
String inner_class = context.cfg.get_by_path("theme/key").to_string() == "portal-light" ? "footer-inner" : "";
String inner_class = first(context.call["inner_class"].to_string(), context.cfg.get_by_path("theme/key").to_string() == "portal-light" ? "footer-inner" : "");
<>
<footer>
<? if(inner_class != "") { ?>
<div class="<?= inner_class ?>"><p><?= text ?></p></div>
<? } else { ?>
<div style="max-width: 1200px; margin: 0 auto; padding: 0 1rem;"><p><?= text ?></p></div>
<div><p><?= text ?></p></div>
<? } ?>
</footer>
</>
@@ -0,0 +1,18 @@
#load "../../lib/app.uce"
COMPONENT(Request& context)
{
starter_boot(context);
if(starter_page_embed_mode(context))
return;
String cookie_value = context.call["cookie_consent"].to_string();
bool cookie_consent = !(cookie_value == "0" || cookie_value == "false" || cookie_value == "FALSE" || cookie_value == "no" || cookie_value == "NO");
<>
<?: component("../example/theme-switcher", context) ?>
<? if(cookie_consent) { ?>
<?: component("../basic/cookie-consent", context) ?>
<? } ?>
</>
}
@@ -0,0 +1,22 @@
#load "../../lib/app.uce"
COMPONENT(Request& context)
{
starter_boot(context);
String title = first(context.var["starter"]["page_title"].to_string(), context.cfg.get_by_path("site/default_page_title").to_string());
String description = first(context.cfg.get_by_path("theme/meta_description").to_string(), "UCE starter example");
String theme_color = first(context.cfg.get_by_path("theme/theme_color").to_string(), "#0f172a");
String icon = starter_asset_url(context.cfg.get_by_path("theme/path").to_string() + "icon.png", context);
<>
<meta charset="utf-8">
<title><?= title + " | " + context.cfg.get_by_path("site/name").to_string() ?></title>
<meta name="description" content="<?= description ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="<?= theme_color ?>">
<link rel="apple-touch-icon" href="<?= icon ?>" />
<link rel="icon" type="image/png" sizes="32x32" href="<?= icon ?>" />
<? starter_render_registered_css(context); ?>
<? starter_render_registered_js(context); ?>
</>
}
@@ -3,115 +3,18 @@
COMPONENT(Request& context)
{
starter_boot(context);
String page_type = first(context.var["starter"]["page_type"].to_string(), "html");
if(context.flags.status >= 300 && context.flags.status < 400)
return;
if(page_type == "blank")
{
print(context.call["main_html"].to_string());
return;
}
if(page_type == "json")
{
context.header["Content-Type"] = "application/json";
context.header["Cache-Control"] = "no-cache, no-store, must-revalidate";
if(context.var["starter"]["json"].get_type_name() == "array")
{
print(json_encode(context.var["starter"]["json"]));
}
else
{
print(context.call["main_html"].to_string());
}
return;
}
String theme_key = context.cfg.get_by_path("theme/key").to_string();
bool embed_mode = context.var["starter"]["embed_mode"].to_string() == "1";
String body_class = embed_mode ? "embed-mode" : "";
if(theme_key == "portal-dark")
body_class = "portal-theme portal-dark-theme dark-theme" + String(embed_mode ? " embed-mode" : "");
else if(theme_key == "portal-light")
body_class = "portal-theme portal-light-theme" + String(embed_mode ? " embed-mode" : "");
else if(theme_key == "localfirst")
body_class = "admin-page localfirst-theme dark-theme" + String(embed_mode ? " embed-mode" : "");
else if(theme_key == "retro-gaming")
body_class = embed_mode ? "embed-mode" : "";
<>
<!doctype html>
<html class="<?= starter_html_class(context) ?>" lang="en" data-theme-key="<?= context.cfg.get_by_path("theme/key").to_string() ?>">
<head>
<? render_component(":HEAD", context.call, context); ?>
</head>
<body<?: body_class != "" ? " class=\"" + html_escape(body_class) + "\"" : "" ?>>
<? if(theme_key == "retro-gaming") { ?><div class="retro-stars"></div><? } ?>
<? if(!embed_mode) { ?>
<?: component("../example/theme-switcher", context) ?>
<? if(theme_key != "localfirst") { ?>
<?: component("../basic/cookie-consent", context) ?>
<? } ?>
<? } ?>
<? if(theme_key == "localfirst") { ?>
<div class="admin-shell">
<nav class="admin-nav">
<div class="admin-nav-header">
<a class="admin-nav-title" href="<?= starter_link("", context) ?>">
<img class="admin-nav-logo-img" src="<?= starter_asset_url("themes/localfirst/img/local_first_logo.png", context) ?>" alt="<?= context.cfg.get_by_path("site/name").to_string() ?>" />
</a>
</div>
<? context.cfg.get_by_path("menu").each([&](DTree menu_item, String menu_key) {
if(menu_item["hidden"].to_string() == "1")
return;
String current_path = context.var["starter"]["route"]["l_path"].to_string();
bool active = menu_key != "" && (current_path == menu_key || current_path.rfind(menu_key + "/", 0) == 0);
?><a class="admin-nav-item<?= active ? " active" : "" ?>" href="<?= starter_menu_href(menu_key, menu_item, context) ?>"><?= menu_item["title"].to_string() ?></a><?
}); ?>
</nav>
<div class="admin-main">
<? if(!embed_mode) { ?>
<div class="admin-toolbar">
<?: component("account_links", context) ?>
</div>
<? } ?>
<div id="content" class="admin-content">
<?: context.call["main_html"].to_string() ?>
</div>
</div>
</div>
<? } else { ?>
<?: component("standard_nav", context) ?>
<div id="content"<?: embed_mode ? " class=\"embed-content\"" : "" ?>>
<?: context.call["main_html"].to_string() ?>
</div>
<?: component("footer", context) ?>
<? } ?>
</body>
</html>
</>
if(context.call["main_html"].to_string() != "")
context.var["starter"]["fragments"]["main"] = context.call["main_html"];
if(context.call["json"].get_type_name() == "array")
context.var["starter"]["json"] = context.call["json"];
if(context.call["page_type"].to_string() != "")
context.var["starter"]["page_type"] = context.call["page_type"];
if(context.call["embed_mode"].to_string() != "")
context.var["starter"]["embed_mode"] = context.call["embed_mode"];
starter_render_page(context);
}
COMPONENT:HEAD(Request& context)
{
starter_boot(context);
String title = first(context.var["starter"]["page_title"].to_string(), context.cfg.get_by_path("site/default_page_title").to_string());
String description = first(context.cfg.get_by_path("theme/meta_description").to_string(), "UCE starter example");
String theme_color = first(context.cfg.get_by_path("theme/theme_color").to_string(), "#0f172a");
String icon = starter_asset_url(context.cfg.get_by_path("theme/path").to_string() + "icon.png", context);
<>
<meta charset="utf-8">
<title><?= title + " | " + context.cfg.get_by_path("site/name").to_string() ?></title>
<meta name="description" content="<?= description ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="<?= theme_color ?>">
<link rel="apple-touch-icon" href="<?= icon ?>" />
<link rel="icon" type="image/png" sizes="32x32" href="<?= icon ?>" />
<? starter_render_registered_css(context); ?>
<? starter_render_registered_js(context); ?>
</>
print(component("head", context.call, context));
}
@@ -3,9 +3,20 @@
COMPONENT(Request& context)
{
starter_boot(context);
String nav_class = context.call["nav_class"].to_string();
if(nav_class == "" && (context.cfg.get_by_path("theme/key").to_string() == "portal-dark" || context.cfg.get_by_path("theme/key").to_string() == "dark" || context.cfg.get_by_path("theme/key").to_string() == "retro-gaming"))
nav_class = "nav-shell";
DTree account_props;
if(context.call["account_wrapper_class"].to_string() != "")
account_props["wrapper_class"] = context.call["account_wrapper_class"];
if(context.call["links_wrapper_class"].to_string() != "")
account_props["links_wrapper_class"] = context.call["links_wrapper_class"];
if(context.call["name_class"].to_string() != "")
account_props["name_class"] = context.call["name_class"];
<>
<nav<?: context.cfg.get_by_path("theme/key").to_string() == "portal-dark" || context.cfg.get_by_path("theme/key").to_string() == "dark" || context.cfg.get_by_path("theme/key").to_string() == "retro-gaming" ? " class=\"nav-shell\"" : "" ?>>
<nav<?: nav_class != "" ? " class=\"" + html_escape(nav_class) + "\"" : "" ?>>
<div class="nav-menu">
<a href="<?= starter_link("", context) ?>"><?= context.cfg.get_by_path("site/name").to_string() ?></a>
<? context.cfg.get_by_path("menu").each([&](DTree menu_item, String menu_key) {
@@ -14,7 +25,7 @@ COMPONENT(Request& context)
?><a href="<?= starter_menu_href(menu_key, menu_item, context) ?>"><?= menu_item["title"].to_string() ?></a><?
}); ?>
</div>
<?: component("account_links", context) ?>
<?: component("account_links", account_props, context) ?>
</nav>
</>
}