diff --git a/data/edit.htm b/data/edit.htm index cd185e2c..f25ffeff 100644 --- a/data/edit.htm +++ b/data/edit.htm @@ -1,665 +1 @@ - - -
- - - - - - - - - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'); - ihtm("pkg","Based on the previous work of the following open source developers:
Copyright© 2019 Allen Derusha allen @derusha.orgMIT License
Copyright© 2021 LVGL KftMIT License
Copyright© 2020 lovyan03 (https://github.com/lovyan03) All rights reserved.FreeBSD License
Copyright© 2020 Bodmer (https://github.com/Bodmer) All rights reserved.FreeBSD License
Copyright© 2012 Adafruit Industries. All rights reservedBSD License
Copyright© 2014-2021 Benoit BLANCHONMIT License
Copyright© 2008-2015 Nicholas O'LearyMIT License
Copyright© 2017,2018 Thijs Elenbaas, MrRobot62, rahuldeo2047, NOX73, dhylands, Josha blemasle, mfalkviddMIT License
Copyright© Project NayukiMIT License
Copyright© 2017 Renzo Mischianti www.mischianti.org All right reserved.MIT License
Copyright© 2018 Brian T. ParkMIT License
"); -} -function handleSubmit(e) { - e.preventDefault(); - const t = new FormData(e.target), - o = Object.fromEntries(t.entries()); - console.log({ value: o }); -} -function info2() { - try { - data = JSON.parse(this.response); - var e = "${t} | |
---|---|
${o}: | ${data[t][o]} |
\n ${e}\n
`);const a=_("toast").firstElementChild;a.addEventListener("animationend",(()=>a.remove()))}document.addEventListener("blur",(function(){hidectx()})),document.addEventListener("DOMContentLoaded",(function(){createEditor("editor",void 0,void 0,void 0);listFiles(_("tree"),"/"),_("tree").getElementsByTagName("div")[0].oncontextmenu=e=>{ctx(e,{name:"",children:[]},"",_("tree"))},_("load").onclick=function(e){const t=new FormData;t.append("load",""),fetchData("/edit","PUT",t)},_("init").onclick=function(e){const t=new FormData;t.append("init",""),fetchData("/edit","PUT",t)},_("home").onclick=function(e){window.location.href="/"},_("page").onchange=function(e){const t=new FormData;t.append("page",_("page").value),fetchData("/edit","PUT",t)}})),document.addEventListener("DOMContentLoaded",(function(){const e=document.getElementById("dragMe"),t=e.previousElementSibling,n=e.nextElementSibling;let o=0,a=0,i=0;const c=function(a){const c=a.clientX-o,s=(a.clientY,100*(i+c)/e.parentNode.getBoundingClientRect().width);t.style.width=`${s}%`,t.style.right=t.style.width,e.style.cursor="col-resize",document.body.style.cursor="col-resize",t.style.userSelect="none",t.style.pointerEvents="none",n.style.userSelect="none",n.style.pointerEvents="none",ace.edit("editor").resize()},s=function(){e.style.removeProperty("cursor"),document.body.style.removeProperty("cursor"),t.style.removeProperty("user-select"),t.style.removeProperty("pointer-events"),n.style.removeProperty("user-select"),n.style.removeProperty("pointer-events"),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",s)};e.addEventListener("mousedown",(function(e){o=e.clientX,a=e.clientY,i=t.getBoundingClientRect().width,document.addEventListener("mousemove",c),document.addEventListener("mouseup",s)})),e.addEventListener("dblclick",(()=>{var e=t.style.visibility="hidden"===t.style.visibility;t.style.visibility=e?"unset":"hidden",t.style.position=e?"unset":"absolute",ace.edit("editor").resize()}))})); \ No newline at end of file diff --git a/data/static/edit.htm.gz b/data/static/edit.htm.gz index cbea9b3c..8ddca4a7 100644 Binary files a/data/static/edit.htm.gz and b/data/static/edit.htm.gz differ diff --git a/data/static/en.json.gz b/data/static/en.json.gz index 4c8f258b..69abbe80 100644 Binary files a/data/static/en.json.gz and b/data/static/en.json.gz differ diff --git a/data/static/main.js.gz b/data/static/main.js.gz index d5feb9cf..1db00d05 100644 Binary files a/data/static/main.js.gz and b/data/static/main.js.gz differ diff --git a/data/static/script.js.gz b/data/static/script.js.gz index 3fc28f3e..0bbc6fe8 100644 Binary files a/data/static/script.js.gz and b/data/static/script.js.gz differ diff --git a/data/static/style.css.gz b/data/static/style.css.gz index d7ed0ac6..6d8a3513 100644 Binary files a/data/static/style.css.gz and b/data/static/style.css.gz differ diff --git a/data/style.css b/data/style.css index eea45e82..6b3ac6eb 100644 --- a/data/style.css +++ b/data/style.css @@ -9,6 +9,8 @@ --star: url('data:image/svg+xml,'); --trash: url('data:image/svg+xml,'); --download: url('data:image/svg+xml,'); + --upload: url('data:image/svg+xml,'); + --flash: url('data:image/svg+xml,'); --file: url('data:image/svg+xml,'); --dir: url('data:image/svg+xml,'); --diropen: url('data:image/svg+xml,'); @@ -17,8 +19,10 @@ --zip: url('data:image/svg+xml,'); --cmd: url('data:image/svg+xml,'); --css: url('data:image/svg+xml,'); + --ttf: url('data:image/svg+xml,'); --eye: url('data:image/svg+xml,'); --json: url('data:image/svg+xml,'); + --audio: url('data:image/svg+xml,'); } .fn:hover { @@ -57,12 +61,14 @@ .fa-browse { mask-image: var(--browse); -webkit-mask-image: var(--browse)} .fa-cog { mask-image: var(--cog); -webkit-mask-image: var(--cog)} .fa-download{ mask-image: var(--download); -webkit-mask-image: var(--download)} +.fa-upload { mask-image: var(--upload); -webkit-mask-image: var(--upload)} .fa-home { mask-image: var(--home); -webkit-mask-image: var(--home)} .fa-info { mask-image: var(--info); -webkit-mask-image: var(--info)} .fa-ota { mask-image: var(--ota); -webkit-mask-image: var(--ota)} .fa-shot { mask-image: var(--shot); -webkit-mask-image: var(--shot)} .fa-star { mask-image: var(--star); -webkit-mask-image: var(--star)} .fa-trash { mask-image: var(--trash); -webkit-mask-image: var(--trask)} +.fa-flash { mask-image: var(--flash); -webkit-mask-image: var(--flash)} .fa-file { mask-image: var(--file); -webkit-mask-image: var(--file)} .fa-dir { mask-image: var(--dir); -webkit-mask-image: var(--dir)} .fa-diropen { mask-image: var(--diropen); -webkit-mask-image: var(--diropen)} @@ -73,7 +79,9 @@ .fa-json { mask-image: var(--json); -webkit-mask-image: var(--json)} .fa-jsonl { mask-image: var(--json); -webkit-mask-image: var(--json)} .fa-image { mask-image: var(--image); -webkit-mask-image: var(--image)} +.fa-audio { mask-image: var(--audio); -webkit-mask-image: var(--audio)} .fa-html { mask-image: var(--html); -webkit-mask-image: var(--html)} +.fa-ttf { mask-image: var(--ttf); -webkit-mask-image: var(--ttf)} .nav-list { font-size: var(--fs-nav); @@ -455,6 +463,7 @@ a.foot:visited { justify-content: left; overflow-x: clip; overflow-y: scroll; + background-color: var(--treebg); /* Popout */ top: 0; @@ -479,8 +488,7 @@ a.foot:visited { /* Misc */ align-items: center; display: flex; - justify-content: center; - background-color: var(--grpbg) + background-color: #888; } .toolbar { text-align: center; @@ -519,9 +527,7 @@ a.foot:visited { #ctx > ul { padding-left: 0px; } -#ctx > ul > li, -.sub_div > ul > li { - cursor: pointer; +#ctx > ul > li { white-space: nowrap } #ctx > ul > li:hover { @@ -531,8 +537,7 @@ a.foot:visited { width: 3rem } #preview { - background-color: #888; - padding: 5px; + padding: 0.3rem; overflow: scroll; } #preview > img { @@ -550,10 +555,11 @@ a.foot:visited { width: 100%; line-height: 1.3rem; font-size: 0.95rem; - background-color: var(--treebg) } .download{background-image: var(--download)} +.upload{background-image: var(--upload)} .eye{background-image: var(--eye)} +.flash{background-image: var(--flash)} .file{background-image: var(--file)} .zip{background-image: var(--zip)} .css{background-image: var(--css)} @@ -561,6 +567,41 @@ a.foot:visited { .json{background-image: var(--json)} .jsonl{background-image: var(--json)} .image{background-image: var(--image)} +.audio{background-image: var(--audio)} .html{background-image: var(--html)} .dir{background-image: var(--dir)} .diropen{background-image: var(--diropen)} + + +#toast { + position: fixed; + bottom: 1rem; + right: 1.5rem; + display: grid; + align-items: end; + align-content: end; + gap: 1rem; +} + +.toast { + font-size: 1rem; + margin: 0; + font-weight: bold; + line-height: 1; + padding: 0.5em 1em; + background-color: lightblue; + animation: toastIt 3000ms cubic-bezier(0.785, 0.135, 0.15, 0.86) forwards; +} + +@keyframes toastIt { + 0%, + 100% { + transform: translateY(150%); + opacity: 0; + } + 10%, + 90% { + transform: translateY(0); + opacity: 1; + } +} diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp index 75ccecf2..a72d94aa 100644 --- a/src/sys/svc/hasp_http.cpp +++ b/src/sys/svc/hasp_http.cpp @@ -80,16 +80,16 @@ extern const uint8_t SCRIPT_JS_GZ_START[] asm("_binary_data_static_script_js_gz_ extern const uint8_t SCRIPT_JS_GZ_END[] asm("_binary_data_static_script_js_gz_end"); extern const uint8_t LOGO_SVG_GZ_START[] asm("_binary_data_static_logo_svg_gz_start"); extern const uint8_t LOGO_SVG_GZ_END[] asm("_binary_data_static_logo_svg_gz_end"); -extern const uint8_t ACE_JS_GZ_START[] asm("_binary_data_static_ace_1_9_6_min_js_gz_start"); -extern const uint8_t ACE_JS_GZ_END[] asm("_binary_data_static_ace_1_9_6_min_js_gz_end"); extern const uint8_t PETITE_VUE_HASP_JS_GZ_START[] asm("_binary_data_static_petite_vue_hasp_js_gz_start"); extern const uint8_t PETITE_VUE_HASP_JS_GZ_END[] asm("_binary_data_static_petite_vue_hasp_js_gz_end"); extern const uint8_t MAIN_JS_GZ_START[] asm("_binary_data_static_main_js_gz_start"); extern const uint8_t MAIN_JS_GZ_END[] asm("_binary_data_static_main_js_gz_end"); extern const uint8_t EN_JSON_GZ_START[] asm("_binary_data_static_en_json_gz_start"); extern const uint8_t EN_JSON_GZ_END[] asm("_binary_data_static_en_json_gz_end"); -extern const uint8_t HASP_HTM_GZ_START[] asm("_binary_data_static_hasp_htm_gz_start"); -extern const uint8_t HASP_HTM_GZ_END[] asm("_binary_data_static_hasp_htm_gz_end"); +// extern const uint8_t HASP_HTM_GZ_START[] asm("_binary_data_static_hasp_htm_gz_start"); +// extern const uint8_t HASP_HTM_GZ_END[] asm("_binary_data_static_hasp_htm_gz_end"); +// extern const uint8_t ACE_JS_GZ_START[] asm("_binary_data_static_ace_1_9_6_min_js_gz_start"); +// extern const uint8_t ACE_JS_GZ_END[] asm("_binary_data_static_ace_1_9_6_min_js_gz_end"); #endif // CONFIG_IDF_TARGET_ESP32 @@ -1218,22 +1218,31 @@ static void handleFileDelete() { if(!http_is_authenticated(F("filedelete"))) return; - char mimetype[16]; - snprintf_P(mimetype, sizeof(mimetype), PSTR("text/plain")); + const char mimetype[] = "text/plain"; - if(webServer.args() == 0) { - return webServer.send_P(500, mimetype, PSTR("BAD ARGS")); + if(!webServer.hasArg("path")) { + return webServer.send(500, mimetype, "BAD ARGS"); } - String path = webServer.arg(0); + String path = webServer.arg("path"); LOG_TRACE(TAG_HTTP, F("handleFileDelete: %s"), path.c_str()); if(path == "/") { - return webServer.send_P(500, mimetype, PSTR("BAD PATH")); + return webServer.send(500, mimetype, "BAD PATH"); } if(!HASP_FS.exists(path)) { - return webServer.send_P(404, mimetype, PSTR("FileNotFound")); + return webServer.send(404, mimetype, "FileNotFound"); + } + bool result; + if(path.endsWith("/")) { + path.remove(path.length() - 1); + result = HASP_FS.rmdir(path); + } else { + result = HASP_FS.remove(path); + } + if(result) { + webServer.send(200, mimetype, String("")); + } else { + webServer.send(405, mimetype, "RemoveFailed"); } - HASP_FS.remove(path); - webServer.send(200, mimetype, String("")); } static void handleFileCreate() @@ -2275,16 +2284,16 @@ static inline int handleFirmwareFile(String path) #if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) if(path == F("/edit.htm")) { return http_send_static_gzip_file(EDIT_HTM_GZ_START, EDIT_HTM_GZ_END, contentType); - } else if(path == F("/hasp.htm")) { // 39 kB - return http_send_static_gzip_file(HASP_HTM_GZ_START, HASP_HTM_GZ_END, contentType); + // } else if(path == F("/hasp.htm")) { // 39 kB + // return http_send_static_gzip_file(HASP_HTM_GZ_START, HASP_HTM_GZ_END, contentType); } else if(path == F("/logo.svg")) { // 300 bytes return http_send_static_gzip_file(LOGO_SVG_GZ_START, LOGO_SVG_GZ_END, contentType); } else if(path == F("/style.css")) { // 11 kB return http_send_static_gzip_file(STYLE_CSS_GZ_START, STYLE_CSS_GZ_END, contentType); } else if(path == F("/vars.css")) { return http_send_static_file(HTTP_VARS_CSS, HTTP_VARS_CSS + sizeof(HTTP_VARS_CSS) - 1, contentType); - // } else if(path == F("/script.js")) { // 3 kB - // return http_send_static_gzip_file(SCRIPT_JS_GZ_START, SCRIPT_JS_GZ_END, contentType); + } else if(path == F("/script.js")) { // 3 kB + return http_send_static_gzip_file(SCRIPT_JS_GZ_START, SCRIPT_JS_GZ_END, contentType); } else if(path == F("/en.json")) { // 2 kB return http_send_static_gzip_file(EN_JSON_GZ_START, EN_JSON_GZ_END, contentType); } else if(path == F("/main.js")) { // 9 kB @@ -2292,8 +2301,8 @@ static inline int handleFirmwareFile(String path) } else if(path == F("/petite-vue.hasp.js")) { // 9 kB return http_send_static_gzip_file(PETITE_VUE_HASP_JS_GZ_START, PETITE_VUE_HASP_JS_GZ_END, contentType); #if ESP_FLASH_SIZE > 4 - } else if(path == F("/ace.js")) { // 96 kB - return http_send_static_gzip_file(ACE_JS_GZ_START, ACE_JS_GZ_END, contentType); + // } else if(path == F("/ace.js")) { // 96 kB + // return http_send_static_gzip_file(ACE_JS_GZ_START, ACE_JS_GZ_END, contentType); #endif } #endif // ARDUINO_ARCH_ESP32 diff --git a/tools/auto_firmware_version.py b/tools/auto_firmware_version.py index f0a3d901..d4fd4f2e 100644 --- a/tools/auto_firmware_version.py +++ b/tools/auto_firmware_version.py @@ -48,3 +48,21 @@ with open("data/main.js", "r", encoding="utf-8") as f: html = html.replace("COMMIT_HASH", commit_hash) with gzip.open('data/static/main.js.gz', 'wb') as f: f.write(html.encode('utf-8')) + +with open("data/script.js", "r", encoding="utf-8") as f: + html=f.read() +html = html.replace("COMMIT_HASH", commit_hash) +with gzip.open('data/static/script.js.gz', 'wb') as f: + f.write(html.encode('utf-8')) + +with open("data/en.json", "r", encoding="utf-8") as f: + html=f.read() +html = html.replace("COMMIT_HASH", commit_hash) +with gzip.open('data/static/en.json.gz', 'wb') as f: + f.write(html.encode('utf-8')) + +with open("data/style.css", "r", encoding="utf-8") as f: + html=f.read() +html = html.replace("COMMIT_HASH", commit_hash) +with gzip.open('data/static/style.css.gz', 'wb') as f: + f.write(html.encode('utf-8')) diff --git a/tools/esp_merge_bin.py b/tools/esp_merge_bin.py index 6cada46c..4c484f78 100644 --- a/tools/esp_merge_bin.py +++ b/tools/esp_merge_bin.py @@ -58,10 +58,11 @@ def copy_merge_bins(source, target, env): mcu = board.get("build.mcu", "esp32") bootloader = "{}tools{}sdk{}{}{}bin{}bootloader_{}_{}.bin".format(FRAMEWORK_DIR, os.path.sep, os.path.sep, mcu, os.path.sep, os.path.sep, flash_mode, flash_freq) + # # if not os.path.isfile(bootloader): + # # bootloader = "{}tools{}sdk{}bin{}bootloader_dio_40m.bin".format(FRAMEWORK_DIR, os.path.sep, os.path.sep, os.path.sep, os.path.sep, os.path.sep) # if not os.path.isfile(bootloader): - # bootloader = "{}tools{}sdk{}bin{}bootloader_dio_40m.bin".format(FRAMEWORK_DIR, os.path.sep, os.path.sep, os.path.sep, os.path.sep, os.path.sep) - if not os.path.isfile(bootloader): - bootloader = "{}tools{}sdk{}{}{}bin{}bootloader_{}_{}.bin".format(FRAMEWORK_DIR, os.path.sep, os.path.sep, mcu, os.path.sep, os.path.sep, flash_mode, flash_freq) + # bootloader = "{}tools{}sdk{}{}{}bin{}bootloader_{}_{}.bin".format(FRAMEWORK_DIR, os.path.sep, os.path.sep, mcu, os.path.sep, os.path.sep, flash_mode, flash_freq) + bootloader = str(target[0]).replace('firmware.bin','bootloader.bin') bootloader_location = '0x1000' if (mcu == 'esp32s3'): bootloader_location = '0x0000' @@ -94,7 +95,10 @@ def copy_merge_bins(source, target, env): print(f_flash) print(flash_mode) - process = subprocess.Popen(['python', 'tools/esptool_with_merge_bin.py', '--chip', mcu, 'merge_bin', '--output', firmware_dst, '--flash_mode', 'dio', '--flash_size', flash_size, '--flash_freq', flash_freq, bootloader_location, bootloader, '0x8000', partitions, '0xe000', boot_app0, '0x10000', firmware_src], + # esptool = 'tools/esptool_with_merge_bin.py' + esptool = '{}{}esptool.py'.format(platform.get_package_dir("tool-esptoolpy"),os.path.sep) + print(esptool) + process = subprocess.Popen(['python', esptool, '--chip', mcu, 'merge_bin', '--output', firmware_dst, '--flash_mode', 'dio', '--flash_size', flash_size, '--flash_freq', flash_freq, bootloader_location, bootloader, '0x8000', partitions, '0xe000', boot_app0, '0x10000', firmware_src], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() diff --git a/tools/minifiy.py b/tools/minifiy.py new file mode 100644 index 00000000..1c83e7b2 --- /dev/null +++ b/tools/minifiy.py @@ -0,0 +1,69 @@ +import gzip, minify_html + +# options = { +# "do_not_minify_doctype": True, +# "ensure_spec_compliant_unquoted_attribute_values": False, +# "keep_closing_tags": True, +# "keep_html_and_head_opening_tags": True, +# "keep_spaces_between_attributes": True, +# "keep_comments": True, +# "minify_css": True, +# "minify_js": True, +# "remove_bangs": False, +# "remove_processing_instructions": False +# } + +# with open("data/script.js", "r") as f: +# html=f.read() +# minified = minify_html.minify(html, options) +# with gzip.open('data/static/script.js.gz', 'wb') as f: +# f.write(minified.encode('utf-8')) + +# with open("data/editor.htm", "r") as f: +# html=f.read() +# # minified = minify_html.minify(html, options) +# with gzip.open('data/static/edit.htm.gz', 'wb') as f: +# f.write(html.encode('utf-8')) +# with open('data/edit.htm', 'wb') as f: +# f.write(html.encode('utf-8')) + + +# with open("data/style.css", "r") as f: +# html=f.read() +# with gzip.open('data/static/style.css.gz', 'wb') as f: +# f.write(html.encode('utf-8')) +# minified = minify_html.minify(html, options).replace('"id=mdi-','" id=mdi-') +# with open('data/style.min.css', 'wb') as f: +# f.write(minified.encode('utf-8')) + + +# with open("data/hasp.htm", "r") as f: +# html=f.read() +# minified = minify_html.minify(html, options) +# with gzip.open('data/static/hasp.htm.gz', 'wb') as f: +# f.write(minified.encode('utf-8')) + + + +# with open("data/en.json", "r") as f: +# html=f.read() +# minified = minify_html.minify(html, options) +# with gzip.open('data/static/en.json.gz', 'wb') as f: +# f.write(minified.encode('utf-8')) + +# with open("data/nl.json", "r") as f: +# html=f.read() +# minified = minify_html.minify(html, options) +# with gzip.open('data/static/nl.json.gz', 'wb') as f: +# f.write(minified.encode('utf-8')) + +# with open("data/fr.json", "r") as f: +# html=f.read() +# minified = minify_html.minify(html, options) +# with gzip.open('data/static/fr.json.gz', 'wb') as f: +# f.write(minified.encode('utf-8')) + +# with open("data/main.js", "r") as f: +# html=f.read() +# with gzip.open('data/static/main.js.gz', 'wb') as f: +# f.write(html.encode('utf-8')) diff --git a/user_setups/esp32/_esp32.ini b/user_setups/esp32/_esp32.ini index 727dce69..5b969c98 100644 --- a/user_setups/esp32/_esp32.ini +++ b/user_setups/esp32/_esp32.ini @@ -23,11 +23,11 @@ board_build.embed_files = data/cert/x509_crt_bundle.bin ; -- new dynamic website files ------------------- data/static/logo.svg.gz - data/static/ace.1.9.6.min.js.gz + ; data/static/ace.1.9.6.min.js.gz data/static/petite-vue.hasp.js.gz data/static/main.js.gz data/static/en.json.gz - data/static/hasp.htm.gz + ; data/static/hasp.htm.gz build_flags = ${env.build_flags}