2018-09-17 04:31:46 -04:00
|
|
|
(function() {
|
2018-10-02 00:29:04 -04:00
|
|
|
var ps = require("preload-store").default;
|
2018-09-17 04:31:46 -04:00
|
|
|
var preloadedDataElement = document.getElementById("data-preloaded");
|
|
|
|
|
|
|
|
if (preloadedDataElement) {
|
|
|
|
var preloaded = JSON.parse(preloadedDataElement.dataset.preloaded);
|
|
|
|
|
|
|
|
Object.keys(preloaded).forEach(function(key) {
|
|
|
|
ps.store(key, JSON.parse(preloaded[key]));
|
|
|
|
});
|
|
|
|
}
|
2018-10-02 00:29:04 -04:00
|
|
|
|
|
|
|
var setupData = document.getElementById("data-discourse-setup").dataset;
|
|
|
|
|
|
|
|
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);
|
|
|
|
Discourse.Session.currentProp(
|
|
|
|
"disableCustomCSS",
|
|
|
|
setupData.disableCustomCss === "true"
|
|
|
|
);
|
|
|
|
|
|
|
|
if (setupData.safeMode) {
|
|
|
|
Discourse.Session.currentProp("safe_mode", setupData.safeMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
})();
|