From e35808f582dcfaeee09248833c09f3ca2dc4b2cc Mon Sep 17 00:00:00 2001 From: Gregg Date: Sun, 23 Apr 2023 10:01:00 -0500 Subject: [PATCH] Added homeSpan.setWebLogCSS(const char *css) Allows user to define a custom style sheet to change the webLog output. Style sheet is based on pre-defined class: bod1 = main body of web page, including header (in format of

) tabl1 = top table showing general status tab2 = bottom table showing all weblog entries --- src/HAP.cpp | 11 +++++------ src/HomeSpan.h | 4 +++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/HAP.cpp b/src/HAP.cpp index c688892..4205529 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -1250,11 +1250,10 @@ int HAPClient::getStatusURL(){ String response="HTTP/1.1 200 OK\r\nContent-type: text/html; charset=utf-8\r\n\r\n"; response+="" + String(homeSpan.displayName) + "\n"; - response+= String(homeSpan.webLog.cssStyle); - response+="\n"; - response+="\n"; - response+="

" + String(homeSpan.displayName) + "

\n"; - response+="\n"; + response+="\n"; + response+="

" + String(homeSpan.displayName) + "

\n"; + + response+="
\n"; response+="\n"; response+="\n"; response+="\n"; @@ -1281,7 +1280,7 @@ int HAPClient::getStatusURL(){ response+="

"; if(homeSpan.webLog.maxEntries>0){ - response+="
Up Time:" + String(uptime) + "
Current Time:" + String(clocktime) + "
Boot Time:" + String(homeSpan.webLog.bootTime) + "
\n"; + response+="
EntryUp TimeLog TimeClientMessage
\n"; int lastIndex=homeSpan.webLog.nEntries-homeSpan.webLog.maxEntries; if(lastIndex<0) lastIndex=0; diff --git a/src/HomeSpan.h b/src/HomeSpan.h index d16ebef..b774136 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -151,7 +151,7 @@ struct SpanWebLog{ // optional web status/log data char bootTime[33]="Unknown"; // boot time String statusURL; // URL of status log uint32_t waitTime=10000; // number of milliseconds to wait for initial connection to time server - String cssStyle; // Default CSS style. + String css=""; // optional user-defined style sheet for web log struct log_t { // log entry type uint64_t upTime; // number of seconds since booting @@ -342,6 +342,8 @@ class Span{ va_end(ap); } + void setWebLogCSS(const char *css){webLog.css="\n" + String(css) + "\n";} + void autoPoll(uint32_t stackSize=8192, uint32_t priority=1, uint32_t cpu=0){ // start pollTask() xTaskCreateUniversal([](void *parms){for(;;)homeSpan.pollTask();}, "pollTask", stackSize, NULL, priority, &pollTaskHandle, cpu); Serial.printf("\n*** AutoPolling Task started with priority=%d\n\n",uxTaskPriorityGet(pollTaskHandle));
EntryUp TimeLog TimeClientMessage