nodebb-plugin-discord-onekite 1.1.25 → 1.1.27

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,17 +1,5 @@
1
- # nodebb-plugin-discord-onekite v1.1.4.15
2
-
3
- ACP is implemented like the working `nodebb-plugin-calendar-onekite` you provided:
4
- - Admin template uses `admin/partials/settings/header.tpl` + `footer.tpl` (top save bar)
5
- - Admin JS uses NodeBB v3 admin API endpoints:
6
- - GET /api/v3/admin/plugins/discord-onekite/settings
7
- - PUT /api/v3/admin/plugins/discord-onekite/settings
8
- - Save buttons from header are intercepted and call the PUT endpoint.
9
-
10
- Toast:
11
- - Shows "Succès" (title) and "Paramètres enregistrés" (message) via `app.alert` when available.
1
+ # nodebb-plugin-discord-onekite v1.1.4.18
12
2
 
13
3
  Discord:
14
- - Embed only: clickable title (embed.url) + message excerpt in embed.description.
15
-
16
-
17
- Toast updated to match calendar-onekite: alerts.success/error with dedup.
4
+ - Embed title is prefixed with the category name: `[Catégorie] Titre du sujet`
5
+ - Message excerpt remains in embed description.
package/library.js CHANGED
@@ -6,6 +6,7 @@ const routeHelpers = require.main.require('./src/routes/helpers');
6
6
  const meta = require.main.require('./src/meta');
7
7
 
8
8
  const topics = require.main.require('./src/topics');
9
+ const categories = require.main.require('./src/categories');
9
10
  const posts = require.main.require('./src/posts');
10
11
 
11
12
  const controllers = require('./lib/controllers');
@@ -123,13 +124,22 @@ async function buildEmbed({ tid, pid, isReply }) {
123
124
  const topicData = await topics.getTopicFields(tid, ['tid', 'cid', 'title', 'slug', 'mainPid']);
124
125
  if (!topicData) return null;
125
126
 
127
+ let categoryName = '';
128
+ try {
129
+ const cat = await categories.getCategoryData(topicData.cid);
130
+ if (cat && cat.name) categoryName = cat.name;
131
+ } catch (e) {}
132
+
126
133
  const topicUrl = ensureAbsoluteUrl(baseUrl, `/topic/${topicData.slug || topicData.tid}`);
127
134
  const targetUrl = (isReply && pid) ? `${topicUrl}/${pid}` : topicUrl;
128
135
 
129
- const title = (topicData.title || (isReply ? 'Nouvelle réponse' : 'Nouveau sujet')).toString().slice(0, 256);
136
+ const baseTitle = (topicData.title || (isReply ? 'Nouvelle réponse' : 'Nouveau sujet')).toString();
137
+ const title = categoryName ? `[${categoryName}] ${baseTitle}` : baseTitle;
138
+ const safeTitle = title.slice(0, 256);
139
+
130
140
  const excerpt = await getPostExcerpt(isReply ? pid : topicData.mainPid);
131
141
 
132
- return { topicData, embed: { title, url: targetUrl, description: excerpt || '' } };
142
+ return { topicData, embed: { title: safeTitle, url: targetUrl, description: excerpt || '' } };
133
143
  }
134
144
 
135
145
  function extractTidPid(data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-discord-onekite",
3
- "version": "1.1.25",
3
+ "version": "1.1.27",
4
4
  "description": "Discord webhook notifier for Onekite (NodeBB v4.x only)",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/plugin.json CHANGED
@@ -32,5 +32,5 @@
32
32
  "acpScripts": [
33
33
  "public/admin.js"
34
34
  ],
35
- "version": "1.1.4.16"
35
+ "version": "1.1.4.18"
36
36
  }
package/public/admin.js CHANGED
@@ -89,7 +89,7 @@ define('admin/plugins/discord-onekite', ['alerts', 'bootbox'], function (alerts)
89
89
  }
90
90
 
91
91
  function bindSaveButtons() {
92
- const SAVE_SELECTOR = '#save, .save, [data-action="save"], .settings-save, .floating-save, .btn[data-action="save"], #onekite-save, #save-top';
92
+ const SAVE_SELECTOR = '#save, .save, [data-action="save"], .settings-save, .floating-save, .btn[data-action="save"], #onekite-save, #save-top, #onekite-discord-save';
93
93
  if (window.oneKiteDiscordAdminBound) return;
94
94
  window.oneKiteDiscordAdminBound = true;
95
95
 
@@ -1,40 +1,41 @@
1
- <!-- IMPORT admin/partials/settings/header.tpl -->
2
-
3
- <div class="row">
4
- <div class="col-lg-8">
5
- <div class="card mb-3">
6
- <div class="card-header">
7
- <strong>Discord Onekite</strong>
8
- </div>
9
- <div class="card-body">
10
- <p class="text-muted">Notifications Discord via webhook.</p>
1
+ <div class="acp-page-container">
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 class="btn btn-primary" id="onekite-discord-save" type="button">Enregistrer</button>
8
+ </div>
11
9
 
12
- <form class="discord-onekite-settings" role="form">
13
- <div class="mb-3">
14
- <label class="form-label" for="webhookUrl">Discord Webhook URL</label>
15
- <input id="webhookUrl" type="text" class="form-control" placeholder="https://discord.com/api/webhooks/..." value="{settings.webhookUrl}" />
16
- </div>
10
+ <div class="row">
11
+ <div class="col-lg-8">
12
+ <div class="card mb-3">
13
+ <div class="card-body">
14
+ <form class="discord-onekite-settings" role="form">
15
+ <div class="mb-3">
16
+ <label class="form-label" for="webhookUrl">Discord Webhook URL</label>
17
+ <input id="webhookUrl" type="text" class="form-control" placeholder="https://discord.com/api/webhooks/..." value="{settings.webhookUrl}" />
18
+ </div>
17
19
 
18
- <div class="form-check mb-3">
19
- <input class="form-check-input" type="checkbox" id="notifyReplies" <!-- IF settings.notifyReplies -->checked<!-- ENDIF settings.notifyReplies -->>
20
- <label class="form-check-label" for="notifyReplies">Notifier aussi les réponses</label>
21
- </div>
20
+ <div class="form-check mb-3">
21
+ <input class="form-check-input" type="checkbox" id="notifyReplies" <!-- IF settings.notifyReplies -->checked<!-- ENDIF settings.notifyReplies -->>
22
+ <label class="form-check-label" for="notifyReplies">Notifier aussi les réponses</label>
23
+ </div>
22
24
 
23
- <div class="mb-3">
24
- <label class="form-label" for="cidsMulti">Catégories à notifier</label>
25
- <select class="form-select" id="cidsMulti" multiple size="12">
26
- <!-- BEGIN categories -->
27
- <option value="{categories.cid}" <!-- IF categories.selected -->selected<!-- ENDIF categories.selected -->>{categories.name}</option>
28
- <!-- END categories -->
29
- </select>
30
- <p class="form-text text-muted">
31
- Si aucune catégorie n’est sélectionnée : <strong>toutes les catégories</strong> seront notifiées.
32
- </p>
33
- </div>
34
- </form>
25
+ <div class="mb-3">
26
+ <label class="form-label" for="cidsMulti">Catégories à notifier</label>
27
+ <select class="form-select" id="cidsMulti" multiple size="12">
28
+ <!-- BEGIN categories -->
29
+ <option value="{categories.cid}" <!-- IF categories.selected -->selected<!-- ENDIF categories.selected -->>{categories.name}</option>
30
+ <!-- END categories -->
31
+ </select>
32
+ <p class="form-text text-muted">
33
+ Si aucune catégorie n’est sélectionnée : <strong>toutes les catégories</strong> seront notifiées.
34
+ </p>
35
+ </div>
36
+ </form>
37
+ </div>
35
38
  </div>
36
39
  </div>
37
40
  </div>
38
41
  </div>
39
-
40
- <!-- IMPORT admin/partials/settings/footer.tpl -->