designcreateplay/NodeBB — pull request #1438 by frissdiegurke (2014-04-24 18:01:26+00:00)
Title: added new settings-system into core

dammit, one wrong key and github clears my message :cry:

I've kept compatibility for the old settings-object :wink:

The new structure takes care to save objects that don't need to be flat as `meta.settings.set` accepts only.
And it allows plugin-devs to create their own element-plugins :smile:
They basically need to add

require(['settings'], function (settings) {
// settings.registerPlugin(some_plugin_loaded_by_require_too);
settings.init('shortcuts');
});

into their admin-template.

And to access the settings server-side they can do the following:
```
Settings = module.parent.require('./settings');
cfg = new Settings('my_plugin', '0.1-1', defConfig); // with defConfig beeing object containing the default settings
```
`cfg.get()` returns the settings, `cfg.sync()` reloads settings from `meta.settings`, ...

`if (id === 'nodebb-plugin-my_plugin') cfg.checkStructure()` should be added to `action:plugin.activate` hook :smile: