diff --git a/README.md b/README.md index c9788f5..5f18fb4 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The source code given in this public repo is for educational use only. Stealing # Some updates about the project -Life being as it is, I was not able to work on this project at all for the last 8 months, and maybe won't be able to for the next few. The project is not dead though, I am just unable to work on it now. Some issues have been submitted regarding the language.h library not being detected. I cannot say with certainty why that is, but if I remember it's just a question of checking your path. I hope to be able to come back to this project as soon as possible, thanks for your understanding. +Life being as it is, I was not able to work on this project at all for the last 8 months, and maybe won't be able to for the next few. The project is not dead though, I am just unable to work on it now. Some issues have been submitted regarding the language.h library not being detected. I cannot say with certainty why that is, but if I remember it's just a question of checking your path. I hope to be able to come back to this project as soon as possible, thanks for your understanding. # Demonstration & How tos @@ -56,7 +56,7 @@ You want to go to the settings to prepare the hook. Let's go through all the set # Installation -You should be able to download the binary from the release tab in github. +You should be able to download the binary from the release tab in github. [https://github.com/willmendil/ESPBug/releases/tag/0.1](https://github.com/willmendil/ESPBug/releases/tag/0.1) and just updload the binary through the arduino IDE. Look below to see how to setup the board. @@ -109,8 +109,100 @@ SSL Support: "All SSL ciphers (most compatible)" Port : "" ``` +# Convert webpages +The web pages are saved in a compress form and in bytes. A small script is available to convert you website into the correct format. this runs in `Python2.7`. In the `web_converter` you must add your web pages in `web_pages`: +``` +\web_converter>tree /F +Folder PATH listing for volume HDD +Volume serial number is 5E0C-E860 +D:. +│ requirements.txt +│ webConverter.py +│ +├───css_html_js_minify +│ │ [...] +│ +└───web_pages + example.html +``` + +Then you just need to run the python script knowing that `anglerfish` must be installed (`python -m pip install anglerfish`). + +``` +\web_converter>PYTHON webConverter.py + +webConverter for master + +p \ESPBug\web_converter +parent +q compressed +arduino_file_path \ESPBug\web_converter\webfiles.h +datadir \ESPBug\web_converter\web_pages +dir \web_interface +datadir \ESPBug\web_converter\web_pages +compressed \ESPBug\web_converter\web_pages\compressed +filelist [] +html_files [WindowsPath('ESPBug/web_converter/web_pages/example.html')] +css_files [] +js_files [] +[+] Minifying example.html... +[+] Compressing example.html... +[+] Saving everything into webfiles.h... + +[+] Done, happy uploading :) +Here are the updated functions + +server.on(String(F("/example.html")).c_str(), HTTP_GET, [](){ + sendProgmem(examplehtml, sizeof(examplehtml), W_HTML); +}); +``` + +This is the ouput, not very pretty, but functionnal. (I replaced the exact path to `` for privacy). +There is the code that must be added to the `void startAP()` function in `servingWebPages.h`. The string `F("/example.html")` is actually the url path that needs to be called to serve the page. You can therefore put anything you want here. + +If we look at the tree we see new stuff now + +``` +\web_converter>tree /F +Folder PATH listing for volume HDD +Volume serial number is 5E0C-E860 +D:. +│ requirements.txt +│ webConverter.py +│ webfiles.h +│ +├───css_html_js_minify +│ │ [...] +│ +└───web_pages + │ example.html + │ + └───compressed + example.html.gz +``` + +Specifically a compressed folder was created in `web_pages`. You actually need to move everything in `web_converter\web_pages` inside the `espbug` folder were the espbug.ino resides. + +``` +\ESPBug>tree +Folder PATH listing for volume HDD +Volume serial number is 5E0C-E860 +D:. +├───espbug +│ └───web_pages <---- [In this folder] +│ ├───compressed | +│ │ └───js | +│ ├───jade | +│ └───json | +└───web_converter | + ├───css_html_js_minify | + └───web_pages [MOVE THIS |] + └───compressed +``` + +Then you'll need to recompile the project and upload it to the board. I know, it's not elegante, but it works. # CREDITS where credit is due diff --git a/web_converter/css_html_js_minify/__pycache__/__init__.cpython-37.pyc b/web_converter/css_html_js_minify/__pycache__/__init__.cpython-37.pyc index 19d208a..2248eb3 100644 Binary files a/web_converter/css_html_js_minify/__pycache__/__init__.cpython-37.pyc and b/web_converter/css_html_js_minify/__pycache__/__init__.cpython-37.pyc differ diff --git a/web_converter/css_html_js_minify/__pycache__/css_minifier.cpython-37.pyc b/web_converter/css_html_js_minify/__pycache__/css_minifier.cpython-37.pyc index fcfa23c..c8fd849 100644 Binary files a/web_converter/css_html_js_minify/__pycache__/css_minifier.cpython-37.pyc and b/web_converter/css_html_js_minify/__pycache__/css_minifier.cpython-37.pyc differ diff --git a/web_converter/css_html_js_minify/__pycache__/html_minifier.cpython-37.pyc b/web_converter/css_html_js_minify/__pycache__/html_minifier.cpython-37.pyc index cf63de8..c09dfd6 100644 Binary files a/web_converter/css_html_js_minify/__pycache__/html_minifier.cpython-37.pyc and b/web_converter/css_html_js_minify/__pycache__/html_minifier.cpython-37.pyc differ diff --git a/web_converter/css_html_js_minify/__pycache__/js_minifier.cpython-37.pyc b/web_converter/css_html_js_minify/__pycache__/js_minifier.cpython-37.pyc index 30ee528..36b42bd 100644 Binary files a/web_converter/css_html_js_minify/__pycache__/js_minifier.cpython-37.pyc and b/web_converter/css_html_js_minify/__pycache__/js_minifier.cpython-37.pyc differ diff --git a/web_converter/css_html_js_minify/__pycache__/minify.cpython-37.pyc b/web_converter/css_html_js_minify/__pycache__/minify.cpython-37.pyc index bee18be..8da210d 100644 Binary files a/web_converter/css_html_js_minify/__pycache__/minify.cpython-37.pyc and b/web_converter/css_html_js_minify/__pycache__/minify.cpython-37.pyc differ diff --git a/web_converter/css_html_js_minify/__pycache__/variables.cpython-37.pyc b/web_converter/css_html_js_minify/__pycache__/variables.cpython-37.pyc index 595a6af..b4a6d79 100644 Binary files a/web_converter/css_html_js_minify/__pycache__/variables.cpython-37.pyc and b/web_converter/css_html_js_minify/__pycache__/variables.cpython-37.pyc differ diff --git a/web_converter/requirements.txt b/web_converter/requirements.txt new file mode 100644 index 0000000..f59a8d0 --- /dev/null +++ b/web_converter/requirements.txt @@ -0,0 +1 @@ +anglerfish \ No newline at end of file diff --git a/web_converter/webConverter.py b/web_converter/webConverter.py index ea6de6b..af774d3 100644 --- a/web_converter/webConverter.py +++ b/web_converter/webConverter.py @@ -7,14 +7,14 @@ try: from css_html_js_minify.minify import process_single_html_file, process_single_js_file, process_single_css_file except ModuleNotFoundError: - print("\n[!] Requirements are not satisfied. Please install the 'anglerfish' package by running 'sudo python3 -m pip install anglerfish'.\n") + print("\n[!] Requirements are not satisfied. Please install the 'anglerfish' package by running 'python -m pip install anglerfish'.\n") exit() print("\nwebConverter for master\n") p = Path.cwd() parent = p.parent.parent -q = PurePath('espbug_public') +q = p #PurePath('ESPBug') arduino_file_path = str(os.path.join(str(parent / q), "webfiles.h")) datadir = parent / q q = PurePath('web_interface') diff --git a/web_converter/web_pages/compressed/example.html.gz b/web_converter/web_pages/compressed/example.html.gz new file mode 100644 index 0000000..51eb60a Binary files /dev/null and b/web_converter/web_pages/compressed/example.html.gz differ diff --git a/web_converter/web_pages/example.html b/web_converter/web_pages/example.html new file mode 100644 index 0000000..c87692f --- /dev/null +++ b/web_converter/web_pages/example.html @@ -0,0 +1,10 @@ + + + + +

