diff --git a/backend/bin/repl b/backend/bin/repl deleted file mode 100755 index 7bf7d1beb..000000000 --- a/backend/bin/repl +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -set -ex -#clojure -Ojmx-remote -A:dev -e "(set! *warn-on-reflection* true)" -m rebel-readline.main -clojure -Ojmx-remote -A:dev -m rebel-readline.main diff --git a/frontend/gulpfile.js b/frontend/gulpfile.js index ec348345e..27ce62ce9 100644 --- a/frontend/gulpfile.js +++ b/frontend/gulpfile.js @@ -108,44 +108,15 @@ function readLocales() { return JSON.stringify(result); } -function readConfig(data) { - const googleClientID = process.env.UXBOX_GOOGLE_CLIENT_ID; - const demoWarn = process.env.UXBOX_DEMO_WARNING; - const deployDate = process.env.UXBOX_DEPLOY_DATE; - const deployCommit = process.env.UXBOX_DEPLOY_COMMIT; - const loginWithLDAP = process.env.UXBOX_LOGIN_WITH_LDAP; - - let cfg = { - demoWarning: demoWarn === "true" - }; - - if (googleClientID !== undefined) { - cfg.googleClientID = googleClientID; - } - - if (deployDate !== undefined) { - cfg.deployDate = deployDate; - } - - if (deployCommit !== undefined) { - cfg.deployCommit = deployCommit; - } - - if (loginWithLDAP !== undefined) { - cfg.loginWithLDAP = loginWithLDAP; - } - - Object.assign(cfg, data); - - return JSON.stringify(cfg); -} - -function readManifest(publicURI) { +function readManifest() { try { const path = __dirname + "/resources/public/js/manifest.json"; const content = JSON.parse(fs.readFileSync(path, {encoding: "utf8"})); - const index = {}; + const index = { + "config": "/js/config.js?ts=" + Date.now() + }; + for (let item of content) { index[item.name] = "/js/" + item["output-name"]; }; @@ -154,6 +125,7 @@ function readManifest(publicURI) { } catch (e) { console.error("Error on reading manifest, using default."); return { + "config": "/js/config.js", "main": "/js/main.js", "shared": "/js/shared.js", "worker": "/js/worker.js" @@ -180,24 +152,23 @@ function templatePipeline(options) { const output = options.output; const ts = Math.floor(new Date()); - const publicURI = process.env.UXBOX_PUBLIC_URI || "http://localhost:3449"; const th = process.env.UXBOX_THEME || "default"; + const deployDate = process.env.UXBOX_DEPLOY_DATE; + const deployCommit = process.env.UXBOX_DEPLOY_COMMIT; const themes = ["default"]; - const locales = readLocales(); - const manifest = readManifest(publicURI); + const manifest = readManifest(); - const config = readConfig({ - workerURI: manifest.worker, - publicURI: publicURI - }); + const defaultConf = `var uxboxConfig = {demoWarning: false, googleClientID: null, loginWithLDAP: null, publicURI: null};` + fs.writeFileSync(__dirname + "/resources/public/js/config.js", defaultConf) const tmpl = mustache({ + deployCommit, + deployDate, ts: ts, th: th, manifest: manifest, - config: JSON.stringify(config), translations: JSON.stringify(locales), themes: JSON.stringify(themes), }); diff --git a/frontend/resources/templates/index.mustache b/frontend/resources/templates/index.mustache index 2c17e8417..566ca82e6 100644 --- a/frontend/resources/templates/index.mustache +++ b/frontend/resources/templates/index.mustache @@ -12,13 +12,17 @@
{{# manifest}} - - + + + + + {{/manifest}} diff --git a/frontend/src/uxbox/config.cljs b/frontend/src/uxbox/config.cljs index faa0cb6e7..a404cef69 100644 --- a/frontend/src/uxbox/config.cljs +++ b/frontend/src/uxbox/config.cljs @@ -11,20 +11,17 @@ (:require [uxbox.util.object :as obj])) (this-as global - (let [config (obj/get global "uxboxConfig") - puri (obj/get config "publicURI") - wuri (obj/get config "workerURI") - gcid (obj/get config "googleClientID" true) - lwl (obj/get config "loginWithLDAP" false) - warn (obj/get config "demoWarning" true)] + (let [config (obj/get global "uxboxConfig" {}) + wuri (obj/get global "uxboxWorkerURI" "/js/worker.js")] (def default-language "en") - (def demo-warning warn) - (def google-client-id gcid) - (def login-with-ldap lwl) - (def worker-uri wuri) - (def public-uri puri) - (def media-uri (str puri "/media")) - (def default-theme "default"))) + (def demo-warning (obj/get config "demoWarning" false)) + (def google-client-id (obj/get config "googleClientID")) + (def login-with-ldap (obj/get config "loginWithLDAP" false)) + (def worker-uri wuri) + (def public-uri (or (obj/get config "publicURI") + (.-origin ^js js/location))) + (def media-uri (str public-uri "/media")) + (def default-theme "default"))) (defn resolve-media-path [path]