1
0
mirror of https://github.com/flarum/core.git synced 2025-07-29 20:50:28 +02:00

Initial refactor of client actions, data preloading, SEO

An initial stab at flarum/core#126. Still WIP. Preliminary
implementation of flarum/core#128 and flarum/core#13.
This commit is contained in:
Toby Zerner
2015-07-07 15:29:21 +09:30
parent fcc5aa17ea
commit 99876e9e36
27 changed files with 413 additions and 241 deletions

View File

@@ -70,7 +70,7 @@ export default class AvatarEditor extends Component {
m.redraw();
m.request({
method: 'POST',
url: app.config['api_url']+'/users/'+user.id()+'/avatar',
url: app.forum.attribute('apiUrl')+'/users/'+user.id()+'/avatar',
data: data,
serialize: data => data,
background: true,
@@ -91,7 +91,7 @@ export default class AvatarEditor extends Component {
m.redraw();
m.request({
method: 'DELETE',
url: app.config['api_url']+'/users/'+user.id()+'/avatar',
url: app.forum.attribute('apiUrl')+'/users/'+user.id()+'/avatar',
config: app.session.authorize.bind(app.session)
}).then(function(data) {
self.loading(false);

View File

@@ -20,7 +20,7 @@ export default class ChangePasswordModal extends FormModal {
m.request({
method: 'POST',
url: app.config['api_url']+'/forgot',
url: app.forum.attribute('apiUrl')+'/forgot',
data: {email: app.session.user().email()},
background: true
}).then(response => {

View File

@@ -64,9 +64,9 @@ export default class DiscussionList extends Component {
}
loadResults(offset) {
if (app.preload.response) {
var discussions = app.store.pushPayload(app.preload.response);
app.preload.response = null;
const discussions = app.preloadedDocument();
if (discussions) {
return m.deferred().resolve(discussions).promise;
} else {
var params = this.params();

View File

@@ -43,17 +43,13 @@ export default class DiscussionPage extends mixin(Component, evented) {
var params = this.params();
params.include = params.include.join(',');
var discussion;
if (app.preload.response) {
const discussion = app.preloadedDocument();
if (discussion) {
// We must wrap this in a setTimeout because if we are mounting this
// component for the first time on page load, then any calls to m.redraw
// will be ineffective and thus any configs (scroll code) will be run
// before stuff is drawn to the page.
setTimeout(() => {
var discussion = app.store.pushPayload(app.preload.response);
app.preload.response = null;
this.setupDiscussion(discussion);
});
setTimeout(this.setupDiscussion.bind(this, discussion));
} else {
app.store.find('discussions', m.route.param('id'), params).then(this.setupDiscussion.bind(this));
}

View File

@@ -44,7 +44,7 @@ export default class ForgotPasswordModal extends FormModal {
m.request({
method: 'POST',
url: app.config['api_url']+'/forgot',
url: app.forum.attribute('apiUrl')+'/forgot',
data: {email: this.email()},
background: true,
extract: xhr => {

View File

@@ -61,7 +61,7 @@ export default class NotificationList extends Component {
badges && badges.length ? m('ul.badges', listItems(badges)) : '',
group.discussion.title()
)
: m('div.notification-group-header', app.config['forum_title']),
: m('div.notification-group-header', app.forum.attribute('title')),
m('ul.notification-group-list', group.notifications.map(notification => {
var NotificationComponent = app.notificationComponentRegistry[notification.contentType()];
return NotificationComponent ? m('li', NotificationComponent.component({notification})) : '';

View File

@@ -45,7 +45,7 @@ export default class UserDropdown extends Component {
ActionButton.component({
icon: 'wrench',
label: 'Administration',
href: app.config['base_url']+'/admin'
href: app.forum.attribute('baseUrl')+'/admin'
})
);
}

View File

@@ -17,8 +17,8 @@ export default class WelcomeHero extends Component {
m('div.container', [
m('button.close.btn.btn-icon.btn-link', {onclick: () => this.$().slideUp(this.hide.bind(this))}, m('i.fa.fa-times')),
m('div.container-narrow', [
m('h2', app.config['welcome_title']),
m('div.subtitle', m.trust(app.config['welcome_message']))
m('h2', app.forum.attribute('welcomeTitle')),
m('div.subtitle', m.trust(app.forum.attribute('welcomeMessage')))
])
])
])