From f3527c889b04b2165a619300dc990db8ab6b0e2d Mon Sep 17 00:00:00 2001 From: nudoragon Date: Mon, 18 May 2026 12:45:57 +0800 Subject: [PATCH] rename page --- build_editor.py | 23 +- main.py | 66 +++ static/js/my-editor.js | 531 +++++++++++++++++- templates/dashboard.html | 21 +- templates/editor.html | 14 +- websites/linktree-test/avatar.png | Bin 0 -> 175928 bytes websites/linktree-test/config.js | 97 ++++ websites/linktree-test/index.html | 168 ++++++ websites/linktree-test/project.json | 6 + websites/linktree-test/style.css | 297 ++++++++++ .../{about-us.html => about-final.html} | 5 +- websites/my-website/index.html | 2 +- 12 files changed, 1212 insertions(+), 18 deletions(-) create mode 100644 websites/linktree-test/avatar.png create mode 100644 websites/linktree-test/config.js create mode 100644 websites/linktree-test/index.html create mode 100644 websites/linktree-test/project.json create mode 100644 websites/linktree-test/style.css rename websites/my-website/{about-us.html => about-final.html} (91%) 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("
設計與開發的探索者 | 建立數位世界的連結