From 24e979a05f6cbda5d0d3714ffba07bd3f054b34f Mon Sep 17 00:00:00 2001 From: bruno Date: Wed, 8 Jul 2026 15:17:14 -0400 Subject: [PATCH] fix: sidebar Favorites + Shared, Library page with tabs, CSRF fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Section Favorites ajoutΓ©e dans le sidebar (⭐) - Section Shared ajoutΓ©e (πŸ‘₯) - Section Library remplacΓ©e par bouton πŸ“š qui ouvre /library - Page /library avec onglets: Recents | Favorites | Shared | Private - CSRF token injectΓ© dans les appels fetch (newPage, newSubPage) - Bouton + sur Γ©lΓ©ments sidebar corrigΓ© (POST /board/api/pages avec X-CSRF-Token) - Bouton πŸ“š sur sections ouvre /library - sidebar_data inclut favorite_pages=[] --- app/routers/board.py | 21 +++++- app/routers/dashboard.py | 15 +++++ app/templates/base.html | 78 +++++++++++++++++----- app/templates/library.html | 130 +++++++++++++++++++++++++++++++++++++ 4 files changed, 227 insertions(+), 17 deletions(-) create mode 100644 app/templates/library.html diff --git a/app/routers/board.py b/app/routers/board.py index 5b6d66b..a18708c 100644 --- a/app/routers/board.py +++ b/app/routers/board.py @@ -141,8 +141,8 @@ def _sidebar_data(request: Request, owner: str = "", repo: str = "") -> dict: }) return {"workspace_name": ws, "workspace_initial": ws[0].upper() if ws else "B", "current_page": repo or "Dashboard", "last_edited": "now", - "recent_pages": recent, "private_pages": [r for r in recent if r.get("active")], - "user": user} + "recent_pages": recent, "private_pages": [r for r in recent if r.get("active") or r["id"].startswith("page/")], + "favorite_pages": [], "user": user} def _extract_ai_keywords(owner: str, repo: str, labels: list[dict], body: str = ""): @@ -241,6 +241,23 @@ def _apply_sorts(cards: list[dict], sorts: str) -> list[dict]: return cards +# ═══════════ Library page ═══════════ + +@router.get("/library", response_class=HTMLResponse) +async def library_page(request: Request): + """Library page avec onglets Recents, Favorites, Shared, Private.""" + from jinja2 import Environment, FileSystemLoader + env = Environment(loader=FileSystemLoader("app/templates")) + sidebar = _sidebar_data(request) + # Enrich with timestamps + for p in sidebar["recent_pages"]: + p["last_edited"] = "now" + for p in sidebar["private_pages"]: + p["last_edited"] = "now" + template = env.get_template("library.html") + return template.render(**sidebar) + + # ═══════════ Board page ═══════════ @router.get("/{owner}/{repo}", response_class=HTMLResponse) diff --git a/app/routers/dashboard.py b/app/routers/dashboard.py index 9077419..3924aa5 100644 --- a/app/routers/dashboard.py +++ b/app/routers/dashboard.py @@ -48,10 +48,25 @@ def _sidebar_data(request: Request, repos: list[dict]) -> dict: "current_page": "Dashboard", "last_edited": "now", "recent_pages": recent_pages, "private_pages": [p for p in recent_pages if p["id"].startswith("page/")], + "favorite_pages": [], "user": user, } +@router.get("/library", response_class=HTMLResponse) +async def library_page(request: Request): + """Library page avec onglets Recents, Favorites, Shared, Private.""" + from jinja2 import Environment, FileSystemLoader + env = Environment(loader=FileSystemLoader("app/templates")) + sidebar = _sidebar_data(request, []) + for p in sidebar["recent_pages"]: + p["last_edited"] = "now" + for p in sidebar["private_pages"]: + p["last_edited"] = "now" + template = env.get_template("library.html") + return template.render(**sidebar) + + @router.get("/", response_class=HTMLResponse) async def dashboard( request: Request, diff --git a/app/templates/base.html b/app/templates/base.html index 1250801..882f67e 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -120,21 +120,59 @@ - + + + + + + +