mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
dd4fe3a68f
refs https://github.com/TryGhost/Ghost/issues/8334, requires https://github.com/TryGhost/Ghost/pull/8827 - added open graph and twitter fields to `Post` model - added facebook and twitter card pane to PSM - 💅🏼 Added preview styles for custom FB/Twitter cards
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
import Ember from 'ember';
|
|
import Service from 'ember-service';
|
|
import computed from 'ember-computed';
|
|
import injectService from 'ember-service/inject';
|
|
import {isBlank} from 'ember-utils';
|
|
|
|
// 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((config) => {
|
|
// normalize blogUrl to non-trailing-slash
|
|
let [{blogUrl}] = config.configuration;
|
|
config.configuration[0].blogUrl = blogUrl.replace(/\/$/, '');
|
|
|
|
this.set('content', config.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;
|
|
});
|
|
}),
|
|
|
|
ghostOAuth: computed('ghostAuthId', function () {
|
|
return !isBlank(this.get('ghostAuthId'));
|
|
}),
|
|
|
|
blogDomain: computed('blogUrl', function () {
|
|
let blogUrl = this.get('blogUrl');
|
|
let blogDomain = blogUrl
|
|
.replace(/^https?:\/\//, '')
|
|
.replace(/\/?$/, '');
|
|
|
|
return blogDomain;
|
|
})
|
|
});
|