add 404 handler, include css in header completely
This commit is contained in:
parent
57fa57fc94
commit
5b54ae3658
5 changed files with 40 additions and 21 deletions
|
@ -71,7 +71,7 @@ Config_System configSystem;
|
||||||
|
|
||||||
|
|
||||||
struct Config_Grow {
|
struct Config_Grow {
|
||||||
char growName[64];
|
char growName[64] = "CanGrow";
|
||||||
unsigned short dayOfGrow;
|
unsigned short dayOfGrow;
|
||||||
byte daysSeed;
|
byte daysSeed;
|
||||||
byte daysVeg;
|
byte daysVeg;
|
||||||
|
|
|
@ -27,7 +27,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* include static files files
|
||||||
|
*/
|
||||||
|
#include "Webserver/File_cangrow_CSS.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* include webpages header files
|
* include webpages header files
|
||||||
|
@ -40,10 +43,7 @@
|
||||||
|
|
||||||
#include "Webserver/Page_wifi.h"
|
#include "Webserver/Page_wifi.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* include static files files
|
|
||||||
*/
|
|
||||||
#include "Webserver/File_cangrow_CSS.h"
|
|
||||||
|
|
||||||
|
|
||||||
AsyncWebServer webserver(80);
|
AsyncWebServer webserver(80);
|
||||||
|
@ -51,9 +51,19 @@ AsyncWebServer webserver(80);
|
||||||
LoggingMiddleware requestLogger;
|
LoggingMiddleware requestLogger;
|
||||||
|
|
||||||
|
|
||||||
|
/* 404 error site - this is also a good example for a simple WebPage */
|
||||||
|
const char* Page_404_HTML PROGMEM = R"(%HEADER%
|
||||||
|
<div class='warnmsg'><h1>❗ ️ 404 - not found</h1></div>
|
||||||
|
%FOOTER%)";
|
||||||
|
|
||||||
|
/* processor */
|
||||||
|
String Proc_WebPage_404(const String& var) {
|
||||||
|
return AddHeaderFooter(var);
|
||||||
|
}
|
||||||
|
|
||||||
// https://github.com/mathieucarbou/ESPAsyncWebServer/blob/main/examples/SimpleServer/SimpleServer.ino
|
// https://github.com/mathieucarbou/ESPAsyncWebServer/blob/main/examples/SimpleServer/SimpleServer.ino
|
||||||
void WebserverNotFound(AsyncWebServerRequest* request) {
|
void WebserverNotFound(AsyncWebServerRequest* request) {
|
||||||
request->send(404, "text/plain", "Not found");
|
request->send(404, "text/html", Page_404_HTML, Proc_WebPage_404);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -28,19 +28,21 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
bool TestHeaderFooter(const String& var) {
|
bool TestHeaderFooter(const String& var) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.print(":: [Webserver:Page:root:proc:hf] var: ");
|
Serial.print(":: [Webserver:Page:root:proc:hf] var: ");
|
||||||
Serial.println(var);
|
Serial.println(var);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(var == "HEADER") {
|
if(
|
||||||
return true;
|
(var == "HEADER") ||
|
||||||
} else if(var == "FOOTER") {
|
(var == "FOOTER") ||
|
||||||
return true;
|
(var == "CGVER") ||
|
||||||
} else if(var == "CGVER") {
|
(var == "CGBUILD") ||
|
||||||
return true;
|
(var == "GROWNAME") ||
|
||||||
} else if(var == "CGBUILD") {
|
(var == "CANGROW_CSS")
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -56,6 +58,10 @@ String AddHeaderFooter(const String& var) {
|
||||||
return String(CANGROW_VER);
|
return String(CANGROW_VER);
|
||||||
} else if(var == "CGBUILD") {
|
} else if(var == "CGBUILD") {
|
||||||
return String(CANGROW_BUILD);
|
return String(CANGROW_BUILD);
|
||||||
|
} else if(var == "GROWNAME") {
|
||||||
|
return String(configGrow.growName);
|
||||||
|
} else if(var == "CANGROW_CSS") {
|
||||||
|
return String(File_cangrow_CSS);
|
||||||
} else {
|
} else {
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ const char* File_cangrow_CSS PROGMEM = R"(body {
|
||||||
}
|
}
|
||||||
|
|
||||||
.center {
|
.center {
|
||||||
width: 100%;
|
width: 100%%;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,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;
|
||||||
|
@ -174,7 +174,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: '';
|
||||||
|
@ -187,9 +187,8 @@ input[type=text], input[type=date], input[type=number], input[type=password], se
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-bottom: 3px;
|
margin-bottom: 3px;
|
||||||
}
|
}
|
||||||
}
|
})";
|
||||||
)";
|
|
||||||
|
|
||||||
void WebFile_cangrow_CSS(AsyncWebServerRequest *request) {
|
void WebFile_cangrow_CSS(AsyncWebServerRequest *request) {
|
||||||
request->send_P(200, "text/stylesheet", File_cangrow_CSS);
|
request->send_P(200, "text/css", File_cangrow_CSS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,13 @@ const char* Header_HTML PROGMEM = R"(<!DOCTYPE html>
|
||||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||||
<title>CanGrow %CGVER% - %CGBUILD%</title>
|
<title>CanGrow %CGVER% - %CGBUILD%</title>
|
||||||
<link rel='icon' href='data:;base64,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rK7Ih7Mr3HaM7jYQVZqXQ6Tb6yqBYdTfomhHiFfUyMI3f+01/z7RHNzTGDyWGThP63SA2d8EEfIkrgQpzmOvH0AV+3M4zegNpUwagAYG8Yp4BS0nl4Kz5Mpf0JXJMby6w/66Aa+M+9uE53/Iexsggq4ESOYWC0jmsBfX8xdXhcJjL4cLc3kBl8uJGQ/CrpAAAAAASUVORK5CYII='>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
%CANGROW_CSS%
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<ul class='nav'><li><a href='/'>🌱 Wohnzimmer Regal</a></li>
|
<ul class='nav'><li><a href='/'>🌱 %GROWNAME%</a></li>
|
||||||
<li><a href='/growSettings' >🔆 Grow settings</a></li>
|
<li><a href='/growSettings' >🔆 Grow settings</a></li>
|
||||||
<li><a href='/systemSettings' >⚙ System settings</a></li>
|
<li><a href='/systemSettings' >⚙ System settings</a></li>
|
||||||
<li><a href='/wifiSettings' class='activeMenu'>📡 WiFi settings</a></li>
|
<li><a href='/wifiSettings' class='activeMenu'>📡 WiFi settings</a></li>
|
||||||
|
|
Loading…
Reference in a new issue