mirror of
https://github.com/penpot/penpot.git
synced 2025-02-05 22:09:06 -05:00
✨ Improve dynamic configuration handling.
This commit is contained in:
parent
fb910a24e1
commit
1118a995e2
4 changed files with 27 additions and 27 deletions
|
@ -150,22 +150,27 @@ function templatePipeline(options) {
|
|||
return function() {
|
||||
const input = options.input;
|
||||
const output = options.output;
|
||||
|
||||
const ts = Math.floor(new Date());
|
||||
|
||||
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();
|
||||
|
||||
const defaultConf = `var uxboxConfig = {demoWarning: false, googleClientID: null, loginWithLDAP: null, publicURI: null};`
|
||||
fs.writeFileSync(__dirname + "/resources/public/js/config.js", defaultConf)
|
||||
const defaultConf = [
|
||||
"var appDemoWarning = null;",
|
||||
"var appLoginWithLDAP = null;",
|
||||
"var appPublicURI = null;",
|
||||
"var appGoogleClientID = null;",
|
||||
"var appDeployDate = null;",
|
||||
"var appDeployCommit = null;"
|
||||
];
|
||||
|
||||
fs.writeFileSync(__dirname + "/resources/public/js/config.js",
|
||||
defaultConf.join("\n"));
|
||||
|
||||
const tmpl = mustache({
|
||||
deployCommit,
|
||||
deployDate,
|
||||
ts: ts,
|
||||
th: th,
|
||||
manifest: manifest,
|
||||
|
|
|
@ -12,14 +12,12 @@
|
|||
<section id="app" tabindex="1"></section>
|
||||
<section id="modal"></section>
|
||||
<script>
|
||||
window.uxboxTranslations = JSON.parse({{& translations }});
|
||||
window.uxboxThemes = {{& themes }};
|
||||
window.uxboxDeployDate = "{{& deployDate }}";
|
||||
window.uxboxDeployCommit = "{{& deployCommit }}";
|
||||
window.appTranslations = JSON.parse({{& translations }});
|
||||
window.appThemes = {{& themes }};
|
||||
</script>
|
||||
{{# manifest}}
|
||||
|
||||
<script>window.uxboxWorkerURI="{{& worker}}"</script>
|
||||
<script>window.appWorkerURI="{{& worker}}"</script>
|
||||
<script src="{{& config}}"></script>
|
||||
<script src="{{& shared}}"></script>
|
||||
<script src="{{& main}}"></script>
|
||||
|
|
|
@ -11,17 +11,15 @@
|
|||
(:require [uxbox.util.object :as obj]))
|
||||
|
||||
(this-as global
|
||||
(let [config (obj/get global "uxboxConfig" {})
|
||||
wuri (obj/get global "uxboxWorkerURI" "/js/worker.js")]
|
||||
(def default-language "en")
|
||||
(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")))
|
||||
(def default-language "en")
|
||||
(def demo-warning (obj/get global "appDemoWarning" false))
|
||||
(def google-client-id (obj/get global "appGoogleClientID" nil))
|
||||
(def login-with-ldap (obj/get global "appLoginWithLDAP" false))
|
||||
(def worker-uri (obj/get global "appWorkerURI" "/js/worker.js"))
|
||||
(def public-uri (or (obj/get global "appPublicURI")
|
||||
(.-origin ^js js/location)))
|
||||
(def media-uri (str public-uri "/media"))
|
||||
(def default-theme "default"))
|
||||
|
||||
(defn resolve-media-path
|
||||
[path]
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
[hashp.core :include-macros true]
|
||||
[cljs.spec.alpha :as s]
|
||||
[beicon.core :as rx]
|
||||
[goog.object :as gobj]
|
||||
[rumext.alpha :as mf]
|
||||
[uxbox.common.uuid :as uuid]
|
||||
[uxbox.main.data.auth :refer [logout]]
|
||||
|
@ -64,8 +63,8 @@
|
|||
|
||||
(defn ^:export init
|
||||
[]
|
||||
(let [translations (obj/get js/window "uxboxTranslations")
|
||||
themes (gobj/get js/window "uxboxThemes")]
|
||||
(let [translations (obj/get js/window "appTranslations")
|
||||
themes (obj/get js/window "appThemes")]
|
||||
(i18n/init! translations)
|
||||
(theme/init! themes)
|
||||
(st/init)
|
||||
|
|
Loading…
Add table
Reference in a new issue