@nodebb/nodebb-plugin-reactions 2.2.10 → 3.0.1

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
@@ -8,6 +8,11 @@ Install via one-click activation in the Admin Control Panel or run the following
8
8
 
9
9
  npm i @nodebb/nodebb-plugin-reactions
10
10
 
11
+ # Emojis in Topic Titles and Notifications
12
+
13
+ In the admin settings of nodebb-plugin-emoji, turn on "Parse emojis in topic titles" to see emojis as images in topic titles and notifications.
14
+ ![](https://private-user-images.githubusercontent.com/2583394/586759879-5b4e6cc9-3568-48fa-a556-83bdb24bd8f2.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Nzc3NDAwNzAsIm5iZiI6MTc3NzczOTc3MCwicGF0aCI6Ii8yNTgzMzk0LzU4Njc1OTg3OS01YjRlNmNjOS0zNTY4LTQ4ZmEtYTU1Ni04M2JkYjI0YmQ4ZjIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDUwMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA1MDJUMTYzNjEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmJkY2ZhZDE0N2ZiMzRjODMyOGM2ODg1NTlkNWU1NDg5ZmEyNGI1MzlkYjg4ODZlNDFjZWUzNmU0Zjk0ZDUwMCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.PoBRMpH7ByDbA-uXoyHAoHFr3eiiN4IYy-Wvqy3p2pM)
15
+
11
16
  # Screenshots
12
17
 
13
18
  ## Reactions:
package/library.js CHANGED
@@ -1,19 +1,19 @@
1
1
  'use strict';
2
2
 
3
- const meta = require.main.require('./src/meta');
4
- const user = require.main.require('./src/user');
5
- const posts = require.main.require('./src/posts');
6
- const topics = require.main.require('./src/topics');
7
- const messaging = require.main.require('./src/messaging');
8
- const privileges = require.main.require('./src/privileges');
9
- const db = require.main.require('./src/database');
10
- const translator = require.main.require('./src/translator');
11
- const notifications = require.main.require('./src/notifications');
12
- const routesHelpers = require.main.require('./src/routes/helpers');
13
- const websockets = require.main.require('./src/socket.io/index');
14
- const SocketPlugins = require.main.require('./src/socket.io/plugins');
15
-
16
- const emojiParser = require.main.require('nodebb-plugin-emoji/build/lib/parse.js');
3
+ const meta = nodebb.require('./src/meta');
4
+ const user = nodebb.require('./src/user');
5
+ const posts = nodebb.require('./src/posts');
6
+ const topics = nodebb.require('./src/topics');
7
+ const messaging = nodebb.require('./src/messaging');
8
+ const privileges = nodebb.require('./src/privileges');
9
+ const db = nodebb.require('./src/database');
10
+ const translator = nodebb.require('./src/translator');
11
+ const notifications = nodebb.require('./src/notifications');
12
+ const routesHelpers = nodebb.require('./src/routes/helpers');
13
+ const websockets = nodebb.require('./src/socket.io/index');
14
+ const SocketPlugins = nodebb.require('./src/socket.io/plugins');
15
+
16
+ const emojiParser = nodebb.require('nodebb-plugin-emoji/build/lib/parse.js');
17
17
 
18
18
  let emojiTable = null;
19
19
  let emojiAliases = null;
@@ -22,14 +22,14 @@ const DEFAULT_MAX_EMOTES = 4;
22
22
 
23
23
  function nameToEmoji(name) {
24
24
  if (!emojiTable) {
25
- emojiTable = require.main.require('nodebb-plugin-emoji/build/emoji/table.json');
25
+ emojiTable = nodebb.require('nodebb-plugin-emoji/build/emoji/table.json');
26
26
  }
27
27
  return emojiTable[name];
28
28
  }
29
29
 
30
30
  function parse(name) {
31
31
  if (!emojiAliases) {
32
- emojiAliases = require.main.require('nodebb-plugin-emoji/build/emoji/aliases.json');
32
+ emojiAliases = nodebb.require('nodebb-plugin-emoji/build/emoji/aliases.json');
33
33
  }
34
34
  const emoji = nameToEmoji(name) || emojiTable[emojiAliases[name]];
35
35
  return emoji ? emojiParser.buildEmoji(emoji, '') : '';
@@ -375,18 +375,18 @@ SocketPlugins.reactions = {
375
375
  }
376
376
 
377
377
  if (postData.uid && postData.uid !== socket.uid) {
378
- const [userData, topicData, parsedPostData] = await Promise.all([
379
- user.getUserFields(socket.uid, ['username', 'fullname']),
380
- topics.getTopicFields(data.tid, ['title']),
378
+ const [displayname, topicTitle, parsedPostData] = await Promise.all([
379
+ user.getNotificationDisplayname(socket.uid),
380
+ topics.getNotificationTitle(data.tid),
381
381
  posts.parsePost(postData),
382
382
  ]);
383
383
  const notifObj = await notifications.create({
384
384
  type: 'reaction',
385
385
  bodyShort: translator.compile(
386
386
  'reactions:notification.user-has-reacted-with-to-your-post-in-topic',
387
- userData.displayname,
387
+ displayname,
388
388
  `:${data.reaction}:`,
389
- topicData.title
389
+ topicTitle
390
390
  ),
391
391
  bodyLong: parsedPostData.content,
392
392
  nid: `uid:${socket.uid}:pid:${data.pid}:reaction:${data.reaction}`,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nodebb/nodebb-plugin-reactions",
3
- "version": "2.2.10",
3
+ "version": "3.0.1",
4
4
  "nbbpm": {
5
- "compatibility": "^3.6.0 || ^4.0.0"
5
+ "compatibility": "^4.14.0"
6
6
  },
7
7
  "description": "Reactions plugin for NodeBB",
8
8
  "main": "library.js",
@@ -38,8 +38,8 @@
38
38
  },
39
39
  "license": "MIT",
40
40
  "devDependencies": {
41
- "eslint": "10.0.2",
42
- "eslint-config-nodebb": "^2.0.0"
41
+ "eslint": "10.6.0",
42
+ "eslint-config-nodebb": "^2.0.3"
43
43
  },
44
44
  "scripts": {
45
45
  "lint": "eslint ."
package/public/client.js CHANGED
@@ -236,9 +236,9 @@ $(document).ready(function () {
236
236
  return;
237
237
  }
238
238
  if (usernames.length + data.otherCount > data.cutoff) {
239
- usernames = usernames.join(', ').replace(/,/g, '|');
240
- usernames = await translator.translate('[[topic:users_and_others, ' + usernames + ', ' + data.otherCount + ']]');
241
- usernames = usernames.replace(/\|/g, ',');
239
+ usernames = await translator.translate(
240
+ translator.compile('topic:users-and-others', usernames.join(', '), data.otherCount),
241
+ );
242
242
  } else {
243
243
  usernames = usernames.join(', ');
244
244
  }
@@ -1,10 +1,10 @@
1
1
  <form>
2
- <div class="form-group">
3
- <label for="reaction">[[reactions:settings.reaction-reputations.reaction]]</label>
4
- <input type="text" id="reaction" name="reaction" class="form-control" placeholder="[[reactions:settings.reaction-reputations.reaction]]" />
2
+ <div class="mb-3">
3
+ <label class="form-label" for="reaction">{{tx("reactions:settings.reaction-reputations.reaction")}}</label>
4
+ <input type="text" id="reaction" name="reaction" class="form-control" placeholder="{{tx("reactions:settings.reaction-reputations.reaction")}}" />
5
5
  </div>
6
- <div class="form-group">
7
- <label for="reputation">[[reactions:settings.reaction-reputations.reputation]]</label>
8
- <input type="number" id="reputation" name="reputation" class="form-control" placeholder="[[reactions:settings.reaction-reputations.reputation]]" />
6
+ <div class="mb-3">
7
+ <label class="form-label" for="reputation">{{tx("reactions:settings.reaction-reputations.reputation")}}</label>
8
+ <input type="number" id="reputation" name="reputation" class="form-control" placeholder="{{tx("reactions:settings.reaction-reputations.reputation")}}" />
9
9
  </div>
10
10
  </form>
@@ -1,12 +1,12 @@
1
1
  <li data-type="item" class="list-group-item">
2
- <div class="row">
3
- <div class="col-xs-9">
2
+ <div class="row align-items-center">
3
+ <div class="col-9">
4
4
  <span data-reaction="{reaction}"></span><strong> {reaction}</strong><br />
5
- <small>[[reactions:settings.reaction-reputations.reaction]]: {reputation}</small>
5
+ <small>{{tx("reactions:settings.reaction-reputations.reputation")}}: {reputation}</small>
6
6
  </div>
7
- <div class="col-xs-3 text-right">
8
- <button type="button" data-type="edit" class="btn btn-info">[[reactions:settings.reaction-reputations.edit]]</button>
9
- <button type="button" data-type="remove" class="btn btn-danger">[[reactions:settings.reaction-reputations.remove]]</button>
7
+ <div class="col-3 d-flex gap-2">
8
+ <button type="button" data-type="edit" class="btn btn-sm btn-info">{{tx("reactions:settings.reaction-reputations.edit")}}</button>
9
+ <button type="button" data-type="remove" class="btn btn-sm btn-danger">{{tx("reactions:settings.reaction-reputations.remove")}}</button>
10
10
  </div>
11
11
  </div>
12
12
  </li>
@@ -6,50 +6,50 @@
6
6
  <div id="spy-container" class="col-12 col-md-8 px-0 mb-4" tabindex="0">
7
7
  <form role="form" class="reactions-settings">
8
8
  <div class="mb-3">
9
- <h5 class="fw-bold tracking-tight settings-header">[[reactions:settings.title]]</h5>
9
+ <h5 class="fw-bold tracking-tight settings-header">{{tx("reactions:settings.title")}}</h5>
10
10
  <div class="form-check form-switch mb-3">
11
11
  <input id="enablePostReactions" name="enablePostReactions" type="checkbox" class="form-check-input">
12
- <label for="enablePostReactions" class="form-check-label">[[reactions:settings.enable-post-reactions]]</label>
12
+ <label for="enablePostReactions" class="form-check-label">{{tx("reactions:settings.enable-post-reactions")}}</label>
13
13
  </div>
14
14
  <div class="mb-3">
15
- <label class="form-label">[[reactions:settings.max-reactions-per-post]]</label>
15
+ <label class="form-label">{{tx("reactions:settings.max-reactions-per-post")}}</label>
16
16
  <input type="number" min="0" class="form-control" id="maximumReactions" name="maximumReactions">
17
17
  </div>
18
18
  <div class="mb-3">
19
- <label class="form-label">[[reactions:settings.max-reactions-per-user-per-post]]</label>
19
+ <label class="form-label">{{tx("reactions:settings.max-reactions-per-user-per-post")}}</label>
20
20
  <input type="number" min="0" class="form-control" id="maximumReactionsPerUserPerPost" name="maximumReactionsPerUserPerPost">
21
21
  <p class="form-text">
22
- [[reactions:settings.max-reactions-per-user-per-post-help]]
22
+ {{tx("reactions:settings.max-reactions-per-user-per-post-help")}}
23
23
  </p>
24
24
  </div>
25
25
  <hr/>
26
26
  <div class="form-check form-switch mb-3">
27
27
  <input id="enableMessageReactions" name="enableMessageReactions" type="checkbox" class="form-check-input">
28
- <label for="enableMessageReactions" class="form-check-label">[[reactions:settings.enable-message-reactions]]</label>
28
+ <label for="enableMessageReactions" class="form-check-label">{{tx("reactions:settings.enable-message-reactions")}}</label>
29
29
  </div>
30
30
  <div class="mb-3">
31
- <label class="form-label">[[reactions:settings.max-reactions-per-message]]</label>
31
+ <label class="form-label">{{tx("reactions:settings.max-reactions-per-message")}}</label>
32
32
  <input type="number" min="0" class="form-control" id="maximumReactionsPerMessage" name="maximumReactionsPerMessage">
33
33
 
34
34
  </div>
35
35
  <div class="">
36
- <label class="form-label">[[reactions:settings.max-reactions-per-user-per-message]]</label>
36
+ <label class="form-label">{{tx("reactions:settings.max-reactions-per-user-per-message")}}</label>
37
37
  <input type="number" min="0" class="form-control" id="maximumReactionsPerUserPerMessage" name="maximumReactionsPerUserPerMessage">
38
38
  <p class="form-text">
39
- [[reactions:settings.max-reactions-per-user-per-message-help]]
39
+ {{tx("reactions:settings.max-reactions-per-user-per-message-help")}}
40
40
  </p>
41
41
  </div>
42
42
  </div>
43
43
 
44
44
  <div class="mb-3">
45
- <h5 class="fw-bold tracking-tight settings-header">[[reactions:settings.reaction-reputations]]</h5>
45
+ <h5 class="fw-bold tracking-tight settings-header">{{tx("reactions:settings.reaction-reputations")}}</h5>
46
46
 
47
47
  <p class="form-text">
48
- [[reactions:settings.reaction-reputations-help]]
48
+ {{tx("reactions:settings.reaction-reputations-help")}}
49
49
  </p>
50
50
  <div class="form-group" data-type="sorted-list" data-sorted-list="reaction-reputations" data-item-template="admin/plugins/reactions/partials/sorted-list/emoji-item" data-form-template="admin/plugins/reactions/partials/sorted-list/emoji-form">
51
51
  <ul data-type="list" class="list-group"></ul>
52
- <button type="button" data-type="add" class="btn btn-info mt-2">[[reactions:settings.reaction-reputations.add]]</button>
52
+ <button type="button" data-type="add" class="btn btn-info mt-2">{{tx("reactions:settings.reaction-reputations.add")}}</button>
53
53
  </div>
54
54
  </div>
55
55
  </form>
@@ -1,5 +1,5 @@
1
1
  {{{ if config.enableMessageReactions }}}
2
- <button class="reaction-add btn btn-sm btn-link {{{ if messages.maxReactionsReached }}}max-reactions{{{ end }}}" component="message/reaction/add" data-mid="{messages.mid}" title="[[reactions:add-reaction]]">
2
+ <button class="reaction-add btn btn-sm btn-link {{{ if messages.maxReactionsReached }}}max-reactions{{{ end }}}" component="message/reaction/add" data-mid="{messages.mid}" title="{{tx("reactions:add-reaction")}}">
3
3
  <i class="fa fa-face-smile"></i>
4
4
  </button>
5
5
  {{{ end }}}
@@ -1,4 +1,4 @@
1
1
  <span class="reaction mb-2 {{{ if ./reacted }}}reacted{{{ end }}}" component="message/reaction" data-mid="{./mid}" data-reaction="{./reaction}">
2
- {./reactionImage}
2
+ {{./reactionImage}}
3
3
  <small class="reaction-emoji-count" data-count="{./reactionCount}"></small>
4
4
  </span>
@@ -1,4 +1,4 @@
1
1
  <span class="reaction {{{ if ./reacted }}}reacted{{{ end }}}" component="post/reaction" data-pid="{./pid}" data-reaction="{./reaction}">
2
- {./reactionImage}
2
+ {{./reactionImage}}
3
3
  <small class="reaction-emoji-count" data-count="{./reactionCount}"></small>
4
4
  </span>
@@ -3,7 +3,7 @@
3
3
  {{{ each ./reactions }}}
4
4
  <!-- IMPORT partials/topic/reaction.tpl -->
5
5
  {{{ end }}}
6
- <a href="#" class="reaction-add btn btn-ghost btn-sm {{{ if ./maxReactionsReached }}}max-reactions{{{ end }}}" component="post/reaction/add" data-pid="{./pid}" title="[[reactions:add-reaction]]">
6
+ <a href="#" class="reaction-add btn btn-ghost btn-sm {{{ if ./maxReactionsReached }}}max-reactions{{{ end }}}" component="post/reaction/add" data-pid="{./pid}" title="{{tx("reactions:add-reaction")}}">
7
7
  <i class="fa fa-face-smile text-primary"></i>
8
8
  </a>
9
9
  </span>