nodebb-plugin-link-preview 2.0.7 → 2.0.9

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 CHANGED
@@ -70,12 +70,12 @@ async function preview(url) {
70
70
  return false;
71
71
  },
72
72
  }).then((preview) => {
73
- winston.verbose(`[link-preview] ${preview.url} (${preview.contentType}, cache: miss)`);
73
+ // winston.verbose(`[link-preview] ${preview.url} (${preview.contentType}, cache: miss)`);
74
74
  cache.set(`link-preview:${url}`, preview);
75
75
 
76
76
  return preview;
77
77
  }).catch(() => {
78
- winston.verbose(`[link-preview] ${url} (invalid, cache: miss)`);
78
+ // winston.verbose(`[link-preview] ${url} (invalid, cache: miss)`);
79
79
  cache.set(`link-preview:${url}`, { url });
80
80
  });
81
81
  }
@@ -132,6 +132,7 @@ async function process(content, { type, pid, tid, attachments }) {
132
132
 
133
133
  // Render cache hits immediately
134
134
  let attachmentHtml = '';
135
+ let placeholderHtml = '';
135
136
  const cold = new Set();
136
137
  await Promise.all(Array.from(requests.keys()).map(async (url) => {
137
138
  const options = requests.get(url);
@@ -155,6 +156,9 @@ async function process(content, { type, pid, tid, attachments }) {
155
156
  }
156
157
  }
157
158
  } else {
159
+ if (options.type === 'attachment') {
160
+ placeholderHtml += `<p><a href="${url}" rel="nofollow ugc">${url}</a></p>`;
161
+ }
158
162
  cold.add(url);
159
163
  }
160
164
  }));
@@ -217,6 +221,7 @@ async function process(content, { type, pid, tid, attachments }) {
217
221
 
218
222
  content = $.html();
219
223
  content += attachmentHtml ? `\n\n<div class="row"><div class="col-12">${attachmentHtml}</div></div>` : '';
224
+ content += placeholderHtml ? `\n\n<div class="row"><div class="col-12">${placeholderHtml}</div></div>` : '';
220
225
  return content;
221
226
  }
222
227
 
@@ -224,7 +229,7 @@ async function render(preview) {
224
229
  const { app } = require.main.require('./src/webserver');
225
230
  const { embedHtml, embedImage, embedAudio, embedVideo } = await meta.settings.get('link-preview');
226
231
 
227
- winston.verbose(`[link-preview] ${preview.url} (${preview.contentType || 'invalid'}, cache: hit)`);
232
+ // winston.verbose(`[link-preview] ${preview.url} (${preview.contentType || 'invalid'}, cache: hit)`);
228
233
 
229
234
  if (!preview.contentType) {
230
235
  return false;
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "nodebb-plugin-link-preview",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "nodebb-plugin-link-preview",
9
- "version": "2.0.7",
9
+ "version": "2.0.9",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "cheerio": "^1.0.0-rc.12",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-link-preview",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "A starter kit for quickly creating NodeBB plugins",
5
5
  "main": "library.js",
6
6
  "repository": {