Working on Formating DSL completion

This commit is contained in:
2026-01-31 19:09:14 +01:00
parent 778e5ac69d
commit d7ec99c3d9
77 changed files with 7563 additions and 63 deletions

View File

@@ -33,6 +33,7 @@ def get_asset_content(filename):
def create_app(daisyui: Optional[bool] = True,
vis: Optional[bool] = True,
code_mirror: Optional[bool] = True,
protect_routes: Optional[bool] = True,
mount_auth_app: Optional[bool] = False,
base_url: Optional[str] = None,
@@ -41,8 +42,15 @@ def create_app(daisyui: Optional[bool] = True,
Creates and configures a FastHtml application with optional support for daisyUI themes and
authentication routes.
:param daisyui: Flag to enable or disable inclusion of daisyUI-related assets for styling.
Defaults to False.
:param daisyui: Flag to enable or disable inclusion of daisyUI (https://daisyui.com/).
Defaults to True.
:param vis: Flag to enable or disable inclusion of Vis network (https://visjs.org/)
Defaults to True.
:param code_mirror: Flag to enable or disable inclusion of Code Mirror (https://codemirror.net/)
Defaults to True.
:param protect_routes: Flag to enable or disable routes protection based on authentication.
Defaults to True.
:param mount_auth_app: Flag to enable or disable mounting of authentication routes.
@@ -70,6 +78,17 @@ def create_app(daisyui: Optional[bool] = True,
Script(src="/myfasthtml/vis-network.min.js"),
]
if code_mirror:
hdrs += [
Script(src="/myfasthtml/codemirror.min.js"),
Link(href="/myfasthtml/codemirror.min.css", rel="stylesheet", type="text/css"),
Script(src="/myfasthtml/placeholder.min.js"),
Script(src="/myfasthtml/show-hint.min.js"),
Link(href="/myfasthtml/show-hint.min.css", rel="stylesheet", type="text/css"),
]
beforeware = create_auth_beforeware() if protect_routes else None
app, rt = fasthtml.fastapp.fast_app(before=beforeware, hdrs=tuple(hdrs), **kwargs)
@@ -80,13 +99,14 @@ def create_app(daisyui: Optional[bool] = True,
# Serve assets
@app.get("/myfasthtml/{filename:path}.{ext:static}")
def serve_assets(filename: str, ext: str):
logger.debug(f"Serving asset: {filename=}, {ext=}")
path = filename + "." + ext
try:
content = get_asset_content(path)
if filename.endswith('.css'):
if ext == '.css':
return Response(content, media_type="text/css")
elif filename.endswith('.js'):
elif ext == 'js':
return Response(content, media_type="application/javascript")
else:
return Response(content)