diff --git a/.env.embed b/.env.embed index 91e7c7d6..c3526a22 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 a1797326..5275e48b 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/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index c41e5cfb..96926e95 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -77,6 +77,8 @@ jobs: echo "URL_FILE_MODE=all-remote" >> $GITHUB_ENV echo "IMAGE_PROXY_BYPASS=true" >> $GITHUB_ENV echo "POSTMESSAGE_ORIGIN=*" >> $GITHUB_ENV + echo "APP_NAME=code.pyret.org" >> $GITHUB_ENV + echo "APP_DOMAIN=code.pyret.org" >> $GITHUB_ENV - name: Start application server run: | diff --git a/src/scripts/get-image.js b/src/scripts/get-image.js index 6c37a497..022b488e 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 9395dab6..b1dce7a4 100644 --- a/src/server.js +++ b/src/server.js @@ -20,6 +20,9 @@ var SHAREURL_PROXY_MAX_BYTES = 1 * 1024 * 1024; // 1 MB var SHAREURL_PROXY_TIMEOUT_MS = 10 * 1000; // 10 s function start(config, onServerReady) { + var APP_NAME = process.env.APP_NAME || "code.pyret.org"; + var APP_DOMAIN = process.env.APP_DOMAIN || "code.pyret.org"; + var defaultOpts = { PYRET: process.env.PYRET, BASE_URL: config.baseUrl, @@ -30,7 +33,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: APP_NAME, + APP_DOMAIN: APP_DOMAIN, }; var express = require('express'); var cookieSession = require('cookie-session'); @@ -98,7 +103,7 @@ function start(config, onServerReady) { app.use(cookieSession({ secret: config.sessionSecret, - key: "code.pyret.org", + key: APP_NAME, sameSite: 'lax' })); @@ -123,12 +128,12 @@ function start(config, onServerReady) { app.use(csrf()); - app.get("/close.html", function(_, res) { res.render("close.html"); }); - app.get("/faq.html", function(_, res) { res.render("faq.html"); }); - app.get("/privacy.html", function(_, res) { res.render("privacy.html"); }); - app.get("/privacy/", function(_, res) { res.render("privacy.html"); }); + app.get("/close.html", function(_, res) { res.render("close.html", defaultOpts); }); + app.get("/faq.html", function(_, res) { res.render("faq.html", defaultOpts); }); + app.get("/privacy.html", function(_, res) { res.render("privacy.html", defaultOpts); }); + app.get("/privacy/", function(_, res) { res.render("privacy.html", defaultOpts); }); - app.get("/faq", function(_, res) { res.render("faq.html"); }); + app.get("/faq", function(_, res) { res.render("faq.html", defaultOpts); }); app.get("/", function(req, res) { var content = loggedIn(req) ? "My Programs" : "Log In"; diff --git a/src/web/blocks.html b/src/web/blocks.html index d5a17cdd..05327366 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 fd59d9e7..b9898812 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 347b190a..f0e5783b 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 75c385bb..5363e354 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 9cc00264..9b46ad02 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 31c336ee..b928b2be 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: