Naming cleanup

closes #4069
- Rename everything from camelCase to lowercase + dashes
- Remove usage of `server`, `app` and `instance`
This commit is contained in:
Fabian Becker 2014-09-19 16:17:58 +00:00
parent a3093b9b42
commit 2c3abeee03
40 changed files with 122 additions and 155 deletions

View File

@ -4,16 +4,16 @@ var _ = require('lodash'),
path = require('path'),
Promise = require('bluebird'),
hbs = require('express-hbs'),
NotFoundError = require('./notfounderror'),
BadRequestError = require('./badrequesterror'),
InternalServerError = require('./internalservererror'),
NoPermissionError = require('./nopermissionerror'),
RequestEntityTooLargeError = require('./requesttoolargeerror'),
UnauthorizedError = require('./unauthorizederror'),
ValidationError = require('./validationerror'),
UnsupportedMediaTypeError = require('./unsupportedmediaerror'),
EmailError = require('./emailerror'),
DataImportError = require('./dataimporterror'),
NotFoundError = require('./not-found-error'),
BadRequestError = require('./bad-request-error'),
InternalServerError = require('./internal-server-error'),
NoPermissionError = require('./no-permission-error'),
RequestEntityTooLargeError = require('./request-too-large-error'),
UnauthorizedError = require('./unauthorized-error'),
ValidationError = require('./validation-error'),
UnsupportedMediaTypeError = require('./unsupported-media-type-error'),
EmailError = require('./email-error'),
DataImportError = require('./data-import-error'),
config,
errors,

View File

@ -4,8 +4,8 @@ var Promise = require('bluebird'),
packageInfo = require('../../package.json'),
config = require('./config');
function GhostServer(app) {
this.app = app;
function GhostServer(rootApp) {
this.rootApp = rootApp;
this.httpServer = null;
this.connections = [];
this.upgradeWarning = setTimeout(this.logUpgradeWarning.bind(this), 5000);
@ -98,7 +98,7 @@ GhostServer.prototype.logUpgradeWarning = function () {
*/
GhostServer.prototype.start = function (externalApp) {
var self = this,
app = externalApp ? externalApp : self.app;
rootApp = externalApp ? externalApp : self.rootApp;
// ## Start Ghost App
return new Promise(function (resolve) {
@ -110,13 +110,13 @@ GhostServer.prototype.start = function (externalApp) {
// We can ignore this.
}
self.httpServer = app.listen(
self.httpServer = rootApp.listen(
config.getSocket()
);
fs.chmod(config.getSocket(), '0660');
} else {
self.httpServer = app.listen(
self.httpServer = rootApp.listen(
config.server.port,
config.server.host
);

View File

@ -19,7 +19,7 @@ var crypto = require('crypto'),
permissions = require('./permissions'),
apps = require('./apps'),
packageInfo = require('../../package.json'),
GhostServer = require('./GhostServer'),
GhostServer = require('./ghost-server'),
// Variables
dbHash;
@ -131,8 +131,8 @@ function initNotifications() {
// Finally it returns an instance of GhostServer
function init(options) {
// Get reference to an express app instance.
var server = options.app ? options.app : express(),
adminExpress = express(),
var blogApp = express(),
adminApp = express(),
// create a hash for cache busting assets
assetHash = (crypto.createHash('md5').update(packageInfo.version + Date.now()).digest('hex')).substring(0, 10);
@ -184,22 +184,22 @@ function init(options) {
// enabled gzip compression by default
if (config.server.compress !== false) {
server.use(compress());
blogApp.use(compress());
}
// ## View engine
// set the view engine
server.set('view engine', 'hbs');
blogApp.set('view engine', 'hbs');
// Create a hbs instance for admin and init view engine
adminExpress.set('view engine', 'hbs');
adminExpress.engine('hbs', adminHbs.express3({}));
adminApp.set('view engine', 'hbs');
adminApp.engine('hbs', adminHbs.express3({}));
// Load helpers
helpers.loadCoreHelpers(adminHbs, assetHash);
// ## Middleware and Routing
middleware(server, adminExpress);
middleware(blogApp, adminApp);
// Log all theme errors and warnings
_.each(config.paths.availableThemes._messages.errors, function (error) {
@ -210,7 +210,7 @@ function init(options) {
errors.logWarn(warn.message, warn.context, warn.help);
});
return new GhostServer(server);
return new GhostServer(blogApp);
});
}

View File

@ -22,10 +22,10 @@ var api = require('../api'),
passport = require('passport'),
oauth = require('./oauth'),
oauth2orize = require('oauth2orize'),
authStrategies = require('./authStrategies'),
authStrategies = require('./auth-strategies'),
utils = require('../utils'),
expressServer,
blogApp,
setupMiddleware;
// ##Custom Middleware
@ -50,7 +50,7 @@ function activateTheme(activeTheme) {
themePartials = path.join(config.paths.themePath, activeTheme, 'partials');
// clear the view cache
expressServer.cache = {};
blogApp.cache = {};
// set view engine
hbsOptions = {partialsDir: [config.paths.helperTemplates]};
@ -62,13 +62,13 @@ function activateTheme(activeTheme) {
}
});
expressServer.engine('hbs', hbs.express3(hbsOptions));
blogApp.engine('hbs', hbs.express3(hbsOptions));
// Update user error template
errors.updateActiveTheme(activeTheme);
// Set active theme variable on the express server
expressServer.set('activeTheme', activeTheme);
blogApp.set('activeTheme', activeTheme);
}
// ### decideIsAdmin Middleware
// Uses the URL to detect whether this response should be an admin response
@ -89,7 +89,7 @@ function configHbsForContext(req, res, next) {
}
hbs.updateTemplateOptions({data: {blog: themeData}});
expressServer.set('views', path.join(config.paths.themePath, expressServer.get('activeTheme')));
blogApp.set('views', path.join(config.paths.themePath, blogApp.get('activeTheme')));
// Pass 'secure' flag to the view engine
// so that templates can choose 'url' vs 'urlSSL'
@ -99,14 +99,14 @@ function configHbsForContext(req, res, next) {
}
// ### updateActiveTheme
// Updates the expressServer's activeTheme variable and subsequently
// Updates the blogApp's activeTheme variable and subsequently
// activates that theme's views with the hbs templating engine if it
// is not yet activated.
function updateActiveTheme(req, res, next) {
api.settings.read({context: {internal: true}, key: 'activeTheme'}).then(function (response) {
var activeTheme = response.settings[0];
// Check if the theme changed
if (activeTheme.value !== expressServer.get('activeTheme')) {
if (activeTheme.value !== blogApp.get('activeTheme')) {
// Change theme
if (!config.paths.availableThemes.hasOwnProperty(activeTheme.value)) {
if (!res.isAdmin) {
@ -121,7 +121,7 @@ function updateActiveTheme(req, res, next) {
}).catch(function (err) {
// Trying to start up without the active theme present, setup a simple hbs instance
// and render an error page straight away.
expressServer.engine('hbs', hbs.express3());
blogApp.engine('hbs', hbs.express3());
next(err);
});
}
@ -235,7 +235,7 @@ function serveSharedFile(file, type, maxAge) {
};
}
setupMiddleware = function (server, adminExpress) {
setupMiddleware = function (blogAppInstance, adminApp) {
var logging = config.logging,
corePath = config.paths.corePath,
oauthServer = oauth2orize.createServer();
@ -244,98 +244,98 @@ setupMiddleware = function (server, adminExpress) {
authStrategies = authStrategies;
// Cache express server instance
expressServer = server;
middleware.cacheServer(expressServer);
blogApp = blogAppInstance;
middleware.cacheBlogApp(blogApp);
middleware.cacheOauthServer(oauthServer);
oauth.init(oauthServer, middleware.resetSpamCounter);
// Make sure 'req.secure' is valid for proxied requests
// (X-Forwarded-Proto header will be checked, if present)
expressServer.enable('trust proxy');
blogApp.enable('trust proxy');
// Logging configuration
if (logging !== false) {
if (expressServer.get('env') !== 'development') {
expressServer.use(logger('combined', logging));
if (blogApp.get('env') !== 'development') {
blogApp.use(logger('combined', logging));
} else {
expressServer.use(logger('dev', logging));
blogApp.use(logger('dev', logging));
}
}
// Favicon
expressServer.use(serveSharedFile('favicon.ico', 'image/x-icon', utils.ONE_DAY_S));
blogApp.use(serveSharedFile('favicon.ico', 'image/x-icon', utils.ONE_DAY_S));
// Static assets
expressServer.use('/shared', express['static'](path.join(corePath, '/shared'), {maxAge: utils.ONE_HOUR_MS}));
expressServer.use('/content/images', storage.getStorage().serve());
expressServer.use('/ghost/scripts', express['static'](path.join(corePath, '/built/scripts'), {maxAge: utils.ONE_YEAR_MS}));
expressServer.use('/public', express['static'](path.join(corePath, '/built/public'), {maxAge: utils.ONE_YEAR_MS}));
blogApp.use('/shared', express['static'](path.join(corePath, '/shared'), {maxAge: utils.ONE_HOUR_MS}));
blogApp.use('/content/images', storage.getStorage().serve());
blogApp.use('/ghost/scripts', express['static'](path.join(corePath, '/built/scripts'), {maxAge: utils.ONE_YEAR_MS}));
blogApp.use('/public', express['static'](path.join(corePath, '/built/public'), {maxAge: utils.ONE_YEAR_MS}));
// First determine whether we're serving admin or theme content
expressServer.use(decideIsAdmin);
expressServer.use(updateActiveTheme);
expressServer.use(configHbsForContext);
blogApp.use(decideIsAdmin);
blogApp.use(updateActiveTheme);
blogApp.use(configHbsForContext);
// Admin only config
expressServer.use('/ghost', express['static'](path.join(corePath, '/client/assets'), {maxAge: utils.ONE_YEAR_MS}));
blogApp.use('/ghost', express['static'](path.join(corePath, '/client/assets'), {maxAge: utils.ONE_YEAR_MS}));
// Force SSL
// NOTE: Importantly this is _after_ the check above for admin-theme static resources,
// 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!
expressServer.use(checkSSL);
adminExpress.set('views', config.paths.adminViews);
blogApp.use(checkSSL);
adminApp.set('views', config.paths.adminViews);
// Theme only config
expressServer.use(middleware.staticTheme());
blogApp.use(middleware.staticTheme());
// Serve robots.txt if not found in theme
expressServer.use(serveSharedFile('robots.txt', 'text/plain', utils.ONE_YEAR_S));
blogApp.use(serveSharedFile('robots.txt', 'text/plain', utils.ONE_YEAR_S));
// Add in all trailing slashes, properly include the subdir path
// in the redirect.
expressServer.use(slashes(true, {
blogApp.use(slashes(true, {
headers: {
'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S
},
base: config.paths.subdir
}));
expressServer.use(uncapitalise);
blogApp.use(uncapitalise);
// Body parsing
expressServer.use(bodyParser.json());
expressServer.use(bodyParser.urlencoded({extended: true}));
blogApp.use(bodyParser.json());
blogApp.use(bodyParser.urlencoded({extended: true}));
expressServer.use(passport.initialize());
blogApp.use(passport.initialize());
// ### Caching
expressServer.use(middleware.cacheControl('public'));
adminExpress.use(middleware.cacheControl('private'));
blogApp.use(middleware.cacheControl('public'));
adminApp.use(middleware.cacheControl('private'));
// enable authentication
expressServer.use(middleware.authenticate);
blogApp.use(middleware.authenticate);
// local data
expressServer.use(ghostLocals);
blogApp.use(ghostLocals);
// ### Routing
// Set up API routes
expressServer.use(routes.apiBaseUri, routes.api(middleware));
blogApp.use(routes.apiBaseUri, routes.api(middleware));
// Mount admin express app to /ghost and set up routes
adminExpress.use(middleware.redirectToSetup);
adminExpress.use(routes.admin());
expressServer.use('/ghost', adminExpress);
adminApp.use(middleware.redirectToSetup);
adminApp.use(routes.admin());
blogApp.use('/ghost', adminApp);
// Set up Frontend routes
expressServer.use(routes.frontend());
blogApp.use(routes.frontend());
// ### Error handling
// 404 Handler
expressServer.use(errors.error404);
blogApp.use(errors.error404);
// 500 Handler
expressServer.use(errors.error500);
blogApp.use(errors.error500);
};
module.exports = setupMiddleware;

View File

@ -13,7 +13,7 @@ var _ = require('lodash'),
utils = require('../utils'),
middleware,
expressServer,
blogApp,
oauthServer,
loginSecurity = [],
forgottenSecurity = [];
@ -24,8 +24,8 @@ function isBlackListedFileType(file) {
return _.contains(blackListedFileTypes, ext);
}
function cacheServer(server) {
expressServer = server;
function cacheBlogApp(app) {
blogApp = app;
}
function cacheOauthServer(server) {
@ -105,7 +105,7 @@ middleware = {
whenEnabled: function (setting, fn) {
return function settingEnabled(req, res, next) {
// Set from server/middleware/index.js for now
if (expressServer.enabled(setting)) {
if (blogApp.enabled(setting)) {
fn(req, res, next);
} else {
next();
@ -263,5 +263,5 @@ middleware = {
};
module.exports = middleware;
module.exports.cacheServer = cacheServer;
module.exports.cacheBlogApp = cacheBlogApp;
module.exports.cacheOauthServer = cacheOauthServer;

View File

@ -282,13 +282,13 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
add: function (data, options) {
data = this.filterData(data);
options = this.filterOptions(options, 'add');
var instance = this.forge(data);
var model = this.forge(data);
// We allow you to disable timestamps when importing posts so that the new posts `updated_at` value is the same
// as the import json blob. More details refer to https://github.com/TryGhost/Ghost/issues/1696
if (options.importing) {
instance.hasTimestamps = false;
model.hasTimestamps = false;
}
return instance.save(null, options);
return model.save(null, options);
},
/**

View File

@ -51,7 +51,7 @@ CanThisResult = function () {
CanThisResult.prototype.buildObjectTypeHandlers = function (objTypes, actType, context, permissionLoad) {
// @TODO: remove this lazy require
var objectTypeModelMap = require('./objectTypeModelMap');
var objectTypeModelMap = require('./object-type-model-map');
// Iterate through the object types, i.e. ['post', 'tag', 'user']
return _.reduce(objTypes, function (objTypeHandlers, objType) {

View File

@ -4,7 +4,7 @@ var errors = require('../errors'),
function getStorage(storageChoice) {
// TODO: this is where the check for storage apps should go
// Local file system is the default. Fow now that is all we support.
storageChoice = 'localfilesystem';
storageChoice = 'local-file-store';
if (storage[storageChoice]) {
return storage[storageChoice];

View File

@ -6,7 +6,6 @@
// But then again testing real code, rather than mock code, might be more useful...
var request = require('supertest'),
express = require('express'),
should = require('should'),
testUtils = require('../../utils'),
@ -47,11 +46,9 @@ describe('Admin Routing', function () {
}
before(function (done) {
var app = express();
ghost({app: app}).then(function () {
ghost().then(function (ghostServer) {
// Setup the request object with the ghost express app
request = request(app);
request = request(ghostServer.rootApp);
done();
}).catch(function (e) {

View File

@ -1,7 +1,6 @@
/*global describe, it, before, after */
/*jshint expr:true*/
var supertest = require('supertest'),
express = require('express'),
should = require('should'),
testUtils = require('../../../utils'),
user = testUtils.DataGenerator.forModel.users[0],
@ -12,12 +11,10 @@ describe('Authentication API', function () {
var accesstoken = '';
before(function (done) {
var app = express();
// starting ghost automatically populates the db
// TODO: prevent db init, and manage bringing up the DB with fixtures ourselves
ghost({app: app}).then(function () {
request = supertest.agent(app);
ghost().then(function (ghostServer) {
request = supertest.agent(ghostServer.rootApp);
}).then(function () {
return testUtils.doAuth(request);
}).then(function (token) {

View File

@ -1,7 +1,6 @@
/*global describe, it, before, after */
/*jshint expr:true*/
var supertest = require('supertest'),
express = require('express'),
should = require('should'),
testUtils = require('../../../utils'),
ghost = require('../../../../../core'),
@ -11,12 +10,10 @@ describe('DB API', function () {
var accesstoken = '';
before(function (done) {
var app = express();
// starting ghost automatically populates the db
// TODO: prevent db init, and manage bringing up the DB with fixtures ourselves
ghost({app: app}).then(function () {
request = supertest.agent(app);
ghost().then(function (ghostServer) {
request = supertest.agent(ghostServer.rootApp);
}).then(function () {
return testUtils.doAuth(request);
}).then(function (token) {

View File

@ -6,7 +6,6 @@
// But then again testing real code, rather than mock code, might be more useful...
var supertest = require('supertest'),
express = require('express'),
should = require('should'),
testUtils = require('../../../utils'),
@ -15,10 +14,8 @@ var supertest = require('supertest'),
describe('Unauthorized', function () {
before(function (done) {
var app = express();
ghost({app: app}).then(function () {
request = supertest.agent(app);
ghost().then(function (ghostServer) {
request = supertest.agent(ghostServer.rootApp);
done();
});

View File

@ -2,7 +2,6 @@
/*jshint expr:true*/
var testUtils = require('../../../utils'),
supertest = require('supertest'),
express = require('express'),
ghost = require('../../../../../core'),
@ -12,12 +11,10 @@ describe('Notifications API', function () {
var accesstoken = '';
before(function (done) {
var app = express();
// starting ghost automatically populates the db
// TODO: prevent db init, and manage bringing up the DB with fixtures ourselves
ghost({app: app}).then(function () {
request = supertest.agent(app);
ghost().then(function (ghostServer) {
request = supertest.agent(ghostServer.rootApp);
}).then(function () {
return testUtils.doAuth(request);
}).then(function (token) {

View File

@ -3,7 +3,6 @@
var testUtils = require('../../../utils'),
should = require('should'),
supertest = require('supertest'),
express = require('express'),
_ = require('lodash'),
ghost = require('../../../../../core'),
@ -14,12 +13,10 @@ describe('Post API', function () {
var accesstoken = '';
before(function (done) {
var app = express();
// starting ghost automatically populates the db
// TODO: prevent db init, and manage bringing up the DB with fixtures ourselves
ghost({app: app}).then(function () {
request = supertest.agent(app);
ghost().then(function (ghostServer) {
request = supertest.agent(ghostServer.rootApp);
}).then(function () {
return testUtils.doAuth(request, 'posts');
}).then(function (token) {

View File

@ -3,7 +3,6 @@
var testUtils = require('../../../utils'),
should = require('should'),
supertest = require('supertest'),
express = require('express'),
ghost = require('../../../../../core'),
@ -13,12 +12,10 @@ describe('Settings API', function () {
var accesstoken = '';
before(function (done) {
var app = express();
// starting ghost automatically populates the db
// TODO: prevent db init, and manage bringing up the DB with fixtures ourselves
ghost({app: app}).then(function () {
request = supertest.agent(app);
ghost().then(function (ghostServer) {
request = supertest.agent(ghostServer.rootApp);
}).then(function () {
return testUtils.doAuth(request);
}).then(function (token) {

View File

@ -3,7 +3,6 @@
var testUtils = require('../../../utils'),
should = require('should'),
supertest = require('supertest'),
express = require('express'),
ghost = require('../../../../../core'),
@ -13,12 +12,10 @@ describe('Slug API', function () {
var accesstoken = '';
before(function (done) {
var app = express();
// starting ghost automatically populates the db
// TODO: prevent db init, and manage bringing up the DB with fixtures ourselves
ghost({app: app}).then(function () {
request = supertest.agent(app);
ghost().then(function (ghostServer) {
request = supertest.agent(ghostServer.rootApp);
}).then(function () {
return testUtils.doAuth(request);
}).then(function (token) {

View File

@ -3,7 +3,6 @@
var testUtils = require('../../../utils'),
should = require('should'),
supertest = require('supertest'),
express = require('express'),
ghost = require('../../../../../core'),
@ -13,12 +12,10 @@ describe('Tag API', function () {
var accesstoken = '';
before(function (done) {
var app = express();
// starting ghost automatically populates the db
// TODO: prevent db init, and manage bringing up the DB with fixtures ourselves
ghost({app: app}).then(function () {
request = supertest.agent(app);
ghost().then(function (ghostServer) {
request = supertest.agent(ghostServer.rootApp);
}).then(function () {
return testUtils.doAuth(request, 'posts');
}).then(function (token) {

View File

@ -3,7 +3,6 @@
var testUtils = require('../../../utils'),
should = require('should'),
supertest = require('supertest'),
express = require('express'),
ghost = require('../../../../../core'),
@ -13,12 +12,10 @@ describe('User API', function () {
var accesstoken = '';
before(function (done) {
var app = express();
// starting ghost automatically populates the db
// TODO: prevent db init, and manage bringing up the DB with fixtures ourselves
ghost({app: app}).then(function () {
request = supertest.agent(app);
ghost().then(function (ghostServer) {
request = supertest.agent(ghostServer.rootApp);
}).then(function () {
return testUtils.doAuth(request);
}).then(function (token) {

View File

@ -6,7 +6,6 @@
// But then again testing real code, rather than mock code, might be more useful...
var request = require('supertest'),
express = require('express'),
should = require('should'),
moment = require('moment'),
@ -38,11 +37,9 @@ describe('Frontend Routing', function () {
}
before(function (done) {
var app = express();
ghost({app: app}).then(function () {
ghost().then(function (ghostServer) {
// Setup the request object with the ghost express app
request = request(app);
request = request(ghostServer.rootApp);
done();
}).catch(function (e) {

View File

@ -4,7 +4,7 @@ var testUtils = require('../../utils'),
should = require('should'),
// Stuff we are testing
AppFieldsModel = require('../../../server/models/appField').AppField,
AppFieldsModel = require('../../../server/models/app-field').AppField,
context = testUtils.context.admin;
describe('App Fields Model', function () {

View File

@ -4,7 +4,7 @@ var testUtils = require('../../utils'),
should = require('should'),
// Stuff we are testing
AppSettingModel = require('../../../server/models/appSetting').AppSetting,
AppSettingModel = require('../../../server/models/app-setting').AppSetting,
context = testUtils.context.admin;
describe('App Setting Model', function () {

View File

@ -76,11 +76,11 @@ describe('Middleware', function () {
});
describe('whenEnabled', function () {
var cbFn, server;
var cbFn, blogApp;
beforeEach(function () {
cbFn = sinon.spy();
server = {
blogApp = {
enabled: function (setting) {
if (setting === 'enabled') {
return true;
@ -89,7 +89,7 @@ describe('Middleware', function () {
}
}
};
middleware.cacheServer(server);
middleware.cacheBlogApp(blogApp);
});
it('should call function if setting is enabled', function (done) {

View File

@ -7,8 +7,8 @@ var fs = require('fs-extra'),
rewire = require('rewire'),
_ = require('lodash'),
config = rewire('../../server/config'),
LocalFileStore = rewire('../../server/storage/localfilesystem'),
localfilesystem;
LocalFileStore = rewire('../../server/storage/local-file-store'),
localFileStore;
// To stop jshint complaining
should.equal(true, true);
@ -39,7 +39,7 @@ describe('Local File System Storage', function () {
// Sat Sep 07 2013 21:24
this.clock = sinon.useFakeTimers(new Date(2013, 8, 7, 21, 24).getTime());
localfilesystem = new LocalFileStore();
localFileStore = new LocalFileStore();
});
afterEach(function () {
@ -51,7 +51,7 @@ describe('Local File System Storage', function () {
});
it('should send correct path to image when date is in Sep 2013', function (done) {
localfilesystem.save(image).then(function (url) {
localFileStore.save(image).then(function (url) {
url.should.equal('/content/images/2013/09/IMAGE.jpg');
return done();
}).catch(done);
@ -59,7 +59,7 @@ describe('Local File System Storage', function () {
it('should send correct path to image when original file has spaces', function (done) {
image.name = 'AN IMAGE.jpg';
localfilesystem.save(image).then(function (url) {
localFileStore.save(image).then(function (url) {
url.should.equal('/content/images/2013/09/AN-IMAGE.jpg');
return done();
}).catch(done);
@ -68,14 +68,14 @@ describe('Local File System Storage', function () {
it('should send correct path to image when date is in Jan 2014', function (done) {
// Jan 1 2014 12:00
this.clock = sinon.useFakeTimers(new Date(2014, 0, 1, 12).getTime());
localfilesystem.save(image).then(function (url) {
localFileStore.save(image).then(function (url) {
url.should.equal('/content/images/2014/01/IMAGE.jpg');
return done();
}).catch(done);
});
it('should create month and year directory', function (done) {
localfilesystem.save(image).then(function (url) {
localFileStore.save(image).then(function (url) {
/*jshint unused:false*/
fs.mkdirs.calledOnce.should.be.true;
fs.mkdirs.args[0][0].should.equal(path.resolve('./content/images/2013/09'));
@ -84,7 +84,7 @@ describe('Local File System Storage', function () {
});
it('should copy temp file to new location', function (done) {
localfilesystem.save(image).then(function (url) {
localFileStore.save(image).then(function (url) {
/*jshint unused:false*/
fs.copy.calledOnce.should.be.true;
fs.copy.args[0][0].should.equal('tmp/123456.jpg');
@ -104,7 +104,7 @@ describe('Local File System Storage', function () {
fs.exists.withArgs(path.resolve('.\\content\\images\\2013\\Sep\\IMAGE.jpg')).yields(true);
fs.exists.withArgs(path.resolve('.\\content\\images\\2013\\Sep\\IMAGE-1.jpg')).yields(false);
localfilesystem.save(image).then(function (url) {
localFileStore.save(image).then(function (url) {
url.should.equal('/content/images/2013/09/IMAGE-1.jpg');
return done();
}).catch(done);
@ -126,7 +126,7 @@ describe('Local File System Storage', function () {
fs.exists.withArgs(path.resolve('.\\content\\images\\2013\\Sep\\IMAGE-3.jpg')).yields(true);
fs.exists.withArgs(path.resolve('.\\content\\images\\2013\\Sep\\IMAGE-4.jpg')).yields(false);
localfilesystem.save(image).then(function (url) {
localFileStore.save(image).then(function (url) {
url.should.equal('/content/images/2013/09/IMAGE-4.jpg');
return done();
}).catch(done);
@ -147,7 +147,7 @@ describe('Local File System Storage', function () {
});
it('should send the correct path to image', function (done) {
localfilesystem.save(image).then(function (url) {
localFileStore.save(image).then(function (url) {
url.should.equal('/content/images/2013/09/IMAGE.jpg');
return done();
}).catch(done);
@ -169,7 +169,7 @@ describe('Local File System Storage', function () {
it('should return url in proper format for windows', function (done) {
path.sep = '\\';
path.join.returns('content\\images\\2013\\09\\IMAGE.jpg');
localfilesystem.save(image).then(function (url) {
localFileStore.save(image).then(function (url) {
if (truePathSep === '\\') {
url.should.equal('/content/images/2013/09/IMAGE.jpg');
} else {

View File

@ -6,14 +6,14 @@ var express = require('express'),
ghost = require('./core'),
errors = require('./core/server/errors'),
// Create our parent express app instance.
server = express();
parentApp = express();
ghost().then(function (instance) {
ghost().then(function (ghostServer) {
// Mount our ghost instance on our desired subdirectory path if it exists.
server.use(instance.config.paths.subdir, instance.app);
parentApp.use(ghostServer.config.paths.subdir, ghostServer.rootApp);
// Let ghost handle starting our server instance.
instance.start(server);
ghostServer.start(parentApp);
}).catch(function (err) {
errors.logErrorAndExit(err, err.context, err.help);
});