fix: eliminate x-data quoting bug by moving page data to JSON script tag
Root cause: x-data HTML attribute with tojson creates quote conflicts that survive even Cache-Control: no-store (likely nginx proxy cache). Solution: page data is now in a <script type=application/json> tag, completely decoupled from Alpine x-data HTML attribute. Zero quoting issues regardless of page content. - x-data="editorState()" + x-init="loadPage()" replaces editor(...) - Server passes page_data dict, template renders as JSON script tag - Same approach used for page_share_mode and page_published - All 73 tests pass
This commit is contained in:
@@ -752,7 +752,8 @@ async def view_page(request: Request, page_id: int):
|
||||
).fetchone()
|
||||
ctx = {**sidebar, "page": page, "page_favorited": fav is not None,
|
||||
"page_share_mode": page.get("share_mode", "private"),
|
||||
"page_published": bool(page.get("published", 0))}
|
||||
"page_published": bool(page.get("published", 0)),
|
||||
"page_data": {"id": page_id, "title": page.get("title"), "content_format": page.get("content_format", "blocks"), "content": page.get("content", ""), "favorited": fav is not None, "share_mode": page.get("share_mode", "private"), "published": bool(page.get("published", 0))}}
|
||||
template = env.get_template("page_editor.html")
|
||||
response = template.render(**ctx)
|
||||
return HTMLResponse(content=response, headers={"Cache-Control": "no-store, max-age=0"})
|
||||
|
||||
Reference in New Issue
Block a user