Added modals for popups, and fixed root-level bug.

This commit is contained in:
sarah committed 2026-09-21 21:38:12 +02:00
1 parent 9736a55e00
commit 104198036a
11 files changed
+312 -62

No files matched your search

+16
View File
@@ -47,6 +47,22 @@ def ResolvePath(RootName: str, RelativePath: str) -> Path:
return Candidate
def NormalizeRelativePath(BaseDirectory: str, RawPath: str) -> str:
Combined = f"{BaseDirectory}/{RawPath}" if BaseDirectory else RawPath
Parts: list[str] = []
for Part in Combined.split("/"):
if Part in ("", "."):
continue
if Part == "..":
if Parts:
Parts.pop()
continue
Parts.append(Part)
return "/".join(Parts)
def IsInternalPath(EntryPath: Path) -> bool:
SaraTagConfig = Config.get("SaraTag", {})
+4 -3
View File
@@ -23,7 +23,7 @@ from Auth import (
)
from BookReader import ReadBookForFile
from Blame import LoadBlame, RenameUserInBlame, UpdateBlameOnSave
from Core import ResolvePath
from Core import NormalizeRelativePath, ResolvePath
from Embeds import BuildOgTags
from Editor import WriteTextFile
from Explorer import (
@@ -440,10 +440,11 @@ def PatchTreeEndpoint(
) -> dict:
RequirePathAccessible(Root, Path, CurrentUser)
ParentPath = Path.rsplit("/", 1)[0] if "/" in Path else ""
if Body.DestinationPath:
Destination = Body.DestinationPath
Destination = NormalizeRelativePath(ParentPath, Body.DestinationPath)
elif Body.NewName:
ParentPath = Path.rsplit("/", 1)[0] if "/" in Path else ""
Destination = f"{ParentPath}/{Body.NewName}" if ParentPath else Body.NewName
else:
raise HTTPException(status_code=400, detail="Provide NewName or DestinationPath.")
+4 -20
View File
@@ -2,7 +2,7 @@ from __future__ import annotations
import re
from Core import ResolvePath
from Core import NormalizeRelativePath, ResolvePath
from Explorer import ClassifyFile, ListDirectory
from Locks import IsPathAccessible
from Preview import ReadTextFile
@@ -94,22 +94,6 @@ def _ResolveLocalPortals(Content: str) -> str:
return "".join(Output)
def _NormalizeRelativePath(BaseDirectory: str, RawPath: str) -> str:
Combined = f"{BaseDirectory}/{RawPath}" if BaseDirectory else RawPath
Parts: list[str] = []
for Part in Combined.split("/"):
if Part in ("", "."):
continue
if Part == "..":
if Parts:
Parts.pop()
continue
Parts.append(Part)
return "/".join(Parts)
def _ReadAccessiblePortalSource(
RootName: str, RelativePath: str, Username: str, UserGroups: list[str]
) -> str | None:
@@ -171,7 +155,7 @@ def _ResolveCrossFileReference(
if not PathText:
return _FindNamedPortalInDirectory(RootName, RefererDirectory, Name, Username, UserGroups)
TargetRelativePath = _NormalizeRelativePath(RefererDirectory, PathText)
TargetRelativePath = NormalizeRelativePath(RefererDirectory, PathText)
try:
TargetPath = ResolvePath(RootName, TargetRelativePath)
@@ -205,7 +189,7 @@ def _ResolveWholeFilePipe(
Username: str,
UserGroups: list[str],
) -> str | None:
TargetRelativePath = _NormalizeRelativePath(RefererDirectory, PathText)
TargetRelativePath = NormalizeRelativePath(RefererDirectory, PathText)
Content = _ReadAccessiblePortalSource(RootName, TargetRelativePath, Username, UserGroups)
if Content is None:
@@ -222,7 +206,7 @@ def _ResolveLineNumberReference(
Username: str,
UserGroups: list[str],
) -> str | None:
TargetRelativePath = _NormalizeRelativePath(RefererDirectory, PathText)
TargetRelativePath = NormalizeRelativePath(RefererDirectory, PathText)
Content = _ReadAccessiblePortalSource(RootName, TargetRelativePath, Username, UserGroups)
if Content is None: