1
0
mirror of https://github.com/flarum/core.git synced 2025-08-03 23:17:43 +02:00

Refactor the web app bootstrapping code

- All custom JS variables are now preloaded into the `app.data` object, rather than directly on the `app` object. This means that admin settings are available in `app.data.settings` rather than `app.settings`, etc.
- Cleaner route handler generation
- Renamed ConfigureClientView to ConfigureWebApp, though the former still exists and is deprecated
- Partial fix for #881 (strips ?nojs=1 from URL if possible, so that refreshing will attempt to load JS version again)
This commit is contained in:
Toby Zerner
2016-05-26 19:04:24 +09:30
parent 2525e3e7ad
commit 9bfb797fdc
49 changed files with 1575 additions and 1254 deletions

26
js/forum/dist/app.js vendored
View File

@@ -18418,10 +18418,12 @@ System.register('flarum/App', ['flarum/utils/ItemList', 'flarum/components/Alert
babelHelpers.createClass(App, [{
key: 'boot',
value: function boot() {
value: function boot(data) {
var _this = this;
this.translator.locale = this.locale;
this.data = data;
this.translator.locale = data.locale;
this.initializers.toArray().forEach(function (initializer) {
return initializer(_this);
@@ -18430,9 +18432,9 @@ System.register('flarum/App', ['flarum/utils/ItemList', 'flarum/components/Alert
}, {
key: 'preloadedDocument',
value: function preloadedDocument() {
if (app.preload.document) {
var results = app.store.pushPayload(app.preload.document);
app.preload.document = null;
if (this.data.document) {
var results = this.store.pushPayload(this.data.document);
this.data.document = null;
return results;
}
@@ -22305,14 +22307,14 @@ System.register('flarum/components/HeaderSecondary', ['flarum/Component', 'flaru
items.add('search', app.search.render(), 30);
if (Object.keys(app.locales).length > 1) {
if (Object.keys(app.data.locales).length > 1) {
var locales = [];
var _loop = function _loop(locale) {
locales.push(Button.component({
active: app.locale === locale,
children: app.locales[locale],
icon: app.locale === locale ? 'check' : true,
active: app.data.locale === locale,
children: app.data.locales[locale],
icon: app.data.locale === locale ? 'check' : true,
onclick: function onclick() {
if (app.session.user) {
app.session.user.savePreferences({ locale: locale }).then(function () {
@@ -22326,7 +22328,7 @@ System.register('flarum/components/HeaderSecondary', ['flarum/Component', 'flaru
}));
};
for (var locale in app.locales) {
for (var locale in app.data.locales) {
_loop(locale);
}
@@ -28664,11 +28666,11 @@ System.register('flarum/initializers/humanTime', ['flarum/utils/humanTime'], fun
System.register('flarum/initializers/preload', ['flarum/Session'], function (_export, _context) {
var Session;
function preload(app) {
app.store.pushPayload({ data: app.preload.data });
app.store.pushPayload({ data: app.data.resources });
app.forum = app.store.getById('forums', 1);
app.session = new Session(app.store.getById('users', app.preload.session.userId), app.preload.session.csrfToken);
app.session = new Session(app.store.getById('users', app.data.session.userId), app.data.session.csrfToken);
}
_export('default', preload);