@nodebb/nodebb-plugin-reactions 1.0.2 → 2.0.0

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.
@@ -2,5 +2,14 @@
2
2
  "reactions": "Reactions",
3
3
  "add-reaction": "Add reaction",
4
4
  "error.invalid-reaction": "Invalid reaction",
5
- "error.maximum-reached": "Maximum reactions reached"
5
+ "error.maximum-reached": "Maximum reactions reached",
6
+ "settings.title": "Reactions plugin settings",
7
+ "settings.max-reactions-per-post": "Maximum unique reactions per post",
8
+ "settings.reaction-reputations": "Reaction Reputations (Optional)",
9
+ "settings.reaction-reputations-help": "You can assign a reputation to individual reactions. When a reaction is applied to a post, the owner of that post will get this reputation.",
10
+ "settings.reaction-reputations.add": "Add Rule",
11
+ "settings.reaction-reputations.reaction": "Reaction",
12
+ "settings.reaction-reputations.reputation": "Reputation",
13
+ "settings.reaction-reputations.remove": "Delete",
14
+ "settings.reaction-reputations.edit": "Edit"
6
15
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "reactions": "Reactions",
3
+ "add-reaction": "הוסף תגובה",
4
+ "error.invalid-reaction": "תגובה לא חוקית",
5
+ "error.maximum-reached": "הגעת למספר התגובות המקסימלי לפוסט",
6
+ "settings.title": "הגדרות תגובות",
7
+ "settings.max-reactions-per-post": "מספר התגובות המקסימלי לפוסט",
8
+ "settings.reaction-reputations": "מוניטין תגובה (אופציונלי)",
9
+ "settings.reaction-reputations-help": "אתה יכול להקצות מוניטין לתגובות מסוימות. כאשר התגובה נוספת לפוסט, בעל הפוסט יקבל את המוניטין שנקבע.",
10
+ "settings.reaction-reputations.add": "הוסף כלל",
11
+ "settings.reaction-reputations.reaction": "תגובה",
12
+ "settings.reaction-reputations.reputation": "מוניטין",
13
+ "settings.reaction-reputations.remove": "הסר",
14
+ "settings.reaction-reputations.edit": "ערוך"
15
+ }
package/library.js CHANGED
@@ -203,33 +203,29 @@ SocketPlugins.reactions = {
203
203
 
204
204
  data.uid = socket.uid;
205
205
 
206
- try {
207
- const settings = await meta.settings.get('reactions');
208
- const maximumReactions = settings.maximumReactions || DEFAULT_MAX_EMOTES;
209
- const [totalReactions, isMember, alreadyReacted, reactionReputation] = await Promise.all([
210
- db.setCount(`pid:${data.pid}:reactions`),
211
- db.isSetMember(`pid:${data.pid}:reactions`, data.reaction),
212
- db.isSetMember(`pid:${data.pid}:reaction:${data.reaction}`, socket.uid),
213
- getReactionReputation(data.reaction),
214
- ]);
215
-
216
- if (!isMember && totalReactions >= maximumReactions) {
217
- throw new Error('[[reactions:error.maximum-reached]]');
218
- }
206
+ const settings = await meta.settings.get('reactions');
207
+ const maximumReactions = settings.maximumReactions || DEFAULT_MAX_EMOTES;
208
+ const [totalReactions, isMember, alreadyReacted, reactionReputation] = await Promise.all([
209
+ db.setCount(`pid:${data.pid}:reactions`),
210
+ db.isSetMember(`pid:${data.pid}:reactions`, data.reaction),
211
+ db.isSetMember(`pid:${data.pid}:reaction:${data.reaction}`, socket.uid),
212
+ getReactionReputation(data.reaction),
213
+ ]);
219
214
 
220
- await Promise.all([
221
- db.setAdd(`pid:${data.pid}:reactions`, data.reaction),
222
- db.setAdd(`pid:${data.pid}:reaction:${data.reaction}`, socket.uid),
223
- ]);
215
+ if (!isMember && totalReactions >= maximumReactions) {
216
+ throw new Error('[[reactions:error.maximum-reached]]');
217
+ }
224
218
 
225
- if (!alreadyReacted && reactionReputation > 0) {
226
- await giveOwnerReactionReputation(reactionReputation, data.pid);
227
- }
219
+ await Promise.all([
220
+ db.setAdd(`pid:${data.pid}:reactions`, data.reaction),
221
+ db.setAdd(`pid:${data.pid}:reaction:${data.reaction}`, socket.uid),
222
+ ]);
228
223
 
229
- await sendEvent(data, 'event:reactions.addPostReaction');
230
- } catch (e) {
231
- console.error(e);
224
+ if (!alreadyReacted && reactionReputation > 0) {
225
+ await giveOwnerReactionReputation(reactionReputation, data.pid);
232
226
  }
227
+
228
+ await sendEvent(data, 'event:reactions.addPostReaction');
233
229
  },
234
230
  removePostReaction: async function (socket, data) {
235
231
  if (!socket.uid) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nodebb/nodebb-plugin-reactions",
3
- "version": "1.0.2",
3
+ "version": "2.0.0",
4
4
  "nbbpm": {
5
- "compatibility": "^1.19.7"
5
+ "compatibility": "^3.0.0"
6
6
  },
7
7
  "description": "Reactions plugin for NodeBB",
8
8
  "main": "library.js",
@@ -33,15 +33,14 @@
33
33
  "url": "https://github.com/barisusakli"
34
34
  }
35
35
  ],
36
- "dependencies": {},
37
36
  "peerDependencies": {
38
- "nodebb-plugin-emoji": "^4.0.0"
37
+ "nodebb-plugin-emoji": "^5.0.0"
39
38
  },
40
39
  "license": "MIT",
41
40
  "devDependencies": {
42
- "eslint": "^7.32.0",
43
- "eslint-config-nodebb": "0.0.2",
44
- "eslint-plugin-import": "^2.24.1"
41
+ "eslint": "^8.40.0",
42
+ "eslint-config-nodebb": "^0.2.1",
43
+ "eslint-plugin-import": "^2.27.5"
45
44
  },
46
45
  "scripts": {
47
46
  "lint": "eslint ."
package/plugin.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "id": "nodebb-plugin-reactions",
3
3
  "name": "NodeBB Reactions",
4
4
  "description": "Reactions plugin for NodeBB",
5
- "url": "https://github.com/pichalite/nodebb-plugin-reactions",
5
+ "url": "https://github.com/NodeBB-Community/nodebb-plugin-reactions",
6
6
  "library": "./library.js",
7
7
  "templates": "templates",
8
8
  "languages": "languages",
9
- "less": [
10
- "less/reactions.less"
9
+ "scss": [
10
+ "scss/reactions.scss"
11
11
  ],
12
12
  "scripts": [
13
13
  "public/client.js"
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "nodebb/public"
3
+ }
package/public/admin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  define('admin/plugins/reactions', [
4
- 'settings', 'alerts', 'hooks', 'emoji-dialog', 'emoji',
4
+ 'settings', 'alerts', 'hooks', 'emoji-dialog', 'emoji',
5
5
  ], function (Settings, alerts, hooks, emojiDialog, emoji) {
6
6
  var ACP = {};
7
7
  ACP.init = function () {
@@ -16,7 +16,7 @@ define('admin/plugins/reactions', [
16
16
  if (reactionEl.length) {
17
17
  const reaction = reactionEl.attr('data-reaction');
18
18
  if (reaction) {
19
- const foundEmoji = emoji.table[reaction]
19
+ const foundEmoji = emoji.table[reaction];
20
20
  if (foundEmoji) {
21
21
  reactionEl.html(emoji.buildEmoji(foundEmoji));
22
22
  }
@@ -45,6 +45,7 @@ define('admin/plugins/reactions', [
45
45
  alert_id: 'reactions-saved',
46
46
  title: 'Settings Saved',
47
47
  message: 'Reactions plugin settings saved',
48
+ timeout: 3000,
48
49
  });
49
50
  });
50
51
  });
package/public/client.js CHANGED
@@ -4,8 +4,8 @@ $(document).ready(function () {
4
4
  setupPostReactions();
5
5
 
6
6
  function setupPostReactions() {
7
- require(['hooks'], function (hooks) {
8
- hooks.on('action:ajaxify.end', function (data) {
7
+ require(['hooks', 'alerts'], function (hooks, alerts) {
8
+ hooks.on('action:ajaxify.end', function () {
9
9
  if (ajaxify.data.template.topic) {
10
10
  setupReactionSockets();
11
11
  createReactionTooltips();
@@ -22,7 +22,7 @@ $(document).ready(function () {
22
22
  reaction: reaction,
23
23
  }, function (err) {
24
24
  if (err) {
25
- app.alertError(err.message);
25
+ alerts.error(err.message);
26
26
  }
27
27
  });
28
28
  });
@@ -41,7 +41,7 @@ $(document).ready(function () {
41
41
  reaction: name,
42
42
  }, function (err) {
43
43
  if (err) {
44
- app.alertError(err.message);
44
+ alerts.error(err.message);
45
45
  throw err;
46
46
  }
47
47
 
@@ -80,7 +80,7 @@ $(document).ready(function () {
80
80
  var reactionEl = $('[component="post/reaction"][data-pid="' + data.pid + '"][data-reaction="' + data.reaction + '"]');
81
81
 
82
82
  if (parseInt(data.reactionCount, 10) === 0) {
83
- reactionEl.tooltip('destroy');
83
+ reactionEl.tooltip('dispose');
84
84
  reactionEl.remove();
85
85
  }
86
86
 
@@ -0,0 +1,29 @@
1
+ .reactions {
2
+ .reaction {
3
+ border: 1px solid #9ddefe;
4
+ display: inline-block;
5
+ border-radius: 4px;
6
+ padding: 2px 4px;
7
+ margin: 0 1px;
8
+ cursor: pointer;
9
+ .emoji {
10
+ height: 18px;
11
+ }
12
+ &.reacted {
13
+ border: 1px solid #039BE5;
14
+ }
15
+ .reaction-emoji-count {
16
+ margin-left: 5px;
17
+ &:before {
18
+ content: attr(data-count);
19
+ }
20
+ }
21
+ }
22
+ .reaction-add {
23
+ margin-right: 10px;
24
+ cursor: pointer;
25
+ &.max-reactions {
26
+ display: none !important;
27
+ }
28
+ }
29
+ }
@@ -1,10 +1,10 @@
1
1
  <form>
2
2
  <div class="form-group">
3
- <label for="reaction">Reaction</label>
4
- <input type="text" id="reaction" name="reaction" class="form-control" placeholder="Reaction" />
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]]" />
5
5
  </div>
6
6
  <div class="form-group">
7
- <label for="reputation">Reputation</label>
8
- <input type="number" id="reputation" name="reputation" class="form-control" placeholder="reputation" />
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]]" />
9
9
  </div>
10
10
  </form>
@@ -2,11 +2,11 @@
2
2
  <div class="row">
3
3
  <div class="col-xs-9">
4
4
  <span data-reaction="{reaction}"></span><strong> {reaction}</strong><br />
5
- <small>Reputation: {reputation}</small>
5
+ <small>[[reactions:settings.reaction-reputations.reaction]]: {reputation}</small>
6
6
  </div>
7
7
  <div class="col-xs-3 text-right">
8
- <button type="button" data-type="edit" class="btn btn-info">Edit</button>
9
- <button type="button" data-type="remove" class="btn btn-danger">Delete</button>
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>
10
10
  </div>
11
11
  </div>
12
12
  </li>
@@ -1,31 +1,26 @@
1
1
  <form role="form" class="reactions-settings">
2
2
  <div class="row">
3
- <div class="col-sm-2 col-xs-12 settings-header">Reactions plugin settings</div>
3
+ <div class="col-sm-2 col-xs-12 settings-header">[[reactions:settings.title]]</div>
4
4
  <div class="col-sm-10 col-xs-12">
5
5
  <div class="form-group">
6
- <label>Maximum unique reactions per post</label>
6
+ <label>[[reactions:settings.max-reactions-per-post]]</label>
7
7
  <input type="text" class="form-control" id="maximumReactions" name="maximumReactions">
8
8
  </div>
9
9
  </div>
10
10
  </div>
11
11
  <div class="row">
12
- <div class="col-sm-2 col-xs-12 settings-header">Reaction Reputations (Optional)</div>
13
- <div class="col-sm-10 col-xs-12">
12
+ <div class="col-sm-2 col-xs-12 settings-header">[[reactions:settings.reaction-reputations]]</div>
13
+ <div class="col-sm-10 col-xs-12 mt-2">
14
14
  <p class="help-text">
15
- You can assign a reputation to individual reactions. When a reaction is applied to a post, the owner of that post will get this reputation.
15
+ [[reactions:settings.reaction-reputations-help]]
16
16
  </p>
17
17
  <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">
18
18
  <ul data-type="list" class="list-group"></ul>
19
- <button type="button" data-type="add" class="btn btn-info">Add Item</button>
19
+ <button type="button" data-type="add" class="btn btn-info mt-2">[[reactions:settings.reaction-reputations.add]]</button>
20
20
  </div>
21
21
  </div>
22
22
  </div>
23
23
  </form>
24
24
 
25
25
 
26
-
27
-
28
-
29
- <button id="save" class="floating-button mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored">
30
- <i class="material-icons">save</i>
31
- </button>
26
+ <!-- IMPORT admin/partials/save_button.tpl -->
@@ -1,5 +1,5 @@
1
1
  <span class="reactions" component="post/reactions" data-pid="{./pid}">
2
- <span class="reaction-add {{{ if ./maxReactionsReached }}}max-reactions{{{ end }}}" component="post/reaction/add" data-pid="{./pid}" title="[[reactions:add-reaction]]">
2
+ <span class="reaction-add d-inline-block px-2 mx-1 btn-ghost-sm {{{ if ./maxReactionsReached }}}max-reactions{{{ end }}}" component="post/reaction/add" data-pid="{./pid}" title="[[reactions:add-reaction]]">
3
3
  <i class="fa fa-plus-square-o"></i>
4
4
  </span>
5
5
  {{{ each ./reactions }}}
@@ -1,38 +0,0 @@
1
- @primary-color: #039BE5;
2
-
3
- .reactions {
4
-
5
- .reaction {
6
- border: 1px solid lighten(@primary-color, 35%);
7
- display: inline-block;
8
- border-radius: 4px;
9
- padding: 2px 4px;
10
- margin: 0 1px;
11
- cursor: pointer;
12
-
13
- .emoji {
14
- height: 18px;
15
- }
16
-
17
- &.reacted {
18
- border: 1px solid @primary-color;
19
- }
20
-
21
- .reaction-emoji-count {
22
- margin-left: 5px;
23
-
24
- &:before {
25
- content: attr(data-count);
26
- }
27
- }
28
- }
29
-
30
- .reaction-add {
31
- margin-right: 10px;
32
- cursor: pointer;
33
-
34
- &.max-reactions {
35
- display: none;
36
- }
37
- }
38
- }