forked from external-repos/esp32cam-rtsp
Fixed template typo
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Wstring.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -8,12 +8,12 @@ typedef struct
|
|||||||
const String value;
|
const String value;
|
||||||
} template_substitution_t;
|
} template_substitution_t;
|
||||||
|
|
||||||
template<typename T, size_t n>
|
template <typename T, size_t n>
|
||||||
inline String template_render(const char *format, T (&values)[n])
|
inline String template_render(const char *format, T (&values)[n])
|
||||||
{
|
{
|
||||||
auto s = String(format);
|
auto s = String(format);
|
||||||
for (size_t i=0; i<n; i++)
|
for (size_t i = 0; i < n; i++)
|
||||||
s.replace("{{" + String(values[n].key) + "}}", values[n].value);
|
s.replace("{{" + String(values[i].key) + "}}", values[i].value);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
16
src/main.cpp
16
src/main.cpp
@@ -46,7 +46,7 @@ void handle_root()
|
|||||||
const char *root_page_template =
|
const char *root_page_template =
|
||||||
"<!DOCTYPE html><html lang=\"en\">"
|
"<!DOCTYPE html><html lang=\"en\">"
|
||||||
"<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/>"
|
"<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/>"
|
||||||
"<head><title>{{Title}}" APP_TITLE " v" APP_VERSION "</title></head>"
|
"<head><title>" APP_TITLE " v" APP_VERSION "</title></head>"
|
||||||
"<body>"
|
"<body>"
|
||||||
"<h2>Status page for {{ThingName}}</h2><hr />"
|
"<h2>Status page for {{ThingName}}</h2><hr />"
|
||||||
|
|
||||||
@@ -79,8 +79,6 @@ void handle_root()
|
|||||||
"<br/>Go to <a href=\"config\">configure page</a> to change settings.";
|
"<br/>Go to <a href=\"config\">configure page</a> to change settings.";
|
||||||
|
|
||||||
const template_substitution_t root_page_substitutions[] = {
|
const template_substitution_t root_page_substitutions[] = {
|
||||||
{"Title", APP_TITLE},
|
|
||||||
{"Version", APP_VERSION},
|
|
||||||
{"ThingName", iotWebConf.getThingName()},
|
{"ThingName", iotWebConf.getThingName()},
|
||||||
{"ChipModel", ESP.getChipModel()},
|
{"ChipModel", ESP.getChipModel()},
|
||||||
{"CpuFreqMHz", String(ESP.getCpuFreqMHz())},
|
{"CpuFreqMHz", String(ESP.getCpuFreqMHz())},
|
||||||
@@ -100,10 +98,8 @@ void handle_root()
|
|||||||
auto html = template_render(root_page_template, root_page_substitutions);
|
auto html = template_render(root_page_template, root_page_substitutions);
|
||||||
|
|
||||||
if (config_changed)
|
if (config_changed)
|
||||||
{
|
|
||||||
html += "<br />"
|
html += "<br />"
|
||||||
"<br/><h3 style=\"color:red\">Configuration has changed. Please <a href=\"restart\">restart</a> the device.</h3>";
|
"<br/><h3 style=\"color:red\">Configuration has changed. Please <a href=\"restart\">restart</a> the device.</h3>";
|
||||||
}
|
|
||||||
|
|
||||||
html += "</body></html>";
|
html += "</body></html>";
|
||||||
web_server.send(200, "text/html", html);
|
web_server.send(200, "text/html", html);
|
||||||
@@ -120,11 +116,11 @@ void handle_restart()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String html;
|
const char *html =
|
||||||
html += "<h2>Restarting...</h2>";
|
"<h2>Restarting...</h2>"
|
||||||
html += "<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/>";
|
"<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/>"
|
||||||
html += "<head><title>" APP_TITLE " v" APP_VERSION "</title></head>";
|
"<head><title>" APP_TITLE " v" APP_VERSION "</title></head>"
|
||||||
html += "<body>";
|
"<body>";
|
||||||
web_server.send(200, "text/html", html);
|
web_server.send(200, "text/html", html);
|
||||||
log_v("Restarting... Press refresh to connect again");
|
log_v("Restarting... Press refresh to connect again");
|
||||||
sleep(250);
|
sleep(250);
|
||||||
|
|||||||
Reference in New Issue
Block a user