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