From b0c8eadb6daf6d55f55725ef565c19c6006971c1 Mon Sep 17 00:00:00 2001 From: Emmanuel Schanzer Date: Fri, 22 May 2026 21:10:21 -0400 Subject: [PATCH 1/8] first stab at templating app_domain and app_name strings --- .env.embed | 2 ++ .env.example | 2 ++ src/scripts/get-image.js | 2 +- src/server.js | 6 ++++-- src/web/blocks.html | 4 ++-- src/web/editor.html | 6 +++--- src/web/faq.html | 20 ++++++++++---------- src/web/ide.html | 2 +- src/web/index.html | 2 +- src/web/js/authenticate-storage.js | 2 +- src/web/js/beforeBlocks.js | 4 ++-- src/web/js/beforePyret.js | 4 ++-- src/web/js/dashboard/StudentDashboard.js | 2 +- src/web/js/dashboard/config.js | 2 +- src/web/js/events.js | 2 +- src/web/privacy.html | 6 +++--- src/web/share.template.html | 2 +- webpack.config.js | 2 ++ 18 files changed, 40 insertions(+), 32 deletions(-) diff --git a/.env.embed b/.env.embed index 91e7c7d6d..c3526a22d 100644 --- a/.env.embed +++ b/.env.embed @@ -8,5 +8,7 @@ CURRENT_PYRET_RELEASE="" PYRET="./js/cpo-main.jarr.js" POSTMESSAGE_ORIGIN="*" SHARED_FETCH_SERVER="https://code.pyret.org" +APP_NAME=code.pyret.org +APP_DOMAIN=code.pyret.org URL_FILE_MODE="all-remote" IMAGE_PROXY_BYPASS="true" diff --git a/.env.example b/.env.example index a17973261..5275e48bb 100644 --- a/.env.example +++ b/.env.example @@ -14,5 +14,7 @@ PORT=4999 NODE_ENV=development POSTMESSAGE_ORIGIN="http://localhost:3000" SHARED_FETCH_SERVER="https://code.pyret.org" +APP_NAME=code.pyret.org +APP_DOMAIN=code.pyret.org URL_FILE_MODE="all-remote" IMAGE_PROXY_BYPASS="set to true to avoid image proxying through BASE_URL/downloadImg (the default)" \ No newline at end of file diff --git a/src/scripts/get-image.js b/src/scripts/get-image.js index 6c37a497e..022b488ea 100644 --- a/src/scripts/get-image.js +++ b/src/scripts/get-image.js @@ -145,7 +145,7 @@ function saveBase64PngToFile(base64, filename) { } async function go(example) { - const fetchresult = browser.get("https://code.pyret.org/editor"); + const fetchresult = browser.get("https://" + process.env.APP_DOMAIN + "/editor"); const result = await waitForPyretLoad(browser); const result2 = await setDefinitionsEvalAndWait(browser, example.code, { typeCheck: false }); browser.wait(webdriver.until.elementLocated(webdriver.By.css("canvas")), 10000); diff --git a/src/server.js b/src/server.js index 9395dab6a..3c591f959 100644 --- a/src/server.js +++ b/src/server.js @@ -30,7 +30,9 @@ function start(config, onServerReady) { LOG_USER: config.logUser, GIT_REV : config.gitRev, GIT_BRANCH: config.gitBranch, - POSTMESSAGE_ORIGIN: process.env.POSTMESSAGE_ORIGIN + POSTMESSAGE_ORIGIN: process.env.POSTMESSAGE_ORIGIN, + APP_NAME: process.env.APP_NAME, + APP_DOMAIN: process.env.APP_DOMAIN }; var express = require('express'); var cookieSession = require('cookie-session'); @@ -98,7 +100,7 @@ function start(config, onServerReady) { app.use(cookieSession({ secret: config.sessionSecret, - key: "code.pyret.org", + key: process.env.APP_NAME, sameSite: 'lax' })); diff --git a/src/web/blocks.html b/src/web/blocks.html index d5a17cdd5..05327366a 100644 --- a/src/web/blocks.html +++ b/src/web/blocks.html @@ -2,9 +2,9 @@ - code.pyret.org + {{APP_NAME}} - + diff --git a/src/web/editor.html b/src/web/editor.html index fd59d9e78..b9898812b 100644 --- a/src/web/editor.html +++ b/src/web/editor.html @@ -2,9 +2,9 @@ - code.pyret.org + {{APP_NAME}} - + @@ -156,7 +156,7 @@ aria-label="Contribute detailed usage information"/> - ? diff --git a/src/web/faq.html b/src/web/faq.html index 347b190ac..f0e5783bc 100644 --- a/src/web/faq.html +++ b/src/web/faq.html @@ -2,7 +2,7 @@ - code.pyret.org + {{APP_NAME}} @@ -27,15 +27,15 @@
-

What permissions does code.pyret.org ask for and why?

+

What permissions does {{APP_NAME}} ask for and why?

-

code.pyret.org asks for several permissions when you log in:

+

{{APP_NAME}} asks for several permissions when you log in:

- pyret.org | Policies | Software

+ pyret.org | Policies | Software

diff --git a/src/web/js/dashboard/config.js b/src/web/js/dashboard/config.js index 75c385bbb..5363e354c 100644 --- a/src/web/js/dashboard/config.js +++ b/src/web/js/dashboard/config.js @@ -1,5 +1,5 @@ // App name in *Title Case*. -export const APP_NAME = 'code.pyret.org'; +export const APP_NAME = process.env.APP_NAME; // File extension of code files for this app. export const FILE_EXT = 'arr'; diff --git a/src/web/js/events.js b/src/web/js/events.js index 9cc00264a..9b46ad022 100644 --- a/src/web/js/events.js +++ b/src/web/js/events.js @@ -343,7 +343,7 @@ function makeEvents(config) { return reset(initialState); } // This means we got a CPO link as the initial state. - if((typeof APP_BASE_URL === 'string' && APP_BASE_URL !== "" && message.state.startsWith(APP_BASE_URL)) || message.state.startsWith("https://code.pyret.org")) { + if((typeof APP_BASE_URL === 'string' && APP_BASE_URL !== "" && message.state.startsWith(APP_BASE_URL)) || message.state.startsWith("https://" + window.APP_DOMAIN)) { return resetFromShare(message.state); } try { diff --git a/src/web/privacy.html b/src/web/privacy.html index 31c336eea..b928b2be5 100644 --- a/src/web/privacy.html +++ b/src/web/privacy.html @@ -1,4 +1,4 @@ -

This Privacy Policy governs the manner in which code.pyret.org collects, uses, maintains and discloses information collected from users (each, a "User") of the https://code.pyret.org website ("Site").

+

This Privacy Policy governs the manner in which {{APP_NAME}} collects, uses, maintains and discloses information collected from users (each, a "User") of the https://{{APP_DOMAIN}} website ("Site").

Personal identification information

We may collect personal identification information from Users in a variety of ways in connection with activities, services, features or resources we make available on our Site. Users may visit our Site anonymously. We will collect personal identification information from Users only if they voluntarily submit such information to us. Users can always refuse to supply personally identification information, except that it may prevent them from engaging in certain Site related activities.

@@ -10,7 +10,7 @@

Web browser cookies

Our Site may use "cookies" to enhance User experience. User's web browser places cookies on their hard drive for record-keeping purposes and sometimes to track information about them. User may choose to set their web browser to refuse cookies, or to alert you when cookies are being sent. If they do so, note that some parts of the Site may not function properly.

How we use collected information

-

code.pyret.org may collect and use Users personal information for the following purposes:

+

{{APP_NAME}} may collect and use Users personal information for the following purposes: