Merge pull request #14322 from barbudor/favicon

Add favicon on browser
This commit is contained in:
Theo Arends 2022-01-08 11:14:34 +01:00 committed by GitHub
commit 027eb98e8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 87 additions and 50 deletions

View File

@ -2,21 +2,32 @@
// compressed by tools/unishox/compress-html-uncompressed.py
/////////////////////////////////////////////////////////////////////
const size_t HTTP_HEADER1_SIZE = 371;
const size_t HTTP_HEADER1_SIZE = 692;
const char HTTP_HEADER1_COMPRESSED[] PROGMEM = "\x3D\x0F\xE1\x10\x98\x1D\x19\x0C\x64\x85\x50\xD0\x8F\xC3\xD0\x55\x0D\x09\x05\x7C"
"\x3C\x7C\x3D\x87\xD7\x8F\x62\x0C\x2B\xF7\x8F\x87\xB0\xF6\x1F\x87\xA0\xA7\x62\x1F"
"\x87\xA0\xD7\x56\x83\x15\x7F\xF3\xA3\xE1\xF6\x2E\x8C\x1D\x67\x3E\x7D\x90\x21\x52"
"\xEB\x1A\xCF\x87\xB0\xCF\x58\xF8\xCC\xFD\x1E\xC4\x1E\x75\x3E\xA3\xE1\xEC\x1F\xD1"
"\x28\x51\xF0\x46\x67\xA1\xB3\xAC\x7F\x44\xA1\x47\x56\xF6\xD6\xD8\x47\x5F\x83\xB0"
"\x99\xF0\xE4\x3A\x88\x5F\x9F\xCE\xBF\x07\x61\x58\xE0\x99\xF3\xB0\xF6\x1D\x87\xE1"
"\xE9\x5B\x41\x33\xF0\xFA\xF2\x3A\xD1\xF5\xE3\xD0\xEC\x04\x19\x67\xA7\x83\xFE\x8C"
"\xA3\xF0\xCE\xFE\x8D\x87\xCE\x16\x10\x47\x50\x54\x75\x56\x1D\x54\x30\xEA\x18\x19"
"\xF0\xFB\x3E\xCF\x0C\x71\xF3\xC7\xC3\xF0\x4C\x0C\x58\xD7\xD4\x74\x1E\x74\x4C\x26"
"\x35\xF5\x10\xE3\x22\xD1\x0E\xEF\x8E\xF1\xE0\xD5\xE0\x48\xBA\x6A\x16\xFE\x64\x5E"
"\x61\x30\xEB\x3E\x77\x7C\x77\x8F\x1E\x18\x7C\xD3\xE1\xF8\xC7\x1D\xDD\x3B\xC7\x4A"
"\x32\x18\xCF\x87\x74\x11\xA4\x1F\x0F\x87\xDD\x33\x65\x1F\x67\x68\xFB\x19\x7E\xF0"
"\xFE\x7C\x43\xEC\xF3\x04\x19\xC7\x78\xF0\x3E\x11\xF0\xC1\xF0\xFC\x1F\xDE\x13\x07"
"\xCE\x96\x20\x84\xCC\xDF\x51\x05\xBE\xA7\xCF\xE7\x74\xFB\x0B\x2C\x43\xEC\xEA\x30"
"\x77\x8F\x06";
"\xE8\x16\xF1\xA2\xFB\x08\xF8\x7B\x34\x3C\xE3\xD8\x85\x7D\x98\x3E\x1E\xC1\x2E\xAC"
"\xF3\xD1\xB6\x3C\xCE\xC3\x61\xD7\xA1\xE7\x1E\x07\x5F\x99\xCE\xC3\xA8\x81\x0A\x19"
"\x15\xDD\x8E\xBB\x76\xC7\x58\x77\x6E\xEC\xD4\x19\x0F\x95\x95\x95\x95\x91\x81\xE2"
"\xB2\xB2\xB2\x0C\x78\x8A\xEE\xEC\xD5\x77\x77\xB6\x46\xF4\x02\x26\x40\x85\x28\xDE"
"\xBC\x76\x1D\x87\x61\xD8\x56\x43\x0E\x69\xD8\x43\x8E\xD9\x0A\x39\xC4\x46\xC3\x94"
"\x76\x10\xA3\x9F\x23\x43\x88\x8C\xCE\x61\x32\x36\xF0\xE3\xB6\x42\x85\x88\x72\x8E"
"\xC2\x14\x73\xC5\xC2\x19\x9C\xC2\x67\x36\xC8\x71\xDB\x23\x03\x48\xDA\x34\xEC\x14"
"\x43\x4D\x0D\x86\x67\x30\x88\xDA\x3C\x46\xD1\xC7\x6C\x85\x16\x06\x72\x8E\xC2\x14"
"\x73\x4E\xD9\x08\x66\x73\x08\xC1\x0C\x21\x83\x8E\xD9\x0A\x39\xA5\xC7\x28\xEC\x21"
"\x47\x61\x08\x71\x11\x99\xCC\x23\x07\x34\xEC\x21\xC7\x6C\x99\x59\x59\x61\xCC\x22"
"\x65\x65\x64\x20\xB2\x1C\x56\x56\x56\x73\xC4\x3C\x46\xA0\x4B\x98\x0B\x77\x01\x42"
"\xE1\xEC\x3F\x0F\x4A\xDA\x09\x9F\x87\xD7\x91\xD6\x8F\xAF\x1E\x87\x60\x20\xCB\x3D"
"\x3C\x1F\xF4\x65\x1F\x86\x77\xF4\x6C\x3E\x70\xB0\x82\x3A\x82\xA3\xAA\xB0\xEA\xA1"
"\x87\x50\xC0\xCF\x87\xD9\xF6\x78\x63\x8F\x9E\x3E\x1F\x82\x60\x62\xC6\xBE\xA3\xA0"
"\xF3\xA2\x61\x31\xAF\xA8\x87\x19\x16\x88\x77\x7C\x77\x8F\x06\xAF\x02\x45\xD3\x50"
"\xB7\xF3\x22\xF3\x09\x87\x59\xF3\xBB\xE3\xBC\x78\xF0\xC3\xE6\x9F\x0F\xC6\x38\xEE"
"\xE9\xDE\x3A\x51\x90\xC6\x7C\x3B\xA0\x8D\x20\xF8\x7C\x3E\xE9\x9B\x28\xFB\x3B\x47"
"\xD8\xCB\xF7\x87\xF3\xE2\x1F\x67\x98\x20\xCE\x3B\xC7\x81\xF0\x8F\x86\x0F\x87\xE0"
"\xFE\xF0\x98\x3E\x74\xB1\x04\x26\x66\xFA\x88\x2D\xF5\x3E\x7F\x3B\xA7\xD8\x59\x62"
"\x1F\x67\x51\x83\xBC\x78";
#define HTTP_HEADER1 Decompress(HTTP_HEADER1_COMPRESSED,HTTP_HEADER1_SIZE).c_str()

View File

@ -2,21 +2,33 @@
// compressed by tools/unishox/compress-html-uncompressed.py
/////////////////////////////////////////////////////////////////////
const size_t HTTP_HEADER1_SIZE = 425;
const size_t HTTP_HEADER1_SIZE = 753;
const char HTTP_HEADER1_COMPRESSED[] PROGMEM = "\x3D\x0F\xE1\x10\x98\x1D\x19\x0C\x64\x85\x50\xD0\x8F\xC3\xD0\x55\x0D\x09\x05\x7C"
"\x3C\x7C\x3D\x87\xD7\x8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B\xC7\x83\xDC";
"\xE8\x16\xF1\xA2\xFB\x08\xF8\x7B\x34\x3C\xE3\xD8\x85\x7D\x98\x3E\x1E\xC1\x2E\xAC"
"\xF3\xD1\xB6\x3C\xCE\xC3\x61\xD7\xA1\xE7\x1E\x07\x5F\x99\xCE\xC3\xA8\x81\x0A\x18"
"\x21\x43\x22\xBB\xB1\xD7\x6E\xD8\xEB\x0E\xED\xDD\x9A\x83\x21\xF2\xB2\xB2\xB2\xB2"
"\x30\x3C\x56\x56\x56\x41\x8F\x11\x5D\xDD\x9A\xAE\xEE\xF6\xC8\xDE\x80\x44\xC8\x10"
"\xA5\x1B\xD7\x8E\xC3\xB0\xEC\x3B\x0A\xC8\x61\xCD\x3B\x08\x71\xDB\x21\x47\x38\x88"
"\xD8\x72\x8E\xC2\x14\x73\xE4\x68\x71\x11\x99\xCC\x26\x46\xDE\x1C\x76\xC8\x50\xB1"
"\x0E\x51\xD8\x42\x8E\x78\xB8\x43\x33\x98\x4C\xE6\xD9\x0E\x3B\x64\x60\x69\x1B\x46"
"\x9D\x82\x88\x69\xA1\xB0\xCC\xE6\x11\x1B\x47\x88\xDA\x38\xED\x90\xA2\xC0\xCE\x51"
"\xD8\x42\x8E\x69\xDB\x21\x0C\xCE\x61\x18\x21\x84\x30\x71\xDB\x21\x47\x34\xB8\xE5"
"\x1D\x84\x28\xEC\x21\x0E\x22\x33\x39\x84\x60\xE6\x9D\x84\x38\xED\x93\x2B\x2B\x2C"
"\x39\x84\x4C\xAC\xAC\x84\x16\x43\x8A\xCA\xCA\xCE\x78\x87\x88\xD4\x09\x73\x01\x6E"
"\xE0\x28\x5C\x3D\x87\xE1\xE9\x5B\x41\x33\xF0\xFA\xF2\x3A\xD1\xF5\xE3\xD0\xEC\x04"
"\x19\x67\xA7\x83\xFE\x8C\xA3\xF0\xCE\xFE\x8D\x87\xCE\x16\x10\x47\x50\x54\x75\x56"
"\x1D\x54\x30\xEA\x18\x19\xF0\xFB\x3E\xCF\x06\x05\xF0\x75\xB9\xC9\x8E\x3B\xBE\x3B"
"\xC7\xB7\xEE\x85\xFF\x90\x98\x18\xB1\xAF\xA8\xE8\x3C\xE8\x98\x4C\x6B\xEA\x21\xC6"
"\x45\xA2\x1D\xDF\x1D\xE3\xC1\xEE\x04\x4C\x38\xD5\xE0\x4F\xC3\x8D\x42\xDF\xCC\x8B"
"\xCC\x26\x1D\x67\xC1\x27\x0D\xF0\xC3\xBB\xA7\x78\xF6\xB1\xC7\x77\x4E\xF1\xD2\x8C"
"\x86\x33\xE1\xDD\x04\x69\x07\xC3\xE1\xF7\x4C\xD9\x47\xD9\xDA\x3E\xC6\x5F\xBC\x3F"
"\x9F\x10\xFB\x3C\xC1\x06\x70\x23\xE3\xE3\xE1\x1D\xD3\x07\x78\xF6\x8F\xEF\x09\x83"
"\xE7\x4B\x10\x42\x66\x6F\xA8\x82\xDF\x53\xE7\xF3\xBA\x7D\x85\x96\x21\xF6\x75\x18"
"\x3B\xC7\x83\xDC";
#define HTTP_HEADER1 Decompress(HTTP_HEADER1_COMPRESSED,HTTP_HEADER1_SIZE).c_str()

