1
0
mirror of https://github.com/flarum/core.git synced 2025-08-12 11:24:30 +02:00

Upgrade to L5 + huge refactor + more. closes #2

New stuff:
- Signup + email confirmation.
- Updated authentication strategy with remember cookies. closes #5
- New search system with some example gambits! This is cool - check out
the source. Fulltext drivers will be implemented as decorators
overriding the EloquentPostRepository’s findByContent method.
- Lay down the foundation for bootstrapping the Ember app.
- Update Web layer’s asset manager to properly publish CSS/JS files.
- Console commands to run installation migrations and seeds.

Refactoring:
- New structure: move models, repositories, commands, and events into
their own namespaces, rather than grouping by entity.
- All events are classes.
- Use L5 middleware and command bus implementations.
- Clearer use of repositories and the Active Record pattern.
Repositories are used only for retrieval of ActiveRecord objects, and
then save/delete operations are called directly on those ActiveRecords.
This way, we don’t over-abstract at the cost of Eloquent magic, but
testing is still easy.
- Refactor of Web layer so that it uses the Actions routing
architecture.
- “Actor” concept instead of depending on Laravel’s Auth.
- General cleanup!
This commit is contained in:
Toby Zerner
2015-02-24 20:33:18 +10:30
parent 0e4e44c358
commit 2c46888db5
266 changed files with 5562 additions and 4658 deletions

View File

@@ -1,17 +1,17 @@
import Ember from 'ember';
export default Ember.Controller.extend({
alerts: [],
alerts: [],
actions: {
alert: function(message) {
this.get('alerts').pushObject(message);
},
dismissAlert: function(message) {
this.get('alerts').removeObject(message);
},
clearAlerts: function() {
this.get('alerts').clear();
}
}
actions: {
alert: function(message) {
this.get('alerts').pushObject(message);
},
dismissAlert: function(message) {
this.get('alerts').removeObject(message);
},
clearAlerts: function() {
this.get('alerts').clear();
}
}
});

View File

@@ -54,6 +54,8 @@ export default Ember.Controller.extend({
}
}
// var results = Ember.RSVP.resolve(FLARUM_DATA.discussions);
return this.store.find('discussion', params).then(function(discussions) {
var results = Ember.A();
discussions.forEach(function(discussion) {

View File

@@ -4,31 +4,31 @@ import AuthenticationControllerMixin from 'simple-auth/mixins/authentication-con
import ModalController from 'flarum/mixins/modal-controller';
export default Ember.Controller.extend(ModalController, AuthenticationControllerMixin, {
authenticator: 'authenticator:flarum',
loading: false,
authenticator: 'authenticator:flarum',
loading: false,
actions: {
authenticate: function() {
actions: {
authenticate: function() {
var data = this.getProperties('identification', 'password');
var controller = this;
this.set('error', null);
this.set('loading', true);
return this._super(data).then(function() {
controller.send("sessionChanged");
controller.send("closeModal");
controller.send("sessionChanged");
controller.send("closeModal");
}, function(errors) {
switch(errors[0].code) {
case 'invalidLogin':
controller.set('error', 'Your login details are incorrect.');
break;
switch(errors[0].code) {
case 'invalidLogin':
controller.set('error', 'Your login details are incorrect.');
break;
default:
controller.set('error', 'Something went wrong. (Error code: '+errors[0].code+')');
}
controller.trigger('refocus');
default:
controller.set('error', 'Something went wrong. (Error code: '+errors[0].code+')');
}
controller.trigger('refocus');
}).finally(function() {
controller.set('loading', false);
controller.set('loading', false);
});
}
}
}
});

View File

@@ -3,6 +3,19 @@ import Ember from 'ember';
import ModalController from 'flarum/mixins/modal-controller';
export default Ember.Controller.extend(ModalController, {
emailProviderName: Ember.computed('welcomeUser.email', function() {
if (!this.get('welcomeUser.email')) { return; }
return this.get('welcomeUser.email').split('@')[1];
}),
emailProviderUrl: Ember.computed('emailProviderName', function() {
return 'http://'+this.get('emailProviderName');
}),
welcomeStyle: Ember.computed('welcomeUser.color', function() {
return 'background:'+this.get('welcomeUser.color');
}),
actions: {
submit: function() {
var data = this.getProperties('username', 'email', 'password');
@@ -12,15 +25,9 @@ export default Ember.Controller.extend(ModalController, {
var user = this.store.createRecord('user', data);
return user.save().then(function() {
controller.get('session').authenticate('authenticator:flarum', {
identification: data.email,
password: data.password
}).then(function() {
controller.send('closeModal');
controller.send('sessionChanged');
controller.set('loading', false);
});
return user.save().then(function(user) {
controller.set('welcomeUser', user);
controller.set('loading', false);
}, function(reason) {
controller.set('loading', false);
});