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": "
|
|
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.
|
|
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": "^
|
|
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', [
|
|
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:
|
|
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
|
-
|
|
26
|
+
settings.toggleSaveSuccess($('#save'));
|
|
25
27
|
}
|
|
26
28
|
});
|
|
27
29
|
|
|
@@ -1,77 +1,71 @@
|
|
|
1
|
-
<div class="row">
|
|
2
|
-
<div class="col-
|
|
3
|
-
<div class="
|
|
4
|
-
|
|
5
|
-
<div class="
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
</
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
};
|