mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 18:52:05 +03:00
078f464197
covers 90% of #755 - moved ghost.settings to api.settings - moved ghost.notifications to api.notifications - split up api/index.js to notifications.js, posts.js, settings.js, tags.js and users.js - added instance.globals as temp workaround for blogglobals (Known issue: blog title and blog description are updated after restart only) - added webroot to config() to remove `var root = ...` - changed `e` and `url` helper to async - updated tests
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
|
|
|
|
var path = require('path'),
|
|
when = require('when'),
|
|
url = require('url'),
|
|
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),
|
|
localPath = '',
|
|
availableThemes,
|
|
|
|
availablePlugins;
|
|
|
|
|
|
function getPaths() {
|
|
return {
|
|
'appRoot': appRoot,
|
|
'path': localPath,
|
|
'webroot': localPath === '/' ? '' : localPath,
|
|
'config': path.join(appRoot, 'config.js'),
|
|
'configExample': path.join(appRoot, 'config.example.js'),
|
|
'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/'),
|
|
'availableThemes': availableThemes,
|
|
'availablePlugins': availablePlugins
|
|
};
|
|
}
|
|
|
|
// TODO: remove configURL and give direct access to config object?
|
|
// TODO: not called when executing tests
|
|
function updatePaths(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 = getPaths;
|
|
|
|
module.exports.updatePaths = updatePaths;
|