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

41 lines
1.0 KiB
JavaScript
Raw Normal View History

import Ember from 'ember';
import AuthenticatedRoute from 'ghost/routes/authenticated';
import styleBody from 'ghost/mixins/style-body';
2016-01-19 16:03:27 +03:00
const {
inject: {service}
} = Ember;
export default AuthenticatedRoute.extend(styleBody, {
titleToken: 'About',
classNames: ['view-about'],
2016-01-19 16:03:27 +03:00
ghostPaths: service(),
ajax: 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;
});
}
});