2020-03-11 21:43:55 +08:00
|
|
|
// discourse-skip-module
|
2018-09-17 16:31:46 +08:00
|
|
|
(function() {
|
2020-05-07 03:28:06 +08:00
|
|
|
const ps = require("discourse/lib/preload-store").default;
|
2020-03-25 04:32:56 +08:00
|
|
|
const preloadedDataElement = document.getElementById("data-preloaded");
|
|
|
|
const setupData = document.getElementById("data-discourse-setup").dataset;
|
2020-05-14 22:04:08 +08:00
|
|
|
const I18n = require("I18n").default;
|
2018-09-17 16:31:46 +08:00
|
|
|
|
|
|
|
if (preloadedDataElement) {
|
2020-03-25 04:32:56 +08:00
|
|
|
const preloaded = JSON.parse(preloadedDataElement.dataset.preloaded);
|
2018-09-17 16:31:46 +08:00
|
|
|
|
|
|
|
Object.keys(preloaded).forEach(function(key) {
|
|
|
|
ps.store(key, JSON.parse(preloaded[key]));
|
2020-02-06 11:14:33 +08:00
|
|
|
|
|
|
|
if (setupData.debugPreloadedAppData === "true") {
|
|
|
|
/* eslint-disable no-console */
|
|
|
|
console.log(key, ps.get(key));
|
|
|
|
/* eslint-enable no-console */
|
|
|
|
}
|
2018-09-17 16:31:46 +08:00
|
|
|
});
|
|
|
|
}
|
2018-10-02 12:29:04 +08:00
|
|
|
|
2019-08-20 09:29:11 +08:00
|
|
|
window.Logster = window.Logster || {};
|
|
|
|
window.Logster.enabled = setupData.enableJsErrorReporting === "true";
|
|
|
|
|
2018-10-02 12:29:04 +08:00
|
|
|
Discourse.CDN = setupData.cdn;
|
|
|
|
Discourse.BaseUrl = setupData.baseUrl;
|
|
|
|
Discourse.BaseUri = setupData.baseUri;
|
|
|
|
Discourse.Environment = setupData.environment;
|
|
|
|
Discourse.SiteSettings = ps.get("siteSettings");
|
|
|
|
Discourse.ThemeSettings = ps.get("themeSettings");
|
|
|
|
Discourse.LetterAvatarVersion = setupData.letterAvatarVersion;
|
|
|
|
Discourse.MarkdownItURL = setupData.markdownItUrl;
|
|
|
|
Discourse.ServiceWorkerURL = setupData.serviceWorkerUrl;
|
|
|
|
I18n.defaultLocale = setupData.defaultLocale;
|
|
|
|
Discourse.start();
|
|
|
|
Discourse.set("assetVersion", setupData.assetVersion);
|
2019-11-09 02:46:50 +08:00
|
|
|
|
2020-03-25 04:32:56 +08:00
|
|
|
const Session = require("discourse/models/session").default;
|
2019-11-09 02:46:50 +08:00
|
|
|
Session.currentProp(
|
2018-10-02 12:29:04 +08:00
|
|
|
"disableCustomCSS",
|
|
|
|
setupData.disableCustomCss === "true"
|
|
|
|
);
|
|
|
|
|
|
|
|
if (setupData.safeMode) {
|
2019-11-09 02:46:50 +08:00
|
|
|
Session.currentProp("safe_mode", setupData.safeMode);
|
2018-10-02 12:29:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Discourse.HighlightJSPath = setupData.highlightJsPath;
|
2018-11-27 05:49:57 +08:00
|
|
|
Discourse.SvgSpritePath = setupData.svgSpritePath;
|
|
|
|
|
|
|
|
if (Discourse.Environment === "development") {
|
|
|
|
Discourse.SvgIconList = setupData.svgIconList;
|
|
|
|
}
|
2018-10-02 12:29:04 +08:00
|
|
|
|
2018-10-02 13:02:12 +08:00
|
|
|
if (setupData.s3BaseUrl) {
|
2018-10-02 12:29:04 +08:00
|
|
|
Discourse.S3CDN = setupData.s3Cdn;
|
|
|
|
Discourse.S3BaseUrl = setupData.s3BaseUrl;
|
|
|
|
}
|
2018-10-09 13:50:45 +08:00
|
|
|
|
2020-03-11 21:43:55 +08:00
|
|
|
// eslint-disable-next-line
|
2018-10-09 13:50:45 +08:00
|
|
|
Ember.RSVP.configure("onerror", function(e) {
|
|
|
|
// Ignore TransitionAborted exceptions that bubble up
|
|
|
|
if (e && e.message === "TransitionAborted") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Discourse.Environment === "development") {
|
2018-11-15 06:17:56 +08:00
|
|
|
/* eslint-disable no-console */
|
2018-10-09 13:50:45 +08:00
|
|
|
if (e) {
|
|
|
|
if (e.message || e.stack) {
|
|
|
|
console.log(e.message);
|
|
|
|
console.log(e.stack);
|
|
|
|
} else {
|
|
|
|
console.log("Uncaught promise: ", e);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log("A promise failed but was not caught.");
|
|
|
|
}
|
2018-11-15 06:17:56 +08:00
|
|
|
/* eslint-enable no-console */
|
2018-10-09 13:50:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
window.onerror(e && e.message, null, null, null, e);
|
|
|
|
});
|
2018-09-17 16:31:46 +08:00
|
|
|
})();
|