Added more content, Minor incremental improvements
Update app.py, uuid-generator.yml, and 23 more files...
This commit is contained in:
@@ -1,29 +1,41 @@
|
||||
import os
|
||||
|
||||
from flask import url_for
|
||||
|
||||
from website.content import ContentApplet
|
||||
|
||||
|
||||
def render_applet_head(applet_data: ContentApplet) -> str:
|
||||
def render_applet_head(applet_data: ContentApplet, is_standalone: bool = False) -> str:
|
||||
applet_style_html = ""
|
||||
|
||||
for applet_style in applet_data.resources.stylesheets:
|
||||
applet_style_html += ("<link rel='stylesheet' href='" +
|
||||
url_for(
|
||||
"static",
|
||||
filename="/resources/NibblePoker/applets/" + applet_data.id + "/" + applet_style) +
|
||||
"'>")
|
||||
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>"
|
||||
else:
|
||||
applet_style_html += ("<link rel='stylesheet' href='" +
|
||||
url_for(
|
||||
"static",
|
||||
filename="/resources/NibblePoker/applets/" + applet_data.id + "/" + applet_style) +
|
||||
"'>")
|
||||
|
||||
return applet_style_html
|
||||
|
||||
|
||||
def render_applet_scripts(applet_data: ContentApplet):
|
||||
def render_applet_scripts(applet_data: ContentApplet, is_standalone: bool = False):
|
||||
applet_script_html = ""
|
||||
|
||||
for applet_script in applet_data.resources.scripts:
|
||||
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 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>"
|
||||
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>")
|
||||
|
||||
return applet_script_html
|
||||
|
6
website/renderers/standalone.py
Normal file
6
website/renderers/standalone.py
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
def get_standalone_common_headers() -> str:
|
||||
_html = ""
|
||||
with open("./static/resources/Standalone/nibblepoker.min.css", encoding='utf-8') as f:
|
||||
_html += "<style>" + f.read() + "</style>"
|
||||
return _html
|
Reference in New Issue
Block a user