mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
4e2474a018
no issue - replace camelCase settings keys with underscore_case for consistency - discussed here https://github.com/TryGhost/Ghost-Admin/pull/661#discussion_r112939982
33 lines
1.1 KiB
JavaScript
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};
|
|
};
|