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