mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
b920662790
to standardise getting paths and absolute URLs. Easy to extend for other configurations we may need.
49 lines
No EOL
1.5 KiB
JavaScript
49 lines
No EOL
1.5 KiB
JavaScript
|
|
|
|
var path = require('path'),
|
|
when = require('when'),
|
|
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),
|
|
activeTheme = '',
|
|
availableThemes,
|
|
availablePlugins;
|
|
|
|
|
|
function getPaths() {
|
|
return {
|
|
'appRoot': appRoot,
|
|
'themePath': themePath,
|
|
'pluginPath': pluginPath,
|
|
'activeTheme': path.join(themePath, activeTheme),
|
|
'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
|
|
};
|
|
}
|
|
|
|
|
|
function updatePaths() {
|
|
return when.all([themeDirectories, pluginDirectories]).then(function (paths) {
|
|
availableThemes = paths[0];
|
|
availablePlugins = paths[1];
|
|
return;
|
|
});
|
|
}
|
|
|
|
function setActiveTheme(ghost) {
|
|
if (ghost && ghost.settingsCache) {
|
|
activeTheme = ghost.settingsCache.activeTheme.value;
|
|
}
|
|
}
|
|
|
|
module.exports = getPaths;
|
|
|
|
module.exports.updatePaths = updatePaths;
|
|
|
|
module.exports.setActiveTheme = setActiveTheme; |