From d17e8c017565056fb445f9181f08d172d19d14b8 Mon Sep 17 00:00:00 2001 From: anish-work Date: Tue, 10 Dec 2024 02:49:17 +0530 Subject: [PATCH 1/2] add gooey bot to page wrapper --- routers/root.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/routers/root.py b/routers/root.py index 8ddd9fca8..20346b6a0 100644 --- a/routers/root.py +++ b/routers/root.py @@ -748,6 +748,26 @@ def page_wrapper(request: Request, className=""): with gui.div(id="main-content", className="container-xxl " + className): yield current_workspace + gui.html( + """ +
+ + """ + ) + gui.js( + # language=javascript + """ + async function loadGooeyEmbed() { + await window.waitUntilHydrated; + if (typeof GooeyEmbed === 'undefined') return; + GooeyEmbed.unmount(); + GooeyEmbed.mount({}); + } + const script = document.getElementById("gooey-bot-embed-script"); + if (script) script.onload = loadGooeyEmbed; + loadGooeyEmbed(); + """, + ) gui.html(templates.get_template("footer.html").render(**context)) gui.html(templates.get_template("login_scripts.html").render(**context)) From 83109cbc548ea093b5d1b2c59d3706f18c2d28ae Mon Sep 17 00:00:00 2001 From: anish-work Date: Mon, 23 Dec 2024 15:03:28 +0530 Subject: [PATCH 2/2] hide gooey bot for /copilot --- routers/root.py | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/routers/root.py b/routers/root.py index 20346b6a0..745f616be 100644 --- a/routers/root.py +++ b/routers/root.py @@ -748,30 +748,37 @@ def page_wrapper(request: Request, className=""): with gui.div(id="main-content", className="container-xxl " + className): yield current_workspace - gui.html( - """ -
- - """ - ) - gui.js( - # language=javascript - """ - async function loadGooeyEmbed() { - await window.waitUntilHydrated; - if (typeof GooeyEmbed === 'undefined') return; - GooeyEmbed.unmount(); - GooeyEmbed.mount({}); - } - const script = document.getElementById("gooey-bot-embed-script"); - if (script) script.onload = loadGooeyEmbed; - loadGooeyEmbed(); - """, - ) + # except /copilot insert gooey-bot + if not request.url.path.startswith("/copilot"): + insert_gooey_bot_widget() + gui.html(templates.get_template("footer.html").render(**context)) gui.html(templates.get_template("login_scripts.html").render(**context)) +def insert_gooey_bot_widget(): + gui.html( + """ +
+ + """ + ) + gui.js( + # language=javascript + """ + async function loadGooeyEmbed() { + await window.waitUntilHydrated; + if (typeof GooeyEmbed === 'undefined') return; + GooeyEmbed.unmount(); + GooeyEmbed.mount({ "target": "#gooey-bot-embed" }); + } + const script = document.getElementById("gooey-bot-embed-script"); + if (script) script.onload = loadGooeyEmbed; + loadGooeyEmbed(); + """, + ) + + def anonymous_login_container(request: Request, context: dict): login_url = str(furl("/login/", query_params=dict(next=request.url.path)))