nodebb-plugin-discord-onekite 1.1.11 → 1.1.13

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 CHANGED
@@ -1,9 +1,11 @@
1
- # nodebb-plugin-discord-onekite v1.1.4.2
1
+ # nodebb-plugin-discord-onekite v1.1.4.4
2
2
 
3
- Based on v1.1.4.
3
+ Based on v1.1.4, with adjustments:
4
4
 
5
- Change: Discord notification format is now:
6
- - Single clickable link line: 🆕 Nouveau sujet : [Titre](URL) (or reply variant)
7
- - Excerpt below
5
+ ACP
6
+ - Save button at top (disk icon) like other plugins
7
+ - AJAX save + NodeBB toast (bottom-right)
8
8
 
9
- ACP behavior unchanged from v1.1.4.
9
+ Discord
10
+ - Single clickable link line (no raw URL shown)
11
+ - Ensures absolute URLs prefixed with https://www.onekite.com when config url is missing
package/library.js CHANGED
@@ -129,7 +129,8 @@ async function getPostExcerpt(pid) {
129
129
  }
130
130
 
131
131
  async function buildPayload({ tid, pid, isReply }) {
132
- const baseUrl = normalizeBaseUrl(meta.config.url);
132
+ let baseUrl = normalizeBaseUrl(meta.config.url || meta.config['url']);
133
+ if (!baseUrl) { baseUrl = 'https://www.onekite.com'; }
133
134
 
134
135
  const topicData = await topics.getTopicFields(tid, ['tid', 'uid', 'cid', 'title', 'slug', 'mainPid']);
135
136
  if (!topicData) return null;
@@ -161,8 +162,7 @@ async function buildPayload({ tid, pid, isReply }) {
161
162
  ? `🗨️ Nouvelle réponse : [${title}](${postUrl})`
162
163
  : `🆕 Nouveau sujet : [${title}](${topicUrl})`;
163
164
 
164
- const content = [linkLine, description].filter(Boolean).join('
165
- ');
165
+ const content = [linkLine, description].filter(Boolean).join('\n');
166
166
 
167
167
  return { topicData, embed, content };
168
168
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-discord-onekite",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "description": "Discord webhook notifier for Onekite (NodeBB v4.x only)",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
@@ -10,28 +10,34 @@ define('admin/plugins/discord-onekite', ['api'], function (api) {
10
10
  return Array.from(el.selectedOptions || []).map(o => o.value);
11
11
  }
12
12
 
13
+ function doSave() {
14
+ const payload = {
15
+ webhookUrl: String($('#webhookUrl').val() || '').trim(),
16
+ notifyReplies: $('#notifyReplies').is(':checked'),
17
+ cids: getMultiSelectValues('#cids'),
18
+ };
19
+
20
+ return api.post('/admin/plugins/discord-onekite/save', payload).then(function () {
21
+ if (window.app && typeof app.alertSuccess === 'function') {
22
+ app.alertSuccess('Paramètres enregistrés !');
23
+ }
24
+ }).catch(function (err) {
25
+ // eslint-disable-next-line no-console
26
+ console.error(err);
27
+ if (window.app && typeof app.alertError === 'function') {
28
+ app.alertError('Erreur lors de l’enregistrement');
29
+ }
30
+ });
31
+ }
32
+
13
33
  ACP.init = function () {
14
34
  const $form = $('.discord-onekite-settings');
15
35
  if (!$form.length) return;
16
36
 
17
- $('#save').off('click.discordOnekite').on('click.discordOnekite', function () {
18
- const payload = {
19
- webhookUrl: String($('#webhookUrl').val() || '').trim(),
20
- notifyReplies: $('#notifyReplies').is(':checked'),
21
- cids: getMultiSelectValues('#cids'),
22
- };
23
-
24
- api.post('/admin/plugins/discord-onekite/save', payload).then(function () {
25
- if (window.app && typeof app.alertSuccess === 'function') {
26
- app.alertSuccess('Paramètres enregistrés !');
27
- }
28
- }).catch(function (err) {
29
- // eslint-disable-next-line no-console
30
- console.error(err);
31
- if (window.app && typeof app.alertError === 'function') {
32
- app.alertError('Erreur lors de l’enregistrement');
33
- }
34
- });
37
+ // Bind save click (button is in the header)
38
+ $(document).off('click.discordOnekite', '#save').on('click.discordOnekite', '#save', function (e) {
39
+ e.preventDefault();
40
+ doSave();
35
41
  });
36
42
  };
37
43
 
@@ -1,8 +1,13 @@
1
1
  <div class="acp-page-container">
2
- <h4>Discord Onekite</h4>
3
- <p class="text-muted">
4
- Notifications Discord via webhook.
5
- </p>
2
+ <div class="d-flex justify-content-between align-items-start mb-3">
3
+ <div>
4
+ <h4 class="mb-1">Discord Onekite</h4>
5
+ <p class="text-muted mb-0">Notifications Discord via webhook.</p>
6
+ </div>
7
+ <button id="save" class="btn btn-primary">
8
+ <i class="fa fa-save"></i> Enregistrer
9
+ </button>
10
+ </div>
6
11
 
7
12
  <form role="form" class="discord-onekite-settings">
8
13
  <div class="mb-3">
@@ -28,7 +33,5 @@
28
33
  Si aucune catégorie n’est sélectionnée : <strong>toutes les catégories</strong> seront notifiées.
29
34
  </p>
30
35
  </div>
31
-
32
- <!-- IMPORT admin/partials/save_button.tpl -->
33
36
  </form>
34
37
  </div>