yera.ui.apps_sidebar
Build and render the source-oriented app navigation tree.
Stable app IDs are separated into directory, Python-file, and app-function nodes. Directory-only chains are compacted without removing file ownership. Rendering escapes labels and app names, URL-encodes destinations, and preserves the selected app and default expansion state.
Symbols
app_icon
app_icon(
app_id: str,
app: AppReference,
) → strRender the escaped initial badge used for an app.
Parameters
Stable identifier used to choose the badge colour.
App reference supplying the user-facing name.
Returns
An HTML badge whose displayed initial is escaped.
AppTreeFile
Describe a Python source file containing app functions.
Fields
Display filename including its .py suffix.
Number of app leaves beneath the file.
App functions sorted by function name.
Methods
AppTreeFile.__init__
__init__(
label: str,
count: int,
children: list[AppTreeLeaf],
) → NoneAppTreeFolder
Describe a directory containing app folders or source files.
Fields
Directory label, including compacted path segments.
Number of app leaves beneath the directory.
Nested folders and source files in display order.
Methods
AppTreeFolder.__init__
__init__(
label: str,
count: int,
children: list[AppTreeFolder | AppTreeFile],
) → NoneAppTreeLeaf
Describe a selectable app function inside a source file.
Fields
Stable slash-delimited app identifier.
App metadata and callable reference.
Source-level function name shown beneath the file.
Methods
AppTreeLeaf.__init__
__init__(
app_id: str,
app: AppReference,
function_name: str,
) → Nonebuild_app_tree
build_app_tree(
apps: Mapping[str, AppReference],
) → list[AppTreeFolder | AppTreeFile]Build source-oriented navigation from stable app identifiers.
Normal app IDs are interpreted as directory segments followed by a Python module and function. Custom single-segment IDs fall back to app metadata for their file label. Directories and files are sorted, function leaves are sorted by name, and directory-only chains are compacted.
Parameters
Available applications keyed by their stable identifiers.
Returns
Ordered folder and file nodes containing every supplied app.
render_app_tree
render_app_tree(
nodes: Sequence[AppTreeLeaf | AppTreeFolder | AppTreeFile],
depth: int = 0,
selected_app_id: str | None = None,
) → strRender app navigation as nested folders, files, and runnable leaves.
Folder expansion is based on nesting depth. Selection links use canonical app URLs, while each leaf also provides an HTMX action that creates a session. Labels, names, accessible text, and URL attributes are escaped.
Parameters
Tree nodes at the current level.
Current nesting depth, used only for default folder expansion.
App identifier marked as the current selection.
Returns
HTML for the app tree at this level and all descendants.