nodebb-plugin-dbsearch 5.1.5 → 6.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/lib/dbsearch.js CHANGED
@@ -366,7 +366,6 @@ async function reIndexPids(pids, topic) {
366
366
  async function renderAdmin(req, res) {
367
367
  const results = await getGlobalAndPluginData();
368
368
  results.plugin.progressData = await getProgress();
369
- results.plugin.csrf = req.csrfToken();
370
369
  res.render('admin/plugins/dbsearch', results.plugin);
371
370
  }
372
371
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-dbsearch",
3
- "version": "5.1.5",
3
+ "version": "6.0.1",
4
4
  "description": "A Plugin that lets users search posts and topics",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -19,7 +19,7 @@
19
19
  "license": "BSD-2-Clause",
20
20
  "dependencies": {
21
21
  "lodash": "4.17.21",
22
- "redisearch": "^1.0.0"
22
+ "redisearch": "^1.0.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "eslint": "7.32.0",
@@ -27,6 +27,6 @@
27
27
  "eslint-plugin-import": "2.25.2"
28
28
  },
29
29
  "nbbpm": {
30
- "compatibility": "^1.19.6"
30
+ "compatibility": "^3.0.0"
31
31
  }
32
32
  }
package/public/admin.js CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
- define('admin/plugins/dbsearch', ['alerts'], function (alerts) {
3
+ define('admin/plugins/dbsearch', [
4
+ 'alerts', 'admin/settings',
5
+ ], function (alerts, settings) {
4
6
  var dbsearch = {};
5
7
  var intervalId = 0;
6
8
 
@@ -15,13 +17,13 @@ define('admin/plugins/dbsearch', ['alerts'], function (alerts) {
15
17
  dbsearch.init = function () {
16
18
  $('#save').on('click', function () {
17
19
  $.post(config.relative_path + '/api/admin/plugins/dbsearch/save', {
18
- _csrf: $('#csrf_token').val(),
20
+ _csrf: config.csrf_token,
19
21
  topicLimit: $('#topicLimit').val(),
20
22
  postLimit: $('#postLimit').val(),
21
23
  excludeCategories: $('#exclude-categories').val(),
22
24
  }, function (data) {
23
25
  if (typeof data === 'string') {
24
- alerts.success('Settings saved');
26
+ settings.toggleSaveSuccess($('#save'));
25
27
  }
26
28
  });
27
29
 
@@ -1,77 +1,71 @@
1
- <div class="row">
2
- <div class="col-lg-12">
3
- <div class="panel panel-default">
4
-
5
- <div class="panel-heading"><h4>DB Search</h4></div>
6
-
7
- <div class="panel-body">
8
-
9
- <div class="alert alert-info">
10
- Topics Indexed: <strong id="topics-indexed">{topicsIndexed}</strong> / <strong>{topicCount}</strong>
11
- </div>
12
- <div class="progress">
13
- <div class="topic-progress progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:{progressData.topicsPercent}%;min-width: 2em;">{progressData.topicsPercent}%</div>
14
- </div>
15
-
16
- <div class="alert alert-info">
17
- Posts Indexed: <strong id="posts-indexed">{postsIndexed}</strong> / <strong>{postCount}</strong>
18
- </div>
19
- <div class="progress">
20
- <div class="post-progress progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:{progressData.postsPercent}%;min-width: 2em;">{progressData.postsPercent}%</div>
21
- </div>
22
-
23
- <button class="btn btn-warning" id="reindex" <!-- IF working -->disabled<!-- ENDIF working -->>Re Index</button>
24
- <button class="btn btn-danger" id="clear-index">Clear Index</button>
25
- <span id="work-in-progress" class="<!-- IF !working -->hidden<!-- ENDIF !working -->">
26
- <i class="fa fa-gear fa-spin"></i> Working...
27
- </span>
28
- <hr/>
29
-
30
- <div class="form-group post-search-item">
31
- <label>Select categories to exclude from indexing</label>
32
- <select multiple class="form-control" id="exclude-categories" size="10">
33
- <!-- BEGIN allCategories -->
34
- <option value="{allCategories.value}" <!-- IF allCategories.selected -->selected<!-- ENDIF allCategories.selected -->>{allCategories.text}</option>
35
- <!-- END allCategories -->
36
- </select>
37
- </div>
38
-
39
- <!-- IF languageSupported -->
40
- <form class="form">
41
- <div class="row">
42
- <div class="col-sm-4 col-xs-12">
43
- <div class="form-group">
44
- <label>Index Language</label>
45
- <select class="form-control" id="indexLanguage">
46
- <!-- BEGIN languages -->
47
- <option value="{languages.value}" <!-- IF languages.selected -->selected<!-- ENDIF languages.selected -->>{languages.name}</option>
48
- <!-- END languages -->
49
- </select>
50
- </div>
51
- </div>
52
- </div>
53
- </form>
54
- <button class="btn btn-primary" id="changeLanguage">Change Language</button>
55
- <hr/>
56
- <!-- ENDIF languageSupported -->
57
-
58
- <form class="form">
59
- <div class="row">
60
- <div class="col-sm-4 col-xs-12">
61
- <div class="form-group">
62
- <label>Topic Limit</label>
63
- <input id="topicLimit" type="text" class="form-control" placeholder="Number of topics to return" value="{topicLimit}">
64
- <label>Post Limit</label>
65
- <input id="postLimit" type="text" class="form-control" placeholder="Number of posts to return" value="{postLimit}">
66
- </div>
67
- </div>
68
- </div>
69
- </form>
70
-
71
- <button class="btn btn-primary" id="save">Save</button>
72
-
73
- <input id="csrf_token" type="hidden" value="{csrf}" />
74
- </div>
75
- </div>
76
- </div>
77
- </div>
1
+ <div class="row">
2
+ <div class="col-12">
3
+ <div class="card">
4
+ <div class="card-header">DB Search</div>
5
+ <div class="card-body row">
6
+ <div class="col-6">
7
+ <div class="mb-3">
8
+ <div class="alert alert-info">
9
+ Topics Indexed: <strong id="topics-indexed">{topicsIndexed}</strong> / <strong>{topicCount}</strong>
10
+ </div>
11
+
12
+ <div class="progress" style="height:24px;">
13
+ <div class="topic-progress progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:{progressData.topicsPercent}%;min-width: 2em;">{progressData.topicsPercent}%</div>
14
+ </div>
15
+ </div>
16
+ <div class="mb-3">
17
+ <div class="alert alert-info">
18
+ Posts Indexed: <strong id="posts-indexed">{postsIndexed}</strong> / <strong>{postCount}</strong>
19
+ </div>
20
+ <div class="progress" style="height:24px;">
21
+ <div class="post-progress progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:{progressData.postsPercent}%;min-width: 2em;">{progressData.postsPercent}%</div>
22
+ </div>
23
+ </div>
24
+
25
+ <button class="btn btn-warning" id="reindex" <!-- IF working -->disabled<!-- ENDIF working -->>Re Index</button>
26
+ <button class="btn btn-danger" id="clear-index">Clear Index</button>
27
+ <span id="work-in-progress" class="<!-- IF !working -->hidden<!-- ENDIF !working -->">
28
+ <i class="fa fa-gear fa-spin"></i> Working...
29
+ </span>
30
+
31
+ <hr/>
32
+
33
+ <!-- IF languageSupported -->
34
+ <div class="mb-3">
35
+ <label class="form-label">Index Language</label>
36
+ <select class="form-select" id="indexLanguage">
37
+ <!-- BEGIN languages -->
38
+ <option value="{languages.value}" <!-- IF languages.selected -->selected<!-- ENDIF languages.selected -->>{languages.name}</option>
39
+ <!-- END languages -->
40
+ </select>
41
+ </div>
42
+ <button class="btn btn-primary" id="changeLanguage">Change Language</button>
43
+ <hr/>
44
+ <!-- ENDIF languageSupported -->
45
+
46
+ <div class="mb-3">
47
+ <label class="form-label">Topic Limit</label>
48
+ <input id="topicLimit" type="text" class="form-control" placeholder="Number of topics to return" value="{topicLimit}">
49
+ </div>
50
+ <div class="mb-3">
51
+ <label class="form-label">Post Limit</label>
52
+ <input id="postLimit" type="text" class="form-control" placeholder="Number of posts to return" value="{postLimit}">
53
+ </div>
54
+ </div>
55
+
56
+ <div class="col-6">
57
+ <div class="post-search-item">
58
+ <label class="form-label">Select categories to exclude from indexing</label>
59
+ <select multiple class="form-select" id="exclude-categories" size="30">
60
+ <!-- BEGIN allCategories -->
61
+ <option value="{allCategories.value}" <!-- IF allCategories.selected -->selected<!-- ENDIF allCategories.selected -->>{allCategories.text}</option>
62
+ <!-- END allCategories -->
63
+ </select>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </div>
70
+
71
+ <!-- IMPORT admin/partials/save_button.tpl -->
@@ -1,28 +1,28 @@
1
- 'use strict';
2
-
3
-
4
- const winston = require.main.require('winston');
5
- const db = module.parent.require('./database');
6
-
7
- module.exports = {
8
- name: 'Changing dbsearch mongodb search schema to use _id',
9
- timestamp: Date.UTC(2018, 10, 26),
10
- method: async function () {
11
- const nconf = require.main.require('nconf');
12
- const isMongo = nconf.get('database') === 'mongo';
13
- if (!isMongo) {
14
- return;
15
- }
16
-
17
- const plugin = require('../lib/dbsearch');
18
- await db.client.collection('searchtopic').deleteMany({});
19
- await db.client.collection('searchpost').deleteMany({});
20
- try {
21
- await db.client.collection('searchtopic').dropIndex({ id: 1 });
22
- await db.client.collection('searchpost').dropIndex({ id: 1 });
23
- } catch (err) {
24
- winston.error(err.stack);
25
- }
26
- await plugin.reindex();
27
- },
1
+ 'use strict';
2
+
3
+
4
+ const winston = require.main.require('winston');
5
+ const db = module.parent.require('./database');
6
+
7
+ module.exports = {
8
+ name: 'Changing dbsearch mongodb search schema to use _id',
9
+ timestamp: Date.UTC(2018, 10, 26),
10
+ method: async function () {
11
+ const nconf = require.main.require('nconf');
12
+ const isMongo = nconf.get('database') === 'mongo';
13
+ if (!isMongo) {
14
+ return;
15
+ }
16
+
17
+ const plugin = require('../lib/dbsearch');
18
+ await db.client.collection('searchtopic').deleteMany({});
19
+ await db.client.collection('searchpost').deleteMany({});
20
+ try {
21
+ await db.client.collection('searchtopic').dropIndex({ id: 1 });
22
+ await db.client.collection('searchpost').dropIndex({ id: 1 });
23
+ } catch (err) {
24
+ winston.error(err.stack);
25
+ }
26
+ await plugin.reindex();
27
+ },
28
28
  };