Implemented tools as applets, Added Docker CCTV page, Fixed small issues

Update app.py, uuid-generator.yml, and 47 more files...
This commit is contained in:
2025-02-20 17:24:05 +01:00
parent bd96d85699
commit 0e91b5ed96
43 changed files with 889 additions and 337 deletions

View File

@@ -0,0 +1,29 @@
from flask import url_for
from website.content import ContentApplet
def render_applet_head(applet_data: ContentApplet) -> 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) +
"'>")
return applet_style_html
def render_applet_scripts(applet_data: ContentApplet):
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>")
return applet_script_html

31
website/renderers/code.py Normal file
View File

@@ -0,0 +1,31 @@
import html
import re
from typing import Optional
from flask import render_template
def render_code_block(code_lines: list[str], language: Optional[str] = None):
_code_lines = list()
for code_line in code_lines:
code_line = html.escape(code_line)
code_line = code_line.replace('\t', '&nbsp;' * 4)
code_line = code_line.replace(' ', '&nbsp;')
_code_lines.append(code_line)
return render_template(
"elements/code.jinja",
code_lines=_code_lines,
code_language=language,
)
# return re.sub('>\s*<span', "><span",
# re.sub('<br>\s*</code>', "</code>",
# render_template(
# "elements/code.jinja",
# code_lines=_code_lines,
# code_language=language,
# )
# )
# )

View File

@@ -0,0 +1,3 @@
def render_file_input() -> str:
return ""

View File

@@ -35,3 +35,11 @@ def render_h3(inner_html: str, icon: Optional[str] = None, right_html: Optional[
return render_heading(
inner_html, 3, icon, right_html, anchor_id, background_class
)
def render_h4(inner_html: str, icon: Optional[str] = None, right_html: Optional[str] = None,
anchor_id: Optional[str] = None, background_class: str = "bkgd-grid") -> str:
return render_heading(
inner_html, 4, icon, right_html, anchor_id, background_class
)

View File

@@ -0,0 +1,11 @@
from typing import Union
from flask import render_template
def render_list_ul(items: list[Union[str|list]]) -> str:
return render_template(
"elements/list-ul.jinja",
list_items=items,
render_list_ul=render_list_ul
)