mirror of
https://hk.gh-proxy.com/https://github.com/NodeBB/nodebb-plugin-poll.git
synced 2025-10-04 04:41:13 +08:00
- Reworked server code - Reworked poll creator - Moved a couple of files around - Cleaned up a lot of code
59 lines
No EOL
1.1 KiB
JavaScript
Executable file
59 lines
No EOL
1.1 KiB
JavaScript
Executable file
"use strict";
|
|
|
|
var NodeBB = require('./nodebb'),
|
|
|
|
packageInfo = require('../package.json'),
|
|
pluginInfo = require('../plugin.json'),
|
|
pluginId = pluginInfo.id.replace('nodebb-plugin-', ''),
|
|
|
|
Config = {};
|
|
|
|
Config.plugin = {
|
|
name: pluginInfo.name,
|
|
id: pluginId,
|
|
version: packageInfo.version,
|
|
description: packageInfo.description,
|
|
icon: 'fa-bar-chart-o'
|
|
};
|
|
|
|
Config.defaults = {
|
|
toggles: {
|
|
allowAnon: false
|
|
},
|
|
limits: {
|
|
maxOptions: 10
|
|
},
|
|
defaults: {
|
|
title: 'Poll',
|
|
maxvotes: 1,
|
|
end: 0
|
|
},
|
|
version: ''
|
|
};
|
|
|
|
Config.settings = {};
|
|
|
|
Config.init = function(callback) {
|
|
Config.settings = new NodeBB.Settings(Config.plugin.id, Config.plugin.version, Config.defaults, function() {
|
|
var oldVersion = Config.settings.get('version');
|
|
|
|
if (oldVersion < Config.settings.version) {
|
|
Config.settings.set('version', Config.plugin.version);
|
|
Config.settings.persist();
|
|
callback();
|
|
} else {
|
|
callback();
|
|
}
|
|
});
|
|
};
|
|
|
|
Config.adminSockets = {
|
|
sync: function() {
|
|
Config.settings.sync();
|
|
},
|
|
getDefaults: function(socket, data, callback) {
|
|
callback(null, Config.settings.createDefaultWrapper());
|
|
}
|
|
};
|
|
|
|
module.exports = Config; |