Skip to content

Layout

HTML layout templates and page rendering utilities.

Provides the base page structure including sidebar navigation and main content area. All dashboard pages are rendered through render_page which wraps content in the standard layout with navigation and base styles.

SIDEBAR_HTML = '\n<aside class="sidebar">\n <div class="sidebar-header">\n <h1>OneSecondTrader</h1>\n </div>\n <nav class="sidebar-nav">\n <a href="/backtest" class="{backtest_active}">\n <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path></svg>\n Backtest\n </a>\n </nav>\n</aside>\n' module-attribute

render_sidebar(active='')

Render the sidebar navigation HTML.

Parameters:

Name Type Description Default
active str

Name of the currently active page for highlighting.

''

Returns:

Type Description
str

HTML string for the sidebar.

Source code in src/onesecondtrader/dashboard/layout.py
def render_sidebar(active: str = "") -> str:
    """
    Render the sidebar navigation HTML.

    Parameters:
        active:
            Name of the currently active page for highlighting.

    Returns:
        HTML string for the sidebar.
    """
    return SIDEBAR_HTML.format(
        backtest_active="active" if active == "backtest" else "",
    )

render_page(title, content, active='')

Render a complete HTML page with layout.

Parameters:

Name Type Description Default
title str

Page title displayed in the browser tab.

required
content str

HTML content to render in the main content area.

required
active str

Name of the currently active page for sidebar highlighting.

''

Returns:

Type Description
str

Complete HTML document string.

Source code in src/onesecondtrader/dashboard/layout.py
def render_page(title: str, content: str, active: str = "") -> str:
    """
    Render a complete HTML page with layout.

    Parameters:
        title:
            Page title displayed in the browser tab.
        content:
            HTML content to render in the main content area.
        active:
            Name of the currently active page for sidebar highlighting.

    Returns:
        Complete HTML document string.
    """
    sidebar = render_sidebar(active)
    return f"""<!DOCTYPE html>
<html>
<head>
    <title>{title} - OneSecondTrader</title>
    <style>{BASE_CSS}</style>
</head>
<body>
    {sidebar}
    <main class="main-content">
        <div class="container">
            {content}
        </div>
    </main>
</body>
</html>"""