|
@@ -10,10 +10,10 @@ if True:
|
|
|
|
|
|
import os
|
|
import os
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
-from typing import Optional
|
|
|
|
|
|
+from typing import Awaitable, Callable, Optional
|
|
|
|
|
|
from fastapi import Request
|
|
from fastapi import Request
|
|
-from fastapi.responses import FileResponse, RedirectResponse
|
|
|
|
|
|
+from fastapi.responses import FileResponse, RedirectResponse, Response
|
|
from starlette.middleware.sessions import SessionMiddleware
|
|
from starlette.middleware.sessions import SessionMiddleware
|
|
|
|
|
|
import prometheus
|
|
import prometheus
|
|
@@ -36,17 +36,18 @@ app.add_static_files('/fonts', str(Path(__file__).parent / 'website' / 'fonts'))
|
|
|
|
|
|
|
|
|
|
@app.get('/logo.png')
|
|
@app.get('/logo.png')
|
|
-def logo():
|
|
|
|
|
|
+def logo() -> FileResponse:
|
|
return FileResponse(svg.PATH / 'logo.png', media_type='image/png')
|
|
return FileResponse(svg.PATH / 'logo.png', media_type='image/png')
|
|
|
|
|
|
|
|
|
|
@app.get('/logo_square.png')
|
|
@app.get('/logo_square.png')
|
|
-def logo():
|
|
|
|
|
|
+def logo_square() -> FileResponse:
|
|
return FileResponse(svg.PATH / 'logo_square.png', media_type='image/png')
|
|
return FileResponse(svg.PATH / 'logo_square.png', media_type='image/png')
|
|
|
|
|
|
|
|
|
|
@app.middleware('http')
|
|
@app.middleware('http')
|
|
-async def redirect_reference_to_documentation(request: Request, call_next):
|
|
|
|
|
|
+async def redirect_reference_to_documentation(request: Request,
|
|
|
|
+ call_next: Callable[[Request], Awaitable[Response]]) -> Response:
|
|
if request.url.path == '/reference':
|
|
if request.url.path == '/reference':
|
|
return RedirectResponse('/documentation')
|
|
return RedirectResponse('/documentation')
|
|
return await call_next(request)
|
|
return await call_next(request)
|
|
@@ -82,11 +83,11 @@ def add_header(menu: Optional[ui.left_drawer] = None) -> None:
|
|
with ui.row().classes('max-lg:hidden'):
|
|
with ui.row().classes('max-lg:hidden'):
|
|
for title, target in menu_items.items():
|
|
for title, target in menu_items.items():
|
|
ui.link(title, target).classes(replace='text-lg text-white')
|
|
ui.link(title, target).classes(replace='text-lg text-white')
|
|
- with ui.link(target='https://discord.gg/TEpFeAaF4f').classes('max-[435px]:hidden'):
|
|
|
|
|
|
+ with ui.link(target='https://discord.gg/TEpFeAaF4f').classes('max-[435px]:hidden').tooltip('Discord'):
|
|
svg.discord().classes('fill-white scale-125 m-1')
|
|
svg.discord().classes('fill-white scale-125 m-1')
|
|
- with ui.link(target='https://www.reddit.com/r/nicegui/').classes('max-[385px]:hidden'):
|
|
|
|
|
|
+ with ui.link(target='https://www.reddit.com/r/nicegui/').classes('max-[385px]:hidden').tooltip('Reddit'):
|
|
svg.reddit().classes('fill-white scale-125 m-1')
|
|
svg.reddit().classes('fill-white scale-125 m-1')
|
|
- with ui.link(target='https://github.com/zauberzeug/nicegui/'):
|
|
|
|
|
|
+ with ui.link(target='https://github.com/zauberzeug/nicegui/').tooltip('GitHub'):
|
|
svg.github().classes('fill-white scale-125 m-1')
|
|
svg.github().classes('fill-white scale-125 m-1')
|
|
add_star().classes('max-[480px]:hidden')
|
|
add_star().classes('max-[480px]:hidden')
|
|
with ui.row().classes('lg:hidden'):
|
|
with ui.row().classes('lg:hidden'):
|
|
@@ -97,7 +98,7 @@ def add_header(menu: Optional[ui.left_drawer] = None) -> None:
|
|
|
|
|
|
|
|
|
|
@ui.page('/')
|
|
@ui.page('/')
|
|
-async def index_page(client: Client):
|
|
|
|
|
|
+async def index_page(client: Client) -> None:
|
|
client.content.classes('p-0 gap-0')
|
|
client.content.classes('p-0 gap-0')
|
|
add_head_html()
|
|
add_head_html()
|
|
add_header()
|
|
add_header()
|
|
@@ -269,6 +270,7 @@ async def index_page(client: Client):
|
|
example_link('Local File Picker', 'demonstrates a dialog for selecting files locally on the server')
|
|
example_link('Local File Picker', 'demonstrates a dialog for selecting files locally on the server')
|
|
example_link('Search as you type', 'using public API of thecocktaildb.com to search for cocktails')
|
|
example_link('Search as you type', 'using public API of thecocktaildb.com to search for cocktails')
|
|
example_link('Menu and Tabs', 'uses Quasar to create foldable menu and tabs inside a header bar')
|
|
example_link('Menu and Tabs', 'uses Quasar to create foldable menu and tabs inside a header bar')
|
|
|
|
+ example_link('Todo list', 'shows a simple todo list with checkboxes and text input')
|
|
example_link('Trello Cards', 'shows Trello-like cards that can be dragged and dropped into columns')
|
|
example_link('Trello Cards', 'shows Trello-like cards that can be dragged and dropped into columns')
|
|
example_link('Slots', 'shows how to use scoped slots to customize Quasar elements')
|
|
example_link('Slots', 'shows how to use scoped slots to customize Quasar elements')
|
|
example_link('Table and slots', 'shows how to use component slots in a table')
|
|
example_link('Table and slots', 'shows how to use component slots in a table')
|
|
@@ -317,7 +319,7 @@ async def index_page(client: Client):
|
|
|
|
|
|
|
|
|
|
@ui.page('/documentation')
|
|
@ui.page('/documentation')
|
|
-def documentation_page():
|
|
|
|
|
|
+def documentation_page() -> None:
|
|
add_head_html()
|
|
add_head_html()
|
|
menu = side_menu()
|
|
menu = side_menu()
|
|
add_header(menu)
|
|
add_header(menu)
|
|
@@ -332,7 +334,7 @@ def documentation_page():
|
|
|
|
|
|
|
|
|
|
@ui.page('/documentation/{name}')
|
|
@ui.page('/documentation/{name}')
|
|
-async def documentation_page_more(name: str, client: Client):
|
|
|
|
|
|
+async def documentation_page_more(name: str, client: Client) -> None:
|
|
if not hasattr(ui, name):
|
|
if not hasattr(ui, name):
|
|
name = name.replace('_', '') # NOTE: "AG Grid" leads to anchor name "ag_grid", but class is `ui.aggrid`
|
|
name = name.replace('_', '') # NOTE: "AG Grid" leads to anchor name "ag_grid", but class is `ui.aggrid`
|
|
module = importlib.import_module(f'website.more_documentation.{name}_documentation')
|
|
module = importlib.import_module(f'website.more_documentation.{name}_documentation')
|