2015-10-13 14:55:24 +03:00
|
|
|
/**
|
2017-03-01 16:09:31 +03:00
|
|
|
* # Read Themes
|
|
|
|
*
|
|
|
|
* Util that wraps packages.read
|
2015-10-13 14:55:24 +03:00
|
|
|
*/
|
2017-03-01 16:09:31 +03:00
|
|
|
var packages = require('../utils/packages'),
|
|
|
|
logging = require('../logging'),
|
|
|
|
i18n = require('../i18n'),
|
2015-10-13 14:55:24 +03:00
|
|
|
|
2017-02-22 02:26:19 +03:00
|
|
|
readOneTheme,
|
|
|
|
readAllThemes;
|
2015-10-13 14:55:24 +03:00
|
|
|
|
2017-02-22 02:26:19 +03:00
|
|
|
readOneTheme = function readOneTheme(dir, name) {
|
2017-03-01 16:09:31 +03:00
|
|
|
return packages
|
|
|
|
.read.one(dir, name)
|
|
|
|
.catch(function () {
|
|
|
|
// For now we return an empty object as this is not fatal unless the frontend of the blog is requested
|
|
|
|
logging.warn(i18n.t('errors.middleware.themehandler.missingTheme', {theme: name}));
|
|
|
|
return {};
|
2017-02-22 02:26:19 +03:00
|
|
|
});
|
|
|
|
};
|
2015-10-13 14:55:24 +03:00
|
|
|
|
2017-02-22 02:26:19 +03:00
|
|
|
readAllThemes = function readAllThemes(dir) {
|
2017-03-01 16:09:31 +03:00
|
|
|
return packages.read.all(dir);
|
2017-02-22 02:26:19 +03:00
|
|
|
};
|
2015-10-13 14:55:24 +03:00
|
|
|
|
|
|
|
/**
|
2017-02-22 02:26:19 +03:00
|
|
|
* Expose public API
|
2015-10-13 14:55:24 +03:00
|
|
|
*/
|
|
|
|
|
2017-02-22 02:26:19 +03:00
|
|
|
module.exports.all = readAllThemes;
|
|
|
|
module.exports.one = readOneTheme;
|