0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00
ghost/core/server/themes/to-json.js
Katharina Irrgang 4e2474a018 🎨 settings inconsistency (#8381)
no issue
- replace camelCase settings keys with underscore_case for consistency
- discussed here https://github.com/TryGhost/Ghost-Admin/pull/661#discussion_r112939982
2017-04-24 18:41:00 +01:00

33 lines
1.1 KiB
JavaScript

var _ = require('lodash'),
themeList = require('./list'),
packages = require('../utils/packages'),
settingsCache = require('../settings/cache');
/**
* Provides a JSON object which can be returned via the API
*
* @param {string} [name] - the theme to output
* @param {object} [checkedTheme] - a theme result from gscan
* @return {*}
*/
module.exports = function toJSON(name, checkedTheme) {
var themeResult, toFilter;
if (!name) {
toFilter = themeList.getAll();
// Default to returning the full list
themeResult = packages.filterPackages(toFilter, settingsCache.get('active_theme'));
} else {
// If we pass in a gscan result, convert this instead
toFilter = {};
toFilter[name] = themeList.get(name);
themeResult = packages.filterPackages(toFilter, settingsCache.get('active_theme'));
if (checkedTheme && checkedTheme.results.warning.length > 0) {
themeResult[0].warnings = _.cloneDeep(checkedTheme.results.warning);
}
}
return {themes: themeResult};
};