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