Editor: jump-to-section dropdown (parses /* banner */ comments)

This commit is contained in:
FuelBoard Contributor
2026-08-13 12:45:36 +01:00
parent d47e4f2ead
commit a597157622
3 changed files with 43 additions and 2 deletions
+15 -1
View File
@@ -20,6 +20,7 @@ Config via env: FUELBOARD_REPO, TOKEN, PORT (default 8790).
import json
import os
import re
import secrets
import shutil
import subprocess
@@ -76,6 +77,18 @@ def git_head() -> str:
return git("log", "--oneline", "-1") or "no commits"
def parse_sections(content: str) -> list:
"""Find single-line comment banners like /* Stations tab */ so the
editor can offer a jump-to-section dropdown. The multi-line header
comment at the top never matches (it doesn't end with */ on one line)."""
sections = []
for i, line in enumerate(content.splitlines(), start=1):
m = re.match(r"^/\* (.+) \*/$", line.strip())
if m:
sections.append({"name": m.group(1).strip(), "line": i})
return sections
# --------------------------------------------------------------------------
# Build job (runs in a background thread so the phone doesn't wait on it)
# --------------------------------------------------------------------------
@@ -212,7 +225,8 @@ class Handler(BaseHTTPRequestHandler):
self._json(404, {"error": f"missing {STRINGS_FILE}"})
return
self._json(200, {"content": content, "dirty": git_dirty_files(),
"head": git_head(), "repo": str(REPO)})
"head": git_head(), "repo": str(REPO),
"sections": parse_sections(content)})
return
if self.path.startswith("/job/"):
if not self._authorized():