View File

@ -3,6 +3,9 @@ const char HTTP_HEADER1[] PROGMEM =
"<head>"
"<meta charset='utf-8'>"
"<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,user-scalable=no\"/>"
#ifdef USE_WEB_FAVICON // No impact when using unishox as compressor ignore #if
"<link rel=\"icon\" href=\"data:image/x-icon;base64,base64,AAABAAEAEBACAAEAAQCwAAAAFgAAACgAAAAQAAAAIAAAAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AP5/b+H6X2/h8k9v4eZnb+Hud2/h7ndv4e53b+FmZm/hMkxv4ZgZb+HOc2/h5+dv4fPPb+H5n2/h/D9v4f5/b+EAAO4EAADuBAAA7gQAAO4EAADuBAAA7gQAAO4EAADuBAAA7gQAAO4EAADuBAAA7gQAAO4EAADuBAAA7gQAAO4E\">"
#endif
"<title>%s - %s</title>"
"<script>"

View File

@ -3,6 +3,9 @@ const char HTTP_HEADER1[] PROGMEM =
"<head>"
"<meta charset='utf-8'>"
"<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,user-scalable=no\"/>"
#ifdef USE_WEB_FAVICON // No impact when using unishox as compressor ignore #if
"<link rel=\"icon\" href=\"data:image/x-icon;base64,base64,base64,AAABAAEAEBACAAEAAQCwAAAAFgAAACgAAAAQAAAAIAAAAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AP5/b+H6X2/h8k9v4eZnb+Hud2/h7ndv4e53b+FmZm/hMkxv4ZgZb+HOc2/h5+dv4fPPb+H5n2/h/D9v4f5/b+EAAO4EAADuBAAA7gQAAO4EAADuBAAA7gQAAO4EAADuBAAA7gQAAO4EAADuBAAA7gQAAO4EAADuBAAA7gQAAO4E\">"
#endif
"<title>%s - %s</title>"
"<script>"

View File

@ -7396,25 +7396,9 @@ char buff[512];
#ifdef SCRIPT_FULL_WEBPAGE
const char HTTP_WEB_FULL_DISPLAY[] PROGMEM =
"<p><form action='" "sfd%1d" "' method='get'><button>" "%s" "</button></form></p>";
"<p><form action='sfd%1d' method='get'><button>%s</button></form></p>";
const char HTTP_SCRIPT_FULLPAGE1[] PROGMEM =
"<!DOCTYPE html><html lang=\"" D_HTML_LANGUAGE "\" class=\"\">"
"<head>"
"<meta charset='utf-8'>"
"<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,user-scalable=no\"/>"
"<title>%s - %s</title>"
"<script>"
"var x=null,lt,to,tp,pc='';" // x=null allow for abortion
"function eb(s){"
"return document.getElementById(s);" // Alias to save code space
"}"
"function qs(s){" // Alias to save code space
"return document.querySelector(s);"
"}"
"function wl(f){" // Execute multiple window.onload
"window.addEventListener('load',f);"
"}"
"var rfsh=1;"
"function la(p){"
"var a='';"
@ -7497,7 +7481,8 @@ void ScriptFullWebpage(uint8_t page) {
WSContentBegin(200, CT_HTML);
const char *title = "Full Screen";
WSContentSend_P(HTTP_SCRIPT_FULLPAGE1, SettingsText(SET_DEVICENAME), title, page , fullpage_refresh);
WSContentSend_P(HTTP_HEADER1, PSTR(D_HTML_LANGUAGE), SettingsText(SET_DEVICENAME), title);
WSContentSend_P(HTTP_SCRIPT_FULLPAGE1, page , fullpage_refresh);
WSContentSend_P(HTTP_SCRIPT_FULLPAGE2, fullpage_refresh);
//WSContentSend_P(PSTR("<div id='l1' name='l1'></div>"));
@ -9288,7 +9273,7 @@ void script_add_subpage(uint8_t num) {
}
sprintf_P(id, PSTR("/sfd%1d"), num);
Webserver->on(id, wptr);
WSContentSend_PD(HTTP_WEB_FULL_DISPLAY, num, bname);
WSContentSend_PD( HTTP_WEB_FULL_DISPLAY , num, bname);
}
}
#endif // SCRIPT_FULL_WEBPAGE