My First Heading

+ +

My first paragraph.

+ + + diff --git a/web_converter/webfiles.h b/web_converter/webfiles.h new file mode 100644 index 0000000..2c4465f --- /dev/null +++ b/web_converter/webfiles.h @@ -0,0 +1,4 @@ +const char examplehtml[] PROGMEM = {0x1f, 0x8b, 0x08, 0x08, 0x1e, 0x53, 0xde, 0x5e, 0x02, 0xff, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x00, 0xb3, 0x51, 0x74, 0xf1, 0x77, 0x0e, 0x89, 0x0c, 0x70, 0x55, 0xc8, 0x28, 0xc9, 0xcd, 0xb1, 0x53, 0xb0, 0xc9, 0x30, 0xb4, 0xf3, 0xad, 0x54, 0x70, 0xcb, 0x2c, 0x2a, 0x2e, 0x51, 0xf0, 0x48, 0x4d, 0x4c, 0xc9, 0xcc, 0x4b, 0xb7, 0xd1, 0x07, 0x0a, 0x2a, 0xd8, 0x14, 0x80, 0x24, 0xd2, 0xc0, 0x12, 0x05, 0x89, 0x45, 0x89, 0xe9, 0x45, 0x89, 0x05, 0x19, 0x7a, 0x36, 0xfa, 0x05, 0x76, 0x00, 0x99, 0x55, 0xaf, 0xa0, 0x44, 0x00, 0x00, 0x00}; +void copyWebFiles(bool force){ + if(!SPIFFS.exists(String(F("/web/example.html.gz"))) || force) progmemToSpiffs(examplehtml, sizeof(examplehtml), String(F("/web/example.html.gz"))); +}