put cangrow.css and favicon to sepereate webserver path and not incldue them in the html body

This commit is contained in:
Marcus 2024-10-24 23:22:56 +02:00
parent d679d896b2
commit 3517f6abf4
5 changed files with 62 additions and 14 deletions

View file

@ -31,6 +31,7 @@
* include static files files * include static files files
*/ */
#include "Webserver/File_cangrow_CSS.h" #include "Webserver/File_cangrow_CSS.h"
#include "Webserver/File_favicon_ico.h"
/* /*
* include webpages header files * include webpages header files
@ -85,6 +86,8 @@ void Webserver_Init() {
/* url handler definition */ /* url handler definition */
webserver.on("/", HTTP_GET, WebPage_root); webserver.on("/", HTTP_GET, WebPage_root);
webserver.on("/cangrow.css", HTTP_GET, WebFile_cangrow_CSS); webserver.on("/cangrow.css", HTTP_GET, WebFile_cangrow_CSS);
webserver.on("/favicon.ico", HTTP_GET, WebFile_favicon_ico);
webserver.on("/wifi/", HTTP_GET, WebPage_wifi); webserver.on("/wifi/", HTTP_GET, WebPage_wifi);
webserver.on("/wifi/", HTTP_POST, WebPage_wifi); webserver.on("/wifi/", HTTP_POST, WebPage_wifi);
webserver.on("/system/", HTTP_GET, WebPage_system); webserver.on("/system/", HTTP_GET, WebPage_system);
@ -99,8 +102,11 @@ void Webserver_Init() {
webserver.on("/system/wipe", HTTP_GET, WebPage_system_wipe); webserver.on("/system/wipe", HTTP_GET, WebPage_system_wipe);
webserver.on("/system/wipe", HTTP_POST, WebPage_system_wipe); webserver.on("/system/wipe", HTTP_POST, WebPage_system_wipe);
webserver.on("/system/output", HTTP_GET, WebPage_system_output); webserver.on("/system/output/", HTTP_GET, WebPage_system_output);
webserver.on("/system/output", HTTP_POST, WebPage_system_output); webserver.on("/system/output/", HTTP_POST, WebPage_system_output);
webserver.on("/system/output/add", HTTP_GET, WebPage_system_output_add);
webserver.on("/system/output/add", HTTP_POST, WebPage_system_output_add);
requestLogger.setOutput(Serial); requestLogger.setOutput(Serial);
// this activates the middleware // this activates the middleware

View file

@ -41,7 +41,7 @@ const char* File_cangrow_CSS PROGMEM = R"(body {
} }
.center { .center {
width: 100%%; /*width: 100; */
margin: auto; margin: auto;
} }
@ -104,7 +104,7 @@ a:active {
} }
.nav { .nav {
background: #333; background: #333;
/*width: 100%%; */ /*width: 100; */
margin: auto; margin: auto;
margin-bottom: 10px; margin-bottom: 10px;
padding: 0; padding: 0;
@ -207,7 +207,7 @@ input[type=text], input[type=date], input[type=number], input[type=password], se
@media only screen and (min-width: 1820px) { @media only screen and (min-width: 1820px) {
/*.center, .nav { /*.center, .nav {
width: 60%%; min-width: 420px; width: 60; min-width: 420px;
}*/ }*/
.subnav li { .subnav li {
display: ''; display: '';

View file

@ -33,10 +33,7 @@ const char* Header_HTML PROGMEM = R"(<!DOCTYPE html>
<meta charset='UTF-8'> <meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'> <meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>%GROWNAME% - CanGrow v%CGVER%</title> <title>%GROWNAME% - CanGrow v%CGVER%</title>
<link rel='icon' href='data:;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsTAAALEwEAmpwYAAABcElEQVQ4y42TzU/bQBDFf7Nx1qGuAYVgQSuo2khBggPhyIH//9AiJAQ9tEeLqCKiUD6sxF52OMSEBCdW57aa9968fTsr3V5XWVLPO6sANNL7ZRAMNeU6Ea4T1UEI6pr55kcAwhpMrYOpk2/r/yEQmKWkIonf+TZVgex4Fw0bIEtIAALF3gbZ8U5VwKa3PJ18JT9IpiLvyflBwuhLG5veVUM0/0aoCONPa2hQjWZ8uEVeupJnXSBwO8YOH8iTeAKc2Q4Xt2C1VZL93F7MjbK/bxDnp5Zn7b+So+9pdQ+K/Q5qJlrRj5Ts6DM+rK7Ih7Mr3HaM7jYQVZqXQ6Tb6yqBYdTfomhHiFfUyMI3f+01/z7RHNzTGDyWGThP63SA2d8EEfIkrgQpzmOvH0AV+3M4zegNpUwagAYG8Yp4BS0nl4Kz5Mpf0JXJMby6w/66Aa+M+9uE53/Iexsggq4ESOYWC0jmsBfX8xdXhcJjL4cLc3kBl8uJGQ/CrpAAAAAASUVORK5CYII='> <link rel='stylesheet' href='/cangrow.css'>
<style>
%CANGROW_CSS%
</style>
</head> </head>
<body> <body>
<ul class='nav'><li><a href='/'>&#x1F331; %GROWNAME%</a></li> <ul class='nav'><li><a href='/'>&#x1F331; %GROWNAME%</a></li>

View file

@ -292,6 +292,10 @@ void WebPage_system_wipe(AsyncWebServerRequest *request) {
* Subpage output * Subpage output
*/ */
String Proc_WebPage_system_output(const String& var) { String Proc_WebPage_system_output(const String& var) {
#ifndef DEBUG
Serial.print("DB [Webserver:system:output(Proc)] var: ");
Serial.println(var);
#endif
if(TestHeaderFooter(var)) { if(TestHeaderFooter(var)) {
return AddHeaderFooter(var, 2); return AddHeaderFooter(var, 2);
} else if(Test_WebPage_system_SUBNAV(var)) { } else if(Test_WebPage_system_SUBNAV(var)) {
@ -321,3 +325,39 @@ void WebPage_system_output(AsyncWebServerRequest *request) {
} }
/*
* Subpage output add
*/
String Proc_WebPage_system_output_add(const String& var) {
#ifndef DEBUG
Serial.print("DB [Webserver:system:output:add(Proc)] var: ");
Serial.println(var);
#endif
if(TestHeaderFooter(var)) {
return AddHeaderFooter(var, 2);
} else if(Test_WebPage_system_SUBNAV(var)) {
return Proc_WebPage_system_SUBNAV(var, 1);
} else{
return String();
}
}
String Proc_WebPage_system_output_add_POST(const String& var) {
if(var == "SAVE_MSG") {
return String(Common_HTML_SAVE_MSG);
} else {
return Proc_WebPage_system_output_add(var);
}
}
void WebPage_system_output_add(AsyncWebServerRequest *request) {
if(request->method() == HTTP_POST) {
request->send_P(200, "text/html", Page_system_output_add_HTML, Proc_WebPage_system_output_add_POST);
Serial.println(":: [Webserver:system:output:add] [POST] hello");
} else {
request->send_P(200, "text/html", Page_system_output_add_HTML, Proc_WebPage_system_output_add);
}
}

View file

@ -54,7 +54,7 @@ const char* Page_system_HTML PROGMEM = R"(%HEADER%
%FOOTER%)"; %FOOTER%)";
const char* Page_system_HTML_SUBNAV PROGMEM = R"(<ul class='subnav'> const char* Page_system_HTML_SUBNAV PROGMEM = R"(<ul class='subnav'>
<li><a class='%ACTIVE_SUBNAV_OUTPUT%' href='/system/output'>&#9889; Output configuration</a></li> <li><a class='%ACTIVE_SUBNAV_OUTPUT%' href='/system/output/'>&#9889; Output configuration</a></li>
<li><a class='%ACTIVE_SUBNAV_UPDATE%' href='/system/update'>&#x1F504; Firmware update</a></li> <li><a class='%ACTIVE_SUBNAV_UPDATE%' href='/system/update'>&#x1F504; Firmware update</a></li>
<li><a class='%ACTIVE_SUBNAV_RESTART%' href='/system/restart' >&#x1F501; CanGrow restart</a></li> <li><a class='%ACTIVE_SUBNAV_RESTART%' href='/system/restart' >&#x1F501; CanGrow restart</a></li>
<li><a class='%ACTIVE_SUBNAV_WIPE%' href='/system/wipe' >&#x1F4A3; Factory reset</a></li> <li><a class='%ACTIVE_SUBNAV_WIPE%' href='/system/wipe' >&#x1F4A3; Factory reset</a></li>
@ -115,8 +115,6 @@ const char* Page_system_restart_HTML_RESTART_MSG_POST PROGMEM = R"(Restarting...
* Subpage wipe * Subpage wipe
*/ */
const char* Page_system_wipe_HTML PROGMEM = R"(%HEADER% const char* Page_system_wipe_HTML PROGMEM = R"(%HEADER%
%SUBNAV% %SUBNAV%
<div class='warnmsg'> <div class='warnmsg'>
%WIPE_MSG% %WIPE_MSG%
@ -138,7 +136,14 @@ const char* Page_system_wipe_HTML_WIPE_MSG_POST PROGMEM = R"(Restarting...)";
* Subpage output * Subpage output
*/ */
const char* Page_system_output_HTML PROGMEM = R"(%HEADER% const char* Page_system_output_HTML PROGMEM = R"(%HEADER%
%SUBNAV% %SUBNAV%
<a class='button' href='/system/output/add'>&#10133; Add output</a>
%FOOTER%)";
/*
* Subpage output add
*/
const char* Page_system_output_add_HTML PROGMEM = R"(%HEADER%
%SUBNAV%
<h3>&#10133; Add output</h3>
%FOOTER%)"; %FOOTER%)";