BIN
tools/logo/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

View File

@ -4,11 +4,11 @@
# Instructions:
# open a console, e.g. in vscode, open a 'terminal'
# cd .\tools\unishox
# run:
# run:
# python compress-html-uncompressed.py
#
# The intent it to commit both uncompressed and compressed to the repo
# else this script would need to be run at build.
# else this script would need to be run at build.
#
# Example Tasmota code:
# #ifdef USE_UNISHOX_COMPRESSION
@ -24,6 +24,30 @@ from os import listdir
from os import path
from datetime import datetime
def extract_c_string(s: str) -> str:
state = 0
escape = False
out = ""
for c in s:
if state == 0: # before string
if c == '"': # entering string
out = '"'
state = 1
elif c == '/': # start of comment before entering string
state = 99 # we're done
elif state == 1: # in string
if escape: # escaped char
out += '\\' + c
escape = False
elif c == '\\': # escaped char
escape = True
elif c == '"': # end of string
out += '"'
state = 99 # we're done
else:
out += c
return out
path_compressed = path.join('..','..','tasmota','html_compressed')
path_uncompressed = path.join('..','..','tasmota','html_uncompressed')
@ -56,10 +80,9 @@ for file in files:
const_name = el[:-2] #extract the "const char" variable name
line_list.pop(line_number)
else: # remove line comments
line_el = line.rsplit("//")
# print('Splitted line list by //' % line_el)
# print(line_el[0])
text = text + line_el[0]
line_el = extract_c_string(line)
# print(line_el)
text = text + line_el
line_number = line_number +1
# print const_name
@ -86,9 +109,9 @@ for file in files:
# print(text[lastel+1:pos:])
lastel = pos
print("####### Parsing input from " + path_uncompressed + path.sep + file)
print("####### Parsing input from " + path_uncompressed + path.sep + file)
print(" Const char name: "+const_name)
#print('####### Cleaned input:')
#print('####### Cleaned input:')
#print(input)
#construct output (taken from shadinger)
@ -121,7 +144,7 @@ for file in files:
print(" the optimal case would be raw bytes + 8, real difference: "+str(in_real - out_real)+ "bytes")
# https://www.geeksforgeeks.org/break-list-chunks-size-n-python/
def chunked(my_list, n):
return [my_list[i * n:(i + 1) * n] for i in range((len(my_list) + n - 1) // n )]
return [my_list[i * n:(i + 1) * n] for i in range((len(my_list) + n - 1) // n )]
# split in chunks of 20 characters
chunks = chunked(out_bytes, 20)
@ -130,7 +153,7 @@ for file in files:
line_complete = "const char " + const_name + "_COMPRESSED" +"[] PROGMEM = " + ("\n" + " "*29).join(lines_raw) + ";"
lines = "\nconst size_t " + const_name +"_SIZE = {size};\n{lines}\n\n".format(size=in_len, lines=line_complete)
#print('####### Final output:')
#print('####### Final output:')
#print(lines)
definition = "#define " + const_name + " Decompress(" + const_name + "_COMPRESSED" + "," + const_name +"_SIZE" + ").c_str()"
@ -148,6 +171,6 @@ for file in files:
f = open(path_compressed + path.sep + file, "w")
f.write(comment + lines + definition)
f.close()
print("####### Wrote output to " + path_compressed + path.sep + file)
print("####### Wrote output to " + path_compressed + path.sep + file)
print("If all files are in use, total saving was "+str(totalSaved)+" out of "+str(totalIn))