2017-08-15 14:29:27 +03:00
|
|
|
var debug = require('ghost-ignition').debug('themes:loader'),
|
2019-06-19 12:30:28 +03:00
|
|
|
config = require('../../../server/config'),
|
|
|
|
packageJSON = require('../../../server/lib/fs/package-json'),
|
2017-03-02 19:53:48 +03:00
|
|
|
themeList = require('./list'),
|
|
|
|
loadAllThemes,
|
2017-03-13 19:30:35 +03:00
|
|
|
loadOneTheme;
|
2017-02-22 02:26:19 +03:00
|
|
|
|
2017-03-02 19:53:48 +03:00
|
|
|
loadAllThemes = function loadAllThemes() {
|
2017-12-15 00:07:53 +03:00
|
|
|
return packageJSON.read
|
2017-02-22 02:26:19 +03:00
|
|
|
.all(config.getContentPath('themes'))
|
2017-03-13 19:30:35 +03:00
|
|
|
.then(function updateThemeList(themes) {
|
|
|
|
debug('loading themes', Object.keys(themes));
|
|
|
|
|
|
|
|
themeList.init(themes);
|
|
|
|
});
|
2017-03-02 19:53:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
loadOneTheme = function loadOneTheme(themeName) {
|
2017-12-15 00:07:53 +03:00
|
|
|
return packageJSON.read
|
2017-03-02 19:53:48 +03:00
|
|
|
.one(config.getContentPath('themes'), themeName)
|
|
|
|
.then(function (readThemes) {
|
2017-03-13 19:30:35 +03:00
|
|
|
debug('loaded one theme', themeName);
|
2017-03-02 19:53:48 +03:00
|
|
|
return themeList.set(themeName, readThemes[themeName]);
|
|
|
|
});
|
2017-02-22 02:26:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
2017-03-02 19:53:48 +03:00
|
|
|
loadAllThemes: loadAllThemes,
|
|
|
|
loadOneTheme: loadOneTheme
|
2017-02-22 02:26:19 +03:00
|
|
|
};
|