mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
94d53cf5fb
no issue - browse will now include the correct activated theme again - PUT /theme/:name/activate will activate a theme - tests now read from a temp directory not content/themes - all tests check errors and responses
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
/**
|
|
* Store themes after loading them from the file system
|
|
*/
|
|
var _ = require('lodash'),
|
|
packages = require('../utils/packages'),
|
|
themeListCache = {};
|
|
|
|
module.exports = {
|
|
get: function get(key) {
|
|
return themeListCache[key];
|
|
},
|
|
|
|
getAll: function getAll() {
|
|
return themeListCache;
|
|
},
|
|
|
|
set: function set(key, theme) {
|
|
themeListCache[key] = _.cloneDeep(theme);
|
|
return themeListCache[key];
|
|
},
|
|
|
|
del: function del(key) {
|
|
delete themeListCache[key];
|
|
},
|
|
|
|
init: function init(themes) {
|
|
var self = this;
|
|
// First, reset the cache
|
|
themeListCache = {};
|
|
// For each theme, call set. Allows us to do processing on set later.
|
|
_.each(themes, function (theme, key) {
|
|
self.set(key, theme);
|
|
});
|
|
|
|
return themeListCache;
|
|
},
|
|
toAPI: function toAPI(themes, active) {
|
|
var toFilter;
|
|
|
|
if (themes.hasOwnProperty('name')) {
|
|
toFilter = {};
|
|
toFilter[themes.name] = themes;
|
|
} else {
|
|
toFilter = themes;
|
|
}
|
|
|
|
return packages.filterPackages(toFilter, active);
|
|
}
|
|
};
|