2020-03-11 09:43:55 -04:00
|
|
|
// discourse-skip-module
|
2018-09-17 04:31:46 -04:00
|
|
|
(function() {
|
2020-03-24 16:32:56 -04:00
|
|
|
const ps = require("preload-store").default;
|
|
|
|
const preloadedDataElement = document.getElementById("data-preloaded");
|
|
|
|
const setupData = document.getElementById("data-discourse-setup").dataset;
|
2018-09-17 04:31:46 -04:00
|
|
|
|
|
|
|
if (preloadedDataElement) {
|
2020-03-24 16:32:56 -04:00
|
|
|
const preloaded = JSON.parse(preloadedDataElement.dataset.preloaded);
|
2018-09-17 04:31:46 -04:00
|
|
|
|
|
|
|
Object.keys(preloaded).forEach(function(key) {
|
|
|
|
ps.store(key, JSON.parse(preloaded[key]));
|
2020-02-05 22:14:33 -05:00
|
|
|
|
|
|
|
if (setupData.debugPreloadedAppData === "true") {
|
|
|
|
/* eslint-disable no-console */
|
|
|
|
console.log(key, ps.get(key));
|
|
|
|
/* eslint-enable no-console */
|
|
|
|
}
|
2018-09-17 04:31:46 -04:00
|
|
|
});
|
|
|
|
}
|
2018-10-02 00:29:04 -04:00
|
|
|
|
2019-08-19 21:29:11 -04:00
|
|
|
window.Logster = window.Logster || {};
|
|
|
|
window.Logster.enabled = setupData.enableJsErrorReporting === "true";
|
|
|
|
|
2018-10-02 00:29:04 -04: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-08 13:46:50 -05:00
|
|
|
|
2020-03-24 16:32:56 -04:00
|
|
|
const Session = require("discourse/models/session").default;
|
2019-11-08 13:46:50 -05:00
|
|
|
Session.currentProp(
|
2018-10-02 00:29:04 -04:00
|
|
|
"disableCustomCSS",
|
|
|
|
setupData.disableCustomCss === "true"
|
|
|
|
);
|
|
|
|
|
|
|
|
if (setupData.safeMode) {
|
2019-11-08 13:46:50 -05:00
|
|
|
Session.currentProp("safe_mode", setupData.safeMode);
|
2018-10-02 00:29:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Discourse.HighlightJSPath = setupData.highlightJsPath;
|
2018-11-26 16:49:57 -05:00
|
|
|
Discourse.SvgSpritePath = setupData.svgSpritePath;
|
|
|
|
|
|
|
|
if (Discourse.Environment === "development") {
|
|
|
|
Discourse.SvgIconList = setupData.svgIconList;
|
|
|
|
}
|
2018-10-02 00:29:04 -04:00
|
|
|
|
2018-10-02 01:02:12 -04:00
|
|
|
if (setupData.s3BaseUrl) {
|
2018-10-02 00:29:04 -04:00
|
|
|
Discourse.S3CDN = setupData.s3Cdn;
|
|
|
|
Discourse.S3BaseUrl = setupData.s3BaseUrl;
|
|
|
|
}
|
2018-10-09 01:50:45 -04:00
|
|
|
|
2020-03-11 09:43:55 -04:00
|
|
|
// eslint-disable-next-line
|
2018-10-09 01:50:45 -04: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-14 17:17:56 -05:00
|
|
|
/* eslint-disable no-console */
|
2018-10-09 01:50:45 -04: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-14 17:17:56 -05:00
|
|
|
/* eslint-enable no-console */
|
2018-10-09 01:50:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
window.onerror(e && e.message, null, null, null, e);
|
|
|
|
});
|
2018-09-17 04:31:46 -04:00
|
|
|
})();
|