nodebb-plugin-ezoic-infinite 0.1.0 → 0.2.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/README.md +21 -5
- package/library.js +10 -0
- package/package.json +3 -15
- package/plugin.json +17 -4
- package/public/client.js +6 -19
package/README.md
CHANGED
|
@@ -2,12 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
Plugin NodeBB 4.x pour intégrer Ezoic lors des chargements en infinite scroll.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
- Pool d'IDs Ezoic (un ID par placeholder)
|
|
8
|
-
- Fenêtre glissante: le nombre de pubs simultanées est limité à la taille du pool
|
|
9
|
-
- Exclusion par groupes (configurable)
|
|
5
|
+
## Installation (recommandée)
|
|
6
|
+
Depuis le dossier NodeBB (où se trouve `package.json` du forum) :
|
|
10
7
|
|
|
8
|
+
### Option A — installer depuis un chemin local (simple)
|
|
9
|
+
```bash
|
|
10
|
+
npm i ./node_modules/nodebb-plugin-ezoic-infinite
|
|
11
|
+
# ou si tu as le dossier ailleurs : npm i /chemin/vers/nodebb-plugin-ezoic-infinite
|
|
12
|
+
./nodebb build
|
|
13
|
+
./nodebb restart
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Option B — npm link (workflow dev)
|
|
17
|
+
```bash
|
|
18
|
+
cd node_modules/nodebb-plugin-ezoic-infinite
|
|
19
|
+
npm link
|
|
20
|
+
cd /usr/src/app # dossier NodeBB
|
|
21
|
+
npm link nodebb-plugin-ezoic-infinite
|
|
22
|
+
./nodebb build
|
|
23
|
+
./nodebb restart
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
> Note: NodeBB n’est généralement pas publié sur le registre npm, donc on **ne met pas** `nodebb` en dépendance npm “résoluble”.
|
|
11
27
|
## Configuration
|
|
12
28
|
ACP -> Plugins -> Ezoic Infinite Ads
|
|
13
29
|
- **Pool d’IDs**: un par ligne (ou séparé par virgules)
|
package/library.js
CHANGED
|
@@ -34,6 +34,16 @@ async function isUserExcluded(uid, excludedGroups) {
|
|
|
34
34
|
return userGroups[0].some(g => excludedGroups.includes(g.name));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
plugin.addAdminNavigation = async (header) => {
|
|
38
|
+
header.plugins = header.plugins || [];
|
|
39
|
+
header.plugins.push({
|
|
40
|
+
route: '/plugins/ezoic-infinite',
|
|
41
|
+
icon: 'fa-ad',
|
|
42
|
+
name: 'Ezoic Infinite Ads'
|
|
43
|
+
});
|
|
44
|
+
return header;
|
|
45
|
+
};
|
|
46
|
+
|
|
37
47
|
plugin.init = async ({ router, middleware }) => {
|
|
38
48
|
router.get('/admin/plugins/ezoic-infinite', middleware.admin.buildHeader, async (req, res) => {
|
|
39
49
|
const settings = await getSettings();
|
package/package.json
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-ezoic-infinite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Ezoic ads with infinite scroll using a pool of placeholder IDs",
|
|
5
5
|
"main": "library.js",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"nodebb",
|
|
8
|
-
"nodebb-plugin",
|
|
9
8
|
"ezoic",
|
|
10
|
-
"ads"
|
|
11
|
-
"infinite-scroll"
|
|
9
|
+
"ads"
|
|
12
10
|
],
|
|
13
|
-
"license": "MIT"
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "https://example.com/nodebb-plugin-ezoic-infinite.git"
|
|
17
|
-
},
|
|
18
|
-
"engines": {
|
|
19
|
-
"node": ">=18"
|
|
20
|
-
},
|
|
21
|
-
"peerDependencies": {
|
|
22
|
-
"nodebb": ">=4.0.0"
|
|
23
|
-
}
|
|
11
|
+
"license": "MIT"
|
|
24
12
|
}
|
package/plugin.json
CHANGED
|
@@ -4,10 +4,23 @@
|
|
|
4
4
|
"description": "Ezoic ads with infinite scroll using a pool of placeholder IDs",
|
|
5
5
|
"library": "./library.js",
|
|
6
6
|
"hooks": [
|
|
7
|
-
{
|
|
7
|
+
{
|
|
8
|
+
"hook": "static:app.load",
|
|
9
|
+
"method": "init"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"hook": "filter:admin.header.build",
|
|
13
|
+
"method": "addAdminNavigation"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"staticDirs": {
|
|
17
|
+
"public": "public"
|
|
18
|
+
},
|
|
19
|
+
"acpScripts": [
|
|
20
|
+
"public/admin.js"
|
|
21
|
+
],
|
|
22
|
+
"scripts": [
|
|
23
|
+
"public/client.js"
|
|
8
24
|
],
|
|
9
|
-
"staticDirs": { "public": "public" },
|
|
10
|
-
"acpScripts": ["public/admin.js"],
|
|
11
|
-
"scripts": ["public/client.js"],
|
|
12
25
|
"templates": "public/templates"
|
|
13
26
|
}
|
package/public/client.js
CHANGED
|
@@ -21,18 +21,6 @@ function parsePool(raw) {
|
|
|
21
21
|
));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function destroyEzoic() {
|
|
25
|
-
if (window.ezstandalone?.destroyPlaceholders) {
|
|
26
|
-
window.ezstandalone.destroyPlaceholders();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function showAd(id) {
|
|
31
|
-
if (window.ezstandalone?.showAds) {
|
|
32
|
-
window.ezstandalone.showAds(id);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
24
|
async function refreshAds() {
|
|
37
25
|
const cfg = await fetchConfig();
|
|
38
26
|
if (!cfg || cfg.excluded) return;
|
|
@@ -40,14 +28,12 @@ async function refreshAds() {
|
|
|
40
28
|
const pool = parsePool(cfg.placeholderIds);
|
|
41
29
|
const interval = cfg.intervalPosts;
|
|
42
30
|
const $posts = $('.posts .post');
|
|
43
|
-
|
|
44
31
|
if (!pool.length || !$posts.length) return;
|
|
45
32
|
|
|
46
|
-
pool.forEach(id => $(
|
|
33
|
+
pool.forEach(id => $('#ezoic-pub-ad-placeholder-' + id).remove());
|
|
47
34
|
|
|
48
35
|
const slots = Math.floor($posts.length / interval);
|
|
49
36
|
const start = Math.max(1, slots - pool.length + 1);
|
|
50
|
-
|
|
51
37
|
const activeIds = [];
|
|
52
38
|
|
|
53
39
|
for (let slot = start, i = 0; slot <= slots; slot++, i++) {
|
|
@@ -55,13 +41,14 @@ async function refreshAds() {
|
|
|
55
41
|
const index = slot * interval - 1;
|
|
56
42
|
const $target = $posts.eq(index);
|
|
57
43
|
if (!$target.length) continue;
|
|
58
|
-
|
|
59
|
-
$target.after(`<div id="ezoic-pub-ad-placeholder-${id}"></div>`);
|
|
44
|
+
$target.after('<div id="ezoic-pub-ad-placeholder-' + id + '"></div>');
|
|
60
45
|
activeIds.push(id);
|
|
61
46
|
}
|
|
62
47
|
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
if (window.ezstandalone?.destroyPlaceholders) {
|
|
49
|
+
window.ezstandalone.destroyPlaceholders();
|
|
50
|
+
}
|
|
51
|
+
activeIds.forEach(id => window.ezstandalone?.showAds?.(id));
|
|
65
52
|
}
|
|
66
53
|
|
|
67
54
|
function debounceRefresh() {
|