nodebb-plugin-poll 3.0.5 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/library.js +51 -48
- package/package.json +2 -2
- package/templates/admin/plugins/poll.tpl +37 -37
package/library.js
CHANGED
|
@@ -6,60 +6,63 @@ const Sockets = require('./lib/sockets');
|
|
|
6
6
|
const Hooks = require('./lib/hooks');
|
|
7
7
|
const Scheduler = require('./lib/scheduler');
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
Plugin.hooks = Hooks;
|
|
9
|
+
const Plugin = module.exports;
|
|
11
10
|
|
|
12
|
-
Plugin.load = function (params, callback) {
|
|
13
|
-
function renderAdmin(req, res) {
|
|
14
|
-
res.render(`admin/plugins/${Config.plugin.id}`, {});
|
|
15
|
-
}
|
|
16
11
|
|
|
17
|
-
|
|
18
|
-
params.router.get(`/api/admin/plugins/${Config.plugin.id}`, renderAdmin);
|
|
12
|
+
Plugin.hooks = Hooks;
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
Plugin.load = function (params, callback) {
|
|
15
|
+
const routeHelpers = require.main.require('./src/routes/helpers');
|
|
16
|
+
const { router } = params;
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
routeHelpers.setupAdminPageRoute(router, `/admin/plugins/${Config.plugin.id}`, (req, res) => {
|
|
19
|
+
res.render(`admin/plugins/${Config.plugin.id}`, {
|
|
20
|
+
title: 'Poll',
|
|
21
|
+
});
|
|
22
|
+
});
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
NodeBB.PluginSockets[Config.plugin.id] = Sockets;
|
|
25
|
+
NodeBB.AdminSockets[Config.plugin.id] = Config.adminSockets;
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
route: `/plugins/${Config.plugin.id}`,
|
|
32
|
-
icon: Config.plugin.icon,
|
|
33
|
-
name: Config.plugin.name,
|
|
34
|
-
});
|
|
27
|
+
NodeBB.app = params.app;
|
|
28
|
+
Scheduler.start();
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
Config.init(callback);
|
|
31
|
+
};
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
Plugin.addAdminNavigation = function (adminHeader, callback) {
|
|
34
|
+
adminHeader.plugins.push({
|
|
35
|
+
route: `/plugins/${Config.plugin.id}`,
|
|
36
|
+
icon: Config.plugin.icon,
|
|
37
|
+
name: Config.plugin.name,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
callback(null, adminHeader);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
Plugin.registerFormatting = function (payload, callback) {
|
|
44
|
+
payload.options.push({
|
|
45
|
+
name: 'poll',
|
|
46
|
+
className: `fa ${Config.plugin.icon}`,
|
|
47
|
+
title: '[[poll:creator_title]]',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
callback(null, payload);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Plugin.addPrivilege = function (hookData) {
|
|
54
|
+
hookData.privileges.set(
|
|
55
|
+
'poll:create', { label: '[[poll:admin.create-poll]]' },
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
Plugin.copyPrivilegesFrom = function (data, callback) {
|
|
60
|
+
if (data.privileges.indexOf('poll:create') === -1) {
|
|
61
|
+
data.privileges.push('poll:create');
|
|
62
|
+
}
|
|
45
63
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
'poll:create', { label: '[[poll:admin.create-poll]]' },
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
Plugin.copyPrivilegesFrom = function (data, callback) {
|
|
56
|
-
if (data.privileges.indexOf('poll:create') === -1) {
|
|
57
|
-
data.privileges.push('poll:create');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (data.privileges.indexOf('groups:poll:create') === -1) {
|
|
61
|
-
data.privileges.push('groups:poll:create');
|
|
62
|
-
}
|
|
63
|
-
callback(null, data);
|
|
64
|
-
};
|
|
65
|
-
}(exports));
|
|
64
|
+
if (data.privileges.indexOf('groups:poll:create') === -1) {
|
|
65
|
+
data.privileges.push('groups:poll:create');
|
|
66
|
+
}
|
|
67
|
+
callback(null, data);
|
|
68
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-poll",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "NodeBB Poll Plugin",
|
|
5
5
|
"main": "library.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"cron": "^1.8.2"
|
|
27
27
|
},
|
|
28
28
|
"nbbpm": {
|
|
29
|
-
"compatibility": "^3.
|
|
29
|
+
"compatibility": "^3.2.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"eslint": "^7.31.0",
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
<div class="
|
|
2
|
-
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
<div class="acp-page-container">
|
|
2
|
+
<div component="settings/main/header" class="row border-bottom py-2 m-0 sticky-top acp-page-main-header align-items-center">
|
|
3
|
+
<div class="col-12 col-md-8 px-0 mb-1 mb-md-0">
|
|
4
|
+
<h4 class="fw-bold tracking-tight mb-0">{title}</h4>
|
|
5
|
+
</div>
|
|
6
|
+
<div class="col-12 col-md-4 px-0 px-md-3 text-end">
|
|
7
|
+
<button id="reset" class="btn btn-warning btn-sm fw-semibold ff-secondary text-center text-nowrap">[[poll:reset]]</button>
|
|
8
|
+
<button id="save" class="btn btn-primary btn-sm fw-semibold ff-secondary text-center text-nowrap">[[admin/admin:save-changes]]</button>
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<div class="row m-0">
|
|
13
|
+
<div id="spy-container" class="col-12 px-0 mb-4" tabindex="0">
|
|
14
|
+
<form class="form poll-settings">
|
|
15
|
+
<div class="card">
|
|
16
|
+
<div class="card-header">[[poll:poll]]</div>
|
|
17
|
+
<div class="card-body">
|
|
18
|
+
<div class="mb-3">
|
|
9
19
|
<h6>[[poll:toggles]]</h6>
|
|
10
20
|
<div class="mb-3">
|
|
11
21
|
<div class="form-check">
|
|
@@ -14,7 +24,7 @@
|
|
|
14
24
|
</div>
|
|
15
25
|
</div>
|
|
16
26
|
</div>
|
|
17
|
-
<div class="
|
|
27
|
+
<div class="mb-3">
|
|
18
28
|
<h6>[[poll:limits]]</h6>
|
|
19
29
|
<div>
|
|
20
30
|
<label class="form-label" for="maxPollOptions">[[poll:max_options]]</label>
|
|
@@ -23,36 +33,26 @@
|
|
|
23
33
|
</div>
|
|
24
34
|
</div>
|
|
25
35
|
</div>
|
|
26
|
-
</div>
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
</
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
<input type="number" class="form-control" id="defaultsMaxVotes" placeholder="1" min="1" max="100" data-key="defaults.maxvotes">
|
|
40
|
-
<p class="form-text">[[poll:info_choices]]</p>
|
|
41
|
-
</div>
|
|
37
|
+
<div class="card">
|
|
38
|
+
<div class="card-header">[[poll:defaults]]</div>
|
|
39
|
+
<div class="card-body">
|
|
40
|
+
<div class="mb-3">
|
|
41
|
+
<label class="form-label" for="defaultsTitle">[[poll:default_title]]</label>
|
|
42
|
+
<input type="text" class="form-control" id="defaultsTitle" placeholder="Poll" data-key="defaults.title">
|
|
43
|
+
</div>
|
|
44
|
+
<div>
|
|
45
|
+
<label class="form-label" for="defaultsMaxVotes">[[poll:max_votes]]</label>
|
|
46
|
+
<input type="number" class="form-control" id="defaultsMaxVotes" placeholder="1" min="1" max="100" data-key="defaults.maxvotes">
|
|
47
|
+
<p class="form-text">[[poll:info_choices]]</p>
|
|
42
48
|
</div>
|
|
43
49
|
</div>
|
|
44
50
|
</div>
|
|
45
|
-
</
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
</form>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<!-- IMPORT admin/partials/settings/toc.tpl -->
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
48
58
|
|
|
49
|
-
<div class="col-lg-3">
|
|
50
|
-
<div class="card">
|
|
51
|
-
<div class="card-header">[[poll:settings]]</div>
|
|
52
|
-
<div class="card-body">
|
|
53
|
-
<button id="save" class="btn btn-primary btn-block">[[poll:save]]</button>
|
|
54
|
-
<button id="reset" class="btn btn-warning btn-block">[[poll:reset]]</button>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|