Add /api/log endpoint and WikiLog page; update site submodule
This commit is contained in:
@@ -231,6 +231,23 @@ app.add_middleware(
|
||||
|
||||
# ── Auth endpoints ────────────────────────────────────────────────────────────
|
||||
|
||||
@app.get("/api/log")
|
||||
async def get_wiki_log(user: User = Depends(require_auth)) -> JSONResponse:
|
||||
env = _git_env()
|
||||
proc = await asyncio.create_subprocess_exec(
|
||||
"git", "log", "--format=%h|%ar|%aN|%s", "-n", "50", "--", "pages/", "blog/",
|
||||
cwd=str(_ROOT), env=env,
|
||||
stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.DEVNULL,
|
||||
)
|
||||
stdout, _ = await proc.communicate()
|
||||
entries = []
|
||||
for line in stdout.decode().strip().splitlines():
|
||||
parts = line.split("|", 3)
|
||||
if len(parts) == 4:
|
||||
entries.append({"hash": parts[0], "date": parts[1], "author": parts[2], "message": parts[3]})
|
||||
return JSONResponse({"log": entries})
|
||||
|
||||
|
||||
@app.get("/api/me")
|
||||
async def me(user: User = Depends(require_auth)) -> JSONResponse:
|
||||
return JSONResponse({
|
||||
|
||||
+1
-1
Submodule site updated: 476f605a4a...dfce744001
Reference in New Issue
Block a user