0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-18 02:21:47 -05:00

🎨 change how we get and set config

refs #6982
- a replace for all config usages
- always use config.get or config.set
- this a pure replacement, no logic has changed

[ci skip]
This commit is contained in:
kirrg001 2016-09-13 17:41:14 +02:00 committed by Hannah Wolfe
parent 4aaacff62c
commit 0ae0a0b490
77 changed files with 315 additions and 317 deletions

View file

@ -168,7 +168,7 @@ authentication = {
}
function sendResetNotification(data) {
var baseUrl = config.forceAdminSSL ? (config.urlSSL || config.url) : config.url,
var baseUrl = config.get('forceAdminSSL') ? (config.get('urlSSL') || config.get('url')) : config.get('url'),
resetUrl = baseUrl.replace(/\/$/, '') +
'/ghost/reset/' +
globalUtils.encodeBase64URLsafe(data.resetToken) + '/';

View file

@ -20,10 +20,10 @@ function fetchAvailableTimezones() {
function getAboutConfig() {
return {
version: config.ghostVersion,
version: config.get('ghostVersion'),
environment: process.env.NODE_ENV,
database: config.database.client,
mail: _.isObject(config.mail) ? config.mail.transport : ''
database: config.get('database').client,
mail: _.isObject(config.get('mail')) ? config.get('mail').transport : ''
};
}
@ -33,9 +33,9 @@ function getBaseConfig() {
useGravatar: {value: !config.isPrivacyDisabled('useGravatar'), type: 'bool'},
publicAPI: labsFlag('publicAPI'),
internalTags: labsFlag('internalTags'),
blogUrl: {value: config.url.replace(/\/$/, ''), type: 'string'},
blogTitle: {value: config.theme.title, type: 'string'},
routeKeywords: {value: JSON.stringify(config.routeKeywords), type: 'json'}
blogUrl: {value: config.get('url').replace(/\/$/, ''), type: 'string'},
blogTitle: {value: config.get('theme').title, type: 'string'},
routeKeywords: {value: JSON.stringify(config.get('routeKeywords')), type: 'json'}
};
}

View file

@ -100,7 +100,7 @@ cacheInvalidationHeader = function cacheInvalidationHeader(req, result) {
if (hasStatusChanged || wasPublishedUpdated) {
return INVALIDATE_ALL;
} else {
return config.urlFor({relativeUrl: '/' + config.routeKeywords.preview + '/' + post.uuid + '/'});
return utils.url.urlFor({relativeUrl: '/' + config.get('routeKeywords').preview + '/' + post.uuid + '/'});
}
}
}

View file

@ -2,11 +2,11 @@ var _ = require('lodash'),
Promise = require('bluebird'),
moment = require('moment'),
config = require('../config'),
pipeline = require(config.paths.corePath + '/server/utils/pipeline'),
dataProvider = require(config.paths.corePath + '/server/models'),
i18n = require(config.paths.corePath + '/server/i18n'),
errors = require(config.paths.corePath + '/server/errors'),
apiPosts = require(config.paths.corePath + '/server/api/posts'),
pipeline = require(config.get('paths').corePath + '/server/utils/pipeline'),
dataProvider = require(config.get('paths').corePath + '/server/models'),
i18n = require(config.get('paths').corePath + '/server/i18n'),
errors = require(config.get('paths').corePath + '/server/errors'),
apiPosts = require(config.get('paths').corePath + '/server/api/posts'),
utils = require('./utils');
/**
@ -21,7 +21,7 @@ exports.publishPost = function publishPost(object, options) {
}
var post, publishedAtMoment,
publishAPostBySchedulerToleranceInMinutes = config.times.publishAPostBySchedulerToleranceInMinutes;
publishAPostBySchedulerToleranceInMinutes = config.get('times').publishAPostBySchedulerToleranceInMinutes;
// CASE: only the scheduler client is allowed to publish (hardcoded because of missing client permission system)
if (!options.context || !options.context.client || options.context.client !== 'ghost-scheduler') {

View file

@ -50,20 +50,20 @@ updateConfigCache = function () {
}
}
config.set({
theme: {
title: (settingsCache.title && settingsCache.title.value) || '',
description: (settingsCache.description && settingsCache.description.value) || '',
logo: (settingsCache.logo && settingsCache.logo.value) || '',
cover: (settingsCache.cover && settingsCache.cover.value) || '',
navigation: (settingsCache.navigation && JSON.parse(settingsCache.navigation.value)) || [],
postsPerPage: (settingsCache.postsPerPage && settingsCache.postsPerPage.value) || 5,
permalinks: (settingsCache.permalinks && settingsCache.permalinks.value) || '/:slug/',
twitter: (settingsCache.twitter && settingsCache.twitter.value) || '',
facebook: (settingsCache.facebook && settingsCache.facebook.value) || '',
timezone: (settingsCache.activeTimezone && settingsCache.activeTimezone.value) || config.theme.timezone
},
labs: labsValue
config.set('theme:title', (settingsCache.title && settingsCache.title.value) || '');
config.set('theme:description', (settingsCache.description && settingsCache.description.value) || '');
config.set('theme:logo', (settingsCache.logo && settingsCache.logo.value) || '');
config.set('theme:cover', (settingsCache.cover && settingsCache.cover.value) || '');
config.set('theme:navigation', (settingsCache.navigation && JSON.parse(settingsCache.navigation.value)) || []);
config.set('theme:postsPerPage', (settingsCache.postsPerPage && settingsCache.postsPerPage.value) || config.get('theme').postsPerPage);
config.set('theme:permalinks', (settingsCache.permalinks && settingsCache.permalinks.value) || config.get('theme').permalinks);
config.set('theme:twitter', (settingsCache.twitter && settingsCache.twitter.value) || '');
config.set('theme:facebook', (settingsCache.facebook && settingsCache.facebook.value) || '');
config.set('theme:timezone', (settingsCache.activeTimezone && settingsCache.activeTimezone.value) || config.get('theme').timezone);
config.set('theme:url', config.get('url') ? config.get('url').replace(/\/$/, '') : '');
_.each(labsValue, function (value, key) {
config.set('labs:' + key, value);
});
};
@ -177,8 +177,8 @@ readSettingsResult = function (settingsModels) {
return memo;
}, {}),
themes = config.paths.availableThemes,
apps = config.paths.availableApps,
themes = config.get('paths').availableThemes,
apps = config.get('paths').availableApps,
res;
if (settings.activeTheme && themes) {

View file

@ -21,9 +21,9 @@ var Promise = require('bluebird'),
*/
themes = {
loadThemes: function () {
return utils.readThemes(config.paths.themePath)
return utils.readThemes(config.get('paths').themePath)
.then(function (result) {
config.paths.availableThemes = result;
config.set('paths:availableThemes', result);
});
},
@ -63,12 +63,12 @@ themes = {
);
})
.then(function () {
return storageAdapter.exists(config.paths.themePath + '/' + zip.shortName);
return storageAdapter.exists(config.get('paths').themePath + '/' + zip.shortName);
})
.then(function (themeExists) {
// delete existing theme
if (themeExists) {
return storageAdapter.delete(zip.shortName, config.paths.themePath);
return storageAdapter.delete(zip.shortName, config.get('paths').themePath);
}
})
.then(function () {
@ -77,7 +77,7 @@ themes = {
return storageAdapter.save({
name: zip.shortName,
path: theme.path
}, config.paths.themePath);
}, config.get('paths').themePath);
})
.then(function () {
// force reload of availableThemes
@ -119,7 +119,7 @@ themes = {
download: function download(options) {
var themeName = options.name,
theme = config.paths.availableThemes[themeName],
theme = config.get('paths').availableThemes[themeName],
storageAdapter = storage.getStorage('themes');
if (!theme) {
@ -148,14 +148,14 @@ themes = {
throw new errors.ValidationError(i18n.t('errors.api.themes.destroyCasper'));
}
theme = config.paths.availableThemes[name];
theme = config.get('paths').availableThemes[name];
if (!theme) {
throw new errors.NotFoundError(i18n.t('errors.api.themes.themeDoesNotExist'));
}
events.emit('theme.deleted', name);
return storageAdapter.delete(name, config.paths.themePath);
return storageAdapter.delete(name, config.get('paths').themePath);
})
.then(function () {
return themes.loadThemes();

View file

@ -41,7 +41,7 @@ sendInviteEmail = function sendInviteEmail(user) {
return dataProvider.User.generateResetToken(user.email, expires, dbHash);
}).then(function (resetToken) {
var baseUrl = config.forceAdminSSL ? (config.urlSSL || config.url) : config.url;
var baseUrl = config.get('forceAdminSSL') ? (config.get('urlSSL') || config.get('url')) : config.get('url');
emailData.resetLink = baseUrl.replace(/\/$/, '') + '/ghost/signup/' + globalUtils.encodeBase64URLsafe(resetToken) + '/';

View file

@ -10,6 +10,6 @@ module.exports = {
},
setupRoutes: function setupRoutes(blogRouter) {
blogRouter.use('*/' + config.routeKeywords.amp + '/', router);
blogRouter.use('*/' + config.get('routeKeywords').amp + '/', router);
}
};

View file

@ -119,7 +119,7 @@ function getAmperizeHTML(html, post) {
}
// make relative URLs abolute
html = makeAbsoluteUrl(html, config.url, post.url).html();
html = makeAbsoluteUrl(html, config.get('url'), post.url).html();
if (!amperizeCache[post.id] || moment(new Date(amperizeCache[post.id].updated_at)).diff(new Date(post.updated_at)) < 0) {
return new Promise(function (resolve) {

View file

@ -40,7 +40,7 @@ describe('AMP Controller', function () {
body: {}
};
defaultPath = path.join(configUtils.config.paths.appRoot, '/core/server/apps/amp/lib/views/amp.hbs');
defaultPath = path.join(configUtils.config.get('paths').appRoot, '/core/server/apps/amp/lib/views/amp.hbs');
configUtils.set({
theme: {

View file

@ -21,13 +21,13 @@ function getInstalledApps() {
return Promise.reject(e);
}
return installed.concat(config.internalApps);
return installed.concat(config.get('internalApps'));
});
}
function saveInstalledApps(installedApps) {
return getInstalledApps().then(function (currentInstalledApps) {
var updatedAppsInstalled = _.difference(_.uniq(installedApps.concat(currentInstalledApps)), config.internalApps);
var updatedAppsInstalled = _.difference(_.uniq(installedApps.concat(currentInstalledApps)), config.get('internalApps'));
return api.settings.edit({settings: [{key: 'installedApps', value: updatedAppsInstalled}]}, {context: {internal: true}});
});
@ -44,7 +44,7 @@ module.exports = {
appsToLoad = JSON.parse(aApps.value) || [];
appsToLoad = appsToLoad.concat(config.internalApps);
appsToLoad = appsToLoad.concat(config.get('internalApps'));
});
} catch (e) {
errors.logError(

View file

@ -11,16 +11,16 @@ var path = require('path'),
loader;
function isInternalApp(name) {
return _.includes(config.internalApps, name);
return _.includes(config.get('internalApps'), name);
}
// Get the full path to an app by name
function getAppAbsolutePath(name) {
if (isInternalApp(name)) {
return path.join(config.paths.internalAppPath, name);
return path.join(config.get('paths').internalAppPath, name);
}
return path.join(config.paths.appPath, name);
return path.join(config.get('paths').appPath, name);
}
// Get a relative path to the given apps root, defaults

View file

@ -10,7 +10,7 @@ module.exports = {
if (utils.url.getSubdir()) {
var paths = utils.url.getSubdir().split('/');
if (paths.pop() === config.routeKeywords.private) {
if (paths.pop() === config.get('routeKeywords').private) {
errors.logErrorAndExit(
new Error(i18n.t('errors.config.urlCannotContainPrivateSubdir.error')),
i18n.t('errors.config.urlCannotContainPrivateSubdir.description'),
@ -26,6 +26,6 @@ module.exports = {
},
setupRoutes: function setupRoutes(blogRouter) {
blogRouter.use('/' + config.routeKeywords.private + '/', router);
blogRouter.use('/' + config.get('routeKeywords').private + '/', router);
}
};

View file

@ -9,7 +9,7 @@ var _ = require('lodash'),
session = require('cookie-session'),
utils = require('../../../utils'),
i18n = require('../../../i18n'),
privateRoute = '/' + config.routeKeywords.private + '/',
privateRoute = '/' + config.get('routeKeywords').private + '/',
protectedSecurity = [],
privateBlogging;

View file

@ -30,7 +30,7 @@ describe('Private Controller', function () {
params: {}
};
defaultPath = path.join(configUtils.config.paths.appRoot, '/core/server/apps/private-blogging/lib/views/private.hbs');
defaultPath = path.join(configUtils.config.get('paths').appRoot, '/core/server/apps/private-blogging/lib/views/private.hbs');
configUtils.set({
theme: {

View file

@ -39,7 +39,7 @@ function makeHidden(name, extras) {
function subscribeFormHelper(options) {
var root = options.data.root,
data = _.merge({}, options.hash, _.pick(root, params), {
action: path.join('/', globalUtils.url.getSubdir(), config.routeKeywords.subscribe, '/'),
action: path.join('/', globalUtils.url.getSubdir(), config.get('routeKeywords').subscribe, '/'),
script: new hbs.handlebars.SafeString(subscribeScript),
hidden: new hbs.handlebars.SafeString(
makeHidden('confirm') +
@ -71,7 +71,7 @@ module.exports = {
},
setupRoutes: function setupRoutes(blogRouter) {
blogRouter.use('/' + config.routeKeywords.subscribe + '/', function labsEnabledRouter(req, res, next) {
blogRouter.use('/' + config.get('routeKeywords').subscribe + '/', function labsEnabledRouter(req, res, next) {
if (labs.isSet('subscribers') === true) {
return router.apply(this, arguments);
}

View file

@ -48,7 +48,7 @@
},
"themes": {
"extensions": [".zip"],
"contentTypes": ["application/zip", "application/x-zip-compressed"]
"contentTypes": ["application/zip", "application/x-zip-compressed", "application/octet-stream"]
}
},
"storage": {

View file

@ -11,7 +11,7 @@ channelConfig = function channelConfig() {
},
tag: {
name: 'tag',
route: '/' + config.routeKeywords.tag + '/:slug/',
route: '/' + config.get('routeKeywords').tag + '/:slug/',
postOptions: {
filter: 'tags:\'%s\''
},
@ -27,7 +27,7 @@ channelConfig = function channelConfig() {
},
author: {
name: 'author',
route: '/' + config.routeKeywords.author + '/:slug/',
route: '/' + config.get('routeKeywords').author + '/:slug/',
postOptions: {
filter: 'author:\'%s\''
},

View file

@ -12,7 +12,7 @@ var express = require('express'),
channelRouter;
function handlePageParam(req, res, next, page) {
var pageRegex = new RegExp('/' + config.routeKeywords.page + '/(.*)?/'),
var pageRegex = new RegExp('/' + config.get('routeKeywords').page + '/(.*)?/'),
rssRegex = new RegExp('/rss/(.*)?/');
page = parseInt(page, 10);
@ -50,8 +50,8 @@ rssRouter = function rssRouter(channelConfig) {
router.get('/feed/', function redirectToRSS(req, res) {
return utils.redirect301(res, utils.url.getSubdir() + req.baseUrl + baseRoute);
});
router.param('page', handlePageParam);
router.param('page', handlePageParam);
return router;
};
@ -65,7 +65,7 @@ channelRouter = function router() {
var channelsRouter = express.Router({mergeParams: true}),
baseRoute = '/',
pageRoute = '/' + config.routeKeywords.page + '/:page/';
pageRoute = '/' + config.get('routeKeywords').page + '/:page/';
_.each(channelConfig.list(), function (channel) {
var channelRouter = express.Router({mergeParams: true}),

View file

@ -14,9 +14,9 @@
var config = require('../../config'),
// Context patterns, should eventually come from Channel configuration
privatePattern = new RegExp('^\\/' + config.routeKeywords.private + '\\/'),
subscribePattern = new RegExp('^\\/' + config.routeKeywords.subscribe + '\\/'),
ampPattern = new RegExp('\\/' + config.routeKeywords.amp + '\\/$'),
privatePattern = new RegExp('^\\/' + config.get('routeKeywords').private + '\\/'),
subscribePattern = new RegExp('^\\/' + config.get('routeKeywords').subscribe + '\\/'),
ampPattern = new RegExp('\\/' + config.get('routeKeywords').amp + '\\/$'),
rssPattern = new RegExp('^\\/rss\\/'),
homePattern = new RegExp('^\\/$');

View file

@ -33,7 +33,7 @@ _.extend(defaultPostQuery, queryDefaults, {
function fetchPostsPerPage(options) {
options = options || {};
var postsPerPage = parseInt(config.theme.postsPerPage);
var postsPerPage = parseInt(config.get('theme').postsPerPage);
// No negative posts per page, must be number
if (!isNaN(postsPerPage) && postsPerPage > 0) {

View file

@ -13,7 +13,7 @@ function getOptionsFormat(linkStructure) {
function postLookup(postUrl) {
var postPath = url.parse(postUrl).path,
postPermalink = config.theme.permalinks,
postPermalink = config.get('theme').permalinks,
pagePermalink = '/:slug/',
isEditURL = false,
isAmpURL = false,

View file

@ -6,7 +6,7 @@ var _ = require('lodash'),
config = require('../../config');
function getActiveThemePaths(activeTheme) {
return config.paths.availableThemes[activeTheme];
return config.get('paths').availableThemes[activeTheme];
}
/**

View file

@ -50,8 +50,8 @@ function configure(dbConfig) {
return dbConfig;
}
if (!knexInstance && config.database && config.database.client) {
knexInstance = knex(configure(config.database));
if (!knexInstance && config.get('database') && config.get('database').client) {
knexInstance = knex(configure(config.get('database')));
}
module.exports = knexInstance;

View file

@ -9,14 +9,14 @@ var _ = require('lodash'),
ImageHandler = {
type: 'images',
extensions: config.uploads.images.extensions,
contentTypes: config.uploads.images.contentTypes,
extensions: config.get('uploads').images.extensions,
contentTypes: config.get('uploads').images.contentTypes,
directories: ['images', 'content'],
loadFile: function (files, baseDir) {
var store = storage.getStorage(),
baseDirRegex = baseDir ? new RegExp('^' + baseDir + '/') : new RegExp(''),
imageFolderRegexes = _.map(config.paths.imagesRelPath.split('/'), function (dir) {
imageFolderRegexes = _.map(config.get('paths').imagesRelPath.split('/'), function (dir) {
return new RegExp('^' + dir + '/');
});
@ -31,15 +31,16 @@ ImageHandler = {
file.originalPath = noBaseDir;
file.name = noGhostDirs;
file.targetDir = path.join(config.paths.imagesPath, path.dirname(noGhostDirs));
file.targetDir = path.join(config.get('paths').imagesPath, path.dirname(noGhostDirs));
return file;
});
return Promise.map(files, function (image) {
return store.getUniqueFileName(store, image, image.targetDir).then(function (targetFilename) {
image.newPath = (utils.url.getSubdir() + '/' +
config.paths.imagesRelPath + '/' + path.relative(config.paths.imagesPath, targetFilename))
config.get('paths').imagesRelPath + '/' + path.relative(config.get('paths').imagesPath, targetFilename))
.replace(new RegExp('\\' + path.sep, 'g'), '/');
return image;
});
});

View file

@ -25,7 +25,7 @@ function getAssetUrl(path, isAdmin, minify) {
output += path;
if (!path.match(/^favicon\.ico$/)) {
output = output + '?v=' + config.assetHash;
output = output + '?v=' + config.get('assetHash');
}
return output;

View file

@ -2,7 +2,7 @@ var config = require('../../config'),
_ = require('lodash');
function getContextObject(data, context) {
var blog = config.theme,
var blog = config.get('theme'),
contextObject;
context = _.includes(context, 'page') || _.includes(context, 'amp') ? 'post' : context;

View file

@ -10,7 +10,7 @@ function getDescription(data, root) {
} else if (_.includes(context, 'paged')) {
description = '';
} else if (_.includes(context, 'home')) {
description = config.theme.description;
description = config.get('theme').description;
} else if (_.includes(context, 'author') && data.author) {
description = data.author.meta_description || data.author.bio;
} else if (_.includes(context, 'tag') && data.tag) {

View file

@ -46,12 +46,12 @@ function getMetaData(data, root) {
publishedDate: getPublishedDate(data),
modifiedDate: getModifiedDate(data),
ogType: getOgType(data),
blog: _.cloneDeep(config.theme)
blog: _.cloneDeep(config.get('theme'))
};
metaData.blog.logo = {};
metaData.blog.logo.url = config.theme.logo ?
utils.url.urlFor('image', {image: config.theme.logo}, true) : utils.url.urlFor({relativeUrl: '/ghost/img/ghosticon.jpg'}, {}, true);
metaData.blog.logo.url = config.get('theme').logo ?
utils.url.urlFor('image', {image: config.get('theme').logo}, true) : utils.url.urlFor({relativeUrl: '/ghost/img/ghosticon.jpg'}, {}, true);
// TODO: cleanup these if statements
if (data.post && data.post.html) {

View file

@ -8,9 +8,9 @@ function getPaginatedUrl(page, data, absolute) {
return null;
}
var pagePath = '/' + config.routeKeywords.page + '/',
var pagePath = '/' + config.get('routeKeywords').page + '/',
// Try to match the base url, as whatever precedes the pagePath
baseUrlPattern = new RegExp('(.+)?(/' + config.routeKeywords.page + '/\\d+/)'),
baseUrlPattern = new RegExp('(.+)?(/' + config.get('routeKeywords').page + '/\\d+/)'),
baseUrlMatch = data.relativeUrl.match(baseUrlPattern),
// If there is no match for pagePath, use the original url, without the trailing slash
baseUrl = baseUrlMatch ? baseUrlMatch[1] : data.relativeUrl.slice(0, -1),

View file

@ -4,7 +4,7 @@ var _ = require('lodash'),
function getTitle(data, root) {
var title = '',
context = root ? root.context : null,
blog = config.theme,
blog = config.get('theme'),
pagination = root ? root.pagination : null,
pageString = '';

View file

@ -11,7 +11,7 @@ var _ = require('lodash'),
backup;
writeExportFile = function writeExportFile(exportResult) {
var filename = path.resolve(config.paths.contentPath + '/data/' + exportResult.filename);
var filename = path.resolve(config.get('paths').contentPath + '/data/' + exportResult.filename);
return Promise.promisify(fs.writeFile)(filename, JSON.stringify(exportResult.data)).return(filename);
};

View file

@ -41,7 +41,7 @@ module.exports = function moveJQuery(options, logger) {
}
})
.then(function () {
if (_.isEmpty(config.privacy)) {
if (_.isEmpty(config.get('privacy'))) {
return Promise.resolve();
}

View file

@ -1,7 +1,7 @@
var config = require('../../../../config'),
models = require(config.paths.corePath + '/server/models'),
api = require(config.paths.corePath + '/server/api'),
sequence = require(config.paths.corePath + '/server/utils/sequence'),
models = require(config.get('paths').corePath + '/server/models'),
api = require(config.get('paths').corePath + '/server/api'),
sequence = require(config.get('paths').corePath + '/server/utils/sequence'),
moment = require('moment'),
_ = require('lodash'),
Promise = require('bluebird'),
@ -43,11 +43,11 @@ module.exports = function transformDatesIntoUTC(options, logger) {
return Promise.reject(new Error('skip'));
}
if (config.database.isPostgreSQL()) {
if (config.get('database').isPostgreSQL()) {
_private.noOffset = true;
} else if (config.database.client === 'mysql') {
} else if (config.get('database').client === 'mysql') {
_private.noOffset = false;
} else if (config.database.client === 'sqlite3') {
} else if (config.get('database').client === 'sqlite3') {
_private.noOffset = true;
}
@ -187,7 +187,7 @@ module.exports = function transformDatesIntoUTC(options, logger) {
});
},
function setActiveTimezone() {
var timezone = config.forceTimezoneOnMigration || moment.tz.guess();
var timezone = config.get('forceTimezoneOnMigration') || moment.tz.guess();
return models.Settings.edit({
key: 'activeTimezone',
value: timezone

View file

@ -133,15 +133,15 @@ validateSettings = function validateSettings(defaultSettings, model) {
validateActiveTheme = function validateActiveTheme(themeName) {
// If Ghost is running and its availableThemes collection exists
// give it priority.
if (config.paths.availableThemes && Object.keys(config.paths.availableThemes).length > 0) {
availableThemes = Promise.resolve(config.paths.availableThemes);
if (config.get('paths').availableThemes && Object.keys(config.get('paths').availableThemes).length > 0) {
availableThemes = Promise.resolve(config.get('paths').availableThemes);
}
if (!availableThemes) {
// A Promise that will resolve to an object with a property for each installed theme.
// This is necessary because certain configuration data is only available while Ghost
// is running and at times the validations are used when it's not (e.g. tests)
availableThemes = readThemes(config.paths.themePath);
availableThemes = readThemes(config.get('paths').themePath);
}
return availableThemes.then(function then(themes) {

View file

@ -18,11 +18,11 @@ var crypto = require('crypto'),
feedCache = {};
function isTag(req) {
return req.originalUrl.indexOf('/' + config.routeKeywords.tag + '/') !== -1;
return req.originalUrl.indexOf('/' + config.get('routeKeywords').tag + '/') !== -1;
}
function isAuthor(req) {
return req.originalUrl.indexOf('/' + config.routeKeywords.author + '/') !== -1;
return req.originalUrl.indexOf('/' + config.get('routeKeywords').author + '/') !== -1;
}
function handleError(next) {
@ -41,8 +41,8 @@ function getData(channelOpts, slugParam) {
if (result.data && result.data.tag) { titleStart = result.data.tag[0].name + ' - ' || ''; }
if (result.data && result.data.author) { titleStart = result.data.author[0].name + ' - ' || ''; }
response.title = titleStart + config.theme.title;
response.description = config.theme.description;
response.title = titleStart + config.get('theme').title;
response.description = config.get('theme').description;
response.results = {
posts: result.posts,
meta: result.meta
@ -56,9 +56,9 @@ function getBaseUrl(req, slugParam) {
var baseUrl = utils.url.getSubdir();
if (isTag(req)) {
baseUrl += '/' + config.routeKeywords.tag + '/' + slugParam + '/rss/';
baseUrl += '/' + config.get('routeKeywords').tag + '/' + slugParam + '/rss/';
} else if (isAuthor(req)) {
baseUrl += '/' + config.routeKeywords.author + '/' + slugParam + '/rss/';
baseUrl += '/' + config.get('routeKeywords').author + '/' + slugParam + '/rss/';
} else {
baseUrl += '/rss/';
}

View file

@ -69,7 +69,7 @@ function getStatusCode(error) {
*/
errors = {
updateActiveTheme: function (activeTheme) {
userErrorTemplateExists = getConfigModule().paths.availableThemes[activeTheme].hasOwnProperty('error.hbs');
userErrorTemplateExists = getConfigModule().get('paths').availableThemes[activeTheme].hasOwnProperty('error.hbs');
},
throwError: function (err) {
@ -295,7 +295,7 @@ errors = {
renderErrorPage: function (statusCode, err, req, res, next) {
/*jshint unused:false*/
var self = this,
defaultErrorTemplatePath = path.resolve(getConfigModule().paths.adminViews, 'user-error.hbs');
defaultErrorTemplatePath = path.resolve(getConfigModule().get('paths').adminViews, 'user-error.hbs');
function parseStack(stack) {
if (!_.isString(stack)) {

View file

@ -53,8 +53,8 @@ GhostServer.prototype.start = function (externalApp) {
fs.chmod(socketConfig.path, socketConfig.permissions);
} else {
self.httpServer = rootApp.listen(
config.server.port,
config.server.host
config.get('server').port,
config.get('server').host
);
}
@ -62,7 +62,7 @@ GhostServer.prototype.start = function (externalApp) {
if (error.errno === 'EADDRINUSE') {
errors.logError(
i18n.t('errors.httpServer.addressInUse.error'),
i18n.t('errors.httpServer.addressInUse.context', {port: config.server.port}),
i18n.t('errors.httpServer.addressInUse.context', {port: config.get('server').port}),
i18n.t('errors.httpServer.addressInUse.help')
);
} else {
@ -169,15 +169,15 @@ GhostServer.prototype.logStartMessages = function () {
if (process.env.NODE_ENV === 'production') {
console.log(
chalk.green(i18n.t('notices.httpServer.ghostIsRunningIn', {env: process.env.NODE_ENV})),
i18n.t('notices.httpServer.yourBlogIsAvailableOn', {url: config.url}),
i18n.t('notices.httpServer.yourBlogIsAvailableOn', {url: config.get('url')}),
chalk.gray(i18n.t('notices.httpServer.ctrlCToShutDown'))
);
} else {
console.log(
chalk.green(i18n.t('notices.httpServer.ghostIsRunningIn', {env: process.env.NODE_ENV})),
i18n.t('notices.httpServer.listeningOn'),
config.getSocket() || config.server.host + ':' + config.server.port,
i18n.t('notices.httpServer.urlConfiguredAs', {url: config.url}),
config.getSocket() || config.get('server').host + ':' + config.get('server').port,
i18n.t('notices.httpServer.urlConfiguredAs', {url: config.get('url')}),
chalk.gray(i18n.t('notices.httpServer.ctrlCToShutDown'))
);
}

View file

@ -82,7 +82,7 @@ function ghost_head(options) {
context = this.context ? this.context : null,
useStructuredData = !config.isPrivacyDisabled('useStructuredData'),
safeVersion = this.safeVersion,
referrerPolicy = config.referrerPolicy ? config.referrerPolicy : 'no-referrer-when-downgrade',
referrerPolicy = config.get('referrerPolicy') ? config.get('referrerPolicy') : 'no-referrer-when-downgrade',
fetch = {
metaData: getMetaData(this, options.data.root),
client: getClient()

View file

@ -77,9 +77,9 @@ function init(options) {
return config.load(options.config).then(function () {
return config.checkDeprecated();
}).then(function loadApps() {
return readDirectory(config.paths.appPath)
return readDirectory(config.get('paths').appPath)
.then(function (result) {
config.paths.availableApps = result;
config.set('paths:availableApps', result);
});
}).then(function loadThemes() {
return api.themes.loadThemes();
@ -95,15 +95,15 @@ function init(options) {
}), maintenanceState;
if (response.migrate === true) {
maintenanceState = config.maintenance.enabled || false;
config.maintenance.enabled = true;
maintenanceState = config.get('maintenance').enabled || false;
config.set('maintenance:enabled', true);
migrations.update.execute({
fromVersion: currentVersion,
toVersion: versioning.getNewestDatabaseVersion(),
forceMigration: process.env.FORCE_MIGRATION
}).then(function () {
config.maintenance.enabled = maintenanceState;
config.set('maintenance:enabled', maintenanceState);
}).catch(function (err) {
if (!err) {
return;
@ -151,7 +151,7 @@ function init(options) {
middleware(parentApp);
// Log all theme errors and warnings
validateThemes(config.paths.themePath)
validateThemes(config.get('paths').themePath)
.catch(function (result) {
// TODO: change `result` to something better
result.errors.forEach(function (err) {
@ -169,7 +169,7 @@ function init(options) {
// scheduling can trigger api requests, that's why we initialize the module after the ghost server creation
// scheduling module can create x schedulers with different adapters
return scheduling.init(_.extend(config.scheduling, {apiUrl: utils.url.apiUrl()}));
return scheduling.init(_.extend(config.get('scheduling'), {apiUrl: utils.url.apiUrl()}));
}).then(function () {
return ghostServer;
});

View file

@ -8,8 +8,8 @@ var _ = require('lodash'),
i18n = require('../i18n');
function GhostMailer() {
var transport = config.mail && config.mail.transport || 'direct',
options = config.mail && _.clone(config.mail.options) || {};
var transport = config.get('mail') && config.get('mail').transport || 'direct',
options = config.get('mail') && _.clone(config.get('mail').options) || {};
this.state = {};
@ -19,7 +19,7 @@ function GhostMailer() {
}
GhostMailer.prototype.from = function () {
var from = config.mail && (config.mail.from || config.mail.fromaddress),
var from = config.get('mail') && (config.get('mail').from || config.get('mail').fromaddress),
defaultBlogTitle;
// If we don't have a from address at all
@ -30,7 +30,7 @@ GhostMailer.prototype.from = function () {
// If we do have a from address, and it's just an email
if (validator.isEmail(from)) {
defaultBlogTitle = config.theme.title ? config.theme.title : i18n.t('common.mail.title', {domain: this.getDomain()});
defaultBlogTitle = config.get('theme').title ? config.get('theme').title : i18n.t('common.mail.title', {domain: this.getDomain()});
from = '"' + defaultBlogTitle + '" <' + from + '>';
}
@ -40,7 +40,7 @@ GhostMailer.prototype.from = function () {
// Moved it to its own module
GhostMailer.prototype.getDomain = function () {
var domain = config.url.match(new RegExp('^https?://([^/:?#]+)(?:[/:?#]|$)', 'i'));
var domain = config.get('url').match(new RegExp('^https?://([^/:?#]+)(?:[/:?#]|$)', 'i'));
return domain && domain[1];
};

View file

@ -13,7 +13,7 @@ exports.generateContent = function generateContent(options) {
data;
defaults = {
siteUrl: config.forceAdminSSL ? (config.urlSSL || config.url) : config.url
siteUrl: config.get('forceAdminSSL') ? (config.get('urlSSL') || config.get('url')) : config.get('url')
};
data = _.defaults(defaults, options.data);

View file

@ -38,12 +38,12 @@ function sslForbiddenOrRedirect(opt) {
// Check to see if we should use SSL
// and redirect if needed
checkSSL = function checkSSL(req, res, next) {
if (isSSLrequired(res.isAdmin, config.url, config.forceAdminSSL)) {
if (isSSLrequired(res.isAdmin, config.get('url'), config.get('forceAdminSSL'))) {
if (!req.secure) {
var response = sslForbiddenOrRedirect({
forceAdminSSL: config.forceAdminSSL,
configUrlSSL: config.urlSSL,
configUrl: config.url,
forceAdminSSL: config.get('forceAdminSSL'),
configUrlSSL: config.get('urlSSL'),
configUrl: config.get('url'),
reqUrl: req.url
});

View file

@ -32,10 +32,10 @@ function getIPs() {
}
function getUrls() {
var urls = [url.parse(config.url).hostname];
var urls = [url.parse(config.get('url')).hostname];
if (config.urlSSL) {
urls.push(url.parse(config.urlSSL).hostname);
if (config.get('urlSSL')) {
urls.push(url.parse(config.get('urlSSL')).hostname);
}
return urls;

View file

@ -61,15 +61,15 @@ middleware = {
};
setupMiddleware = function setupMiddleware(blogApp) {
var logging = config.logging,
corePath = config.paths.corePath,
var logging = config.get('logging'),
corePath = config.get('paths').corePath,
adminApp = express(),
adminHbs = hbs.create();
// ##Configuration
// enabled gzip compression by default
if (config.server.compress !== false) {
if (config.get('server').compress !== false) {
blogApp.use(compress());
}
@ -103,10 +103,10 @@ setupMiddleware = function setupMiddleware(blogApp) {
}
// Preload link headers
if (config.preloadHeaders) {
if (config.get('preloadHeaders')) {
blogApp.use(netjet({
cache: {
max: config.preloadHeaders
max: config.get('preloadHeaders')
}
}));
}
@ -136,7 +136,7 @@ setupMiddleware = function setupMiddleware(blogApp) {
// Admin only config
blogApp.use('/ghost', serveStatic(
config.paths.clientAssets,
config.get('paths').clientAssets,
{maxAge: utils.ONE_YEAR_MS}
));
@ -145,15 +145,15 @@ setupMiddleware = function setupMiddleware(blogApp) {
// which do not need HTTPS. In fact, if HTTPS is forced on them, then 404 page might
// not display properly when HTTPS is not available!
blogApp.use(checkSSL);
adminApp.set('views', config.paths.adminViews);
adminApp.set('views', config.get('paths').adminViews);
// Theme only config
blogApp.use(staticTheme());
// setup middleware for internal apps
// @TODO: refactor this to be a proper app middleware hook for internal & external apps
config.internalApps.forEach(function (appName) {
var app = require(path.join(config.paths.internalAppPath, appName));
config.get('internalApps').forEach(function (appName) {
var app = require(path.join(config.get('paths').internalAppPath, appName));
if (app.hasOwnProperty('setupMiddleware')) {
app.setupMiddleware(blogApp);
}

View file

@ -3,7 +3,7 @@ var config = require('../config'),
errors = require('../errors');
module.exports = function (req, res, next) {
if (config.maintenance.enabled) {
if (config.get('maintenance').enabled) {
return next(new errors.Maintenance(
i18n.t('errors.general.maintenance')
));

View file

@ -8,7 +8,7 @@ var crypto = require('crypto'),
// Handles requests to robots.txt and favicon.ico (and caches them)
function serveSharedFile(file, type, maxAge) {
var content,
corePath = config.paths.corePath,
corePath = config.get('paths').corePath,
filePath,
blogRegex = /(\{\{blog-url\}\})/g,
apiRegex = /(\{\{api-url\}\})/g;
@ -27,7 +27,7 @@ function serveSharedFile(file, type, maxAge) {
}
if (type === 'text/xsl' || type === 'text/plain' || type === 'application/javascript') {
buf = buf.toString().replace(blogRegex, config.url.replace(/\/$/, ''));
buf = buf.toString().replace(blogRegex, config.get('url').replace(/\/$/, ''));
buf = buf.toString().replace(apiRegex, utils.url.apiUrl({cors: true}));
}
content = {

View file

@ -21,7 +21,7 @@ function forwardToExpressStatic(req, res, next) {
next();
} else {
express.static(
path.join(config.paths.themePath, req.app.get('activeTheme')),
path.join(config.get('paths').themePath, req.app.get('activeTheme')),
{maxAge: utils.ONE_YEAR_MS}
)(req, res, next);
}

View file

@ -15,8 +15,8 @@ themeHandler = {
ghostLocals: function ghostLocals(req, res, next) {
// Make sure we have a locals value.
res.locals = res.locals || {};
res.locals.version = config.ghostVersion;
res.locals.safeVersion = config.ghostVersion.match(/^(\d+\.)?(\d+)/)[0];
res.locals.version = config.get('ghostVersion');
res.locals.safeVersion = config.get('ghostVersion').match(/^(\d+\.)?(\d+)/)[0];
// relative path from the URL
res.locals.relativeUrl = req.path;
@ -26,13 +26,13 @@ themeHandler = {
// ### configHbsForContext Middleware
// Setup handlebars for the current context (admin or theme)
configHbsForContext: function configHbsForContext(req, res, next) {
var themeData = _.cloneDeep(config.theme),
labsData = _.cloneDeep(config.labs),
var themeData = _.cloneDeep(config.get('theme')),
labsData = _.cloneDeep(config.get('labs')),
blogApp = req.app;
if (req.secure && config.urlSSL) {
if (req.secure && config.get('urlSSL')) {
// For secure requests override .url property with the SSL version
themeData.url = config.urlSSL.replace(/\/$/, '');
themeData.url = config.get('urlSSL').replace(/\/$/, '');
}
// Change camelCase to snake_case
@ -41,8 +41,8 @@ themeHandler = {
hbs.updateTemplateOptions({data: {blog: themeData, labs: labsData}});
if (config.paths.themePath && blogApp.get('activeTheme')) {
blogApp.set('views', path.join(config.paths.themePath, blogApp.get('activeTheme')));
if (config.get('paths').themePath && blogApp.get('activeTheme')) {
blogApp.set('views', path.join(config.get('paths').themePath, blogApp.get('activeTheme')));
}
// Pass 'secure' flag to the view engine
@ -56,14 +56,14 @@ themeHandler = {
// Helper for updateActiveTheme
activateTheme: function activateTheme(blogApp, activeTheme) {
var hbsOptions,
themePartials = path.join(config.paths.themePath, activeTheme, 'partials');
themePartials = path.join(config.get('paths').themePath, activeTheme, 'partials');
// clear the view cache
blogApp.cache = {};
// set view engine
hbsOptions = {
partialsDir: [config.paths.helperTemplates],
partialsDir: [config.get('paths').helperTemplates],
onCompile: function onCompile(exhbs, source) {
return exhbs.handlebars.compile(source, {preventIndent: true});
}
@ -98,7 +98,7 @@ themeHandler = {
// Check if the theme changed
if (activeTheme.value !== blogApp.get('activeTheme')) {
// Change theme
if (!config.paths.availableThemes.hasOwnProperty(activeTheme.value)) {
if (!config.get('paths').availableThemes.hasOwnProperty(activeTheme.value)) {
if (!res.isAdmin) {
// Throw an error if the theme is not available, but not on the admin UI
return errors.throwError(i18n.t('errors.middleware.themehandler.missingTheme', {theme: activeTheme.value}));

View file

@ -8,8 +8,8 @@ module.exports = function upload(options) {
// if we finish the data/importer logic, we forward the request to the specified importer
return function (req, res, next) {
var extensions = (config.uploads[type] && config.uploads[type].extensions) || [],
contentTypes = (config.uploads[type] && config.uploads[type].contentTypes) || [];
var extensions = (config.get('uploads')[type] && config.get('uploads')[type].extensions) || [],
contentTypes = (config.get('uploads')[type] && config.get('uploads')[type].contentTypes) || [];
req.file = req.file || {};
req.file.name = req.file.originalname;

View file

@ -525,7 +525,7 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
}
// Check the filtered slug doesn't match any of the reserved keywords
return filters.doFilter('slug.reservedSlugs', config.slugs.reserved).then(function then(slugList) {
return filters.doFilter('slug.reservedSlugs', config.get('slugs').reserved).then(function then(slugList) {
// Some keywords cannot be changed
slugList = _.union(slugList, utils.url.getProtectedSlugs());

View file

@ -1,8 +1,8 @@
var config = require('../../config'),
events = require(config.paths.corePath + '/server/events'),
models = require(config.paths.corePath + '/server/models'),
errors = require(config.paths.corePath + '/server/errors'),
sequence = require(config.paths.corePath + '/server/utils/sequence'),
events = require(config.get('paths:corePath') + '/server/events'),
models = require(config.get('paths:corePath') + '/server/models'),
errors = require(config.get('paths:corePath') + '/server/errors'),
sequence = require(config.get('paths:corePath') + '/server/utils/sequence'),
moment = require('moment-timezone');
/**

View file

@ -177,10 +177,10 @@ Post = ghostBookshelf.Model.extend({
i18n.t('errors.models.post.valueCannotBeBlank', {key: 'published_at'})
));
// CASE: to schedule/reschedule a post, a minimum diff of x minutes is needed (default configured is 2minutes)
} else if (publishedAtHasChanged && moment(publishedAt).isBefore(moment().add(config.times.cannotScheduleAPostBeforeInMinutes, 'minutes'))) {
} else if (publishedAtHasChanged && moment(publishedAt).isBefore(moment().add(config.get('times').cannotScheduleAPostBeforeInMinutes, 'minutes'))) {
return Promise.reject(new errors.ValidationError(
i18n.t('errors.models.post.expectedPublishedAtInFuture', {
cannotScheduleAPostBeforeInMinutes: config.times.cannotScheduleAPostBeforeInMinutes
cannotScheduleAPostBeforeInMinutes: config.get('times').cannotScheduleAPostBeforeInMinutes
})
));
}

View file

@ -10,7 +10,7 @@ var express = require('express'),
frontendRoutes = function frontendRoutes() {
var router = express.Router(),
subdir = utils.url.getSubdir(),
routeKeywords = config.routeKeywords;
routeKeywords = config.get('routeKeywords');
// ### Admin routes
router.get(/^\/(logout|signout)\/$/, function redirectToSignout(req, res) {
@ -33,8 +33,8 @@ frontendRoutes = function frontendRoutes() {
// setup routes for internal apps
// @TODO: refactor this to be a proper app route hook for internal & external apps
config.internalApps.forEach(function (appName) {
var app = require(path.join(config.paths.internalAppPath, appName));
config.get('internalApps').forEach(function (appName) {
var app = require(path.join(config.get('paths').internalAppPath, appName));
if (app.hasOwnProperty('setupRoutes')) {
app.setupRoutes(router);
}

View file

@ -10,8 +10,8 @@ var errors = require('../errors'),
function getStorage(type) {
type = type || 'images';
var storageChoice = config.storage.active[type],
storageConfig = config.storage[storageChoice];
var storageChoice = config.get('storage').active[type],
storageConfig = config.get('storage')[storageChoice];
// CASE: type does not exist
if (!storageChoice) {
@ -25,24 +25,24 @@ function getStorage(type) {
// CASE: load adapter from custom path (.../content/storage)
try {
storage[storageChoice] = require(config.paths.storagePath.custom + storageChoice);
storage[storageChoice] = require(config.get('paths').storagePath.custom + storageChoice);
} catch (err) {
// CASE: only throw error if module does exist
if (err.code !== 'MODULE_NOT_FOUND') {
throw new errors.IncorrectUsage(err.message);
}
// CASE: if module not found it can be an error within the adapter (cannot find bluebird for example)
else if (err.code === 'MODULE_NOT_FOUND' && err.message.indexOf(config.paths.storagePath.custom + storageChoice) === -1) {
else if (err.code === 'MODULE_NOT_FOUND' && err.message.indexOf(config.get('paths').storagePath.custom + storageChoice) === -1) {
throw new errors.IncorrectUsage(err.message);
}
}
// CASE: either storage[storageChoice] is already set or why check for in the default storage path
try {
storage[storageChoice] = storage[storageChoice] || require(config.paths.storagePath.default + storageChoice);
storage[storageChoice] = storage[storageChoice] || require(config.get('paths').storagePath.default + storageChoice);
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
throw new errors.IncorrectUsage('We cannot find your adpter in: ' + config.paths.storagePath.custom + ' or: ' + config.paths.storagePath.default);
throw new errors.IncorrectUsage('We cannot find your adpter in: ' + config.get('paths').storagePath.custom + ' or: ' + config.get('paths').storagePath.default);
} else {
throw new errors.IncorrectUsage(err.message);
}

View file

@ -24,7 +24,7 @@ util.inherits(LocalFileStore, BaseStore);
// - image is the express image object
// - returns a promise which ultimately returns the full url to the uploaded image
LocalFileStore.prototype.save = function (image, targetDir) {
targetDir = targetDir || this.getTargetDir(config.paths.imagesPath);
targetDir = targetDir || this.getTargetDir(config.get('paths').imagesPath);
var targetFilename;
return this.getUniqueFileName(this, image, targetDir).then(function (filename) {
@ -35,8 +35,8 @@ LocalFileStore.prototype.save = function (image, targetDir) {
}).then(function () {
// The src for the image must be in URI format, not a file system path, which in Windows uses \
// For local file system storage can use relative path so add a slash
var fullUrl = (utils.url.getSubdir() + '/' + config.paths.imagesRelPath + '/' +
path.relative(config.paths.imagesPath, targetFilename)).replace(new RegExp('\\' + path.sep, 'g'), '/');
var fullUrl = (utils.url.getSubdir() + '/' + config.get('paths').imagesRelPath + '/' +
path.relative(config.get('paths').imagesPath, targetFilename)).replace(new RegExp('\\' + path.sep, 'g'), '/');
return fullUrl;
}).catch(function (e) {
errors.logError(e);
@ -63,7 +63,7 @@ LocalFileStore.prototype.serve = function (options) {
if (options.isTheme) {
return function downloadTheme(req, res, next) {
var themeName = options.name,
themePath = path.join(config.paths.themePath, themeName),
themePath = path.join(config.get('paths').themePath, themeName),
zipName = themeName + '.zip',
// store this in a unique temporary folder
zipBasePath = path.join(os.tmpdir(), utils.uid(10)),
@ -95,12 +95,12 @@ LocalFileStore.prototype.serve = function (options) {
// CASE: serve images
// For some reason send divides the max age number by 1000
// Fallthrough: false ensures that if an image isn't found, it automatically 404s
return serveStatic(config.paths.imagesPath, {maxAge: utils.ONE_YEAR_MS, fallthrough: false});
return serveStatic(config.get('paths').imagesPath, {maxAge: utils.ONE_YEAR_MS, fallthrough: false});
}
};
LocalFileStore.prototype.delete = function (fileName, targetDir) {
targetDir = targetDir || this.getTargetDir(config.paths.imagesPath);
targetDir = targetDir || this.getTargetDir(config.get('paths').imagesPath);
var pathToDelete = path.join(targetDir, fileName);
return remove(pathToDelete);

View file

@ -36,7 +36,7 @@ var crypto = require('crypto'),
internal = {context: {internal: true}},
allowedCheckEnvironments = ['development', 'production'],
checkEndpoint = 'updates.ghost.org',
currentVersion = config.ghostVersion;
currentVersion = config.get('ghostVersion');
function updateCheckError(error) {
api.settings.edit(
@ -84,12 +84,12 @@ function createCustomNotification(message) {
function updateCheckData() {
var data = {},
mailConfig = config.mail;
mailConfig = config.get('mail');
data.ghost_version = currentVersion;
data.node_version = process.versions.node;
data.env = process.env.NODE_ENV;
data.database_type = config.database.client;
data.database_type = config.get('database').client;
data.email_transport = mailConfig &&
(mailConfig.options && mailConfig.options.service ?
mailConfig.options.service :
@ -116,7 +116,7 @@ function updateCheckData() {
posts = descriptors.posts.value(),
users = descriptors.users.value(),
npm = descriptors.npm.value(),
blogUrl = url.parse(config.url),
blogUrl = url.parse(config.get('url')),
blogId = blogUrl.hostname + blogUrl.pathname.replace(/\//, '') + hash.value;
data.blog_id = crypto.createHash('md5').update(blogId).digest('hex');
@ -212,7 +212,7 @@ function updateCheck() {
// 2. we've already done a check this session
// 3. we're not in production or development mode
// TODO: need to remove config.updateCheck in favor of config.privacy.updateCheck in future version (it is now deprecated)
if (config.updateCheck === false || config.isPrivacyDisabled('useUpdateCheck') || _.indexOf(allowedCheckEnvironments, process.env.NODE_ENV) === -1) {
if (config.get('updateCheck') === false || config.isPrivacyDisabled('useUpdateCheck') || _.indexOf(allowedCheckEnvironments, process.env.NODE_ENV) === -1) {
// No update check
return Promise.resolve();
} else {

View file

@ -2,7 +2,7 @@ var config = require('../config'),
flagIsSet;
flagIsSet = function flagIsSet(flag) {
var labsConfig = config.labs;
var labsConfig = config.get('labs');
return labsConfig && labsConfig[flag] && labsConfig[flag] === true;
};

View file

@ -9,13 +9,13 @@ var moment = require('moment-timezone'),
apiPath = '/ghost/api/v0.1';
function getBaseUrl(secure) {
if (secure && config.urlSSL) {
return config.urlSSL;
if (secure && config.get('urlSSL')) {
return config.get('urlSSL');
} else {
if (secure) {
return config.url.replace('http://', 'https://');
return config.get('url').replace('http://', 'https://');
} else {
return config.url;
return config.get('url');
}
}
}
@ -24,8 +24,8 @@ function getSubdir() {
var localPath, subdir;
// Parse local path location
if (config.url) {
localPath = url.parse(config.url).path;
if (config.get('url')) {
localPath = url.parse(config.get('url')).path;
// Remove trailing slash
if (localPath !== '/') {
@ -41,9 +41,9 @@ function getProtectedSlugs() {
var subdir = getSubdir();
if (!_.isEmpty(subdir)) {
return config.slugs.protected.concat([subdir.split('/').pop()]);
return config.get('slugs').protected.concat([subdir.split('/').pop()]);
} else {
return config.slugs.protected;
return config.get('slugs').protected;
}
}
@ -121,8 +121,8 @@ function createUrl(urlPath, absolute, secure) {
*/
function urlPathForPost(post) {
var output = '',
permalinks = config.theme.permalinks,
publishedAtMoment = moment.tz(post.published_at || Date.now(), config.theme.timezone),
permalinks = config.get('theme').permalinks,
publishedAtMoment = moment.tz(post.published_at || Date.now(), config.get('theme').timezone),
tags = {
year: function () { return publishedAtMoment.format('YYYY'); },
month: function () { return publishedAtMoment.format('MM'); },
@ -197,14 +197,14 @@ function urlFor(context, data, absolute) {
urlPath = data.post.url;
secure = data.secure;
} else if (context === 'tag' && data.tag) {
urlPath = urlJoin('/', config.routeKeywords.tag, data.tag.slug, '/');
urlPath = urlJoin('/', config.get('routeKeywords').tag, data.tag.slug, '/');
secure = data.tag.secure;
} else if (context === 'author' && data.author) {
urlPath = urlJoin('/', config.routeKeywords.author, data.author.slug, '/');
urlPath = urlJoin('/', config.get('routeKeywords').author, data.author.slug, '/');
secure = data.author.secure;
} else if (context === 'image' && data.image) {
urlPath = data.image;
imagePathRe = new RegExp('^' + getSubdir() + '/' + config.paths.imagesRelPath);
imagePathRe = new RegExp('^' + getSubdir() + '/' + config.get('paths').imagesRelPath);
absolute = imagePathRe.test(data.image) ? absolute : false;
secure = data.image.secure;
@ -221,6 +221,7 @@ function urlFor(context, data, absolute) {
secure = data.nav.secure || secure;
baseUrl = getBaseUrl(secure);
hostname = baseUrl.split('//')[1] + getSubdir();
if (urlPath.indexOf(hostname) > -1
&& !urlPath.split(hostname)[0].match(/\.|mailto:/)
&& urlPath.split(hostname)[1].substring(0,1) !== ':') {
@ -263,17 +264,17 @@ function apiUrl(options) {
// @TODO unify this with urlFor
var url;
if (config.forceAdminSSL) {
url = (config.urlSSL || config.url).replace(/^.*?:\/\//g, 'https://');
} else if (config.urlSSL) {
url = config.urlSSL.replace(/^.*?:\/\//g, 'https://');
} else if (config.url.match(/^https:/)) {
url = config.url;
if (config.get('forceAdminSSL')) {
url = (config.get('urlSSL') || config.get('url')).replace(/^.*?:\/\//g, 'https://');
} else if (config.get('urlSSL')) {
url = config.get('urlSSL').replace(/^.*?:\/\//g, 'https://');
} else if (config.get('url').match(/^https:/)) {
url = config.get('url');
} else {
if (options.cors === false) {
url = config.url;
url = config.get('url');
} else {
url = config.url.replace(/^.*?:\/\//g, '//');
url = config.get('url').replace(/^.*?:\/\//g, '//');
}
}

View file

@ -2,7 +2,6 @@
// This tests using Ghost as an npm module
var should = require('should'),
ghost = require('../../../../core'),
utils = require('../../../../core/server/utils'),
i18n = require('../../../../core/server/i18n');
i18n.init();
@ -30,11 +29,8 @@ describe('Module', function () {
ghost().then(function (ghostServer) {
should.exist(ghostServer);
should.exist(ghostServer.config);
should.exist(ghostServer.config.server);
should.exist(ghostServer.config.paths);
should.exist(utils.url.getSubdir());
should.equal(utils.url.getSubdir(), '');
should.exist(ghostServer.config.get('server'));
should.exist(ghostServer.config.get('paths'));
done();
}).catch(done);
});

View file

@ -30,7 +30,7 @@ describe('Authentication API', function () {
it('can authenticate', function (done) {
request.post(testUtils.API.getApiQuery('authentication/token'))
.set('Origin', config.url)
.set('Origin', config.get('url'))
.send({
grant_type: 'password',
username: user.email,
@ -57,7 +57,7 @@ describe('Authentication API', function () {
it('can\'t authenticate unknown user', function (done) {
request.post(testUtils.API.getApiQuery('authentication/token'))
.set('Origin', config.url)
.set('Origin', config.get('url'))
.send({
grant_type: 'password',
username: 'invalid@email.com',
@ -80,7 +80,7 @@ describe('Authentication API', function () {
it('can\'t authenticate invalid password user', function (done) {
request.post(testUtils.API.getApiQuery('authentication/token'))
.set('Origin', config.url)
.set('Origin', config.get('url'))
.send({
grant_type: 'password',
username: user.email,
@ -103,7 +103,7 @@ describe('Authentication API', function () {
it('can request new access token', function (done) {
request.post(testUtils.API.getApiQuery('authentication/token'))
.set('Origin', config.url)
.set('Origin', config.get('url'))
.send({
grant_type: 'password',
username: user.email,
@ -120,7 +120,7 @@ describe('Authentication API', function () {
}
var refreshToken = res.body.refresh_token;
request.post(testUtils.API.getApiQuery('authentication/token'))
.set('Origin', config.url)
.set('Origin', config.get('url'))
.send({
grant_type: 'refresh_token',
refresh_token: refreshToken,
@ -144,7 +144,7 @@ describe('Authentication API', function () {
it('can\'t request new access token with invalid refresh token', function (done) {
request.post(testUtils.API.getApiQuery('authentication/token'))
.set('Origin', config.url)
.set('Origin', config.get('url'))
.send({
grant_type: 'refresh_token',
refresh_token: 'invalid',

View file

@ -42,11 +42,11 @@ describe('Themes API', function () {
after(function (done) {
// clean successful uploaded themes
fs.removeSync(config.paths.themePath + '/valid');
fs.removeSync(config.paths.themePath + '/casper.zip');
fs.removeSync(config.get('paths').themePath + '/valid');
fs.removeSync(config.get('paths').themePath + '/casper.zip');
// gscan creates /test/tmp in test mode
fs.removeSync(config.paths.appRoot + '/test');
fs.removeSync(config.get('paths').appRoot + '/test');
testUtils.clearData()
.then(function () {
@ -92,7 +92,7 @@ describe('Themes API', function () {
}
// ensure contains two files (zip and extracted theme)
fs.readdirSync(config.paths.themePath).join().match(/valid/gi).length.should.eql(1);
fs.readdirSync(config.get('paths').themePath).join().match(/valid/gi).length.should.eql(1);
done();
});
});
@ -139,8 +139,8 @@ describe('Themes API', function () {
return done(err);
}
fs.existsSync(config.paths.themePath + '/valid').should.eql(false);
fs.existsSync(config.paths.themePath + '/valid.zip').should.eql(false);
fs.existsSync(config.get('paths').themePath + '/valid').should.eql(false);
fs.existsSync(config.get('paths').themePath + '/valid.zip').should.eql(false);
done();
});
});

View file

@ -27,7 +27,7 @@ describe('Upload API', function () {
after(function (done) {
images.forEach(function (image) {
fs.removeSync(config.paths.appRoot + image);
fs.removeSync(config.get('paths').appRoot + image);
});
testUtils.clearData().then(function () {

View file

@ -4,10 +4,10 @@ var should = require('should'),
Promise = require('bluebird'),
testUtils = require('../../utils'),
config = require(__dirname + '/../../../server/config'),
sequence = require(config.paths.corePath + '/server/utils/sequence'),
errors = require(config.paths.corePath + '/server/errors'),
api = require(config.paths.corePath + '/server/api'),
models = require(config.paths.corePath + '/server/models');
sequence = require(config.get('paths').corePath + '/server/utils/sequence'),
errors = require(config.get('paths').corePath + '/server/errors'),
api = require(config.get('paths').corePath + '/server/api'),
models = require(config.get('paths').corePath + '/server/models');
describe('Schedules API', function () {
var scope = {posts: []};
@ -175,10 +175,10 @@ describe('Schedules API', function () {
var originalCannotScheduleAPostBeforeInMinutes;
beforeEach(function (done) {
originalCannotScheduleAPostBeforeInMinutes = config.times.cannotScheduleAPostBeforeInMinutes;
originalCannotScheduleAPostBeforeInMinutes = config.get('times').cannotScheduleAPostBeforeInMinutes;
// we can insert published_at less then 5minutes
config.times.cannotScheduleAPostBeforeInMinutes = -15;
config.set('times:cannotScheduleAPostBeforeInMinutes', -15);
sequence([
testUtils.teardown,
@ -189,7 +189,7 @@ describe('Schedules API', function () {
});
after(function () {
config.times.cannotScheduleAPostBeforeInMinutes = originalCannotScheduleAPostBeforeInMinutes;
config.set('times:cannotScheduleAPostBeforeInMinutes', originalCannotScheduleAPostBeforeInMinutes);
});
describe('success', function () {

View file

@ -7,9 +7,9 @@ var should = require('should'),
rewire = require('rewire'),
_ = require('lodash'),
config = require('../../../../server/config'),
testUtils = require(config.paths.corePath + '/test/utils'),
events = require(config.paths.corePath + '/server/events'),
models = require(config.paths.corePath + '/server/models');
testUtils = require(config.get('paths').corePath + '/test/utils'),
events = require(config.get('paths').corePath + '/server/events'),
models = require(config.get('paths').corePath + '/server/models');
describe('Models: listeners', function () {
var eventsToRemember = {},
@ -30,7 +30,7 @@ describe('Models: listeners', function () {
eventsToRemember[eventName] = callback;
});
rewire(config.paths.corePath + '/server/models/base/listeners');
rewire(config.get('paths').corePath + '/server/models/base/listeners');
});
afterEach(function (done) {

View file

@ -1,7 +1,7 @@
var should = require('should'),
rewire = require('rewire'),
config = rewire('../../../server/config'),
api = rewire(config.paths.corePath + '/server/api');
api = rewire(config.get('paths').corePath + '/server/api');
describe('API: index', function () {
describe('fn: cacheInvalidationHeader', function () {

View file

@ -44,14 +44,14 @@ describe('Config', function () {
});
it('should have exactly the right keys', function () {
var themeConfig = config.theme;
var themeConfig = config.get('theme');
// This will fail if there are any extra keys
themeConfig.should.have.keys('url', 'title', 'description', 'logo', 'cover', 'timezone');
});
it('should have the correct values for each key', function () {
var themeConfig = config.theme;
var themeConfig = config.get('theme');
// Check values are as we expect
themeConfig.should.have.property('url', 'http://my-ghost-blog.com');
@ -65,7 +65,7 @@ describe('Config', function () {
describe('Timezone default', function () {
it('should use timezone from settings when set', function () {
var themeConfig = config.theme;
var themeConfig = config.get('theme');
// Check values are as we expect
themeConfig.should.have.property('timezone', 'Etc/UTC');
@ -93,7 +93,7 @@ describe('Config', function () {
describe('Index', function () {
it('should have exactly the right keys', function () {
var pathConfig = config.paths;
var pathConfig = config.get('paths');
// This will fail if there are any extra keys
pathConfig.should.have.keys(
@ -115,14 +115,14 @@ describe('Config', function () {
});
it('should have the correct values for each key', function () {
var pathConfig = config.paths,
var pathConfig = config.get('paths'),
appRoot = path.resolve(__dirname, '../../../');
pathConfig.should.have.property('appRoot', appRoot);
});
it('should allow specific properties to be user defined', function () {
var contentPath = path.join(config.paths.appRoot, 'otherContent', '/'),
var contentPath = path.join(config.get('paths').appRoot, 'otherContent', '/'),
configFile = 'configFileDanceParty.js';
configUtils.set({
@ -143,8 +143,8 @@ describe('Config', function () {
describe('Storage', function () {
it('should default to local-file-store', function () {
config.paths.should.have.property('storagePath', {
default: path.join(config.paths.corePath, '/server/storage/'),
custom: path.join(config.paths.contentPath, 'storage/')
default: path.join(config.get('paths').corePath, '/server/storage/'),
custom: path.join(config.get('paths').contentPath, 'storage/')
});
config.storage.should.have.property('active', {
@ -154,7 +154,7 @@ describe('Config', function () {
});
it('should allow setting a custom active storage as string', function () {
var storagePath = path.join(config.paths.contentPath, 'storage', 's3');
var storagePath = path.join(config.get('paths').contentPath, 'storage', 's3');
configUtils.set({
storage: {
@ -172,7 +172,7 @@ describe('Config', function () {
});
it('should use default theme adapter when passing an object', function () {
var storagePath = path.join(config.paths.contentPath, 'storage', 's3');
var storagePath = path.join(config.get('paths').contentPath, 'storage', 's3');
configUtils.set({
storage: {
@ -182,14 +182,14 @@ describe('Config', function () {
}
});
config.storage.should.have.property('active', {
config.get('storage').should.have.property('active', {
images: 'local-file-store',
themes: 'local-file-store'
});
});
it('should allow setting a custom active storage as object', function () {
var storagePath = path.join(config.paths.contentPath, 'storage', 's3');
var storagePath = path.join(config.get('paths').contentPath, 'storage', 's3');
configUtils.set({
storage: {
@ -200,7 +200,7 @@ describe('Config', function () {
}
});
config.storage.should.have.property('active', {
config.get('storage').should.have.property('active', {
images: 's2',
themes: 'local-file-store'
});
@ -245,21 +245,21 @@ describe('Config', function () {
});
config.load().then(function (config) {
config.url.should.equal(configUtils.defaultConfig.url);
config.database.client.should.equal(configUtils.defaultConfig.database.client);
config.get('url').should.equal(configUtils.defaultConfig.url);
config.get('database').client.should.equal(configUtils.defaultConfig.database.client);
if (config.database.client === 'sqlite3') {
config.database.connection.filename.should.eql(configUtils.defaultConfig.database.connection.filename);
if (config.get('database').client === 'sqlite3') {
config.get('database').connection.filename.should.eql(configUtils.defaultConfig.database.connection.filename);
} else {
config.database.connection.charset.should.eql(configUtils.defaultConfig.database.connection.charset);
config.database.connection.database.should.eql(configUtils.defaultConfig.database.connection.database);
config.database.connection.host.should.eql(configUtils.defaultConfig.database.connection.host);
config.database.connection.password.should.eql(configUtils.defaultConfig.database.connection.password);
config.database.connection.user.should.eql(configUtils.defaultConfig.database.connection.user);
config.get('database').connection.charset.should.eql(configUtils.defaultConfig.database.connection.charset);
config.get('database').connection.database.should.eql(configUtils.defaultConfig.database.connection.database);
config.get('database').connection.host.should.eql(configUtils.defaultConfig.database.connection.host);
config.get('database').connection.password.should.eql(configUtils.defaultConfig.database.connection.password);
config.get('database').connection.user.should.eql(configUtils.defaultConfig.database.connection.user);
}
config.server.host.should.equal(configUtils.defaultConfig.server.host);
config.server.port.should.equal(configUtils.defaultConfig.server.port);
config.get('server').host.should.equal(configUtils.defaultConfig.server.host);
config.get('server').port.should.equal(configUtils.defaultConfig.server.port);
done();
}).catch(done);
@ -270,20 +270,20 @@ describe('Config', function () {
readFileStub.restore();
config.load(path.join(configUtils.defaultConfig.paths.appRoot, 'config.example.js')).then(function (config) {
config.url.should.equal(configUtils.defaultConfig.url);
config.database.client.should.equal(configUtils.defaultConfig.database.client);
config.get('url').should.equal(configUtils.defaultConfig.url);
config.get('database').client.should.equal(configUtils.defaultConfig.database.client);
if (config.database.client === 'sqlite3') {
config.database.connection.filename.should.eql(configUtils.defaultConfig.database.connection.filename);
if (config.get('database').client === 'sqlite3') {
config.get('database').connection.filename.should.eql(configUtils.defaultConfig.database.connection.filename);
} else {
config.database.connection.charset.should.eql(configUtils.defaultConfig.database.connection.charset);
config.database.connection.database.should.eql(configUtils.defaultConfig.database.connection.database);
config.database.connection.host.should.eql(configUtils.defaultConfig.database.connection.host);
config.database.connection.password.should.eql(configUtils.defaultConfig.database.connection.password);
config.database.connection.user.should.eql(configUtils.defaultConfig.database.connection.user);
config.get('database').connection.charset.should.eql(configUtils.defaultConfig.database.connection.charset);
config.get('database').connection.database.should.eql(configUtils.defaultConfig.database.connection.database);
config.get('database').connection.host.should.eql(configUtils.defaultConfig.database.connection.host);
config.get('database').connection.password.should.eql(configUtils.defaultConfig.database.connection.password);
config.get('database').connection.user.should.eql(configUtils.defaultConfig.database.connection.user);
}
config.server.host.should.equal(configUtils.defaultConfig.server.host);
config.server.port.should.equal(configUtils.defaultConfig.server.port);
config.get('server').host.should.equal(configUtils.defaultConfig.server.host);
config.get('server').port.should.equal(configUtils.defaultConfig.server.port);
done();
}).catch(done);
@ -309,25 +309,25 @@ describe('Config', function () {
overrideReadFileConfig({url: 'http://testurl.com'});
config.load().then(function (localConfig) {
localConfig.url.should.equal('http://testurl.com');
localConfig.get('url').should.equal('http://testurl.com');
// Next test
overrideReadFileConfig({url: 'https://testurl.com'});
return config.load();
}).then(function (localConfig) {
localConfig.url.should.equal('https://testurl.com');
localConfig.get('url').should.equal('https://testurl.com');
// Next test
overrideReadFileConfig({url: 'http://testurl.com/blog/'});
return config.load();
}).then(function (localConfig) {
localConfig.url.should.equal('http://testurl.com/blog/');
localConfig.get('url').should.equal('http://testurl.com/blog/');
// Next test
overrideReadFileConfig({url: 'http://testurl.com/ghostly/'});
return config.load();
}).then(function (localConfig) {
localConfig.url.should.equal('http://testurl.com/ghostly/');
localConfig.get('url').should.equal('http://testurl.com/ghostly/');
done();
}).catch(done);

View file

@ -4,22 +4,22 @@ var getAssetUrl = require('../../../server/data/meta/asset_url'),
describe('getAssetUrl', function () {
it('should return asset url with just context', function () {
var testUrl = getAssetUrl('myfile.js');
testUrl.should.equal('/assets/myfile.js?v=' + config.assetHash);
testUrl.should.equal('/assets/myfile.js?v=' + config.get('assetHash'));
});
it('should return asset url with just context even with leading /', function () {
var testUrl = getAssetUrl('/myfile.js');
testUrl.should.equal('/assets/myfile.js?v=' + config.assetHash);
testUrl.should.equal('/assets/myfile.js?v=' + config.get('assetHash'));
});
it('should return ghost url if is admin', function () {
var testUrl = getAssetUrl('myfile.js', true);
testUrl.should.equal('/ghost/myfile.js?v=' + config.assetHash);
testUrl.should.equal('/ghost/myfile.js?v=' + config.get('assetHash'));
});
it('should not add ghost to url if is admin and has asset in context', function () {
var testUrl = getAssetUrl('asset/myfile.js', true);
testUrl.should.equal('/asset/myfile.js?v=' + config.assetHash);
testUrl.should.equal('/asset/myfile.js?v=' + config.get('assetHash'));
});
it('should not add ghost or asset to url if favicon.ico', function () {
@ -29,16 +29,16 @@ describe('getAssetUrl', function () {
it('should not add ghost or asset to url has shared in it', function () {
var testUrl = getAssetUrl('shared/myfile.js');
testUrl.should.equal('/shared/myfile.js?v=' + config.assetHash);
testUrl.should.equal('/shared/myfile.js?v=' + config.get('assetHash'));
});
it('should return asset minified url when minify true', function () {
var testUrl = getAssetUrl('myfile.js', false, true);
testUrl.should.equal('/assets/myfile.min.js?v=' + config.assetHash);
testUrl.should.equal('/assets/myfile.min.js?v=' + config.get('assetHash'));
});
it('should not add min to anything besides the last .', function () {
var testUrl = getAssetUrl('test.page/myfile.js', false, true);
testUrl.should.equal('/assets/test.page/myfile.min.js?v=' + config.assetHash);
testUrl.should.equal('/assets/test.page/myfile.min.js?v=' + config.get('assetHash'));
});
});

View file

@ -6,7 +6,7 @@ var config = require(__dirname + '/../../../server/config'),
bodyParser = require('body-parser'),
http = require('http'),
sinon = require('sinon'),
SchedulingDefault = require(config.paths.corePath + '/server/scheduling/SchedulingDefault'),
SchedulingDefault = require(config.get('paths').corePath + '/server/scheduling/SchedulingDefault'),
sandbox = sinon.sandbox.create();
describe('Scheduling Default Adapter', function () {

View file

@ -12,7 +12,7 @@ describe('Scheduling', function () {
before(function () {
sinon.stub(postScheduling, 'init').returns(Promise.resolve());
scope.scheduling = rewire(config.paths.corePath + '/server/scheduling');
scope.scheduling = rewire(config.get('paths').corePath + '/server/scheduling');
});
after(function () {

View file

@ -4,14 +4,14 @@ var should = require('should'),
Promise = require('bluebird'),
moment = require('moment'),
config = require(__dirname + '/../../../../server/config'),
testUtils = require(config.paths.corePath + '/test/utils'),
errors = require(config.paths.corePath + '/server/errors'),
events = require(config.paths.corePath + '/server/events'),
models = require(config.paths.corePath + '/server/models'),
api = require(config.paths.corePath + '/server/api'),
schedulingUtils = require(config.paths.corePath + '/server/scheduling/utils'),
SchedulingDefault = require(config.paths.corePath + '/server/scheduling/SchedulingDefault'),
postScheduling = require(config.paths.corePath + '/server/scheduling/post-scheduling');
testUtils = require(config.get('paths').corePath + '/test/utils'),
errors = require(config.get('paths').corePath + '/server/errors'),
events = require(config.get('paths').corePath + '/server/events'),
models = require(config.get('paths').corePath + '/server/models'),
api = require(config.get('paths').corePath + '/server/api'),
schedulingUtils = require(config.get('paths').corePath + '/server/scheduling/utils'),
SchedulingDefault = require(config.get('paths').corePath + '/server/scheduling/SchedulingDefault'),
postScheduling = require(config.get('paths').corePath + '/server/scheduling/post-scheduling');
describe('Scheduling: Post Scheduling', function () {
var scope = {

View file

@ -2,8 +2,8 @@
var should = require('should'),
fs = require('fs'),
config = require(__dirname + '/../../../server/config'),
errors = require(config.paths.corePath + '/server/errors'),
schedulingUtils = require(config.paths.corePath + '/server/scheduling/utils');
errors = require(config.get('paths').corePath + '/server/errors'),
schedulingUtils = require(config.get('paths').corePath + '/server/scheduling/utils');
describe('Scheduling: utils', function () {
describe('success', function () {

View file

@ -19,7 +19,7 @@ describe('{{navigation}} helper', function () {
before(function (done) {
utils.loadHelpers();
hbs.express3({
partialsDir: [configUtils.config.paths.helperTemplates]
partialsDir: [configUtils.config.get('paths').helperTemplates]
});
hbs.cachePartials(function () {
@ -83,7 +83,7 @@ describe('{{navigation}} helper', function () {
it('can render one item', function () {
var singleItem = {label: 'Foo', url: '/foo'},
testUrl = 'href="' + configUtils.config.url + '/foo"',
testUrl = 'href="' + configUtils.config.get('url') + '/foo"',
rendered;
optionsData.data.blog.navigation = [singleItem];
@ -98,8 +98,8 @@ describe('{{navigation}} helper', function () {
it('can render multiple items', function () {
var firstItem = {label: 'Foo', url: '/foo'},
secondItem = {label: 'Bar Baz Qux', url: '/qux'},
testUrl = 'href="' + configUtils.config.url + '/foo"',
testUrl2 = 'href="' + configUtils.config.url + '/qux"',
testUrl = 'href="' + configUtils.config.get('url') + '/foo"',
testUrl2 = 'href="' + configUtils.config.get('url') + '/qux"',
rendered;
optionsData.data.blog.navigation = [firstItem, secondItem];
@ -151,7 +151,7 @@ describe('{{navigation}} helper with custom template', function () {
before(function (done) {
utils.loadHelpers();
hbs.express3({
partialsDir: [path.resolve(configUtils.config.paths.corePath, 'test/unit/server_helpers/test_tpl')]
partialsDir: [path.resolve(configUtils.config.get('paths').corePath, 'test/unit/server_helpers/test_tpl')]
});
hbs.cachePartials(function () {
@ -175,7 +175,7 @@ describe('{{navigation}} helper with custom template', function () {
it('can render one item and @blog title', function () {
var singleItem = {label: 'Foo', url: '/foo'},
testUrl = 'href="' + configUtils.config.url + '/foo"',
testUrl = 'href="' + configUtils.config.get('url') + '/foo"',
rendered;
optionsData.data.blog.navigation = [singleItem];

View file

@ -11,7 +11,7 @@ var should = require('should'),
describe('{{pagination}} helper', function () {
before(function (done) {
utils.loadHelpers();
hbs.express3({partialsDir: [configUtils.config.paths.helperTemplates]});
hbs.express3({partialsDir: [configUtils.config.get('paths').helperTemplates]});
hbs.cachePartials(function () {
done();
@ -126,7 +126,7 @@ describe('{{pagination}} helper', function () {
describe('{{pagination}} helper with custom template', function () {
before(function (done) {
utils.loadHelpers();
hbs.express3({partialsDir: [path.resolve(configUtils.config.paths.corePath, 'test/unit/server_helpers/test_tpl')]});
hbs.express3({partialsDir: [path.resolve(configUtils.config.get('paths').corePath, 'test/unit/server_helpers/test_tpl')]});
hbs.cachePartials(function () {
done();

View file

@ -4,17 +4,17 @@ var should = require('should'),
Promise = require('bluebird'),
rewire = require('rewire'),
config = require('../../server/config'),
versioning = require(config.paths.corePath + '/server/data/schema/versioning'),
migration = require(config.paths.corePath + '/server/data/migration'),
models = require(config.paths.corePath + '/server/models'),
permissions = require(config.paths.corePath + '/server/permissions'),
api = require(config.paths.corePath + '/server/api'),
apps = require(config.paths.corePath + '/server/apps'),
i18n = require(config.paths.corePath + '/server/i18n'),
xmlrpc = require(config.paths.corePath + '/server/data/xml/xmlrpc'),
slack = require(config.paths.corePath + '/server/data/slack'),
scheduling = require(config.paths.corePath + '/server/scheduling'),
bootstrap = rewire(config.paths.corePath + '/server'),
versioning = require(config.get('paths').corePath + '/server/data/schema/versioning'),
migration = require(config.get('paths').corePath + '/server/data/migration'),
models = require(config.get('paths').corePath + '/server/models'),
permissions = require(config.get('paths').corePath + '/server/permissions'),
api = require(config.get('paths').corePath + '/server/api'),
apps = require(config.get('paths').corePath + '/server/apps'),
i18n = require(config.get('paths').corePath + '/server/i18n'),
xmlrpc = require(config.get('paths').corePath + '/server/data/xml/xmlrpc'),
slack = require(config.get('paths').corePath + '/server/data/slack'),
scheduling = require(config.get('paths').corePath + '/server/scheduling'),
bootstrap = rewire(config.get('paths').corePath + '/server'),
sandbox = sinon.sandbox.create();
describe('server bootstrap', function () {
@ -61,7 +61,7 @@ describe('server bootstrap', function () {
migration.populate.calledOnce.should.eql(true);
migration.update.execute.calledOnce.should.eql(false);
models.Settings.populateDefaults.callCount.should.eql(1);
config.maintenance.enabled.should.eql(false);
config.get('maintenance').enabled.should.eql(false);
done();
})
.catch(function (err) {
@ -112,7 +112,7 @@ describe('server bootstrap', function () {
models.Settings.populateDefaults.callCount.should.eql(1);
migration.populate.calledOnce.should.eql(false);
config.maintenance.enabled.should.eql(false);
config.get('maintenance').enabled.should.eql(false);
done();
})

View file

@ -4,8 +4,8 @@ var _ = require('lodash'),
config = require('../../server/config'),
schema = require('../../server/data/schema').tables,
ApiRouteBase = '/ghost/api/v0.1/',
host = config.server.host,
port = config.server.port,
host = config.get('server').host,
port = config.get('server').port,
protocol = 'http://',
expectedProperties = {
// API top level

View file

@ -553,7 +553,7 @@ login = function login(request) {
return new Promise(function (resolve, reject) {
request.post('/ghost/api/v0.1/authentication/token/')
.set('Origin', config.url)
.set('Origin', config.get('url'))
.send({
grant_type: 'password',
username: user.email,