Ghost/core/client/app/routes/about.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

import Ember from 'ember';
import AuthenticatedRoute from 'ghost/routes/authenticated';
import styleBody from 'ghost/mixins/style-body';
const {inject} = Ember;
export default AuthenticatedRoute.extend(styleBody, {
titleToken: 'About',
classNames: ['view-about'],
ghostPaths: inject.service('ghost-paths'),
2016-01-18 18:37:14 +03:00
ajax: inject.service(),
cachedConfig: false,
model() {
let cachedConfig = this.get('cachedConfig');
2016-01-18 18:37:14 +03:00
let configUrl = this.get('ghostPaths.url').api('configuration');
if (cachedConfig) {
return cachedConfig;
}
2016-01-18 18:37:14 +03:00
return this.get('ajax').request(configUrl)
.then((configurationResponse) => {
let configKeyValues = configurationResponse.configuration;
cachedConfig = {};
configKeyValues.forEach((configKeyValue) => {
cachedConfig[configKeyValue.key] = configKeyValue.value;
});
this.set('cachedConfig', cachedConfig);
return cachedConfig;
});
}
});