Skip to content

Commit

Permalink
added explination for webconvert
Browse files Browse the repository at this point in the history
  • Loading branch information
Will committed Jun 8, 2020
1 parent 7710fd2 commit fd34b29
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 4 deletions.
96 changes: 94 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -109,8 +109,100 @@ SSL Support: "All SSL ciphers (most compatible)"
Port : "<USB 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 <PATH TO>\ESPBug\web_converter
parent <PATH TO>
q compressed
arduino_file_path <PATH TO>\ESPBug\web_converter\webfiles.h
datadir <PATH TO>\ESPBug\web_converter\web_pages
dir <PATH TO>\web_interface
datadir <PATH TO>\ESPBug\web_converter\web_pages
compressed <PATH TO>\ESPBug\web_converter\web_pages\compressed
filelist []
html_files [WindowsPath('<PATH TO>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 `<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

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified web_converter/css_html_js_minify/__pycache__/minify.cpython-37.pyc
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions web_converter/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
anglerfish
4 changes: 2 additions & 2 deletions web_converter/webConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Binary file added web_converter/web_pages/compressed/example.html.gz
Binary file not shown.
10 changes: 10 additions & 0 deletions web_converter/web_pages/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>
4 changes: 4 additions & 0 deletions web_converter/webfiles.h
Original file line number Diff line number Diff line change
@@ -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")));
}

0 comments on commit fd34b29

Please sign in to comment.