From e4e0918f58d382b5da400e680d743dcf0e66fd7f Mon Sep 17 00:00:00 2001
From: AUTOMATIC <16777216c@gmail.com>
Date: Sat, 21 Jan 2023 22:57:19 +0300
Subject: [PATCH] remove timestamp for js files, reformat code
---
modules/ui.py | 34 ++++++++--------------------------
1 file changed, 8 insertions(+), 26 deletions(-)
diff --git a/modules/ui.py b/modules/ui.py
index b5581a06..ef7becc6 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -1918,38 +1918,20 @@ def create_ui():
def reload_javascript():
- scripts_list = modules.scripts.list_scripts("javascript", ".js")
- js_files = []
- for basedir, filename, path in scripts_list:
- path = path[len(script_path) + 1:]
- js_files.append(path)
+ head = f'\n'
- inline = [f"{localization.localization_js(shared.opts.localization)};"]
+ inline = f"{localization.localization_js(shared.opts.localization)};"
if cmd_opts.theme is not None:
- inline.append(f"set_theme('{cmd_opts.theme}');", )
+ inline += f"set_theme('{cmd_opts.theme}');"
- t = int(time.time())
- head = [
- f"""
-
- """.strip()
- ]
- inline_code = "\n".join(inline)
- head.append(f"""
-
- """.strip())
- for file in js_files:
- head.append(f"""
-
- """.strip())
+ head += f'\n'
+
+ for script in modules.scripts.list_scripts("javascript", ".js"):
+ head += f'\n'
def template_response(*args, **kwargs):
res = shared.GradioTemplateResponseOriginal(*args, **kwargs)
- head_inject = "\n".join(head)
- res.body = res.body.replace(
- b'', f'{head_inject}'.encode("utf8"))
+ res.body = res.body.replace(b'', f'{head}'.encode("utf8"))
res.init_headers()
return res