Added more markdown syntax, and added portals.

This commit is contained in:
sarah committed 2026-09-21 18:24:08 +02:00
1 parent ee7e163837
commit 9dba722cd9
6 files changed
+349 -8

No files matched your search

+27
View File
@@ -42,6 +42,7 @@ from Locks import (
RequirePathAccessible,
SetLock,
)
from Portals import ResolvePortals
from Preview import GetFileSize, GetMimeType, ParseRangeHeader, ReadTextFile, TextFileTypes
from Settings import (
DeleteTheme,
@@ -517,6 +518,32 @@ def GetFileEndpoint(
return StreamingResponse(IterateFile(), media_type=MimeType, headers=Headers)
@Application.get("/api/file/resolved")
def GetResolvedFileEndpoint(
Root: str, Path: str, CurrentUser: dict = Depends(GetCurrentUser)
) -> dict:
RequirePathAccessible(Root, Path, CurrentUser)
try:
FilePath = ResolvePath(Root, Path)
except ValueError as Error:
raise HTTPException(status_code=400, detail=str(Error))
if not FilePath.is_file():
raise HTTPException(status_code=404, detail="File not found.")
FileType = ClassifyFile(FilePath)
if FileType not in TextFileTypes:
raise HTTPException(status_code=400, detail="Not a text file.")
Content = ReadTextFile(FilePath)
Resolved = ResolvePortals(
Root, Path, Content, CurrentUser["Username"], CurrentUser.get("Groups", [])
)
return {"Content": Resolved}
@Application.put("/api/file")
async def PutFileEndpoint(
Root: str, Path: str, request: Request, CurrentUser: dict = Depends(GetCurrentUser)