Implemented conditionally included applet resource for standalone mode
Update excel-password-remover.yml, png-chunk-analyser.yml, and 6 more files...
This commit is contained in:
@@ -9,15 +9,39 @@ def render_applet_head(applet_data: ContentApplet, is_standalone: bool = False)
|
||||
applet_style_html = ""
|
||||
|
||||
for applet_style in applet_data.resources.stylesheets:
|
||||
rsc_path = None
|
||||
|
||||
if is_standalone:
|
||||
with open(os.path.join("./static/resources/NibblePoker/applets/", applet_data.id, applet_style)) as applet_style_file:
|
||||
applet_style_html += "<style>" + applet_style_file.read() + "</style>"
|
||||
if not applet_style.can_be_standalone():
|
||||
continue
|
||||
|
||||
if applet_style.is_applet():
|
||||
rsc_path = os.path.join(
|
||||
"./static/resources/NibblePoker/applets/",
|
||||
applet_data.id,
|
||||
applet_style.get_clean_path())
|
||||
print(applet_style)
|
||||
elif applet_style.is_standalone():
|
||||
rsc_path = os.path.join(
|
||||
"./static/resources/Standalone/",
|
||||
applet_style.get_clean_path())
|
||||
|
||||
if rsc_path is not None:
|
||||
with open(rsc_path) as applet_style_file:
|
||||
applet_style_html += "<style>" + applet_style_file.read() + "</style>"
|
||||
|
||||
else:
|
||||
applet_style_html += ("<link rel='stylesheet' href='" +
|
||||
url_for(
|
||||
"static",
|
||||
filename="/resources/NibblePoker/applets/" + applet_data.id + "/" + applet_style) +
|
||||
"'>")
|
||||
if applet_style.is_applet():
|
||||
rsc_path = url_for(
|
||||
"static",
|
||||
filename="/resources/NibblePoker/applets/" +
|
||||
applet_data.id + "/" +
|
||||
applet_style.get_clean_path())
|
||||
elif applet_style.is_remote():
|
||||
rsc_path = applet_style.raw_uri
|
||||
|
||||
if rsc_path is not None:
|
||||
applet_style_html += f"<link rel='stylesheet' href='{rsc_path}'>"
|
||||
|
||||
return applet_style_html
|
||||
|
||||
@@ -26,16 +50,41 @@ def render_applet_scripts(applet_data: ContentApplet, is_standalone: bool = Fals
|
||||
applet_script_html = ""
|
||||
|
||||
for applet_script in applet_data.resources.scripts:
|
||||
rsc_path = None
|
||||
|
||||
if is_standalone:
|
||||
with open(os.path.join("./static/resources/NibblePoker/applets/", applet_data.id, applet_script)) as applet_script_file:
|
||||
applet_script_html += "<script" + (" type='module'>" if applet_script.endswith(".mjs") else ">")
|
||||
applet_script_html += applet_script_file.read()
|
||||
applet_script_html += "</script>"
|
||||
if not applet_script.can_be_standalone():
|
||||
continue
|
||||
|
||||
if applet_script.is_applet():
|
||||
rsc_path = os.path.join(
|
||||
"./static/resources/NibblePoker/applets/",
|
||||
applet_data.id,
|
||||
applet_script.get_clean_path())
|
||||
elif applet_script.is_standalone():
|
||||
rsc_path = os.path.join(
|
||||
"./static/resources/Standalone/",
|
||||
applet_script.get_clean_path())
|
||||
|
||||
if rsc_path is not None:
|
||||
with open(rsc_path) as applet_script_file:
|
||||
applet_script_html += "<script" +(" type='module'>" if applet_script.raw_uri.endswith(".mjs") else ">")
|
||||
applet_script_html += applet_script_file.read()
|
||||
applet_script_html += "</script>"
|
||||
|
||||
else:
|
||||
applet_script_html += ("<script src='" +
|
||||
url_for(
|
||||
"static",
|
||||
filename="/resources/NibblePoker/applets/" + applet_data.id + "/" + applet_script) +
|
||||
"'" + (" type='module'" if applet_script.endswith(".mjs") else "") + "></script>")
|
||||
if applet_script.is_applet():
|
||||
rsc_path = url_for(
|
||||
"static",
|
||||
filename="/resources/NibblePoker/applets/" +
|
||||
applet_data.id + "/" +
|
||||
applet_script.get_clean_path())
|
||||
elif applet_script.is_remote():
|
||||
rsc_path = applet_script.raw_uri
|
||||
|
||||
if rsc_path is not None:
|
||||
applet_script_html += f"<script src='{rsc_path}'{
|
||||
" type='module'" if applet_script.raw_uri.endswith(".mjs") else ""
|
||||
}></script>"
|
||||
|
||||
return applet_script_html
|
||||
|
Reference in New Issue
Block a user