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

Building custom web page (/setup) breaks the library #50

Open
IAmOrion opened this issue Oct 26, 2024 · 5 comments
Open

Building custom web page (/setup) breaks the library #50

IAmOrion opened this issue Oct 26, 2024 · 5 comments

Comments

@IAmOrion
Copy link

I made my own page for setup, but when I tried to compile the library it failed. After some testing, I discovered that even with the original files from the library, with NO changes at all, if I build the setup file and copy it to the src folder, the library has an error and will no longer build.

Error:

/Users/iamorion/Documents/Arduino/libraries/AsyncEspFsWebserver/src/AsyncFsWebServer.cpp: In member function 'void AsyncFsWebServer::handleSetup(AsyncWebServerRequest*)': /Users/iamorion/Documents/Arduino/libraries/AsyncEspFsWebserver/src/AsyncFsWebServer.cpp:219:93: error: '_acsetup_min_htm' was not declared in this scope; did you mean '_acedit_min_htm'? 219 | AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", (uint8_t*)_acsetup_min_htm, sizeof(_acsetup_min_htm)); | ^~~~~~~~~~~~~~~~ | _acedit_min_htm exit status 1 Error compiling for board ESP32C3 Dev Module.

If I restore the setup_htm.h that exists in src from the download, it will compile file. If I compile the file following the instructions and using node minify.js - then move the generated setup_htm.h file into the src folder, it then has the error as above so something is breaking and it's not possible to create custom pages currently (Using version 1.0.7)

@mano1979
Copy link

I have the same issue. Did you manage to fix it?

C:\Users\Mano\Documents\Arduino\libraries\AsyncEspFsWebserver\src\AsyncFsWebServer.cpp: In member function 'void AsyncFsWebServer::handleSetup(AsyncWebServerRequest*)': C:\Users\Mano\Documents\Arduino\libraries\AsyncEspFsWebserver\src\AsyncFsWebServer.cpp:222:93: error: '_acsetup_min_htm' was not declared in this scope; did you mean '_acedit_min_htm'? 222 | AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", (uint8_t*)_acsetup_min_htm, sizeof(_acsetup_min_htm)); | ^~~~~~~~~~~~~~~~ | _acedit_min_htm

@cotestatnt
Copy link
Owner

The problem is due to the fact that the Segger Bin2C tool generates an array with a different name and in the latest versions I decided to use this tool mainly because it is more effective in compressing the file.

I also updated the script so that it generates an array with the same name and I just committed.

@mano1979
Copy link

The problem is due to the fact that the Segger Bin2C tool generates an array with a different name and in the latest versions I decided to use this tool mainly because it is more effective in compressing the file.

I also updated the script so that it generates an array with the same name and I just committed.

Thank you, i will download the updated script.

Unrelated question:

What file and part of this file is responsible for implementing the "custom html" and adding it to the menu in /setup? I had it working, then adhusted the all.htm to match my needs, and the custom menu item is not visible anymore. I must have removed that part from the code so i'm looking to put it back in.

@cotestatnt
Copy link
Owner

The code responsible for customizing /setup starts here.

When you add custom HTML, CSS, or JavaScript code using the library’s methods, a new file is created on the filesystem for each addition. Additionally, an entry mapping id <-> link_to_file is added to /config.json.

When the /setup page is requested and config.json is parsed, the script looks for these "special keys," and the custom code is injected into the main page.
CSS files are added as external links in the <head> section, while JavaScript is appended at the bottom of the <body> section.
HTML content, however, is inserted as it is read from the file, making the order of the keys in config.json important for determining the final placement of the HTML within the page.

Try checking your custom page by enabling the browser's developer tools (typically by pressing F12). In the "console" tab, you should be able to see any errors and act accordingly.

@mano1979
Copy link

mano1979 commented Dec 24, 2024

The code responsible for customizing /setup starts here.

When you add custom HTML, CSS, or JavaScript code using the library’s methods, a new file is created on the filesystem for each addition. Additionally, an entry mapping id <-> link_to_file is added to /config.json.

When the /setup page is requested and config.json is parsed, the script looks for these "special keys," and the custom code is injected into the main page. CSS files are added as external links in the <head> section, while JavaScript is appended at the bottom of the <body> section. HTML content, however, is inserted as it is read from the file, making the order of the keys in config.json important for determining the final placement of the HTML within the page.

Try checking your custom page by enabling the browser's developer tools (typically by pressing F12). In the "console" tab, you should be able to see any errors and act accordingly.

Ok, so for what i figured, the code is fine and working if i just add the lines in the arduino sketch. But as soon as i use add my own css and use minify.js it breaks things and the javascript you mentioned above is not in the page anymore. So it must have something to do with the minifying OR the bin2C i think.

any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants