trying to port web app starter from PHP
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#load "../../lib/app.uce"
|
||||
|
||||
RENDER(Request& context)
|
||||
{
|
||||
starter_boot(context);
|
||||
DTree user = starter_current_user(context);
|
||||
bool signed_in = user["email"].to_string() != "";
|
||||
String wrapper_class = starter_theme_value("key", context) == "localfirst" ? "admin-account-card" : "nav-account nav-menu";
|
||||
String links_class = starter_theme_value("key", context) == "localfirst" ? "admin-account-links" : "";
|
||||
String name_class = starter_theme_value("key", context) == "localfirst" ? "admin-account-name" : "account-name";
|
||||
|
||||
<>
|
||||
<div class="<?= wrapper_class ?>">
|
||||
<? if(signed_in) { ?>
|
||||
<span class="<?= name_class ?>"><?= first(user["username"].to_string(), user["email"].to_string(), "Account") ?></span>
|
||||
<? if(links_class != "") { ?><div class="<?= links_class ?>"><? } ?>
|
||||
<a href="<?= starter_link("account/profile", context) ?>">Profile</a>
|
||||
<a href="<?= starter_link("account/logout", context) ?>">Logout</a>
|
||||
<? if(links_class != "") { ?></div><? } ?>
|
||||
<? } else { ?>
|
||||
<? if(links_class != "") { ?><div class="<?= links_class ?>"><? } ?>
|
||||
<a href="<?= starter_link("account/login", context) ?>">Login</a>
|
||||
<? if(starter_cfg("users/enable_signup", context).to_string() != "") { ?>
|
||||
<a href="<?= starter_link("account/register", context) ?>">Register</a>
|
||||
<? } ?>
|
||||
<? if(links_class != "") { ?></div><? } ?>
|
||||
<? } ?>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#load "../../lib/app.uce"
|
||||
|
||||
RENDER(Request& context)
|
||||
{
|
||||
starter_boot(context);
|
||||
if(context.var["starter"]["embed_mode"].to_string() != "")
|
||||
return;
|
||||
|
||||
String text = first(starter_theme_value("footer_text", context), starter_cfg_string("site/name", context));
|
||||
String inner_class = starter_theme_value("key", context) == "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>
|
||||
<? } ?>
|
||||
</footer>
|
||||
</>
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
#load "../../lib/app.uce"
|
||||
|
||||
RENDER(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 = starter_theme_value("key", context);
|
||||
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="<?= starter_theme_value("key", context) ?>">
|
||||
<head>
|
||||
<? render_component("page_shell: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="<?= starter_cfg_string("site/name", context) ?>" />
|
||||
</a>
|
||||
</div>
|
||||
<? starter_cfg("menu", context).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>
|
||||
</>
|
||||
}
|
||||
|
||||
RENDER:HEAD(Request& context)
|
||||
{
|
||||
starter_boot(context);
|
||||
String title = first(context.var["starter"]["page_title"].to_string(), starter_cfg_string("site/default_page_title", context));
|
||||
String description = first(starter_theme_value("meta_description", context), "UCE starter example");
|
||||
String theme_color = first(starter_theme_value("theme_color", context), "#0f172a");
|
||||
String icon = starter_asset_url(starter_theme_value("path", context) + "icon.png", context);
|
||||
|
||||
<>
|
||||
<meta charset="utf-8">
|
||||
<title><?= title + " | " + starter_cfg_string("site/name", context) ?></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); ?>
|
||||
</>
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#load "../../lib/app.uce"
|
||||
|
||||
RENDER(Request& context)
|
||||
{
|
||||
starter_boot(context);
|
||||
|
||||
<>
|
||||
<nav<?: starter_theme_value("key", context) == "portal-dark" || starter_theme_value("key", context) == "dark" || starter_theme_value("key", context) == "retro-gaming" ? " class=\"nav-shell\"" : "" ?>>
|
||||
<div class="nav-menu">
|
||||
<a href="<?= starter_link("", context) ?>"><?= starter_cfg_string("site/name", context) ?></a>
|
||||
<? starter_cfg("menu", context).each([&](DTree menu_item, String menu_key) {
|
||||
if(menu_item["hidden"].to_string() == "1")
|
||||
return;
|
||||
?><a href="<?= starter_menu_href(menu_key, menu_item, context) ?>"><?= menu_item["title"].to_string() ?></a><?
|
||||
}); ?>
|
||||
</div>
|
||||
<?: component("account_links", context) ?>
|
||||
</nav>
|
||||
</>
|
||||
}
|
||||
Reference in New Issue
Block a user