@waline/vercel 1.2.0 → 1.2.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/vercel",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "vercel server for waline comment system",
|
|
5
5
|
"repository": "https://github.com/walinejs/waline",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"@cloudbase/node-sdk": "^2.7.1",
|
|
10
10
|
"@koa/cors": "^3.1.0",
|
|
11
11
|
"akismet": "^2.0.6",
|
|
12
|
+
"deta": "^1.0.1",
|
|
12
13
|
"dompurify": "^2.3.3",
|
|
13
14
|
"fast-csv": "^4.3.6",
|
|
14
15
|
"jsdom": "^17.0.0",
|
|
@@ -26,20 +26,19 @@ async function formatCmt(
|
|
|
26
26
|
comment.type = user.type;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
comment.mail = helper.md5(
|
|
30
|
-
comment.mail ? comment.mail.toLowerCase() : comment.mail
|
|
31
|
-
);
|
|
32
|
-
|
|
33
29
|
const avatarUrl =
|
|
34
30
|
user && user.avatar
|
|
35
31
|
? user.avatar
|
|
36
|
-
:
|
|
37
|
-
|
|
32
|
+
: await think.service('avatar').stringify(comment);
|
|
38
33
|
comment.avatar =
|
|
39
34
|
avatarProxy && !avatarUrl.includes(avatarProxy)
|
|
40
35
|
? avatarProxy + '?url=' + encodeURIComponent(avatarUrl)
|
|
41
36
|
: avatarUrl;
|
|
42
37
|
|
|
38
|
+
comment.mail = helper.md5(
|
|
39
|
+
comment.mail ? comment.mail.toLowerCase() : comment.mail
|
|
40
|
+
);
|
|
41
|
+
|
|
43
42
|
return comment;
|
|
44
43
|
}
|
|
45
44
|
|
|
@@ -71,6 +70,7 @@ module.exports = class extends BaseRest {
|
|
|
71
70
|
'link',
|
|
72
71
|
'mail',
|
|
73
72
|
'nick',
|
|
73
|
+
'url',
|
|
74
74
|
'pid',
|
|
75
75
|
'rid',
|
|
76
76
|
'ua',
|
package/src/controller/index.js
CHANGED
|
@@ -22,6 +22,7 @@ module.exports = class extends think.Controller {
|
|
|
22
22
|
const waline = new Waline({
|
|
23
23
|
el: '#waline',
|
|
24
24
|
path: '/',
|
|
25
|
+
lang: new URLSearchParams(location.search.slice(1)).get('lng'),
|
|
25
26
|
serverURL: location.protocol + '//' + location.host + location.pathname.replace(/\\/+$/, '')
|
|
26
27
|
});
|
|
27
28
|
</script>
|
package/src/logic/base.js
CHANGED
|
@@ -50,16 +50,20 @@ module.exports = class extends think.Logic {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const userInfo = user[0];
|
|
53
|
-
userInfo.mailMd5 = helper.md5(userInfo.email);
|
|
54
53
|
|
|
55
54
|
let avatarUrl = userInfo.avatar
|
|
56
55
|
? userInfo.avatar
|
|
57
|
-
:
|
|
56
|
+
: await think.service('avatar').stringify({
|
|
57
|
+
mail: userInfo.email,
|
|
58
|
+
nick: userInfo.display_name,
|
|
59
|
+
link: userInfo.url,
|
|
60
|
+
});
|
|
58
61
|
const { avatarProxy } = think.config();
|
|
59
62
|
if (avatarProxy) {
|
|
60
63
|
avatarUrl = avatarProxy + '?url=' + encodeURIComponent(avatarUrl);
|
|
61
64
|
}
|
|
62
65
|
userInfo.avatar = avatarUrl;
|
|
66
|
+
userInfo.mailMd5 = helper.md5(userInfo.email);
|
|
63
67
|
this.ctx.state.userInfo = userInfo;
|
|
64
68
|
}
|
|
65
69
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const nunjucks = require('nunjucks');
|
|
2
|
+
const helper = require('think-helper');
|
|
3
|
+
const { GRAVATAR_STR } = process.env;
|
|
4
|
+
|
|
5
|
+
const env = new nunjucks.Environment();
|
|
6
|
+
env.addFilter('md5', (str) => helper.md5(str));
|
|
7
|
+
|
|
8
|
+
module.exports = class extends think.Service {
|
|
9
|
+
async stringify(comment) {
|
|
10
|
+
const fn = think.config('avatarUrl');
|
|
11
|
+
if (think.isFunction(fn)) {
|
|
12
|
+
const ret = await fn(comment);
|
|
13
|
+
if (think.isString(ret) && ret) {
|
|
14
|
+
return ret;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const gravatarStr =
|
|
19
|
+
GRAVATAR_STR || 'https://seccdn.libravatar.org/avatar/{{mail|md5}}';
|
|
20
|
+
return env.renderString(gravatarStr, comment);
|
|
21
|
+
}
|
|
22
|
+
};
|