Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added method to set custom subtitle #1581

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions WiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,8 @@
String page = getHTTPHead(_title); // @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?
str.replace(FPSTR(T_v), _subtitle.length() ? _subtitle : ( // Use subtitle, AP name or ip
configPortalActive ? _apName : (getWiFiHostname() + " - " + WiFi.localIP().toString())));
page += str;
page += FPSTR(HTTP_PORTAL_OPTIONS);
page += getMenuOut();
Expand Down Expand Up @@ -3140,6 +3141,14 @@
_title = title;
}

/**
* [setSubtitle description]
* @param String subtitle, set app subtitle
*/
void WiFiManager::setSubtitle(String subtitle) {
_subtitle = subtitle;
}

/**
* set menu items and order
* if param is present in menu , params will be removed from wifi page automatically
Expand Down Expand Up @@ -3869,8 +3878,9 @@
if (captivePortal()) return; // If captive portal redirect instead of displaying the page
String page = getHTTPHead(_title); // @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
str.replace(FPSTR(T_t), _title);
str.replace(FPSTR(T_v), _subtitle.length() ? _subtitle : ( // Use subtitle, AP name or ip
configPortalActive ? _apName : (getWiFiHostname() + " - " + WiFi.localIP().toString())));
page += str;

page += FPSTR(HTTP_UPDATE);
Expand Down Expand Up @@ -3979,8 +3989,9 @@

String page = getHTTPHead(FPSTR(S_options)); // @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
str.replace(FPSTR(T_t),_title);

Check failure on line 3992 in WiFiManager.cpp

View workflow job for this annotation

GitHub Actions / build

[cpplint] reported by reviewdog 🐶 Missing space after , [whitespace/comma] [3] Raw Output: WiFiManager.cpp:3992: Missing space after , [whitespace/comma] [3]
str.replace(FPSTR(T_v), _subtitle.length() ? _subtitle : ( // Use subtitle, AP name or ip
configPortalActive ? _apName : (getWiFiHostname() + " - " + WiFi.localIP().toString())));
page += str;

if (Update.hasError()) {
Expand Down
6 changes: 5 additions & 1 deletion WiFiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ class WiFiManager
// set the webapp title, default WiFiManager
void setTitle(String title);

// set the webapp subtitle, default AP name
void setSubtitle(String subtitle);

// add params to its own menu page and remove from wifi, NOT TO BE COMBINED WITH setMenu!
void setParamsPage(bool enable);

Expand Down Expand Up @@ -599,7 +602,8 @@ class WiFiManager
const char* _customHeadElement = ""; // store custom head element html from user isnide <head>
const char* _customMenuHTML = ""; // store custom head element html from user inside <>
String _bodyClass = ""; // class to add to body
String _title = FPSTR(S_brand); // app title - default WiFiManager
String _title = FPSTR(S_brand); // app title - default WiFiManager
String _subtitle = ""; // app subtitle - default AP name

// internal options

Expand Down
Loading