mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Merge pull request #1636 from hswolff/standardize-path-access
Standardize file path access throughout ghost
This commit is contained in:
commit
1c52e3a980
6 changed files with 29 additions and 24 deletions
|
@ -8,6 +8,7 @@ var dataExport = require('../data/export'),
|
||||||
_ = require('underscore'),
|
_ = require('underscore'),
|
||||||
schema = require('../data/schema'),
|
schema = require('../data/schema'),
|
||||||
config = require('../config'),
|
config = require('../config'),
|
||||||
|
debugPath = config.paths().webroot + '/ghost/debug/',
|
||||||
|
|
||||||
db;
|
db;
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ db = {
|
||||||
id: 'per-' + (notifications.length + 1)
|
id: 'per-' + (notifications.length + 1)
|
||||||
};
|
};
|
||||||
return api.notifications.add(notification).then(function () {
|
return api.notifications.add(notification).then(function () {
|
||||||
res.redirect(config.paths().webroot + '/ghost/debug/');
|
res.redirect(debugPath);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -59,7 +60,7 @@ db = {
|
||||||
id: 'per-' + (notifications.length + 1)
|
id: 'per-' + (notifications.length + 1)
|
||||||
};
|
};
|
||||||
return api.notifications.add(notification).then(function () {
|
return api.notifications.add(notification).then(function () {
|
||||||
res.redirect(config.paths().webroot + '/ghost/debug/');
|
res.redirect(debugPath);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -153,7 +154,7 @@ db = {
|
||||||
};
|
};
|
||||||
|
|
||||||
return api.notifications.add(notification).then(function () {
|
return api.notifications.add(notification).then(function () {
|
||||||
res.redirect(config.paths().webroot + '/ghost/debug/');
|
res.redirect(debugPath);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,8 +6,10 @@ var path = require('path'),
|
||||||
url = require('url'),
|
url = require('url'),
|
||||||
requireTree = require('../require-tree'),
|
requireTree = require('../require-tree'),
|
||||||
appRoot = path.resolve(__dirname, '../../../'),
|
appRoot = path.resolve(__dirname, '../../../'),
|
||||||
themePath = path.resolve(appRoot + '/content/themes'),
|
corePath = path.resolve(appRoot, 'core/'),
|
||||||
pluginPath = path.resolve(appRoot + '/content/plugins'),
|
contentPath = path.resolve(appRoot, 'content/'),
|
||||||
|
themePath = path.resolve(contentPath + '/themes'),
|
||||||
|
pluginPath = path.resolve(contentPath + '/plugins'),
|
||||||
themeDirectories = requireTree(themePath),
|
themeDirectories = requireTree(themePath),
|
||||||
pluginDirectories = requireTree(pluginPath),
|
pluginDirectories = requireTree(pluginPath),
|
||||||
localPath = '',
|
localPath = '',
|
||||||
|
@ -23,11 +25,15 @@ function getPaths() {
|
||||||
'webroot': localPath === '/' ? '' : localPath,
|
'webroot': localPath === '/' ? '' : localPath,
|
||||||
'config': path.join(appRoot, 'config.js'),
|
'config': path.join(appRoot, 'config.js'),
|
||||||
'configExample': path.join(appRoot, 'config.example.js'),
|
'configExample': path.join(appRoot, 'config.example.js'),
|
||||||
|
'contentPath': contentPath,
|
||||||
|
'corePath': corePath,
|
||||||
'themePath': themePath,
|
'themePath': themePath,
|
||||||
'pluginPath': pluginPath,
|
'pluginPath': pluginPath,
|
||||||
'adminViews': path.join(appRoot, '/core/server/views/'),
|
'imagesPath': path.resolve(contentPath, 'images/'),
|
||||||
'helperTemplates': path.join(appRoot, '/core/server/helpers/tpl/'),
|
'imagesRelPath': 'content/images',
|
||||||
'lang': path.join(appRoot, '/core/shared/lang/'),
|
'adminViews': path.join(corePath, '/server/views/'),
|
||||||
|
'helperTemplates': path.join(corePath, '/server/helpers/tpl/'),
|
||||||
|
'lang': path.join(corePath, '/shared/lang/'),
|
||||||
'availableThemes': availableThemes,
|
'availableThemes': availableThemes,
|
||||||
'availablePlugins': availablePlugins
|
'availablePlugins': availablePlugins
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
/*jslint regexp: true */
|
/*jslint regexp: true */
|
||||||
var _ = require('underscore'),
|
var _ = require('underscore'),
|
||||||
colors = require('colors'),
|
colors = require('colors'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
path = require('path'),
|
configPaths = require('./config/paths'),
|
||||||
|
path = require('path'),
|
||||||
errors,
|
errors,
|
||||||
|
|
||||||
// Paths for views
|
// Paths for views
|
||||||
appRoot = path.resolve(__dirname, '..', '..'),
|
defaultErrorTemplatePath = path.resolve(configPaths().adminViews, 'user-error.hbs'),
|
||||||
themePath = path.resolve(appRoot, 'content', 'themes'),
|
userErrorTemplatePath = path.resolve(configPaths().themePath, 'error.hbs'),
|
||||||
adminTemplatePath = path.resolve(appRoot, 'core', 'server', 'views'),
|
|
||||||
defaultErrorTemplatePath = path.resolve(adminTemplatePath, 'user-error.hbs'),
|
|
||||||
userErrorTemplatePath = path.resolve(themePath, 'error.hbs'),
|
|
||||||
userErrorTemplateExists;
|
userErrorTemplateExists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +16,7 @@ var _ = require('underscore'),
|
||||||
*/
|
*/
|
||||||
errors = {
|
errors = {
|
||||||
updateActiveTheme: function (activeTheme) {
|
updateActiveTheme: function (activeTheme) {
|
||||||
userErrorTemplatePath = path.resolve(themePath, activeTheme, 'error.hbs');
|
userErrorTemplatePath = path.resolve(configPaths().themePath, activeTheme, 'error.hbs');
|
||||||
userErrorTemplateExists = undefined;
|
userErrorTemplateExists = undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ function setup(server) {
|
||||||
// Are we using sockets? Custom socket or the default?
|
// Are we using sockets? Custom socket or the default?
|
||||||
function getSocket() {
|
function getSocket() {
|
||||||
if (config().server.hasOwnProperty('socket')) {
|
if (config().server.hasOwnProperty('socket')) {
|
||||||
return _.isString(config().server.socket) ? config().server.socket : path.join(__dirname, '../content/', process.env.NODE_ENV + '.socket');
|
return _.isString(config().server.socket) ? config().server.socket : path.join(config.path().contentPath, process.env.NODE_ENV + '.socket');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ function checkSSL(req, res, next) {
|
||||||
module.exports = function (server, dbHash) {
|
module.exports = function (server, dbHash) {
|
||||||
var oneYear = 31536000000,
|
var oneYear = 31536000000,
|
||||||
root = config.paths().webroot,
|
root = config.paths().webroot,
|
||||||
corePath = path.join(config.paths().appRoot, 'core');
|
corePath = config.paths().corePath;
|
||||||
|
|
||||||
// Cache express server instance
|
// Cache express server instance
|
||||||
expressServer = server;
|
expressServer = server;
|
||||||
|
|
|
@ -8,10 +8,10 @@ var _ = require('underscore'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
when = require('when'),
|
when = require('when'),
|
||||||
errors = require('../errorHandling'),
|
errors = require('../errorHandling'),
|
||||||
|
config = require('../config'),
|
||||||
baseStore = require('./base'),
|
baseStore = require('./base'),
|
||||||
|
|
||||||
localFileStore,
|
localFileStore;
|
||||||
localDir = 'content/images';
|
|
||||||
|
|
||||||
localFileStore = _.extend(baseStore, {
|
localFileStore = _.extend(baseStore, {
|
||||||
// ### Save
|
// ### Save
|
||||||
|
@ -20,7 +20,7 @@ localFileStore = _.extend(baseStore, {
|
||||||
// - returns a promise which ultimately returns the full url to the uploaded image
|
// - returns a promise which ultimately returns the full url to the uploaded image
|
||||||
'save': function (image) {
|
'save': function (image) {
|
||||||
var saved = when.defer(),
|
var saved = when.defer(),
|
||||||
targetDir = this.getTargetDir(localDir);
|
targetDir = this.getTargetDir(config.paths().imagesRelPath);
|
||||||
|
|
||||||
this.getUniqueFileName(this, image, targetDir).then(function (filename) {
|
this.getUniqueFileName(this, image, targetDir).then(function (filename) {
|
||||||
nodefn.call(fs.mkdirs, targetDir).then(function () {
|
nodefn.call(fs.mkdirs, targetDir).then(function () {
|
||||||
|
@ -55,7 +55,7 @@ localFileStore = _.extend(baseStore, {
|
||||||
|
|
||||||
// middleware for serving the files
|
// middleware for serving the files
|
||||||
'serve': function () {
|
'serve': function () {
|
||||||
return express['static'](path.join(__dirname, '/../../../', localDir));
|
return express['static'](config.paths().imagesPath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue