This commit is contained in:
@@ -397,6 +397,18 @@ def page_to_dict(page: ContentPage) -> dict[str, Any]:
|
||||
}
|
||||
|
||||
|
||||
def server_diagnostics() -> dict[str, Any]:
|
||||
pages = list_pages()
|
||||
return {
|
||||
"root": ROOT.as_posix(),
|
||||
"cwd": Path.cwd().as_posix(),
|
||||
"executable": sys.executable,
|
||||
"pid": os.getpid(),
|
||||
"pageCount": len(pages),
|
||||
"firstPage": pages[0]["path"] if pages else "",
|
||||
}
|
||||
|
||||
|
||||
def list_pages() -> list[dict[str, Any]]:
|
||||
pages = []
|
||||
org_paths = []
|
||||
@@ -1355,6 +1367,12 @@ class Handler(BaseHTTPRequestHandler):
|
||||
except Exception as exc:
|
||||
self.send_json({"error": str(exc)}, HTTPStatus.INTERNAL_SERVER_ERROR)
|
||||
return
|
||||
if parsed.path == "/api/diagnostics":
|
||||
try:
|
||||
self.send_json(server_diagnostics())
|
||||
except Exception as exc:
|
||||
self.send_json({"error": str(exc)}, HTTPStatus.INTERNAL_SERVER_ERROR)
|
||||
return
|
||||
if parsed.path == "/api/page":
|
||||
query = parse_qs(parsed.query)
|
||||
try:
|
||||
@@ -1408,8 +1426,12 @@ class Handler(BaseHTTPRequestHandler):
|
||||
def main() -> None:
|
||||
port = int(os.environ.get("AUTHOR_PORT", "8765"))
|
||||
server = ThreadingHTTPServer(("127.0.0.1", port), Handler)
|
||||
page_count = len(list_pages())
|
||||
print(f"Authoring UI running at http://127.0.0.1:{port}")
|
||||
print(f"Content root: {ROOT}")
|
||||
print(f"Editable pages: {page_count}")
|
||||
if page_count == 0:
|
||||
print("WARNING: no editable pages were found. Check AUTHOR_ROOT and the launch directory.")
|
||||
print("Press Ctrl-C to stop.")
|
||||
try:
|
||||
server.serve_forever()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
See the categories: @@html:<a href="../home/categories.html">Categories</a>@@
|
||||
|
||||
* Posts:
|
||||
- [[file:career/career-list.org][Career List]] @@html:<span class="post-date">07-05-2026 16:35</span>@@
|
||||
- [[file:career/career-list.org][Career List]] @@html:<span class="post-date">07-05-2026 16:45</span>@@
|
||||
- [[file:posts-list.sync-conflict-20260417-233432-VT6366A.org][Posts List]] @@html:<span class="post-date">14-04-2026 16:36</span>@@
|
||||
- [[file:career/ha-dr.org][High Availability, Disaster Recovery and Business Continuity]] @@html:<span class="post-date">11-03-2026 17:18</span>@@ @@html:<a href="/tags/learning.html"><span class="post-tag">learning</span></a>@@ @@html:<a href="/tags/notes.html"><span class="post-tag">notes</span></a>@@
|
||||
- [[file:career/javascript.org][Understands the Javascript language]] @@html:<span class="post-date">11-03-2026 16:52</span>@@ @@html:<a href="/tags/learning.html"><span class="post-tag">learning</span></a>@@ @@html:<a href="/tags/notes.html"><span class="post-tag">notes</span></a>@@
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
- [[file:tags/notes.org][Tag: notes]]
|
||||
- [[file:tags/review.org][Tag: review]]
|
||||
- [[file:tags/website.org][Tag: website]]
|
||||
- [[file:tags/update.org][Tag: update]]
|
||||
- [[file:tags/life.org][Tag: life]]
|
||||
- [[file:tags/education.org][Tag: education]]
|
||||
- [[file:tags/update.org][Tag: update]]
|
||||
- [[file:tags/insights.org][Tag: insights]]
|
||||
- [[file:tags/emacs.org][Tag: emacs]]
|
||||
- [[file:tags/reading.org][Tag: reading]]
|
||||
- [[file:tags/emacs.org][Tag: emacs]]
|
||||
- [[file:tags/maths.org][Tag: maths]]
|
||||
- home
|
||||
- [[file:home/countdown.org][Countdown]]
|
||||
|
||||
@@ -198,6 +198,15 @@ class PageRenderingTests(AuthoringServerTestCase):
|
||||
|
||||
self.assertEqual(paths, ["blogs/keep.org"])
|
||||
|
||||
def test_server_diagnostics_reports_root_and_page_count(self):
|
||||
(self.blogs / "keep.org").write_text("#+TITLE: Keep\n#+DATE: <2026-05-07 Thu 12:00>\n", encoding="utf-8")
|
||||
|
||||
diagnostics = server.server_diagnostics()
|
||||
|
||||
self.assertEqual(diagnostics["root"], self.root.as_posix())
|
||||
self.assertEqual(diagnostics["pageCount"], 1)
|
||||
self.assertEqual(diagnostics["firstPage"], "blogs/keep.org")
|
||||
|
||||
def test_relative_asset_path_is_calculated_from_lima_page_directory(self):
|
||||
self.assertEqual(
|
||||
server.relative_asset_path("lima/family/update.md", "assets/images/hzone/pic.png"),
|
||||
|
||||
Reference in New Issue
Block a user