Ghost/core/server/config/paths.js
Hannah Wolfe 158b92cc55 Fixing notifications on ugly debug page
- also fixes an issue where the debug tools didn't redirect properly when Ghost was operating in a subdirectory.
2013-12-30 00:00:43 +00:00

64 lines
2.2 KiB
JavaScript

// Contains all path information to be used throughout
// the codebase.
var path = require('path'),
when = require('when'),
url = require('url'),
requireTree = require('../require-tree'),
appRoot = path.resolve(__dirname, '../../../'),
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 = '',
availableThemes,
availablePlugins;
function paths() {
var subdir = localPath === '/' ? '' : localPath;
return {
'appRoot': appRoot,
'subdir': subdir,
'config': path.join(appRoot, 'config.js'),
'configExample': path.join(appRoot, 'config.example.js'),
'contentPath': contentPath,
'corePath': corePath,
'themePath': themePath,
'pluginPath': pluginPath,
'imagesPath': path.resolve(contentPath, 'images/'),
'imagesRelPath': 'content/images',
'adminViews': path.join(corePath, '/server/views/'),
'helperTemplates': path.join(corePath, '/server/helpers/tpl/'),
'exportPath': path.join(corePath, '/server/data/export/'),
'lang': path.join(corePath, '/shared/lang/'),
'debugPath': subdir + '/ghost/debug/',
'availableThemes': availableThemes,
'availablePlugins': availablePlugins
};
}
// TODO: remove configURL and give direct access to config object?
// TODO: not called when executing tests
function update(configURL) {
localPath = url.parse(configURL).path;
// Remove trailing slash
if (localPath !== '/') {
localPath = localPath.replace(/\/$/, '');
}
return when.all([themeDirectories, pluginDirectories]).then(function (paths) {
availableThemes = paths[0];
availablePlugins = paths[1];
return;
});
}
module.exports = paths;
module.exports.update = update;