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'),
|
||||
schema = require('../data/schema'),
|
||||
config = require('../config'),
|
||||
debugPath = config.paths().webroot + '/ghost/debug/',
|
||||
|
||||
db;
|
||||
|
||||
|
@ -34,7 +35,7 @@ db = {
|
|||
id: 'per-' + (notifications.length + 1)
|
||||
};
|
||||
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)
|
||||
};
|
||||
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 () {
|
||||
res.redirect(config.paths().webroot + '/ghost/debug/');
|
||||
res.redirect(debugPath);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,8 +6,10 @@ var path = require('path'),
|
|||
url = require('url'),
|
||||
requireTree = require('../require-tree'),
|
||||
appRoot = path.resolve(__dirname, '../../../'),
|
||||
themePath = path.resolve(appRoot + '/content/themes'),
|
||||
pluginPath = path.resolve(appRoot + '/content/plugins'),
|
||||
corePath = path.resolve(appRoot, 'core/'),
|
||||
contentPath = path.resolve(appRoot, 'content/'),
|
||||
themePath = path.resolve(contentPath + '/themes'),
|
||||
pluginPath = path.resolve(contentPath + '/plugins'),
|
||||
themeDirectories = requireTree(themePath),
|
||||
pluginDirectories = requireTree(pluginPath),
|
||||
localPath = '',
|
||||
|
@ -23,11 +25,15 @@ function getPaths() {
|
|||
'webroot': localPath === '/' ? '' : localPath,
|
||||
'config': path.join(appRoot, 'config.js'),
|
||||
'configExample': path.join(appRoot, 'config.example.js'),
|
||||
'contentPath': contentPath,
|
||||
'corePath': corePath,
|
||||
'themePath': themePath,
|
||||
'pluginPath': pluginPath,
|
||||
'adminViews': path.join(appRoot, '/core/server/views/'),
|
||||
'helperTemplates': path.join(appRoot, '/core/server/helpers/tpl/'),
|
||||
'lang': path.join(appRoot, '/core/shared/lang/'),
|
||||
'imagesPath': path.resolve(contentPath, 'images/'),
|
||||
'imagesRelPath': 'content/images',
|
||||
'adminViews': path.join(corePath, '/server/views/'),
|
||||
'helperTemplates': path.join(corePath, '/server/helpers/tpl/'),
|
||||
'lang': path.join(corePath, '/shared/lang/'),
|
||||
'availableThemes': availableThemes,
|
||||
'availablePlugins': availablePlugins
|
||||
};
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
/*jslint regexp: true */
|
||||
var _ = require('underscore'),
|
||||
colors = require('colors'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
var _ = require('underscore'),
|
||||
colors = require('colors'),
|
||||
fs = require('fs'),
|
||||
configPaths = require('./config/paths'),
|
||||
path = require('path'),
|
||||
errors,
|
||||
|
||||
// Paths for views
|
||||
appRoot = path.resolve(__dirname, '..', '..'),
|
||||
themePath = path.resolve(appRoot, 'content', 'themes'),
|
||||
adminTemplatePath = path.resolve(appRoot, 'core', 'server', 'views'),
|
||||
defaultErrorTemplatePath = path.resolve(adminTemplatePath, 'user-error.hbs'),
|
||||
userErrorTemplatePath = path.resolve(themePath, 'error.hbs'),
|
||||
defaultErrorTemplatePath = path.resolve(configPaths().adminViews, 'user-error.hbs'),
|
||||
userErrorTemplatePath = path.resolve(configPaths().themePath, 'error.hbs'),
|
||||
userErrorTemplateExists;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +16,7 @@ var _ = require('underscore'),
|
|||
*/
|
||||
errors = {
|
||||
updateActiveTheme: function (activeTheme) {
|
||||
userErrorTemplatePath = path.resolve(themePath, activeTheme, 'error.hbs');
|
||||
userErrorTemplatePath = path.resolve(configPaths().themePath, activeTheme, 'error.hbs');
|
||||
userErrorTemplateExists = undefined;
|
||||
},
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ function setup(server) {
|
|||
// Are we using sockets? Custom socket or the default?
|
||||
function getSocket() {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ function checkSSL(req, res, next) {
|
|||
module.exports = function (server, dbHash) {
|
||||
var oneYear = 31536000000,
|
||||
root = config.paths().webroot,
|
||||
corePath = path.join(config.paths().appRoot, 'core');
|
||||
corePath = config.paths().corePath;
|
||||
|
||||
// Cache express server instance
|
||||
expressServer = server;
|
||||
|
|
|
@ -8,10 +8,10 @@ var _ = require('underscore'),
|
|||
path = require('path'),
|
||||
when = require('when'),
|
||||
errors = require('../errorHandling'),
|
||||
config = require('../config'),
|
||||
baseStore = require('./base'),
|
||||
|
||||
localFileStore,
|
||||
localDir = 'content/images';
|
||||
localFileStore;
|
||||
|
||||
localFileStore = _.extend(baseStore, {
|
||||
// ### Save
|
||||
|
@ -20,7 +20,7 @@ localFileStore = _.extend(baseStore, {
|
|||
// - returns a promise which ultimately returns the full url to the uploaded image
|
||||
'save': function (image) {
|
||||
var saved = when.defer(),
|
||||
targetDir = this.getTargetDir(localDir);
|
||||
targetDir = this.getTargetDir(config.paths().imagesRelPath);
|
||||
|
||||
this.getUniqueFileName(this, image, targetDir).then(function (filename) {
|
||||
nodefn.call(fs.mkdirs, targetDir).then(function () {
|
||||
|
@ -55,7 +55,7 @@ localFileStore = _.extend(baseStore, {
|
|||
|
||||
// middleware for serving the files
|
||||
'serve': function () {
|
||||
return express['static'](path.join(__dirname, '/../../../', localDir));
|
||||
return express['static'](config.paths().imagesPath);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue