Skip to content

Commit

Permalink
Merge branch 'master' into header-footer
Browse files Browse the repository at this point in the history
  • Loading branch information
dmadison committed Dec 11, 2024
2 parents e2a287f + 0fad7f5 commit a03f4ee
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 36 deletions.
29 changes: 21 additions & 8 deletions .github/workflows/compile_examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,27 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ github.ref }}
restore-keys: |
${{ runner.os }}-pip-${{ github.ref }}-
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}-${{ github.ref }}
restore-keys: |
${{ runner.os }}-${{ github.ref }}-
${{ runner.os }}-
- name: Set up Python
uses: actions/setup-python@v2
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Install 3rd party dependecies
- name: Install 3rd party dependencies
run: |
pio lib -g install \
file://. \
Expand Down Expand Up @@ -92,20 +99,25 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ github.ref }}
restore-keys: |
${{ runner.os }}-pip-${{ github.ref }}-
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}-${{ github.ref }}
restore-keys: |
${{ runner.os }}-${{ github.ref }}-
${{ runner.os }}-
- name: Set up Python
uses: actions/setup-python@v2
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Install 3rd party dependecies
- name: Install 3rd party dependencies
run: |
pio lib -g install \
file://. \
Expand All @@ -116,3 +128,4 @@ jobs:
run: pio ci --board=esp32dev
env:
PLATFORMIO_CI_SRC: ${{ matrix.example }}

11 changes: 8 additions & 3 deletions .github/workflows/compile_library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ matrix.board }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.board }}-
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}-${{ matrix.board }}
restore-keys: |
${{ runner.os }}-${{ matrix.board }}-
${{ runner.os }}-
- name: Set up Python
uses: actions/setup-python@v2
- name: Install PlatformIO
Expand Down
45 changes: 23 additions & 22 deletions WiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1272,22 +1272,23 @@ void WiFiManager::startWPS() {
}
#endif

String WiFiManager::getHTTPHead(String title){
String WiFiManager::getHTTPHead(String title, String classes){
String page;
page += FPSTR(HTTP_HEAD_START);
page.replace(FPSTR(T_v), title);
page += FPSTR(HTTP_SCRIPT);
page += FPSTR(HTTP_STYLE);
page += _customHeadElement;

if(_bodyClass != ""){
String p = FPSTR(HTTP_HEAD_END);
p.replace(FPSTR(T_c), _bodyClass); // add class str
page += p;
String p = FPSTR(HTTP_HEAD_END);
if (_bodyClass != "") {
if (classes != "") {
classes += " "; // add spacing, if necessary
}
classes += _bodyClass; // add class str
}
else {
page += FPSTR(HTTP_HEAD_END);
}
p.replace(FPSTR(T_c), classes);
page += p;

if (_customBodyHeader) {
page += _customBodyHeader;
Expand Down Expand Up @@ -1346,7 +1347,7 @@ void WiFiManager::handleRoot() {
#endif
if (captivePortal()) return; // If captive portal redirect instead of displaying the page
handleRequest();
String page = getHTTPHead(_title); // @token options @todo replace options with title
String page = getHTTPHead(_title, FPSTR(C_root)); // @token options @todo replace options with title
String str = FPSTR(HTTP_ROOT_MAIN); // @todo custom title
str.replace(FPSTR(T_t),_title);
str.replace(FPSTR(T_v),configPortalActive ? _apName : (getWiFiHostname() + " - " + WiFi.localIP().toString())); // use ip if ap is not active for heading @todo use hostname?
Expand All @@ -1371,7 +1372,7 @@ void WiFiManager::handleWifi(boolean scan) {
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP Wifi"));
#endif
handleRequest();
String page = getHTTPHead(FPSTR(S_titlewifi)); // @token titlewifi
String page = getHTTPHead(FPSTR(S_titlewifi), FPSTR(C_wifi)); // @token titlewifi
if (scan) {
#ifdef WM_DEBUG_LEVEL
// DEBUG_WM(WM_DEBUG_DEV,"refresh flag:",server->hasArg(F("refresh")));
Expand Down Expand Up @@ -1427,7 +1428,7 @@ void WiFiManager::handleParam(){
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP Param"));
#endif
handleRequest();
String page = getHTTPHead(FPSTR(S_titleparam)); // @token titlewifi
String page = getHTTPHead(FPSTR(S_titleparam), FPSTR(C_param)); // @token titlewifi

String pitem = "";

Expand Down Expand Up @@ -1892,11 +1893,11 @@ void WiFiManager::handleWifiSave() {
String page;

if(_ssid == ""){
page = getHTTPHead(FPSTR(S_titlewifisettings)); // @token titleparamsaved
page = getHTTPHead(FPSTR(S_titlewifisettings), FPSTR(C_wifi)); // @token titleparamsaved
page += FPSTR(HTTP_PARAMSAVED);
}
else {
page = getHTTPHead(FPSTR(S_titlewifisaved)); // @token titlewifisaved
page = getHTTPHead(FPSTR(S_titlewifisaved), FPSTR(C_wifi)); // @token titlewifisaved
page += FPSTR(HTTP_SAVED);
}

Expand Down Expand Up @@ -1925,7 +1926,7 @@ void WiFiManager::handleParamSave() {

doParamSave();

String page = getHTTPHead(FPSTR(S_titleparamsaved)); // @token titleparamsaved
String page = getHTTPHead(FPSTR(S_titleparamsaved), FPSTR(C_param)); // @token titleparamsaved
page += FPSTR(HTTP_PARAMSAVED);
if(_showBack) page += FPSTR(HTTP_BACKBTN);
page += getHTTPEnd();
Expand Down Expand Up @@ -1991,7 +1992,7 @@ void WiFiManager::handleInfo() {
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP Info"));
#endif
handleRequest();
String page = getHTTPHead(FPSTR(S_titleinfo)); // @token titleinfo
String page = getHTTPHead(FPSTR(S_titleinfo), FPSTR(C_info)); // @token titleinfo
reportStatus(page);

uint16_t infos = 0;
Expand Down Expand Up @@ -2336,7 +2337,7 @@ void WiFiManager::handleExit() {
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP Exit"));
#endif
handleRequest();
String page = getHTTPHead(FPSTR(S_titleexit)); // @token titleexit
String page = getHTTPHead(FPSTR(S_titleexit), FPSTR(C_exit)); // @token titleexit
page += FPSTR(S_exiting); // @token exiting
page += getHTTPEnd();
// ('Logout', 401, {'WWW-Authenticate': 'Basic realm="Login required"'})
Expand All @@ -2354,7 +2355,7 @@ void WiFiManager::handleReset() {
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP Reset"));
#endif
handleRequest();
String page = getHTTPHead(FPSTR(S_titlereset)); //@token titlereset
String page = getHTTPHead(FPSTR(S_titlereset), FPSTR(C_restart)); //@token titlereset
page += FPSTR(S_resetting); //@token resetting
page += getHTTPEnd();

Expand All @@ -2379,7 +2380,7 @@ void WiFiManager::handleErase(boolean opt) {
DEBUG_WM(WM_DEBUG_NOTIFY,F("<- HTTP Erase"));
#endif
handleRequest();
String page = getHTTPHead(FPSTR(S_titleerase)); // @token titleerase
String page = getHTTPHead(FPSTR(S_titleerase), FPSTR(C_erase)); // @token titleerase

bool ret = erase(opt);

Expand Down Expand Up @@ -2484,7 +2485,7 @@ void WiFiManager::handleClose(){
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP close"));
#endif
handleRequest();
String page = getHTTPHead(FPSTR(S_titleclose)); // @token titleclose
String page = getHTTPHead(FPSTR(S_titleclose), FPSTR(C_close)); // @token titleclose
page += FPSTR(S_closing); // @token closing
page += getHTTPEnd();
HTTPSend(page);
Expand Down Expand Up @@ -3001,7 +3002,7 @@ void WiFiManager::setShowStaticFields(boolean alwaysShow){
*/
void WiFiManager::setShowDnsFields(boolean alwaysShow){
if(_disableIpFields) _staShowDns = alwaysShow ? 1 : -1;
_staShowDns = alwaysShow ? 1 : 0;
else _staShowDns = alwaysShow ? 1 : 0;
}

/**
Expand Down Expand Up @@ -3910,7 +3911,7 @@ void WiFiManager::handleUpdate() {
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- Handle update"));
#endif
if (captivePortal()) return; // If captive portal redirect instead of displaying the page
String page = getHTTPHead(_title); // @token options
String page = getHTTPHead(_title, FPSTR(C_update)); // @token options
String str = FPSTR(HTTP_ROOT_MAIN);
str.replace(FPSTR(T_t), _title);
str.replace(FPSTR(T_v), configPortalActive ? _apName : (getWiFiHostname() + " - " + WiFi.localIP().toString())); // use ip if ap is not active for heading
Expand Down Expand Up @@ -4020,7 +4021,7 @@ void WiFiManager::handleUpdateDone() {
DEBUG_WM(WM_DEBUG_VERBOSE, F("<- Handle update done"));
// if (captivePortal()) return; // If captive portal redirect instead of displaying the page

String page = getHTTPHead(FPSTR(S_options)); // @token options
String page = getHTTPHead(FPSTR(S_options), FPSTR(C_update)); // @token options
String str = FPSTR(HTTP_ROOT_MAIN);
str.replace(FPSTR(T_t),_title);
str.replace(FPSTR(T_v), configPortalActive ? _apName : WiFi.localIP().toString()); // use ip if ap is not active for heading
Expand Down
4 changes: 2 additions & 2 deletions WiFiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ class WiFiManager
unsigned long _startconn = 0; // ms for timing wifi connects

// defaults
const byte DNS_PORT = 53;
const uint8_t DNS_PORT = 53;
String _apName = "no-net";
String _apPassword = "";
String _ssid = ""; // var temp ssid
Expand Down Expand Up @@ -759,7 +759,7 @@ class WiFiManager
String getIpForm(String id, String title, String value);
String getScanItemOut();
String getStaticOut();
String getHTTPHead(String title);
String getHTTPHead(String title, String classes = "");
String getHTTPEnd();
String getMenuOut();
//helpers
Expand Down
13 changes: 13 additions & 0 deletions wm_consts_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static PGM_P _menutokens[] PROGMEM = {
const uint8_t _nummenutokens = (sizeof(_menutokens) / sizeof(PGM_P));


// Routes
const char R_root[] PROGMEM = "/";
const char R_wifi[] PROGMEM = "/wifi";
const char R_wifinoscan[] PROGMEM = "/0wifi";
Expand All @@ -62,6 +63,18 @@ const char R_update[] PROGMEM = "/update";
const char R_updatedone[] PROGMEM = "/u";


// Classes
const char C_root[] PROGMEM = "home";
const char C_wifi[] PROGMEM = "wifi";
const char C_info[] PROGMEM = "info";
const char C_param[] PROGMEM = "param";
const char C_close[] PROGMEM = "close";
const char C_restart[] PROGMEM = "restart";
const char C_exit[] PROGMEM = "exit";
const char C_erase[] PROGMEM = "erase";
const char C_update[] PROGMEM = "update";


//Strings
const char S_ip[] PROGMEM = "ip";
const char S_gw[] PROGMEM = "gw";
Expand Down
13 changes: 13 additions & 0 deletions wm_consts_fr.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static PGM_P _menutokens[] PROGMEM = {
const uint8_t _nummenutokens = (sizeof(_menutokens) / sizeof(PGM_P));


// Routes
const char R_root[] PROGMEM = "/";
const char R_wifi[] PROGMEM = "/wifi";
const char R_wifinoscan[] PROGMEM = "/0wifi";
Expand All @@ -63,6 +64,18 @@ const char R_update[] PROGMEM = "/update";
const char R_updatedone[] PROGMEM = "/u";


// Classes
const char C_root[] PROGMEM = "home";
const char C_wifi[] PROGMEM = "wifi";
const char C_info[] PROGMEM = "info";
const char C_param[] PROGMEM = "param";
const char C_close[] PROGMEM = "close";
const char C_restart[] PROGMEM = "restart";
const char C_exit[] PROGMEM = "exit";
const char C_erase[] PROGMEM = "erase";
const char C_update[] PROGMEM = "update";


//Strings
const char S_ip[] PROGMEM = "ip";
const char S_gw[] PROGMEM = "gw";
Expand Down
3 changes: 2 additions & 1 deletion wm_strings_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ const char HTTP_STYLE[] PROGMEM = "<style>"
"button.D{background-color:#dc3630}"
"button:active{opacity:50% !important;cursor:wait;transition-delay: 0s}"
// invert
"body.invert,body.invert a,body.invert h1 {background-color:#060606;color:#fff;}"
"body.invert{background-color:#060606;}"
"body.invert,body.invert a,body.invert h1 {color:#fff;}"
"body.invert .msg{color:#fff;background-color:#282828;border-top:1px solid #555;border-right:1px solid #555;border-bottom:1px solid #555;}"
"body.invert .q[role=img]{-webkit-filter:invert(1);filter:invert(1);}"
":disabled {opacity: 0.5;}"
Expand Down

0 comments on commit a03f4ee

Please sign in to comment.