mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
71c358b638
No Issue - Switches to the newer style of dependency injection. - Instead of injection Controllers via "needs," use Ember.inject.controller(). - Get rid of initializers that were only injecting objects into various factories. Converts these objects into Ember.Service objects and declaratively inject them where needed via Ember.inject.service(). The added benefit to this is that it's no longer a mystery where these properties/methods come from and it's straightforward to inject them where needed.
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
import Ember from 'ember';
|
|
import {request as ajax} from 'ic-ajax';
|
|
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
|
import styleBody from 'ghost/mixins/style-body';
|
|
|
|
export default AuthenticatedRoute.extend(styleBody, {
|
|
titleToken: 'About',
|
|
|
|
classNames: ['view-about'],
|
|
|
|
ghostPaths: Ember.inject.service('ghost-paths'),
|
|
|
|
cachedConfig: false,
|
|
|
|
model: function () {
|
|
var cachedConfig = this.get('cachedConfig'),
|
|
self = this;
|
|
|
|
if (cachedConfig) {
|
|
return cachedConfig;
|
|
}
|
|
|
|
return ajax(this.get('ghostPaths.url').api('configuration'))
|
|
.then(function (configurationResponse) {
|
|
var configKeyValues = configurationResponse.configuration;
|
|
|
|
cachedConfig = {};
|
|
configKeyValues.forEach(function (configKeyValue) {
|
|
cachedConfig[configKeyValue.key] = configKeyValue.value;
|
|
});
|
|
self.set('cachedConfig', cachedConfig);
|
|
|
|
return cachedConfig;
|
|
});
|
|
}
|
|
});
|