Files
stellars-jupyterhub-ds/doc/ui-template-customization.md
stellarshenson 7ba01412d1 docs: simplify documentation to minimal modus primaris style
Drastically reduced documentation length focusing only on essential
implementation facts:

- doc/notifications.md: Reduced from 250 to 35 lines - key technical facts,
  handler implementation, template details, dependencies, error handling
- doc/ui-template-customization.md: Reduced from 132 to 55 lines - technical
  facts, JavaScript patterns, Bootstrap 5 syntax, CSRF protection, build process
- doc/docker-socket-permissions.md: Reduced from 186 to 66 lines - implementation
  facts, pre-spawn hook code, built-in group system, security implications, usage

All documentation now follows super-minimal "glimpse of implementation" approach
with bullet points and code snippets, absent of lengthy narrative and marketing
language.
2025-11-09 22:23:54 +01:00

55 lines
1.7 KiB
Markdown

# UI Template Customization
JupyterHub templates extended using Jinja2 to add custom UI features (server restart, volume management, notifications). Templates placed in `services/jupyterhub/templates/` and copied to `/srv/jupyterhub/templates/` during Docker build.
**Key Technical Facts**:
- Templates extend base using `{% extends "page.html" %}`
- Override blocks: `{% block main %}`, `{% block script %}`
- Changes require Docker rebuild with `--no-cache` flag
- JupyterHub 5.4.2 uses Bootstrap 5 (not Bootstrap 4)
**JavaScript Integration**:
All custom JavaScript wrapped in RequireJS to ensure library loading:
```javascript
require(["jquery"], function($) {
"use strict";
// Custom code here
});
```
**Bootstrap 5 Modal Syntax**:
```html
<button data-bs-toggle="modal" data-bs-target="#myModal">
<i class="fa fa-rotate" aria-hidden="true"></i> Restart
</button>
```
**CSRF Protection**:
All POST requests include XSRF token via `X-XSRFToken` header:
```javascript
headers: { 'X-XSRFToken': getCookie('_xsrf') }
```
**Custom Handlers** (registered in `jupyterhub_config.py`):
```python
c.JupyterHub.extra_handlers = [
(r'/api/users/([^/]+)/manage-volumes', ManageVolumesHandler),
(r'/api/users/([^/]+)/restart-server', RestartServerHandler),
(r'/api/notifications/broadcast', BroadcastNotificationHandler),
(r'/notifications', NotificationsPageHandler),
]
```
**Font Awesome Icons**:
- Restart: `fa fa-rotate`
- Volumes: `fa fa-database`
- Stop: `fa fa-stop`
- Start: `fa fa-play`
**Build Process**:
```bash
docker compose build --no-cache jupyterhub
docker stop stellars-jupyterhub-ds-jupyterhub && docker rm stellars-jupyterhub-ds-jupyterhub
docker compose up -d jupyterhub
```