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 +3 -15
- package/library.js +12 -2
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/public/admin.js +1 -1
- package/templates/admin/plugins/discord-onekite.tpl +34 -33
package/README.md
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
# nodebb-plugin-discord-onekite v1.1.4.
|
|
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
|
|
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
|
|
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
package/plugin.json
CHANGED
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
|
-
|
|
2
|
-
|
|
3
|
-
<div
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 -->
|