mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
37 lines
817 B
JavaScript
37 lines
817 B
JavaScript
|
/**
|
||
|
* Store themes after loading them from the file system
|
||
|
*/
|
||
|
var _ = require('lodash'),
|
||
|
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;
|
||
|
}
|
||
|
};
|