nodebb-plugin-link-preview 2.1.3 → 2.1.5
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/library.js +15 -7
- package/package-lock.json +4889 -0
- package/package.json +1 -1
- package/plugin.json +2 -1
- package/static/templates/partials/link-preview/html.tpl +1 -1
package/library.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
const winston = require.main.require('winston');
|
|
7
6
|
const nconf = require.main.require('nconf');
|
|
8
7
|
const dns = require('dns');
|
|
9
8
|
|
|
@@ -12,7 +11,12 @@ const { load } = require('cheerio');
|
|
|
12
11
|
const { isURL } = require('validator');
|
|
13
12
|
|
|
14
13
|
const meta = require.main.require('./src/meta');
|
|
15
|
-
const
|
|
14
|
+
const cacheCreate = require.main.require('./src/cacheCreate');
|
|
15
|
+
const cache = cacheCreate({
|
|
16
|
+
name: 'link-preview',
|
|
17
|
+
max: 10000,
|
|
18
|
+
ttl: 0,
|
|
19
|
+
});
|
|
16
20
|
const posts = require.main.require('./src/posts');
|
|
17
21
|
const postsCache = require.main.require('./src/posts/cache');
|
|
18
22
|
const websockets = require.main.require('./src/socket.io');
|
|
@@ -21,7 +25,7 @@ const controllers = require('./lib/controllers');
|
|
|
21
25
|
|
|
22
26
|
const routeHelpers = require.main.require('./src/routes/helpers');
|
|
23
27
|
|
|
24
|
-
const plugin =
|
|
28
|
+
const plugin = module.exports;
|
|
25
29
|
|
|
26
30
|
plugin.init = async (params) => {
|
|
27
31
|
const { router /* , middleware , controllers */ } = params;
|
|
@@ -236,7 +240,7 @@ async function process(content, { type, pid, tid, attachments }) {
|
|
|
236
240
|
}));
|
|
237
241
|
|
|
238
242
|
let content = $.html();
|
|
239
|
-
content += attachmentHtml ? `\n\n<div class="row">${attachmentHtml}</div>` : '';
|
|
243
|
+
content += attachmentHtml ? `\n\n<div class="row mt-3">${attachmentHtml}</div>` : '';
|
|
240
244
|
|
|
241
245
|
// bust posts cache item
|
|
242
246
|
if (pid) {
|
|
@@ -261,8 +265,8 @@ async function process(content, { type, pid, tid, attachments }) {
|
|
|
261
265
|
}
|
|
262
266
|
|
|
263
267
|
content = $.html();
|
|
264
|
-
content += attachmentHtml ? `\n\n<div class="row"><div class="col-12 mt-3">${attachmentHtml}</div></div>` : '';
|
|
265
|
-
content += placeholderHtml ? `\n\n<div class="row"><div class="col-12 mt-3">${placeholderHtml}</div></div>` : '';
|
|
268
|
+
content += attachmentHtml ? `\n\n<div class="row mt-3"><div class="col-12 mt-3">${attachmentHtml}</div></div>` : '';
|
|
269
|
+
content += placeholderHtml ? `\n\n<div class="row mt-3"><div class="col-12 mt-3">${placeholderHtml}</div></div>` : '';
|
|
266
270
|
return content;
|
|
267
271
|
}
|
|
268
272
|
|
|
@@ -393,4 +397,8 @@ plugin.addAdminNavigation = (header) => {
|
|
|
393
397
|
return header;
|
|
394
398
|
};
|
|
395
399
|
|
|
396
|
-
|
|
400
|
+
plugin.filterAdminCacheGet = function (caches) {
|
|
401
|
+
caches['link-preview'] = cache;
|
|
402
|
+
return caches;
|
|
403
|
+
};
|
|
404
|
+
|