[PR #1774] WiFiManagerParameter Encapsulated HTML Generation #1829

Open
opened 2026-02-28 02:13:08 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/tzapu/WiFiManager/pull/1774
Author: @dmadison
Created: 10/30/2024
Status: 🔄 Open

Base: masterHead: params-html-gen


📝 Commits (9)

  • 0df7c77 Refactor parameter 'length' as 'maxLength'
  • f75dd98 Change param value length function name
  • dd38239 Change param getID to getName
  • b002b03 Add setValueReceived function to params
  • c781390 Remove parameter friendship with WiFiManager
  • 2703370 Add negative check to param max length
  • 246d521 Make param destructor virtual
  • 944589c Move param HTML generation to class
  • c4665fc Remove param token "I" processing

📊 Changes

4 files changed (+135 additions, -90 deletions)

View changed files

📝 WiFiManager.cpp (+116 -75)
📝 WiFiManager.h (+16 -12)
📝 examples/NonBlocking/AutoConnectNonBlockingwParams/AutoConnectNonBlockingwParams.ino (+1 -1)
📝 keywords.txt (+2 -2)

📄 Description

This PR encapsulates the WiFiManagerParameter HTML generation as part of the class, rather than as a function within WiFiManager. This allows derived classes to define their own HTML output and greatly increases encapsulation:

 virtual String getHTML() const;

This also greatly simplifies the getParamOut() function of WiFiManager:

...
    // add the extra parameters to the form
    for (int i = 0; i < _paramsCount; i++) {
      page += _params[i]->getHTML();
    }
...

This is a non-breaking change and should not modify the output HTML, with the exception of {I} as noted below.


Note that this PR contains a potentially breaking change, by removing token I (T_I / {I} / capital 'i') processing for parameters which include that token in their string. This was removed because the parameter HTML is no longer generated in the context of the loop, and I didn't see a compelling reason to pass the iterator to the class function.

From what I can see parsing through the history of the strings_en file that feature was never used by the library itself, but it could potentially affect a user somewhere with custom string files (HTTP_FORM_LABEL / HTTP_FORM_PARAM). If that's objectionable I'm happy to revert that commit (c4665fc6cc).

Please note that this PR incorporates the necessary API changes from #1773.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/tzapu/WiFiManager/pull/1774 **Author:** [@dmadison](https://github.com/dmadison) **Created:** 10/30/2024 **Status:** 🔄 Open **Base:** `master` ← **Head:** `params-html-gen` --- ### 📝 Commits (9) - [`0df7c77`](https://github.com/tzapu/WiFiManager/commit/0df7c77b9d813329101b449ff7a8dfbab6ec2e17) Refactor parameter 'length' as 'maxLength' - [`f75dd98`](https://github.com/tzapu/WiFiManager/commit/f75dd98f61032deb17378dc78a9465d7fbf8349e) Change param value length function name - [`dd38239`](https://github.com/tzapu/WiFiManager/commit/dd38239d91a9b9ad895479ea20f6115d523daedb) Change param getID to getName - [`b002b03`](https://github.com/tzapu/WiFiManager/commit/b002b03ea3013a1c2e73e798b217e56dc11a49e9) Add setValueReceived function to params - [`c781390`](https://github.com/tzapu/WiFiManager/commit/c78139047cc866d3e08543b21d701d419cdfc6c4) Remove parameter friendship with WiFiManager - [`2703370`](https://github.com/tzapu/WiFiManager/commit/2703370f4792171aef98c13f91fe868eaeffbb38) Add negative check to param max length - [`246d521`](https://github.com/tzapu/WiFiManager/commit/246d5216a79c1c4b5fa387c91a85ca62f3bb6c1c) Make param destructor virtual - [`944589c`](https://github.com/tzapu/WiFiManager/commit/944589cf29b4f56c1eb39d515193e1b9f06cb539) Move param HTML generation to class - [`c4665fc`](https://github.com/tzapu/WiFiManager/commit/c4665fc6cca7344795e0a88fc9ca4eccaa84085e) Remove param token "I" processing ### 📊 Changes **4 files changed** (+135 additions, -90 deletions) <details> <summary>View changed files</summary> 📝 `WiFiManager.cpp` (+116 -75) 📝 `WiFiManager.h` (+16 -12) 📝 `examples/NonBlocking/AutoConnectNonBlockingwParams/AutoConnectNonBlockingwParams.ino` (+1 -1) 📝 `keywords.txt` (+2 -2) </details> ### 📄 Description This PR encapsulates the `WiFiManagerParameter` HTML generation as part of the class, rather than as a function within `WiFiManager`. This allows derived classes to define their own HTML output and greatly increases encapsulation: ```cpp virtual String getHTML() const; ``` This also greatly simplifies the `getParamOut()` function of `WiFiManager`: ```cpp ... // add the extra parameters to the form for (int i = 0; i < _paramsCount; i++) { page += _params[i]->getHTML(); } ... ``` This is a **non-breaking** change and should not modify the output HTML, with the exception of `{I}` as noted below. --- Note that this PR contains a potentially breaking change, by removing token I (`T_I` / `{I}` / capital 'i') processing for parameters which include that token in their string. This was removed because the parameter HTML is no longer generated in the context of the loop, and I didn't see a compelling reason to pass the iterator to the class function. From what I can see parsing through the history of the `strings_en` file that feature was never used by the library itself, but it could potentially affect a user somewhere with custom string files (`HTTP_FORM_LABEL` / `HTTP_FORM_PARAM`). If that's objectionable I'm happy to revert that commit (c4665fc6cca7344795e0a88fc9ca4eccaa84085e). Please note that this PR incorporates the necessary API changes from #1773. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1829
No description provided.