nudoragon
+設計與開發的探索者 | 建立數位世界的連結
+diff --git a/build_editor.py b/build_editor.py index 597412d..5bd58d1 100644 --- a/build_editor.py +++ b/build_editor.py @@ -7,6 +7,13 @@ OUT = BASE / "templates" / "editor.html" content = SRC.read_text(encoding="utf-8") +# ── Normalize line endings to LF to avoid CRLF mismatch on Windows ── +content = content.replace("\r\n", "\n") + +# ── Correct themeBaseUrl and mediaPath in editor.html ── +content = content.replace("Vvveb.themeBaseUrl = 'demo/landing/';", "Vvveb.themeBaseUrl = '/static/Vvvebjs/demo/landing/';") +content = content.replace("window.mediaPath = '../../media';", "window.mediaPath = '/static/Vvvebjs/media/';") + # ── 1. Fix static asset paths ──────────────────────────────────── VBASE = "/static/Vvvebjs/" replacements = [ @@ -41,6 +48,20 @@ JS_VARS = [ for old, new in JS_VARS: content = content.replace(old, new) +# ── Make editor load requested page from query parameter ── +old_init = 'let firstPage = Object.keys(pages)[0];\nVvveb.Builder.init(pages[firstPage]["url"], function () {' +new_init = """let firstPage = Object.keys(pages)[0]; +const urlParams = new URLSearchParams(window.location.search); +const requestedPage = urlParams.get('page'); +if (requestedPage) { +\tlet pageKey = requestedPage.replace(".html", ""); +\tif (pages[pageKey]) { +\t\tfirstPage = pageKey; +\t} +} +Vvveb.Builder.init(pages[firstPage]["url"], function () {""" +content = content.replace(old_init, new_init) + # ── 4. Wrap everything in {% raw %} ... {% endraw %} to avoid Jinja2 parsing conflicts ── # We do this first so Jinja2 ignores VvvebJS's frontend micro-templates ({%= %}, {% %}). # Then we selectively exit the {% raw %} block using {% endraw %} ... {% raw %} for our dynamic values. @@ -94,7 +115,7 @@ BACK_BTN = """ // Inject project slug for save bridge window.VVVEB_PROJECT_SLUG = "{% endraw %}{{ slug | safe }}{% raw %}"; - + """ content = content.replace("
+設計與開發的探索者 | 建立數位世界的連結
+