nodebb-plugin-facebook-post 1.0.9 → 1.0.11
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 +0 -9
- package/package.json +1 -1
- package/plugin.json +9 -11
- package/static/lib/admin.js +16 -9
package/library.js
CHANGED
|
@@ -383,15 +383,6 @@ Plugin.addAdminNavigation = async function (header) {
|
|
|
383
383
|
return header;
|
|
384
384
|
};
|
|
385
385
|
|
|
386
|
-
Plugin.addClientScripts = async function (scripts) {
|
|
387
|
-
scripts.push('/plugins/nodebb-plugin-facebook-post/lib/composer.js');
|
|
388
|
-
return scripts;
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
Plugin.addAdminScripts = async function (scripts) {
|
|
392
|
-
scripts.push('/plugins/nodebb-plugin-facebook-post/lib/admin.js');
|
|
393
|
-
return scripts;
|
|
394
|
-
};
|
|
395
386
|
|
|
396
387
|
// Save custom composer data into post fields
|
|
397
388
|
Plugin.onPostCreate = async function (hookData) {
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"name": "Facebook Post",
|
|
4
4
|
"description": "Publie automatiquement les nouveaux topics NodeBB sur une Page Facebook fixe (images uploads + place).",
|
|
5
5
|
"url": "https://example.invalid/nodebb-plugin-facebook-post",
|
|
6
|
-
"library": "./library.js",
|
|
7
6
|
"hooks": [
|
|
8
7
|
{
|
|
9
8
|
"hook": "static:app.load",
|
|
@@ -13,14 +12,6 @@
|
|
|
13
12
|
"hook": "filter:admin.header.build",
|
|
14
13
|
"method": "addAdminNavigation"
|
|
15
14
|
},
|
|
16
|
-
{
|
|
17
|
-
"hook": "filter:scripts.get",
|
|
18
|
-
"method": "addClientScripts"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"hook": "filter:admin.scripts.get",
|
|
22
|
-
"method": "addAdminScripts"
|
|
23
|
-
},
|
|
24
15
|
{
|
|
25
16
|
"hook": "filter:post.create",
|
|
26
17
|
"method": "onPostCreate"
|
|
@@ -31,7 +22,14 @@
|
|
|
31
22
|
}
|
|
32
23
|
],
|
|
33
24
|
"staticDirs": {
|
|
34
|
-
"
|
|
25
|
+
"lib": "static/lib",
|
|
26
|
+
"templates": "static/templates"
|
|
35
27
|
},
|
|
36
|
-
"templates": "static/templates"
|
|
28
|
+
"templates": "static/templates",
|
|
29
|
+
"scripts": [
|
|
30
|
+
"static/lib/composer.js"
|
|
31
|
+
],
|
|
32
|
+
"acpScripts": [
|
|
33
|
+
"static/lib/admin.js"
|
|
34
|
+
]
|
|
37
35
|
}
|
package/static/lib/admin.js
CHANGED
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
function toCsv(arr) {
|
|
6
6
|
return (arr || []).map(String).map(s => s.trim()).filter(Boolean).join(',');
|
|
7
7
|
}
|
|
8
|
+
function fromCsv(s) {
|
|
9
|
+
return (s || '').split(',').map(v => v.trim()).filter(Boolean);
|
|
10
|
+
}
|
|
8
11
|
|
|
9
12
|
function init() {
|
|
10
13
|
const $form = $('.facebook-post-settings');
|
|
11
14
|
if (!$form.length) return;
|
|
12
15
|
|
|
13
16
|
require(['settings', 'alerts'], function (Settings, alerts) {
|
|
14
|
-
Settings.load('facebook-post', $form);
|
|
15
|
-
|
|
16
17
|
const $select = $('#allowedGroupsSelect');
|
|
17
18
|
const $hidden = $('#allowedGroups');
|
|
18
19
|
|
|
@@ -20,15 +21,21 @@
|
|
|
20
21
|
$hidden.val(toCsv($select.val() || []));
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
// Prevent full page refresh if user hits Enter
|
|
25
|
+
$form.off('submit.fbpost').on('submit.fbpost', function (e) { e.preventDefault(); return false; });
|
|
26
|
+
|
|
27
|
+
// IMPORTANT: wait for Settings.load to finish before reading hidden input
|
|
28
|
+
Settings.load('facebook-post', $form, function () {
|
|
29
|
+
const existing = fromCsv($hidden.val());
|
|
30
|
+
if (existing.length) {
|
|
31
|
+
$select.val(existing);
|
|
32
|
+
} else {
|
|
33
|
+
$select.val([]);
|
|
34
|
+
}
|
|
35
|
+
syncHidden();
|
|
36
|
+
});
|
|
29
37
|
|
|
30
38
|
$select.off('change.fbpost').on('change.fbpost', syncHidden);
|
|
31
|
-
$form.off('submit.fbpost').on('submit.fbpost', function (e) { e.preventDefault(); return false; });
|
|
32
39
|
|
|
33
40
|
$('#save').off('click.fbpost').on('click.fbpost', function (e) {
|
|
34
41
|
e.preventDefault();
|