Form view: structured key/value editor (keys read-only, values editable; side-by-side desktop, stacked mobile) + testable strings-format.js
This commit is contained in:
@@ -7,6 +7,7 @@ Why stdlib only: no pip installs, one file to read, easy to see how it
|
||||
works. Routes:
|
||||
|
||||
GET / -> the editor page (HTML)
|
||||
GET /strings-format.js -> .strings parse/serialize helpers (pure JS)
|
||||
GET /file -> current Localizable.strings + git dirty banner
|
||||
POST /save -> write the file + plutil lint {body: content}
|
||||
POST /save-build -> write the file, then start a background build job
|
||||
@@ -190,7 +191,8 @@ def start_build_job(content: str) -> str:
|
||||
# HTTP layer
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
PAGE = (Path(__file__).with_name("index.html")).read_text(encoding="utf-8")
|
||||
PAGE = (Path(__file__).parent / "index.html").read_text(encoding="utf-8")
|
||||
FORMAT_JS = (Path(__file__).parent / "strings-format.js").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
@@ -217,6 +219,9 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if path in ("/", "/index.html"):
|
||||
self._send(200, PAGE.encode(), "text/html; charset=utf-8")
|
||||
return
|
||||
if path == "/strings-format.js":
|
||||
self._send(200, FORMAT_JS.encode(), "text/javascript; charset=utf-8")
|
||||
return
|
||||
if path == "/file":
|
||||
if not self._authorized():
|
||||
self._json(401, {"error": "token required"})
|
||||
|
||||
Reference in New Issue
Block a user