2017-08-15 14:29:27 +03:00
|
|
|
var debug = require('ghost-ignition').debug('themes:loader'),
|
2017-02-22 02:26:19 +03:00
|
|
|
config = require('../config'),
|
2017-03-02 19:53:48 +03:00
|
|
|
themeList = require('./list'),
|
2017-03-13 19:30:35 +03:00
|
|
|
read = require('../utils/packages').read,
|
2017-03-02 19:53:48 +03:00
|
|
|
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-02-22 02:26:19 +03:00
|
|
|
return read
|
|
|
|
.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) {
|
|
|
|
return read
|
|
|
|
.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
|
|
|
};
|