Ghost/ghost/admin/app/services/config.js
Kevin Ansfield 03c45a445e Removed defunct Ghost OAuth code (#848)
refs https://github.com/TryGhost/Ghost/issues/8958

- Ghost OAuth isn't coming back, time for the code to disappear and simply all the things
- fixes the `Usage of router is deprecated` notices that flood the console/test logs when testing
2017-09-04 21:17:04 +02:00

57 lines
1.7 KiB
JavaScript

import Ember from 'ember';
import Service from '@ember/service';
import {assign} from '@ember/polyfills';
import {computed} from '@ember/object';
import {inject as injectService} from '@ember/service';
// ember-cli-shims doesn't export _ProxyMixin
const {_ProxyMixin} = Ember;
export default Service.extend(_ProxyMixin, {
ajax: injectService(),
ghostPaths: injectService(),
content: {},
fetch() {
let configUrl = this.get('ghostPaths.url').api('configuration');
return this.get('ajax').request(configUrl).then((publicConfig) => {
// normalize blogUrl to non-trailing-slash
let [{blogUrl}] = publicConfig.configuration;
publicConfig.configuration[0].blogUrl = blogUrl.replace(/\/$/, '');
this.set('content', publicConfig.configuration[0]);
});
},
fetchPrivate() {
let privateConfigUrl = this.get('ghostPaths.url').api('configuration', 'private');
return this.get('ajax').request(privateConfigUrl).then((privateConfig) => {
assign(this.get('content'), privateConfig.configuration[0]);
});
},
availableTimezones: computed(function () {
let timezonesUrl = this.get('ghostPaths.url').api('configuration', 'timezones');
return this.get('ajax').request(timezonesUrl).then((configTimezones) => {
let [timezonesObj] = configTimezones.configuration;
timezonesObj = timezonesObj.timezones;
return timezonesObj;
});
}),
blogDomain: computed('blogUrl', function () {
let blogUrl = this.get('blogUrl');
let blogDomain = blogUrl
.replace(/^https?:\/\//, '')
.replace(/\/?$/, '');
return blogDomain;
})
});