Variables: one engine for server and client, and spans for live editors

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
sarahandClaude Opus 5.5 committed 2026-10-13 17:30:41 +02:00
1 parent c7a7596e99
commit 6d15fb1c53
3 files changed
+561 -467

No files matched your search

+18 -1
View File
@@ -87,7 +87,7 @@ from Users import (
UserColourOptions,
VerifyLogin,
)
from VarFunctions import ResolvePortals
from VarFunctions import ResolvePortals, ResolveSpans
from pydantic import BaseModel
@@ -614,6 +614,23 @@ def GetFileEndpoint(
return StreamBinaryFile(FilePath, request.headers.get("range"))
class SpansRequest(BaseModel):
Content: str
# Where each variable is in the text being edited, and what it resolves to
# (VarEngine.ResolveSpans): the live editors show the results in place.
@Application.post("/api/file/spans")
def PostFileSpansEndpoint(
Root: str, Path: str, Body: SpansRequest, CurrentUser: dict = Depends(GetCurrentUserOrGuest)
) -> dict:
RequirePathAccessible(Root, Path, CurrentUser)
if len(Body.Content) > 2_000_000:
raise HTTPException(status_code=413, detail="Too long to resolve.")
Spans = ResolveSpans(Root, Path, Body.Content, CurrentUser["Username"], CurrentUser.get("Groups", []))
return {"Spans": Spans}
@Application.get("/api/file/resolved")
def GetResolvedFileEndpoint(
Root: str, Path: str, CurrentUser: dict = Depends(GetCurrentUserOrGuest)