mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-15 02:43:17 +02:00
Added more markdown syntax, and added portals.
This commit is contained in:
1 parent
ee7e163837
commit
9dba722cd9
6 files changed
+349
-8
No files matched your search
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user