feat: icônes par type de fichier + filtre par type + fix preview PDF
FlowDeck CI / test (push) Failing after 4s
FlowDeck CI / docker (push) Has been skipped

1. Icônes de fichier contextuelles:
   - _fileIcon() JS et _file_icon() Python: mappe l'extension vers emoji
   - 📕 PDF, 🖼️ images, 🐍 Python, 📜 JS/TS, 🌐 HTML, 🎨 CSS,
     📋 JSON, 🗃️ SQL, 💻 Shell, ⚡ PS1, 📝 MD, 📦 archives...
   - Appliqué dans sidebar (board.py) + page workspace (x-for + renderChildren)

2. Preview PDF: ne fetch plus le contenu binaire (caractères bizarres),
   affiche 📕 'PDF Document' dans le popup hover

3. Filtre par type:
   - Chips 📝 Pages | 📕 PDF | 🖼️ Img | 📜 Code | 📄 Text
   - _filterTree() accepte un paramètre fileType
   - Désélection par second clic sur le même chip
This commit is contained in:
2026-07-11 13:49:12 -04:00
parent a8f9832535
commit fc6e30aebb
2 changed files with 96 additions and 14 deletions
+31 -6
View File
@@ -140,6 +140,27 @@ def _build_page_tree(conn, parent_id: int | None, ws_key: str, depth: int = 0, m
return items
def _file_icon(name: str) -> str:
"""Map file extension to emoji icon."""
import re
n = name.lower()
if re.search(r'\.(png|jpe?g|gif|webp|svg|bmp|ico)$', n): return '🖼️'
if n.endswith('.pdf'): return '📕'
if re.search(r'\.(md|markdown)$', n): return '📝'
if n.endswith('.py'): return '🐍'
if re.search(r'\.(js|jsx|ts|tsx)$', n): return '📜'
if re.search(r'\.(html?|xml)$', n): return '🌐'
if n.endswith('.css'): return '🎨'
if n.endswith('.json'): return '📋'
if n.endswith('.sql'): return '🗃️'
if re.search(r'\.(sh|bash|zsh)$', n): return '💻'
if n.endswith('.ps1'): return '⚡'
if re.search(r'\.(rs|go|java|rb|php|c|cpp|h|swift|kt|scala|r)$', n): return '📜'
if re.search(r'\.(txt|log)$', n): return '📄'
if re.search(r'\.(zip|tar|gz|rar|7z)$', n): return '📦'
return '📄'
def _load_workspace_pages(ws_cookie: str) -> list:
"""Load top-level pages with children for the active workspace."""
if not ws_cookie:
@@ -153,11 +174,13 @@ def _load_workspace_pages(ws_cookie: str) -> list:
).fetchall()
items = []
for r in rows:
is_folder = r["parent_section"] == "Workspace"
title = r["title"] or "Untitled"
items.append({
"db_id": r["id"], "name": r["title"] or "Untitled",
"db_id": r["id"], "name": title,
"id": f"page/{r['id']}",
"icon": "📁" if r["parent_section"] == "Workspace" else "📄",
"is_folder": r["parent_section"] == "Workspace",
"icon": "📁" if is_folder else _file_icon(title),
"is_folder": is_folder,
"children": _load_children(r["id"]),
})
return items
@@ -174,11 +197,13 @@ def _load_children(parent_id: int) -> list:
).fetchall()
children = []
for r in rows:
is_folder = r["parent_section"] == "Workspace"
title = r["title"] or "Untitled"
children.append({
"db_id": r["id"], "name": r["title"] or "Untitled",
"db_id": r["id"], "name": title,
"id": f"page/{r['id']}",
"icon": "📁" if r["parent_section"] == "Workspace" else "📄",
"is_folder": r["parent_section"] == "Workspace",
"icon": "📁" if is_folder else _file_icon(title),
"is_folder": is_folder,
"children": _load_children(r["id"]),
})
return children