nodebb-plugin-ezoic-infinite 0.4.3 → 0.4.5
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 +8 -19
- package/package.json +1 -1
- package/public/admin.js +10 -12
- package/README.md +0 -18
package/library.js
CHANGED
|
@@ -23,9 +23,11 @@ function parseBool(v, def = false) {
|
|
|
23
23
|
async function getAllGroups() {
|
|
24
24
|
const names = await db.getSortedSetRange('groups:createtime', 0, -1);
|
|
25
25
|
const filtered = names.filter(name => !groups.isPrivilegeGroup(name));
|
|
26
|
-
|
|
26
|
+
const data = await groups.getGroupsData(filtered);
|
|
27
|
+
// Sort alphabetically for ACP usability
|
|
28
|
+
data.sort((a, b) => String(a.name).localeCompare(String(b.name), 'fr', { sensitivity: 'base' }));
|
|
29
|
+
return data;
|
|
27
30
|
}
|
|
28
|
-
|
|
29
31
|
async function getSettings() {
|
|
30
32
|
const s = await meta.settings.get(SETTINGS_KEY);
|
|
31
33
|
return {
|
|
@@ -60,7 +62,7 @@ plugin.addAdminNavigation = async (header) => {
|
|
|
60
62
|
};
|
|
61
63
|
|
|
62
64
|
plugin.init = async ({ router, middleware }) => {
|
|
63
|
-
|
|
65
|
+
async function render(req, res) {
|
|
64
66
|
const settings = await getSettings();
|
|
65
67
|
const allGroups = await getAllGroups();
|
|
66
68
|
|
|
@@ -71,21 +73,10 @@ plugin.init = async ({ router, middleware }) => {
|
|
|
71
73
|
enableMessageAds_checked: settings.enableMessageAds ? 'checked' : '',
|
|
72
74
|
allGroups,
|
|
73
75
|
});
|
|
74
|
-
}
|
|
76
|
+
}
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
router.get('/api/admin/plugins/ezoic-infinite',
|
|
78
|
-
const settings = await getSettings();
|
|
79
|
-
const allGroups = await getAllGroups();
|
|
80
|
-
|
|
81
|
-
res.json({
|
|
82
|
-
title: 'Ezoic Infinite Ads',
|
|
83
|
-
...settings,
|
|
84
|
-
enableBetweenAds_checked: settings.enableBetweenAds ? 'checked' : '',
|
|
85
|
-
enableMessageAds_checked: settings.enableMessageAds ? 'checked' : '',
|
|
86
|
-
allGroups,
|
|
87
|
-
});
|
|
88
|
-
});
|
|
78
|
+
router.get('/admin/plugins/ezoic-infinite', middleware.admin.buildHeader, render);
|
|
79
|
+
router.get('/api/admin/plugins/ezoic-infinite', render);
|
|
89
80
|
|
|
90
81
|
router.get('/api/plugins/ezoic-infinite/config', middleware.buildHeader, async (req, res) => {
|
|
91
82
|
const settings = await getSettings();
|
|
@@ -93,11 +84,9 @@ plugin.init = async ({ router, middleware }) => {
|
|
|
93
84
|
|
|
94
85
|
res.json({
|
|
95
86
|
excluded,
|
|
96
|
-
|
|
97
87
|
enableBetweenAds: settings.enableBetweenAds,
|
|
98
88
|
placeholderIds: settings.placeholderIds,
|
|
99
89
|
intervalPosts: settings.intervalPosts,
|
|
100
|
-
|
|
101
90
|
enableMessageAds: settings.enableMessageAds,
|
|
102
91
|
messagePlaceholderIds: settings.messagePlaceholderIds,
|
|
103
92
|
messageIntervalPosts: settings.messageIntervalPosts,
|
package/package.json
CHANGED
package/public/admin.js
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
/* globals
|
|
1
|
+
/* globals ajaxify */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
(function () {
|
|
5
|
-
function isOurPage(data) {
|
|
6
|
-
const url = data?.url || ajaxify?.data?.url || window.location.pathname || '';
|
|
7
|
-
return url.includes('admin/plugins/ezoic-infinite') || url.includes('/plugins/ezoic-infinite');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
5
|
function init() {
|
|
11
6
|
const $form = $('.ezoic-infinite-settings');
|
|
12
7
|
if (!$form.length) return;
|
|
13
8
|
|
|
14
|
-
require(['settings'], function (Settings) {
|
|
9
|
+
require(['settings', 'alerts'], function (Settings, alerts) {
|
|
15
10
|
Settings.load('ezoic-infinite', $form);
|
|
16
11
|
|
|
17
12
|
$('#save').off('click.ezoicInfinite').on('click.ezoicInfinite', function (e) {
|
|
18
13
|
e.preventDefault();
|
|
14
|
+
|
|
19
15
|
Settings.save('ezoic-infinite', $form, function () {
|
|
20
|
-
// Toast vert
|
|
21
|
-
|
|
16
|
+
// Toast vert (NodeBB core)
|
|
17
|
+
if (alerts && typeof alerts.success === 'function') {
|
|
18
|
+
alerts.success('Enregistré');
|
|
19
|
+
} else if (window.app && typeof window.app.alertSuccess === 'function') {
|
|
20
|
+
window.app.alertSuccess('Enregistré');
|
|
21
|
+
}
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
$(document).ready(init);
|
|
28
|
-
$(window).on('action:ajaxify.end',
|
|
29
|
-
if (isOurPage(data)) init();
|
|
30
|
-
});
|
|
28
|
+
$(window).on('action:ajaxify.end', init);
|
|
31
29
|
})();
|
package/README.md
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# nodebb-plugin-ezoic-infinite
|
|
2
|
-
|
|
3
|
-
Plugin NodeBB 4.x pour intégrer Ezoic avec infinite scroll.
|
|
4
|
-
|
|
5
|
-
## Correctifs inclus
|
|
6
|
-
- Route **/api/admin/plugins/ezoic-infinite** ajoutée (indispensable pour le 1er clic dans l'ACP via ajaxify)
|
|
7
|
-
- Toast vert (app.alertSuccess) lors de l'enregistrement
|
|
8
|
-
- package.json non-private (publication npm possible)
|
|
9
|
-
|
|
10
|
-
## Installation (local)
|
|
11
|
-
```bash
|
|
12
|
-
cd /path/to/nodebb/node_modules
|
|
13
|
-
unzip nodebb-plugin-ezoic-infinite.zip -d nodebb-plugin-ezoic-infinite
|
|
14
|
-
cd /path/to/nodebb
|
|
15
|
-
npm i ./node_modules/nodebb-plugin-ezoic-infinite
|
|
16
|
-
./nodebb build
|
|
17
|
-
./nodebb restart
|
|
18
|
-
```
|