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

Merge pull request #1535 from hswolff/create-config-module

Create config module to standardise getting paths and abs URLs
This commit is contained in:
Hannah Wolfe 2013-11-25 14:03:29 -08:00
commit 330722efdc
19 changed files with 173 additions and 125 deletions

View file

@ -6,7 +6,7 @@ var path = require('path'),
spawn = require('child_process').spawn,
buildDirectory = path.resolve(process.cwd(), '.build'),
distDirectory = path.resolve(process.cwd(), '.dist'),
configLoader = require('./core/config-loader.js'),
configLoader = require('./core/server/config/loader'),
buildGlob = [
'**',
@ -499,7 +499,7 @@ var path = require('path'),
grunt.registerTask('loadConfig', function () {
var done = this.async();
configLoader.loadConfig().then(function () {
configLoader().then(function () {
done();
});
});

View file

@ -2,30 +2,23 @@
// Defines core methods required to build the application
// Module dependencies
var config = require('../config'),
when = require('when'),
express = require('express'),
errors = require('./server/errorHandling'),
fs = require('fs'),
path = require('path'),
hbs = require('express-hbs'),
nodefn = require('when/node/function'),
_ = require('underscore'),
url = require('url'),
Polyglot = require('node-polyglot'),
Mailer = require('./server/mail'),
models = require('./server/models'),
requireTree = require('./server/require-tree'),
permissions = require('./server/permissions'),
uuid = require('node-uuid'),
var config = require('./server/config'),
when = require('when'),
express = require('express'),
errors = require('./server/errorHandling'),
fs = require('fs'),
path = require('path'),
hbs = require('express-hbs'),
nodefn = require('when/node/function'),
_ = require('underscore'),
url = require('url'),
Polyglot = require('node-polyglot'),
Mailer = require('./server/mail'),
models = require('./server/models'),
permissions = require('./server/permissions'),
uuid = require('node-uuid'),
// Variables
appRoot = path.resolve(__dirname, '../'),
themePath = path.resolve(appRoot + '/content/themes'),
pluginPath = path.resolve(appRoot + '/content/plugins'),
themeDirectories = requireTree(themePath),
pluginDirectories = requireTree(pluginPath),
Ghost,
instance,
defaults;
@ -60,12 +53,6 @@ Ghost = function () {
// Holds the filter hooks (that are built in to Ghost Core)
instance.filters = [];
// Holds the theme directories temporarily
instance.themeDirectories = {};
// Holds the plugin directories temporarily
instance.pluginDirectories = {};
// Holds the persistent notifications
instance.notifications = [];
@ -78,8 +65,6 @@ Ghost = function () {
polyglot = new Polyglot();
_.extend(instance, {
config: function () { return config[process.env.NODE_ENV]; },
// there's no management here to be sure this has loaded
settings: function (key) {
if (key) {
@ -89,7 +74,7 @@ Ghost = function () {
},
dataProvider: models,
blogGlobals: function () {
var localPath = url.parse(instance.config().url).path;
var localPath = url.parse(config().url).path;
// Remove trailing slash
if (localPath !== '/') {
@ -99,7 +84,7 @@ Ghost = function () {
/* this is a bit of a hack until we have a better way to combine settings and config
* this data is what becomes globally available to themes */
return {
url: instance.config().url.replace(/\/$/, ''),
url: config().url.replace(/\/$/, ''),
path: localPath,
title: instance.settings('title'),
description: instance.settings('description'),
@ -108,27 +93,7 @@ Ghost = function () {
};
},
polyglot: function () { return polyglot; },
mail: new Mailer(),
getPaths: function () {
return when.all([themeDirectories, pluginDirectories]).then(function (paths) {
instance.themeDirectories = paths[0];
instance.pluginDirectories = paths[1];
return;
});
},
paths: function () {
return {
'appRoot': appRoot,
'themePath': themePath,
'pluginPath': pluginPath,
'activeTheme': path.join(themePath, !instance.settingsCache ? '' : instance.settingsCache.activeTheme.value),
'adminViews': path.join(appRoot, '/core/server/views/'),
'helperTemplates': path.join(appRoot, '/core/server/helpers/tpl/'),
'lang': path.join(appRoot, '/core/shared/lang/'),
'availableThemes': instance.themeDirectories,
'availablePlugins': instance.pluginDirectories
};
}
mail: new Mailer()
});
}
return instance;
@ -146,7 +111,7 @@ Ghost.prototype.init = function () {
'</strong>environment.',
'Your URL is set to',
'<strong>' + self.config().url + '</strong>.',
'<strong>' + config().url + '</strong>.',
'See <a href="http://docs.ghost.org/">http://docs.ghost.org</a> for instructions.'
];
@ -180,9 +145,11 @@ Ghost.prototype.init = function () {
// Initialise the models
self.dataProvider.init(),
// Calculate paths
self.getPaths(),
// Initialise mail after first run
self.mail.init(self)
config.paths.updatePaths(),
// Initialise mail after first run,
// passing in config module to prevent
// circular dependencies.
self.mail.init(self, config)
).then(function () {
// Populate any missing default settings
return models.Settings.populateDefaults();
@ -190,6 +157,8 @@ Ghost.prototype.init = function () {
// Initialize the settings cache
return self.updateSettingsCache();
}).then(function () {
// Update path to activeTheme
config.paths.setActiveTheme(self);
return when.join(
// Check for or initialise a dbHash.
initDbHashAndFirstRun(),
@ -229,7 +198,7 @@ Ghost.prototype.readSettingsResult = function (result) {
settings[member.attributes.key] = val;
}
})).then(function () {
return when(instance.paths().availableThemes).then(function (themes) {
return when(config.paths().availableThemes).then(function (themes) {
var themeKeys = Object.keys(themes),
res = [],
i,
@ -269,7 +238,7 @@ Ghost.prototype.loadTemplate = function (name) {
var self = this,
templateFileName = name + '.hbs',
// Check for theme specific version first
templatePath = path.join(this.paths().activeTheme, 'partials', templateFileName),
templatePath = path.join(config.paths().activeTheme, 'partials', templateFileName),
deferred = when.defer();
// Can't use nodefn here because exists just returns one parameter, true or false
@ -277,7 +246,7 @@ Ghost.prototype.loadTemplate = function (name) {
fs.exists(templatePath, function (exists) {
if (!exists) {
// Fall back to helpers templates location
templatePath = path.join(self.paths().helperTemplates, templateFileName);
templatePath = path.join(config.paths().helperTemplates, templateFileName);
}
self.compileTemplate(templatePath).then(deferred.resolve, deferred.reject);

View file

@ -3,7 +3,8 @@
// modules to ensure config gets right setting.
// Module dependencies
var express = require('express'),
var config = require('./server/config'),
express = require('express'),
when = require('when'),
_ = require('underscore'),
semver = require('semver'),
@ -34,7 +35,7 @@ if (process.env.NODE_ENV === 'development') {
// Finally it starts the http server.
function setup(server) {
when(ghost.init()).then(function () {
return helpers.loadCoreHelpers(ghost);
return helpers.loadCoreHelpers(ghost, config);
}).then(function () {
// ##Configuration
@ -63,8 +64,8 @@ function setup(server) {
// Are we using sockets? Custom socket or the default?
function getSocket() {
if (ghost.config().server.hasOwnProperty('socket')) {
return _.isString(ghost.config().server.socket) ? ghost.config().server.socket : path.join(__dirname, '../content/', process.env.NODE_ENV + '.socket');
if (config().server.hasOwnProperty('socket')) {
return _.isString(config().server.socket) ? config().server.socket : path.join(__dirname, '../content/', process.env.NODE_ENV + '.socket');
}
return false;
}
@ -89,7 +90,7 @@ function setup(server) {
console.log(
"Ghost is running...".green,
"\nYour blog is now available on",
ghost.config().url,
config().url,
"\nCtrl+C to shut down".grey
);
@ -105,9 +106,9 @@ function setup(server) {
console.log(
("Ghost is running in " + process.env.NODE_ENV + "...").green,
"\nListening on",
getSocket() || ghost.config().server.host + ':' + ghost.config().server.port,
getSocket() || config().server.host + ':' + config().server.port,
"\nUrl configured as:",
ghost.config().url,
config().url,
"\nCtrl+C to shut down".grey
);
// ensure that Ghost exits correctly on Ctrl+C
@ -144,8 +145,8 @@ function setup(server) {
} else {
server.listen(
ghost.config().server.port,
ghost.config().server.host,
config().server.port,
config().server.host,
startGhost
);
}

View file

@ -0,0 +1,16 @@
var ghostConfig = require('../../../config'),
loader = require('./loader'),
paths = require('./paths');
function configIndex() {
return ghostConfig[process.env.NODE_ENV];
}
configIndex.loader = loader;
configIndex.paths = paths;
module.exports = configIndex;

View file

@ -1,10 +1,10 @@
var fs = require('fs'),
url = require('url'),
when = require('when'),
errors = require('./server/errorHandling'),
errors = require('../errorHandling'),
path = require('path'),
appRoot = path.resolve(__dirname, '../'),
appRoot = path.resolve(__dirname, '../../../'),
configexample = path.join(appRoot, 'config.example.js'),
config = path.join(appRoot, 'config.js');
@ -49,7 +49,7 @@ function validateConfigEnvironment() {
parsedUrl;
try {
config = require('../config')[envVal];
config = require('../../../config')[envVal];
} catch (ignore) {
}
@ -86,7 +86,7 @@ function validateConfigEnvironment() {
return when.resolve();
}
exports.loadConfig = function () {
function loadConfig() {
var loaded = when.defer();
/* Check for config file and copy from config.example.js
if one doesn't exist. After that, start the server. */
@ -98,4 +98,6 @@ exports.loadConfig = function () {
}
});
return loaded.promise;
};
}
module.exports = loadConfig;

View file

@ -0,0 +1,49 @@
var path = require('path'),
when = require('when'),
requireTree = require('../require-tree'),
appRoot = path.resolve(__dirname, '../../../'),
themePath = path.resolve(appRoot + '/content/themes'),
pluginPath = path.resolve(appRoot + '/content/plugins'),
themeDirectories = requireTree(themePath),
pluginDirectories = requireTree(pluginPath),
activeTheme = '',
availableThemes,
availablePlugins;
function getPaths() {
return {
'appRoot': appRoot,
'themePath': themePath,
'pluginPath': pluginPath,
'activeTheme': path.join(themePath, activeTheme),
'adminViews': path.join(appRoot, '/core/server/views/'),
'helperTemplates': path.join(appRoot, '/core/server/helpers/tpl/'),
'lang': path.join(appRoot, '/core/shared/lang/'),
'availableThemes': availableThemes,
'availablePlugins': availablePlugins
};
}
function updatePaths() {
return when.all([themeDirectories, pluginDirectories]).then(function (paths) {
availableThemes = paths[0];
availablePlugins = paths[1];
return;
});
}
function setActiveTheme(ghost) {
if (ghost && ghost.settingsCache) {
activeTheme = ghost.settingsCache.activeTheme.value;
}
}
module.exports = getPaths;
module.exports.updatePaths = updatePaths;
module.exports.setActiveTheme = setActiveTheme;

View file

@ -1,4 +1,5 @@
var Ghost = require('../../ghost'),
config = require('../config'),
_ = require('underscore'),
path = require('path'),
when = require('when'),
@ -154,8 +155,8 @@ adminControllers = {
var email = req.body.email;
api.users.generateResetToken(email).then(function (token) {
var siteLink = '<a href="' + ghost.config().url + '">' + ghost.config().url + '</a>',
resetUrl = ghost.config().url + '/ghost/reset/' + token + '/',
var siteLink = '<a href="' + config().url + '">' + config().url + '</a>',
resetUrl = config().url + '/ghost/reset/' + token + '/',
resetLink = '<a href="' + resetUrl + '">' + resetUrl + '</a>',
message = {
to: email,

View file

@ -5,6 +5,7 @@
/*global require, module */
var Ghost = require('../../ghost'),
config = require('../config'),
api = require('../api'),
RSS = require('rss'),
_ = require('underscore'),
@ -68,7 +69,7 @@ frontendControllers = {
api.posts.read(_.pick(req.params, ['id', 'slug'])).then(function (post) {
if (post) {
ghost.doFilter('prePostsRender', post).then(function (post) {
var paths = ghost.paths().availableThemes[ghost.settings('activeTheme')];
var paths = config.paths().availableThemes[ghost.settings('activeTheme')];
if (post.page && paths.hasOwnProperty('page')) {
res.render('page', {post: post});
} else {
@ -87,7 +88,7 @@ frontendControllers = {
},
'rss': function (req, res, next) {
// Initialize RSS
var siteUrl = ghost.config().url,
var siteUrl = config().url,
pageParam = req.params.page !== undefined ? parseInt(req.params.page, 10) : 1,
feed;
//needs refact for multi user to not use first user as default

View file

@ -97,7 +97,7 @@ coreHelpers.url = function (options) {
output += blog.url;
}
if (blog.path !== '/') {
if (blog.path && blog.path !== '/') {
output += blog.path;
}
@ -219,8 +219,8 @@ coreHelpers.excerpt = function (options) {
// Returns the config value for fileStorage.
coreHelpers.fileStorage = function (context, options) {
/*jslint unparam:true*/
if (coreHelpers.ghost.config().hasOwnProperty('fileStorage')) {
return coreHelpers.ghost.config().fileStorage.toString();
if (coreHelpers.config().hasOwnProperty('fileStorage')) {
return coreHelpers.config().fileStorage.toString();
}
return "true";
};
@ -531,12 +531,15 @@ coreHelpers.helperMissing = function (arg) {
errors.logError('Missing helper: "' + arg + '"');
};
registerHelpers = function (ghost) {
registerHelpers = function (ghost, config) {
var paginationHelper;
// Expose this so our helpers can use it in their code.
coreHelpers.ghost = ghost;
// And expose config
coreHelpers.config = config;
ghost.registerThemeHelper('date', coreHelpers.date);
ghost.registerThemeHelper('encode', coreHelpers.encode);

View file

@ -12,13 +12,16 @@ function GhostMailer(opts) {
// ## E-mail transport setup
// *This promise should always resolve to avoid halting Ghost::init*.
GhostMailer.prototype.init = function (ghost) {
GhostMailer.prototype.init = function (ghost, configModule) {
this.ghost = ghost;
// TODO: fix circular reference ghost -> mail -> api -> ghost, remove this late require
this.api = require('./api');
// We currently pass in the config module to avoid
// circular references, similar to above.
this.config = configModule;
var self = this,
config = ghost.config();
config = this.config();
if (config.mail && config.mail.transport && config.mail.options) {
this.createTransport(config);
@ -95,7 +98,7 @@ GhostMailer.prototype.send = function (message) {
return when.reject(new Error('Email Error: Incomplete message data.'));
}
var from = this.ghost.config().mail.fromaddress || this.ghost.settings('email'),
var from = this.config().mail.fromaddress || this.ghost.settings('email'),
to = message.to || this.ghost.settings('email'),
sendMail = nodefn.lift(this.transport.sendMail.bind(this.transport));

View file

@ -11,6 +11,7 @@ var middleware = require('./middleware'),
path = require('path'),
hbs = require('express-hbs'),
Ghost = require('../../ghost'),
config = require('../config'),
storage = require('../storage'),
packageInfo = require('../../../package.json'),
BSStore = require('../../bookshelf-session'),
@ -66,16 +67,16 @@ function initViews(req, res, next) {
// self.globals is a hack til we have a better way of getting combined settings & config
hbsOptions = {templateOptions: {data: {blog: ghost.blogGlobals()}}};
if (ghost.themeDirectories[ghost.settings('activeTheme')].hasOwnProperty('partials')) {
if (config.paths().availableThemes[ghost.settings('activeTheme')].hasOwnProperty('partials')) {
// Check that the theme has a partials directory before trying to use it
hbsOptions.partialsDir = path.join(ghost.paths().activeTheme, 'partials');
hbsOptions.partialsDir = path.join(config.paths().activeTheme, 'partials');
}
ghost.server.engine('hbs', hbs.express3(hbsOptions));
ghost.server.set('views', ghost.paths().activeTheme);
ghost.server.set('views', config.paths().activeTheme);
} else {
ghost.server.engine('hbs', hbs.express3({partialsDir: ghost.paths().adminViews + 'partials'}));
ghost.server.set('views', ghost.paths().adminViews);
ghost.server.engine('hbs', hbs.express3({partialsDir: config.paths().adminViews + 'partials'}));
ghost.server.set('views', config.paths().adminViews);
}
next();
@ -94,7 +95,7 @@ function activateTheme() {
ghost.server.set('activeTheme', ghost.settings('activeTheme'));
ghost.server.enable(ghost.server.get('activeTheme'));
if (stackLocation) {
ghost.server.stack[stackLocation].handle = middleware.whenEnabled(ghost.server.get('activeTheme'), middleware.staticTheme(ghost));
ghost.server.stack[stackLocation].handle = middleware.whenEnabled(ghost.server.get('activeTheme'), middleware.staticTheme());
}
// Update user error template
@ -123,7 +124,7 @@ function manageAdminAndTheme(req, res, next) {
// Check if the theme changed
if (ghost.settings('activeTheme') !== ghost.server.get('activeTheme')) {
// Change theme
if (!ghost.themeDirectories.hasOwnProperty(ghost.settings('activeTheme'))) {
if (!config.paths().availableThemes.hasOwnProperty(ghost.settings('activeTheme'))) {
if (!res.isAdmin) {
// Throw an error if the theme is not available, but not on the admin UI
errors.logAndThrowError('The currently active theme ' + ghost.settings('activeTheme') + ' is missing.');
@ -139,7 +140,7 @@ function manageAdminAndTheme(req, res, next) {
module.exports = function (server) {
var oneYear = 31536000000,
root = ghost.blogGlobals().path === '/' ? '' : ghost.blogGlobals().path,
corePath = path.join(ghost.paths().appRoot, 'core');
corePath = path.join(config.paths().appRoot, 'core');
// Logging configuration
if (server.get('env') !== 'development') {
@ -169,7 +170,7 @@ module.exports = function (server) {
server.use(root + '/ghost', middleware.whenEnabled('admin', express['static'](path.join(corePath, '/client/assets'))));
// Theme only config
server.use(middleware.whenEnabled(server.get('activeTheme'), middleware.staticTheme(ghost)));
server.use(middleware.whenEnabled(server.get('activeTheme'), middleware.staticTheme()));
// Add in all trailing slashes
server.use(slashes());

View file

@ -5,6 +5,7 @@
var _ = require('underscore'),
express = require('express'),
Ghost = require('../../ghost'),
config = require('../config'),
path = require('path'),
ghost = new Ghost();
@ -106,20 +107,19 @@ var middleware = {
};
},
staticTheme: function (g) {
var ghost = g;
staticTheme: function () {
return function blackListStatic(req, res, next) {
if (isBlackListedFileType(req.url)) {
return next();
}
return middleware.forwardToExpressStatic(ghost, req, res, next);
return middleware.forwardToExpressStatic(req, res, next);
};
},
// to allow unit testing
forwardToExpressStatic: function (ghost, req, res, next) {
return express['static'](ghost.paths().activeTheme)(req, res, next);
forwardToExpressStatic: function (req, res, next) {
return express['static'](config.paths().activeTheme)(req, res, next);
}
};

View file

@ -3,6 +3,7 @@ var path = require('path'),
_ = require('underscore'),
when = require('when'),
createProxy = require('./proxy'),
config = require('../config'),
ghostInstance,
loader;
@ -24,7 +25,7 @@ function getPluginRelativePath(name, relativeTo, ghost) {
ghost = ghost || getGhostInstance();
relativeTo = relativeTo || __dirname;
return path.relative(relativeTo, path.join(ghost.paths().pluginPath, name));
return path.relative(relativeTo, path.join(config.paths().pluginPath, name));
}

View file

@ -1,4 +1,5 @@
var fs = require('fs'),
var fs = require('fs'),
config = require('../../server/config'),
/**
* Create new Polyglot object
* @type {Polyglot}
@ -9,7 +10,7 @@ I18n = function (ghost) {
// TODO: validate
var lang = ghost.settings('defaultLang'),
path = ghost.paths().lang,
path = config.paths().lang,
langFilePath = path + lang + '.json';
return function (req, res, next) {

View file

@ -7,7 +7,8 @@ var testUtils = require('../utils'),
_ = require('underscore'),
// Stuff we are testing
Ghost = require('../../ghost');
config = require('../../server/config'),
Ghost = require('../../ghost');
describe("Ghost API", function () {
var testTemplatePath = 'core/test/utils/fixtures/',
@ -177,7 +178,7 @@ describe("Ghost API", function () {
should.exist(ghost.loadTemplate, 'load template function exists');
// In order for the test to work, need to replace the path to the template
pathsStub = sandbox.stub(ghost, "paths", function () {
pathsStub = sandbox.stub(config, "paths", function () {
return {
// Forcing the theme path to be the same
activeTheme: path.join(process.cwd(), testTemplatePath),
@ -209,7 +210,7 @@ describe("Ghost API", function () {
should.exist(ghost.loadTemplate, 'load template function exists');
// In order for the test to work, need to replace the path to the template
pathsStub = sandbox.stub(ghost, "paths", function () {
pathsStub = sandbox.stub(config, "paths", function () {
return {
activeTheme: path.join(process.cwd(), themeTemplatePath),
helperTemplates: path.join(process.cwd(), testTemplatePath)

View file

@ -16,7 +16,8 @@ var testUtils = require('../utils'),
fakeSettings,
fakeSendmail,
sandbox = sinon.sandbox.create(),
ghost;
ghost,
config;
// Mock SMTP config
SMTP = {
@ -51,9 +52,7 @@ describe("Mail", function () {
ghost = new Ghost();
sandbox.stub(ghost, "config", function () {
return fakeConfig;
});
config = sinon.stub().returns(fakeConfig);
sandbox.stub(ghost, "settings", function () {
return fakeSettings;
@ -81,7 +80,7 @@ describe("Mail", function () {
it('should setup SMTP transport on initialization', function (done) {
fakeConfig.mail = SMTP;
ghost.mail.init(ghost).then(function () {
ghost.mail.init(ghost, config).then(function () {
ghost.mail.should.have.property('transport');
ghost.mail.transport.transportType.should.eql('SMTP');
ghost.mail.transport.sendMail.should.be.a.function;
@ -91,7 +90,7 @@ describe("Mail", function () {
it('should setup sendmail transport on initialization', function (done) {
fakeConfig.mail = SENDMAIL;
ghost.mail.init(ghost).then(function () {
ghost.mail.init(ghost, config).then(function () {
ghost.mail.should.have.property('transport');
ghost.mail.transport.transportType.should.eql('SENDMAIL');
ghost.mail.transport.sendMail.should.be.a.function;
@ -101,7 +100,7 @@ describe("Mail", function () {
it('should fallback to sendmail if no config set', function (done) {
fakeConfig.mail = null;
ghost.mail.init(ghost).then(function () {
ghost.mail.init(ghost, config).then(function () {
ghost.mail.should.have.property('transport');
ghost.mail.transport.transportType.should.eql('SENDMAIL');
ghost.mail.transport.options.path.should.eql(fakeSendmail);
@ -111,7 +110,7 @@ describe("Mail", function () {
it('should fallback to sendmail if config is empty', function (done) {
fakeConfig.mail = {};
ghost.mail.init(ghost).then(function () {
ghost.mail.init(ghost, config).then(function () {
ghost.mail.should.have.property('transport');
ghost.mail.transport.transportType.should.eql('SENDMAIL');
ghost.mail.transport.options.path.should.eql(fakeSendmail);
@ -123,7 +122,7 @@ describe("Mail", function () {
fakeConfig.mail = {};
ghost.mail.detectSendmail.restore();
sandbox.stub(ghost.mail, "detectSendmail", when.reject);
ghost.mail.init(ghost).then(function () {
ghost.mail.init(ghost, config).then(function () {
should.not.exist(ghost.mail.transport);
done();
}).then(null, done);
@ -136,7 +135,7 @@ describe("Mail", function () {
sandbox.stub(ghost.mail, 'isWindows', function () {
return true;
});
ghost.mail.init(ghost).then(function () {
ghost.mail.init(ghost, config).then(function () {
should.not.exist(ghost.mail.transport);
done();
}).then(null, done);
@ -145,7 +144,7 @@ describe("Mail", function () {
it('should fail to send messages when no transport is set', function (done) {
ghost.mail.detectSendmail.restore();
sandbox.stub(ghost.mail, "detectSendmail", when.reject);
ghost.mail.init(ghost).then(function () {
ghost.mail.init(ghost, config).then(function () {
ghost.mail.send().then(function () {
should.fail();
done();

View file

@ -277,9 +277,9 @@ describe('Middleware', function () {
url: 'myvalidfile.css'
};
middleware.staticTheme(ghostStub)(req, null, function (req, res, next) {
middleware.staticTheme(null)(req, null, function (reqArg, res, next) {
middleware.forwardToExpressStatic.calledOnce.should.be.true;
assert.deepEqual(middleware.forwardToExpressStatic.args[0][0], ghostStub);
assert.deepEqual(middleware.forwardToExpressStatic.args[0][0], req);
return done();
});
});

View file

@ -283,7 +283,7 @@ describe('Core Helpers', function () {
});
it('should output an absolute URL if the option is present', function () {
var configStub = sinon.stub(ghost, "config", function () {
var configStub = sinon.stub(ghost, "blogGlobals", function () {
return { url: 'http://testurl.com' };
}),
@ -580,4 +580,4 @@ describe('Core Helpers', function () {
});
});
});
});

View file

@ -2,12 +2,12 @@
// Orchestrates the loading of Ghost
// When run from command line.
var configLoader = require('./core/config-loader.js'),
errors = require('./core/server/errorHandling');
var configLoader = require('./core/server/config/loader'),
errors = require('./core/server/errorHandling');
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
configLoader.loadConfig().then(function () {
configLoader().then(function () {
var ghost = require('./core/server');
ghost();
}).otherwise(errors.logAndThrowError);