1
0
mirror of https://github.com/vladmandic/sdnext.git synced 2026-01-27 15:02:48 +03:00

add webmanifest

This commit is contained in:
Vladimir Mandic
2024-04-27 12:33:54 -04:00
parent 148ae36d7b
commit 1b43c5ec71
2 changed files with 18 additions and 0 deletions

8
html/manifest.json Normal file
View File

@@ -0,0 +1,8 @@
{
"name": "SD.Next",
"short_name": "SD.Next",
"icons": [{ "src": "favicon.png", "sizes": "256x256", "type": "image/png", "purpose": "any maskable" }],
"start_url": "./index.html",
"scope": "/",
"display": "standalone"
}

View File

@@ -81,11 +81,21 @@ def reload_javascript():
head = html_head()
css = html_css(base_css)
body = html_body()
title = '<title>SD.Next</title>'
manifest = f'<link rel="manifest" href="{webpath(os.path.join(script_path, "html", "manifest.json"))}">'
def template_response(*args, **kwargs):
res = shared.GradioTemplateResponseOriginal(*args, **kwargs)
res.body = res.body.replace(b'<head>', f'<head>{title}'.encode("utf8"))
res.body = res.body.replace(b'</head>', f'{head}</head>'.encode("utf8"))
res.body = res.body.replace(b'</head>', f'{manifest}</head>'.encode("utf8"))
res.body = res.body.replace(b'</body>', f'{css}{body}</body>'.encode("utf8"))
lines = res.body.decode("utf8").split('\n')
for line in lines:
if 'meta name="twitter:' in line:
res.body = res.body.replace(line.encode("utf8"), b'')
# if 'iframeResizer.contentWindow.min.js' in line:
# res.body = res.body.replace(line.encode("utf8"), b'<script src="/javascript/iframeResizer.js" async=""></script>')
res.init_headers()
return res