Add project logo to authenticated web UI

This commit is contained in:
2026-08-29 21:25:25 +02:00
parent 96e5792273
commit 57a18be9bd
8 changed files with 582 additions and 6 deletions
+12 -5
View File
@@ -36,8 +36,8 @@ static const char s_index_html[] =
".topbar{display:flex;align-items:center;justify-content:space-between;gap:16px}\n"
".brand{display:flex;align-items:center;gap:12px;min-width:0}\n"
".logo{width:42px;height:42px;border:1px solid #347ba5;border-radius:12px;"
"display:grid;place-items:center;background:#10273a;color:var(--accent);"
"font-weight:800;letter-spacing:.06em;box-shadow:0 0 30px #1c8fc333}\n"
"display:block;padding:4px;background:#10273a;object-fit:contain;"
"box-shadow:0 0 30px #1c8fc333}\n"
"h1{font-size:clamp(18px,3vw,24px);line-height:1.15;margin:0}\n"
".subtitle{color:var(--muted);margin:3px 0 0;font-size:13px}\n"
".badge{display:inline-flex;align-items:center;gap:7px;white-space:nowrap;"
@@ -95,7 +95,8 @@ static const char s_index_html[] =
"<body>\n"
"<main class=\"page\">\n"
"<header class=\"topbar\">\n"
"<div class=\"brand\"><div class=\"logo\" aria-hidden=\"true\">SAK</div><div>"
"<div class=\"brand\"><img class=\"logo\" src=\"/assets/logo.png\""
"alt=\"ESP32 Serial Swiss Army Knife logo\"><div>"
"<h1>ESP32 Serial Console</h1><p class=\"subtitle\">Secure local serial workspace</p></div></div>\n"
"<span id=\"connection-status\" class=\"badge\" data-tone=\"warn\">Connecting</span>\n"
"</header>\n"
@@ -478,6 +479,11 @@ static esp_err_t describe_resource(web_ui_resource_t resource,
response->data = (const uint8_t *)s_app_js;
response->length = sizeof(s_app_js) - 1U;
return ESP_OK;
case WEB_UI_RESOURCE_LOGO_PNG:
response->content_type = "image/png";
response->data = web_asset_logo_png;
response->length = web_asset_logo_png_size;
return ESP_OK;
default:
return ESP_ERR_INVALID_ARG;
}
@@ -505,8 +511,9 @@ static esp_err_t set_response_headers(httpd_req_t *request,
if (result == ESP_OK && response->content_security_policy) {
result = httpd_resp_set_hdr(
request, "Content-Security-Policy",
"default-src 'none'; script-src 'self'; script-src-elem 'self'; "
"style-src 'self' 'unsafe-inline'; img-src data:; connect-src 'self'; "
"default-src 'none'; script-src 'self' 'sha256-5ukY3vEyRwFowsj4k3O4ilN8ezlXoZu1w90PPHg0YVE='; "
"script-src-elem 'self' 'sha256-5ukY3vEyRwFowsj4k3O4ilN8ezlXoZu1w90PPHg0YVE='; "
"style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; "
"base-uri 'none'; form-action 'none'; "
"frame-ancestors 'none'");
}