mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-14 18:38:11 +02:00
Added .sv_* files that are files for directories. So you can now edit
directories as files.
This commit is contained in:
1 parent
70a390f7cf
commit
6083e00504
9 files changed
+176
-18
No files matched your search
+32
-3
@@ -18,7 +18,15 @@ from BookReader import ReadBookForFile
|
||||
from Blame import LoadBlame, RenameUserInBlame, UpdateBlameOnSave
|
||||
from Core import ResolvePath
|
||||
from Editor import WriteTextFile
|
||||
from Explorer import ClassifyFile, CreateEntry, DeleteEntry, ListDirectory, ListRoots, MoveEntry
|
||||
from Explorer import (
|
||||
ClassifyFile,
|
||||
CreateEntry,
|
||||
DeleteEntry,
|
||||
EnsureDirectoryNote,
|
||||
ListDirectory,
|
||||
ListRoots,
|
||||
MoveEntry,
|
||||
)
|
||||
from Groups import (
|
||||
CreateGroup,
|
||||
DeleteGroup,
|
||||
@@ -378,8 +386,10 @@ def GetTreeEndpoint(
|
||||
RequirePathAccessible(Root, Path, CurrentUser)
|
||||
|
||||
try:
|
||||
ShowHidden = LoadSettings(CurrentUser["Username"]).get("ShowHiddenFolders", False)
|
||||
Entries = ListDirectory(Root, Path, ShowHidden)
|
||||
UserSettings = LoadSettings(CurrentUser["Username"])
|
||||
ShowHidden = UserSettings.get("ShowHiddenFolders", False)
|
||||
ShowSvFiles = UserSettings.get("ShowSvFiles", False)
|
||||
Entries = ListDirectory(Root, Path, ShowHidden, ShowSvFiles)
|
||||
except (ValueError, NotADirectoryError, FileNotFoundError) as Error:
|
||||
raise HTTPException(status_code=400, detail=str(Error))
|
||||
|
||||
@@ -400,6 +410,25 @@ def GetTreeEndpoint(
|
||||
]
|
||||
|
||||
|
||||
@Application.post("/api/note")
|
||||
def PostNoteEndpoint(Root: str, Path: str, CurrentUser: dict = Depends(GetCurrentUser)) -> dict:
|
||||
"""Find (or create, for a directory that predates this feature) the
|
||||
directory's own note file, so it can be opened like any other file.
|
||||
"""
|
||||
RequirePathAccessible(Root, Path, CurrentUser)
|
||||
|
||||
try:
|
||||
DirectoryPath = ResolvePath(Root, Path)
|
||||
except ValueError as Error:
|
||||
raise HTTPException(status_code=400, detail=str(Error))
|
||||
|
||||
if not DirectoryPath.is_dir():
|
||||
raise HTTPException(status_code=400, detail="Not a directory.")
|
||||
|
||||
NotePath = EnsureDirectoryNote(DirectoryPath)
|
||||
return {"Name": NotePath.name, "FileType": ClassifyFile(NotePath)}
|
||||
|
||||
|
||||
class CreateEntryRequest(BaseModel):
|
||||
IsDirectory: bool
|
||||
|
||||
|
||||
Reference in new issue
Block a user