Ghost/core/server/services/settings/ensure-settings.js
kirrg001 8bb7088ba0 🔥 Removed permalink setting
refs #9742

- removed usage of single permalink setting
  - with dynamic routing this configuration does no longer makes sense
  - because you can configure your permalinks in the routes.yaml
  - furthermore you can have multiple collections with multiple permalinks
- removed @blog.permalinks
- do not export permalink setting
- do not import permalink setting
- permalink setting UI will be removed soon
- get rid of {globals.permalink} completely
- remove yaml in-built migration
- do not expose settings.permalinks via the private API
- do not allow to edit this setting
- keep phyiscal value in case a blog needs to rollback from v2 to v1
- sorted out when the routers should be created
  - ensure routes.yaml file doesn't get validated before Ghost is fully ready to start
2018-08-16 12:13:24 +02:00

46 lines
1.9 KiB
JavaScript

const fs = require('fs-extra'),
Promise = require('bluebird'),
path = require('path'),
debug = require('ghost-ignition').debug('services:settings:ensure-settings'),
common = require('../../lib/common'),
config = require('../../config');
/**
* Makes sure that all supported settings files are in the
* `/content/settings` directory. If not, copy the default files
* over.
* @param {Array} knownSettings
* @returns {Promise}
* @description Reads the `/settings` folder of the content path and makes
* sure that the associated yaml file for each setting exists. If it doesn't
* copy the default yaml file over.
*/
module.exports = function ensureSettingsFiles(knownSettings) {
const contentPath = config.getContentPath('settings'),
defaultSettingsPath = config.get('paths').defaultSettings;
return Promise.each(knownSettings, function (setting) {
const fileName = `${setting}.yaml`,
defaultFileName = `default-${fileName}`,
filePath = path.join(contentPath, fileName);
return fs.readFile(filePath, 'utf8')
.catch({code: 'ENOENT'}, () => {
// CASE: file doesn't exist, copy it from our defaults
return fs.copy(
path.join(defaultSettingsPath, defaultFileName),
path.join(contentPath, fileName)
).then(() => {
debug(`'${defaultFileName}' copied to ${contentPath}.`);
});
}).catch((error) => {
// CASE: we might have a permission error, as we can't access the directory
throw new common.errors.GhostError({
message: common.i18n.t('errors.services.settings.ensureSettings', {path: contentPath}),
err: error,
context: error.path
});
});
});
};