mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 19:02:29 +03:00
6a97873f98
refs #6982 - create config util fn: getContentPath - we can later let the user change the folder names in contentPath - get rid of custom/default storage paths [ci skip]
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
var path = require('path'),
|
|
_ = require('lodash');
|
|
|
|
exports.isPrivacyDisabled = function isPrivacyDisabled(privacyFlag) {
|
|
if (!this.get('privacy')) {
|
|
return false;
|
|
}
|
|
|
|
if (this.get('privacy').useTinfoil === true) {
|
|
return true;
|
|
}
|
|
|
|
return this.get('privacy')[privacyFlag] === false;
|
|
};
|
|
|
|
/**
|
|
* transform all relative paths to absolute paths
|
|
* @TODO: imagesRelPath is a dirty little attribute (especially when looking at the usages)
|
|
*/
|
|
exports.makePathsAbsolute = function makePathsAbsolute(paths, parent) {
|
|
var self = this;
|
|
|
|
if (!paths && !parent) {
|
|
paths = this.get('paths');
|
|
parent = 'paths';
|
|
}
|
|
|
|
_.each(paths, function (configValue, pathsKey) {
|
|
if (_.isObject(configValue)) {
|
|
makePathsAbsolute.bind(self)(configValue, parent + ':' + pathsKey);
|
|
} else {
|
|
if (configValue[0] !== '/' && pathsKey !== 'imagesRelPath') {
|
|
self.set(parent + ':' + pathsKey, path.join(__dirname + '/../../../', configValue));
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* we can later support setting folder names via custom config values
|
|
*/
|
|
exports.getContentPath = function getContentPath(type) {
|
|
switch (type) {
|
|
case 'storage':
|
|
return path.join(this.get('paths:contentPath'), 'storage/');
|
|
case 'images':
|
|
return path.join(this.get('paths:contentPath'), 'images/');
|
|
case 'apps':
|
|
return path.join(this.get('paths:contentPath'), 'apps/');
|
|
case 'themes':
|
|
return path.join(this.get('paths:contentPath'), 'themes/');
|
|
case 'scheduling':
|
|
return path.join(this.get('paths:contentPath'), 'scheduling/');
|
|
default:
|
|
throw new Error('getContentPath was called with: ' + type);
|
|
}
|
|
};
|