Ghost/core/server/api/configuration.js
Kevin Ansfield 69d5fac61e
Resurrect the old alpha Koenig editor (#9277)
requires https://github.com/TryGhost/Ghost-Admin/pull/916
- add "enableDeveloperExperiments" config flag
- allow any HTML payload through in the HTML mobiledoc card
  - same approach as taken in the markdown card, running the markup through SimpleDOM isn't necessary and is prone to breaking because of it's limited parsing and error handling abilities

To use Koenig modify your `config.development.json` file and add the following flag to the top-level object:

```
"enableDeveloperExperiments": true
```

If you restart the dev server you will then see a new section on the Labs screen with a Koenig Editor checkbox to enable/disable the editor.

⚠️ The editor is in a _very_ broken state, it's there for developer testing and on-going development. _Do not_ try to use this on any production data!
2018-01-18 15:43:22 +00:00

82 lines
2.4 KiB
JavaScript

// # Configuration API
// RESTful API for browsing the configuration
var Promise = require('bluebird'),
_ = require('lodash'),
urlService = require('../services/url'),
models = require('../models'),
config = require('../config'),
settingsCache = require('../services/settings/cache'),
ghostVersion = require('../lib/ghost-version'),
configuration;
function fetchAvailableTimezones() {
var timezones = require('../data/timezones.json');
return timezones;
}
function getAboutConfig() {
return {
version: ghostVersion.full,
environment: config.get('env'),
database: config.get('database').client,
mail: _.isObject(config.get('mail')) ? config.get('mail').transport : ''
};
}
function getBaseConfig() {
return {
useGravatar: !config.isPrivacyDisabled('useGravatar'),
publicAPI: config.get('publicAPI') === true,
blogUrl: urlService.utils.urlFor('home', true),
blogTitle: settingsCache.get('title'),
routeKeywords: config.get('routeKeywords'),
clientExtensions: config.get('clientExtensions'),
enableDeveloperExperiments: config.get('enableDeveloperExperiments')
};
}
/**
* ## Configuration API Methods
*
* We need to load the client credentials dynamically.
*
* **See:** [API Methods](constants.js.html#api%20methods)
*/
configuration = {
/**
* Always returns {configuration: []}
* Sometimes the array contains configuration items
* @param {Object} options
* @returns {Promise<Object>}
*/
read: function read(options) {
options = options || {};
if (!options.key) {
return models.Client.findOne({slug: 'ghost-admin'})
.then(function (ghostAdmin) {
var configuration = getBaseConfig();
configuration.clientId = ghostAdmin.get('slug');
configuration.clientSecret = ghostAdmin.get('secret');
return {configuration: [configuration]};
});
}
if (options.key === 'about') {
return Promise.resolve({configuration: [getAboutConfig()]});
}
// Timezone endpoint
if (options.key === 'timezones') {
return Promise.resolve({configuration: [fetchAvailableTimezones()]});
}
return Promise.resolve({configuration: []});
}
};
module.exports = configuration;