diff --git a/app/routers/board.py b/app/routers/board.py index e108bfd..71f587a 100644 --- a/app/routers/board.py +++ b/app/routers/board.py @@ -980,198 +980,6 @@ async def view_page(request: Request, page_id: int): return HTMLResponse(content=response, headers={"Cache-Control": "no-store, max-age=0"}) -def _render_file_viewer(page: dict, request: Request) -> HTMLResponse: - """Render a file viewer for uploaded files (content_format='file').""" - import json - page_id = page["id"] - title = page.get("title", "File") - user = SessionManager.decode_session(request.cookies.get("flowdeck_session", "")) - ws_name = user.get("login", "Bruno") if user else "Bruno" - initial = ws_name[0].upper() if ws_name else "B" - - try: - meta = json.loads(page.get("content", "{}")) - except json.JSONDecodeError: - meta = {} - file_path = meta.get("file_path", "") - mime_type = meta.get("mime_type", "application/octet-stream") - size = meta.get("size", 0) - - # Build workspace_id from file_path - parts = file_path.split("/") - ws_id = "" - for p in parts: - if p.startswith("workspace_"): - ws_id = p.replace("workspace_", "") - break - filename = parts[-1] if parts else title - - file_url = f"/api/files/{ws_id}/{filename}" if ws_id else "" - - # Determine viewer type - is_image = mime_type.startswith("image/") - is_pdf = mime_type == "application/pdf" - is_text = mime_type.startswith("text/") or mime_type in ( - "application/json", "application/javascript", "application/xml", - "application/x-python", "application/x-sh" - ) - is_code = any(ext in (filename or "").lower() for ext in ( - ".py", ".js", ".ts", ".jsx", ".tsx", ".html", ".htm", ".css", - ".json", ".xml", ".yaml", ".yml", ".md", ".sql", ".sh", ".bash", - ".ps1", ".bat", ".cmd", ".rb", ".go", ".rs", ".java", ".c", ".cpp", - ".h", ".hpp", ".php", ".swift", ".kt", ".scala", ".r", ".toml", - ".ini", ".cfg", ".conf", ".env", ".dockerfile", ".makefile" - )) - if is_code: - is_text = True - - # Determine language class for syntax highlighting - ext_map = { - ".py": "python", ".js": "javascript", ".ts": "typescript", - ".html": "html", ".css": "css", ".json": "json", ".md": "markdown", - ".sql": "sql", ".sh": "bash", ".ps1": "powershell", ".rs": "rust", - ".go": "go", ".java": "java", ".rb": "ruby", ".xml": "xml", - ".yaml": "yaml", ".yml": "yaml", ".toml": "toml", - } - lang = "plaintext" - for ext, name in ext_map.items(): - if (filename or "").lower().endswith(ext): - lang = name - break - - size_str = f"{size:,} bytes" if size < 1024 else f"{size/1024:.1f} KB" if size < 1024*1024 else f"{size/1024/1024:.1f} MB" - - html = f""" - -
-