hexo-theme-solitude 1.8.0 → 1.8.2
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/README.md +12 -9
- package/README_en.md +9 -6
- package/README_zh-tw.md +8 -7
- package/layout/includes/console.pug +1 -1
- package/layout/includes/footer.pug +2 -2
- package/layout/includes/head/config.pug +3 -3
- package/layout/includes/inject/body.pug +15 -13
- package/layout/includes/inject/head.pug +2 -5
- package/layout/includes/rightmenu.pug +2 -2
- package/layout/includes/widgets/page/links/banner.pug +1 -1
- package/layout/includes/widgets/post/postMeta.pug +18 -17
- package/layout/includes/widgets/third-party/comments/artalk.pug +2 -2
- package/layout/includes/widgets/third-party/comments/comment.pug +1 -12
- package/layout/includes/widgets/third-party/comments/js.pug +12 -0
- package/layout/includes/widgets/third-party/comments/twikoo.pug +17 -22
- package/layout/includes/widgets/third-party/comments/valine.pug +23 -27
- package/layout/includes/widgets/third-party/comments/waline.pug +22 -24
- package/layout/includes/widgets/third-party/news-comment/artalk.pug +6 -7
- package/layout/includes/widgets/third-party/news-comment/newest-comment.pug +5 -5
- package/layout/includes/widgets/third-party/news-comment/valine.pug +20 -18
- package/layout/includes/widgets/third-party/news-comment/waline.pug +11 -9
- package/layout/includes/widgets/third-party/pjax.pug +1 -11
- package/layout/page.pug +1 -0
- package/layout/post.pug +1 -0
- package/package.json +1 -1
- package/plugins.yml +5 -4
- package/scripts/filter/default.js +1 -1
- package/source/css/index.styl +1 -1
- package/source/js/barrage_comment.js +19 -13
- package/source/js/right_menu.js +3 -3
package/README.md
CHANGED
@@ -10,11 +10,11 @@
|
|
10
10
|
|
11
11
|
主题由 [@张洪Heo](https://github.com/zhheo) 作者全权授权、设计!
|
12
12
|
|
13
|
-

|
14
14
|

|
15
15
|

|
16
16
|
[](https://github.com/valor-x/hexo-theme-solitude/stargazers)
|
17
|
-
[](https://www.npmjs.com/package/hexo-theme-solitude)
|
18
18
|
|
19
19
|

|
20
20
|

|
@@ -28,8 +28,9 @@
|
|
28
28
|

|
29
29
|
[](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps)
|
30
30
|
|
31
|
-
[](https://twitter.com/efu_oo)
|
32
|
+
[](https://t.me/solitudePro)
|
33
|
+
[](https://discord.gg/Y8VEvVgW)
|
33
34
|
|
34
35
|

|
35
36
|

|
@@ -37,7 +38,7 @@
|
|
37
38
|
[](https://gitee.com/nsjjd_w/hexo-theme-solitude)
|
38
39
|
[](https://gitlab.com/efu/hexo-theme-solitude)
|
39
40
|
|
40
|
-
[预览](https://efu.me/) 丨 [文档](https://solitude-docs.efu.me/)
|
41
|
+
[预览](https://www.efu.me/) 丨 [文档](https://solitude-docs.efu.me/)
|
41
42
|
|
42
43
|
</div>
|
43
44
|
|
@@ -47,7 +48,7 @@
|
|
47
48
|
|
48
49
|
- 页面懒加载(Pjax)、图片懒加载(LazyLoad)、离线应用(PWA)
|
49
50
|
- 评论(Twikoo、Waline、Valine、Artalk),支持双评论
|
50
|
-
-
|
51
|
+
- 昼夜切换(ColorMode)
|
51
52
|
- 灯箱(medium-zoom、fancybox)
|
52
53
|
- 数学公式(Latex)
|
53
54
|
- 特色页面:即刻短文、我的装备、在线工具、音乐馆、友链鱼塘、相册页、豆瓣页
|
@@ -55,9 +56,11 @@
|
|
55
56
|
|
56
57
|
## Todo
|
57
58
|
|
58
|
-
- [x]
|
59
|
-
- [
|
60
|
-
- [
|
59
|
+
- [x] Artalk 评论
|
60
|
+
- [x] 双评论
|
61
|
+
- [x] 相册
|
62
|
+
|
63
|
+
> 如有問題請提 [issue](https://github.com/valor-x/hexo-theme-solitude/issues)
|
61
64
|
|
62
65
|
## 应用
|
63
66
|
|
package/README_en.md
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|

|
15
15
|

|
16
16
|
[](https://github.com/valor-x/hexo-theme-solitude/stargazers)
|
17
|
-
[](https://www.npmjs.com/package/hexo-theme-solitude)
|
18
18
|
|
19
19
|

|
20
20
|

|
@@ -28,8 +28,9 @@
|
|
28
28
|

|
29
29
|
[](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps)
|
30
30
|
|
31
|
-
[](https://twitter.com/efu_oo)
|
32
|
+
[](https://t.me/solitudePro)
|
33
|
+
[](https://discord.gg/Y8VEvVgW)
|
33
34
|
|
34
35
|

|
35
36
|

|
@@ -55,9 +56,11 @@
|
|
55
56
|
|
56
57
|
## Todo
|
57
58
|
|
58
|
-
- [x]
|
59
|
-
- [
|
60
|
-
- [
|
59
|
+
- [x] Artalk
|
60
|
+
- [x] Use double comment
|
61
|
+
- [x] Album
|
62
|
+
|
63
|
+
> If you have any questions, please issue an [issue](https://github.com/valor-x/hexo-theme-solitude/issues)
|
61
64
|
|
62
65
|
## Setup
|
63
66
|
|
package/README_zh-tw.md
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|

|
15
15
|

|
16
16
|
[](https://github.com/valor-x/hexo-theme-solitude/stargazers)
|
17
|
-
[](https://www.npmjs.com/package/hexo-theme-solitude)
|
18
18
|
|
19
19
|

|
20
20
|

|
@@ -28,8 +28,9 @@
|
|
28
28
|

|
29
29
|
[](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps)
|
30
30
|
|
31
|
-
[](https://twitter.com/efu_oo)
|
32
|
+
[](https://t.me/solitudePro)
|
33
|
+
[](https://discord.gg/Y8VEvVgW)
|
33
34
|
|
34
35
|

|
35
36
|

|
@@ -47,7 +48,7 @@
|
|
47
48
|
|
48
49
|
- 頁面懶載入(Pjax)、圖片懶載入(LazyLoad)、離線應用(PWA)
|
49
50
|
- 評論(Twikoo、Waline、Valine、Artalk),支援雙評論
|
50
|
-
-
|
51
|
+
- 晝夜切換(ColorMode)
|
51
52
|
- 燈箱(medium-zoom、fancybox)
|
52
53
|
- 數學公式(Latex)
|
53
54
|
- 特色頁面:即刻短文、我的裝備、在線工具、音樂館、友鏈魚塘、相冊頁、豆瓣頁
|
@@ -55,9 +56,9 @@
|
|
55
56
|
|
56
57
|
## Todo
|
57
58
|
|
58
|
-
- [x]
|
59
|
-
- [
|
60
|
-
- [
|
59
|
+
- [x] Artalk 評論
|
60
|
+
- [x] 雙評論
|
61
|
+
- [x] 相冊
|
61
62
|
|
62
63
|
## 應用
|
63
64
|
|
@@ -39,7 +39,7 @@ div#console
|
|
39
39
|
div.console-btn-item#consoleMusic(onclick="sco.musicToggle()")
|
40
40
|
span.music-switch(title=_p('console.switch_music'))
|
41
41
|
i.solitude.st-disc-fill
|
42
|
-
if theme.comment.
|
42
|
+
if theme.comment.use && theme.comment.commentBarrage
|
43
43
|
div.console-btn-item.on#consoleCommentBarrage(onclick="sco.switchCommentBarrage()")
|
44
44
|
span.commentBarrage
|
45
45
|
i.solitude.st-chat-fill
|
@@ -52,7 +52,7 @@ div#footer-bar
|
|
52
52
|
a.footer-bar-link(href=url_for("/"))= config.author
|
53
53
|
div.footer-bar-right
|
54
54
|
each item in theme.footer.links
|
55
|
-
a.footer-bar-link(href=url_for(item.url),
|
55
|
+
a.footer-bar-link(href=url_for(item.url), alt=item.name)!= item.name
|
56
56
|
a.footer-bar-link.cc(href=url_for(theme.footer.license), aria-label = 'copyright')
|
57
57
|
i.solitude.st-copyright-line
|
58
58
|
i.solitude.st-creative-commons-by-line
|
@@ -65,5 +65,5 @@ if theme.footer.privacy
|
|
65
65
|
span.cookies-tip= __('cookies.tip')
|
66
66
|
a.cookies-link(href=url_for(theme.footer.privacy), title=_p('cookies.privacy'))
|
67
67
|
i.solitude.st-right-btn-fill
|
68
|
-
if theme.comment.
|
68
|
+
if theme.comment.use && theme.comment.commentBarrage
|
69
69
|
div.comment-barrage.needEndHide
|
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
let comment = false
|
28
28
|
|
29
|
-
if (theme.comment.
|
29
|
+
if (theme.comment.use) {
|
30
30
|
comment = {
|
31
31
|
avatar: theme.comment.avatar,
|
32
32
|
commentBarrage: theme.comment.commentBarrage,
|
@@ -85,7 +85,7 @@
|
|
85
85
|
}
|
86
86
|
}
|
87
87
|
|
88
|
-
if (theme.comment.
|
88
|
+
if (theme.comment.use && theme.comment.commentBarrage) {
|
89
89
|
lang.barrage = {
|
90
90
|
title: _p('commentBarrage.title'),
|
91
91
|
}
|
@@ -106,7 +106,7 @@
|
|
106
106
|
stop: _p('right_menu.music.stop'),
|
107
107
|
}
|
108
108
|
}
|
109
|
-
if (theme.comment.
|
109
|
+
if (theme.comment.use && theme.comment.commentBarrage) {
|
110
110
|
rightMenu.barrage = {
|
111
111
|
open: _p('right_menu.barrage.open'),
|
112
112
|
close: _p('right_menu.barrage.close')
|
@@ -80,19 +80,21 @@ div
|
|
80
80
|
each item in theme.extends.body
|
81
81
|
!= item
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
83
|
+
.js-pjax
|
84
|
+
if comment_js
|
85
|
+
include ../widgets/third-party/comments/js
|
86
|
+
if theme.mermaid
|
87
|
+
script.
|
88
|
+
mermaid.run();
|
89
|
+
if is_home() && theme.carousel && site.posts.data.filter(item => item.recommend === true).slice(0, 6) || false
|
90
|
+
script.
|
91
|
+
carousel_swiper()
|
92
|
+
if page.type === 'says' && theme.says.enable
|
93
|
+
script.
|
94
|
+
GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".bber-content-img img"));
|
95
|
+
sco.changeTimeFormat(document.querySelectorAll('.bber-info-time time'))
|
96
|
+
if theme.busuanzi && (theme.aside.siteinfo.uv || theme.aside.siteinfo.pv)
|
97
|
+
script(async src=url_for(theme.cdn.busuanzi_js))
|
96
98
|
|
97
99
|
|
98
100
|
if theme.footer.randomlink
|
@@ -28,7 +28,7 @@ if theme.pwa.enable
|
|
28
28
|
|
29
29
|
script.
|
30
30
|
console.log(
|
31
|
-
"%c Program: Hexo %c Theme: Solitude %c Version: v1.8.
|
31
|
+
"%c Program: Hexo %c Theme: Solitude %c Version: v1.8.2",
|
32
32
|
"border-radius:5px 0 0 5px;padding: 5px 10px;color:white;background:#ff3842;",
|
33
33
|
"padding: 5px 10px;color:white;background:#3e9f50;",
|
34
34
|
"border-radius:0 5px 5px 0;padding: 5px 10px;background:#0084ff;color:white;"
|
@@ -39,7 +39,4 @@ if theme.extends.head
|
|
39
39
|
!= item
|
40
40
|
|
41
41
|
script(src=url_for(theme.cdn.utils))
|
42
|
-
script(src=url_for(theme.cdn.main))
|
43
|
-
|
44
|
-
if theme.comment.use.includes('Valine')
|
45
|
-
script(src=url_for(theme.cdn.blueimp_md5))
|
42
|
+
script(src=url_for(theme.cdn.main))
|
@@ -17,7 +17,7 @@ div#rightMenu
|
|
17
17
|
div.rightMenu-item#menu-pastetext
|
18
18
|
i.solitude.st-clipboard-fill
|
19
19
|
span= _p('right_menu.paste')
|
20
|
-
if theme.comment.
|
20
|
+
if theme.comment.use
|
21
21
|
div.rightMenu-item#menu-commenttext
|
22
22
|
i.solitude.st-chat-new-fill
|
23
23
|
span= _p('right_menu.comment')
|
@@ -56,7 +56,7 @@ div#rightMenu
|
|
56
56
|
i.solitude(class=item.icon)
|
57
57
|
span= item.name
|
58
58
|
div.rightMenu-group.rightMenu-line.rightMenuOther
|
59
|
-
if theme.right_menu.commentBarrage && theme.comment.
|
59
|
+
if theme.right_menu.commentBarrage && theme.comment.use && theme.comment.commentBarrage
|
60
60
|
div.rightMenu-item#menu-commentBarrage(onclick="sco.switchCommentBarrage()")
|
61
61
|
i.solitude.st-chat-fill
|
62
62
|
span.menu-commentBarrage-text= _p('right_menu.barrage.open')
|
@@ -7,7 +7,7 @@
|
|
7
7
|
a.banner-button.secondary(onclick="travelling()")
|
8
8
|
i.solitude.st-signal-tower-fill
|
9
9
|
span.banner-button-text=_p('link.banner.random')
|
10
|
-
if theme.comment.
|
10
|
+
if theme.comment.use
|
11
11
|
a.banner-button(onclick="sco.scrollToComment()")
|
12
12
|
i.solitude.st-right-btn-fill
|
13
13
|
span.solitude.banner-button-text=_p('link.banner.toComment')
|
@@ -40,25 +40,26 @@
|
|
40
40
|
if theme.post.meta.pv
|
41
41
|
a.post-meta-pv(href=url_for(page.path), title=_p('post.pv'))
|
42
42
|
i.post-meta-icon.solitude.st-fire-fill
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
span.
|
43
|
+
if theme.comment.use
|
44
|
+
case theme.comment.use[0]
|
45
|
+
when "Twikoo"
|
46
|
+
span#twikoo_visitors
|
47
|
+
i.solitude.st-loading-line
|
48
|
+
when "Waline"
|
49
|
+
span.waline-pageview-count
|
50
|
+
i.solitude.st-loading-line
|
51
|
+
when "Valine"
|
52
|
+
span.leancloud_visitors(id=url_for(page.path))
|
53
|
+
span.leancloud-visitors-count
|
54
|
+
i.solitude.st-loading-line
|
55
|
+
when 'Artalk'
|
56
|
+
span#ArtalkPV
|
53
57
|
i.solitude.st-loading-line
|
54
|
-
|
55
|
-
|
58
|
+
else
|
59
|
+
if theme.busuanzi
|
60
|
+
span#busuanzi_value_page_pv
|
56
61
|
i.solitude.st-loading-line
|
57
|
-
|
58
|
-
if theme.busuanzi
|
59
|
-
span#busuanzi_value_page_pv
|
60
|
-
i.solitude.st-loading-line
|
61
|
-
if theme.post.meta.comment && page.comment && theme.comment.count
|
62
|
+
if theme.post.meta.comment && page.comment && theme.comment.count && theme.comment.use
|
62
63
|
span.post-meta-commentcount(title=_p('post.comment'), onclick="sco.scrollTo('post-comment')")
|
63
64
|
i.solitude.st-chat-fill
|
64
65
|
a(href=url_for(page.path) + "#post-comment")
|
@@ -25,7 +25,7 @@ script.
|
|
25
25
|
utils.lightbox($content.querySelectorAll('img:not([atk-emoticon])'))
|
26
26
|
sco.owoBig({body: '.atk-grp', item: '.atk-item'})
|
27
27
|
})
|
28
|
-
!{commentBarrage} &&
|
28
|
+
!{commentBarrage} && barrageArtalk(array)
|
29
29
|
})
|
30
30
|
const destroyArtalk = () => artalkItem.destroy()
|
31
31
|
utils.addGlobalFn('pjax', destroyArtalk, 'destroyArtalk')
|
@@ -54,7 +54,7 @@ script.
|
|
54
54
|
|
55
55
|
if commentBarrage
|
56
56
|
script.
|
57
|
-
async function
|
57
|
+
async function barrageArtalk(array) {
|
58
58
|
await utils.getScript('!{url_for(theme.cdn.commentBarrage)}').then(() => {
|
59
59
|
initializeCommentBarrage(array)
|
60
60
|
})
|
@@ -39,15 +39,4 @@
|
|
39
39
|
when 'Waline'
|
40
40
|
#waline-wrap
|
41
41
|
when 'Artalk'
|
42
|
-
#artalk-wrap
|
43
|
-
|
44
|
-
each name in use
|
45
|
-
case name
|
46
|
-
when 'Twikoo'
|
47
|
-
!=partial('includes/widgets/third-party/comments/twikoo', {}, {cache: true})
|
48
|
-
when 'Waline'
|
49
|
-
!=partial('includes/widgets/third-party/comments/waline', {}, {cache: true})
|
50
|
-
when 'Valine'
|
51
|
-
!=partial('includes/widgets/third-party/comments/valine', {}, {cache: true})
|
52
|
-
when 'Artalk'
|
53
|
-
!=partial('includes/widgets/third-party/comments/artalk', {}, {cache: true})
|
42
|
+
#artalk-wrap
|
@@ -0,0 +1,12 @@
|
|
1
|
+
- const {use} = theme.comment
|
2
|
+
|
3
|
+
each name in use
|
4
|
+
case name
|
5
|
+
when 'Twikoo'
|
6
|
+
!=partial('includes/widgets/third-party/comments/twikoo', {}, {cache: true})
|
7
|
+
when 'Waline'
|
8
|
+
!=partial('includes/widgets/third-party/comments/waline', {}, {cache: true})
|
9
|
+
when 'Valine'
|
10
|
+
!=partial('includes/widgets/third-party/comments/valine', {}, {cache: true})
|
11
|
+
when 'Artalk'
|
12
|
+
!=partial('includes/widgets/third-party/comments/artalk', {}, {cache: true})
|
@@ -12,7 +12,7 @@ script.
|
|
12
12
|
urls: [window.location.pathname],
|
13
13
|
includeReply: false
|
14
14
|
}).then(res => {
|
15
|
-
ele.forEach(item => item.textContent=res[0].count)
|
15
|
+
ele.forEach(item => item.textContent = res[0].count)
|
16
16
|
}).catch(err => {
|
17
17
|
console.error(err)
|
18
18
|
})
|
@@ -33,7 +33,7 @@ script.
|
|
33
33
|
item: '.OwO-items li'
|
34
34
|
})
|
35
35
|
|
36
|
-
!{commentBarrage}
|
36
|
+
if (!{commentBarrage}) await barrageTwikoo()
|
37
37
|
}
|
38
38
|
|
39
39
|
const loadTwikoo = () => {
|
@@ -51,23 +51,20 @@ script.
|
|
51
51
|
|
52
52
|
if commentBarrage
|
53
53
|
script.
|
54
|
-
async function
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
throw new Error("HTTP error! status: " + response.status);
|
69
|
-
}
|
70
|
-
const data = await response.json();
|
54
|
+
async function barrageTwikoo() {
|
55
|
+
await fetch("!{envId}", {
|
56
|
+
method: "POST",
|
57
|
+
headers: {
|
58
|
+
"Content-Type": "application/json"
|
59
|
+
},
|
60
|
+
body: JSON.stringify({
|
61
|
+
event: "COMMENT_GET",
|
62
|
+
accessToken: "!{accessToken}",
|
63
|
+
url: window.location.pathname
|
64
|
+
})
|
65
|
+
}).then(async res => {
|
66
|
+
if (!res.ok) throw new Error("HTTP error! status: " + res.status)
|
67
|
+
const data = await res.json();
|
71
68
|
await utils.getScript('!{url_for(theme.cdn.commentBarrage)}').then(() => {
|
72
69
|
initializeCommentBarrage((data.data).map(item => Object.assign({
|
73
70
|
content: item.comment,
|
@@ -76,7 +73,5 @@ if commentBarrage
|
|
76
73
|
id: item.id
|
77
74
|
})))
|
78
75
|
})
|
79
|
-
}
|
80
|
-
console.error("An error occurred while fetching comments: ", error);
|
81
|
-
}
|
76
|
+
}).catch(error => console.error("An error occurred while fetching comments: ", error))
|
82
77
|
}
|
@@ -27,7 +27,7 @@ script.
|
|
27
27
|
else {
|
28
28
|
await utils.getScript('!{url_for(theme.cdn.valine)}').then(initValine)
|
29
29
|
}
|
30
|
-
!{commentBarrage} &&
|
30
|
+
!{commentBarrage} && barrageValine()
|
31
31
|
}
|
32
32
|
if ('!{use[0]}' === 'Valine' || !{lazyload}) {
|
33
33
|
if (!{lazyload}) utils.loadComment(document.getElementById('vcomment'), loadValine)
|
@@ -39,36 +39,32 @@ script.
|
|
39
39
|
|
40
40
|
if commentBarrage
|
41
41
|
script.
|
42
|
-
async function
|
42
|
+
async function barrageValine() {
|
43
43
|
const url = new URL('!{serverURLs}/1.1/classes/Comment')
|
44
44
|
const params = {
|
45
45
|
url: window.location.pathname,
|
46
46
|
order: '-createdAt'
|
47
47
|
}
|
48
48
|
Object.entries(params).forEach(([key, value]) => url.searchParams.append(key, value))
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
})
|
58
|
-
|
59
|
-
|
60
|
-
}
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
})))
|
71
|
-
} catch (error) {
|
72
|
-
console.error("An error occurred while fetching comments: ", error)
|
73
|
-
}
|
49
|
+
await fetch(url, {
|
50
|
+
method: "GET",
|
51
|
+
headers: {
|
52
|
+
"X-LC-Id": "#{appId}",
|
53
|
+
"X-LC-Key": "#{appKey}",
|
54
|
+
"Content-Type": "application/json"
|
55
|
+
},
|
56
|
+
}).then(async res => {
|
57
|
+
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`)
|
58
|
+
const data = await res.json()
|
59
|
+
if (typeof md5 === "undefined") await utils.getScript('!{url_for(theme.cdn.blueimp_md5)}')
|
60
|
+
await utils.getScript('!{url_for(theme.cdn.commentBarrage)}').then(() =>
|
61
|
+
initializeCommentBarrage(data.results
|
62
|
+
.filter(item => item.url === window.location.pathname)
|
63
|
+
.map(item => ({
|
64
|
+
content: item.comment,
|
65
|
+
nick: item.nick,
|
66
|
+
mailMd5: md5(item.mail),
|
67
|
+
id: item.objectId
|
68
|
+
}))))
|
69
|
+
}).catch(error => console.error("An error occurred while fetching comments: ", error))
|
74
70
|
}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
- const { envId, option ,pageview } = theme.
|
2
|
-
- const { lazyload, count, commentBarrage } = theme.comment
|
1
|
+
- const { envId, option ,pageview } = theme.waline
|
2
|
+
- const { lazyload, count, commentBarrage,use } = theme.comment
|
3
3
|
|
4
4
|
script.
|
5
5
|
!function () {
|
@@ -18,7 +18,10 @@ script.
|
|
18
18
|
const walineInstance = initFn(walineOptions)
|
19
19
|
utils.addGlobalFn('pjax', () => walineInstance.destroy(), 'destroyWaline')
|
20
20
|
GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll('#comment .wl-content img:not(.wl-emoji)'))
|
21
|
-
sco.owoBig(
|
21
|
+
sco.owoBig({
|
22
|
+
body: '.wl-emoji-popup',
|
23
|
+
item: '.wl-tab-wrapper button'
|
24
|
+
})
|
22
25
|
}
|
23
26
|
|
24
27
|
async function loadWaline() {
|
@@ -30,10 +33,10 @@ script.
|
|
30
33
|
initWaline(walineInitFunction)
|
31
34
|
window.walineFn = walineInitFunction
|
32
35
|
}
|
33
|
-
|
36
|
+
!{commentBarrage} && barrageWaline()
|
34
37
|
}
|
35
38
|
|
36
|
-
if (
|
39
|
+
if (!{use[0] === 'Waline'} || !{lazyload}) {
|
37
40
|
if (!{lazyload}) utils.loadComment(document.getElementById('waline-wrap'), loadWaline)
|
38
41
|
else loadWaline()
|
39
42
|
} else window.loadTwoComment = loadWaline
|
@@ -41,27 +44,22 @@ script.
|
|
41
44
|
|
42
45
|
if commentBarrage
|
43
46
|
script.
|
44
|
-
async function
|
47
|
+
async function barrageWaline() {
|
45
48
|
const url = new URL('!{envId}/api/comment')
|
46
49
|
const params = {path: window.location.pathname, sortBy: 'insertedAt_asc'}
|
47
50
|
Object.entries(params).forEach(([key, value]) => url.searchParams.append(key, value))
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
await fetch(url).then(async res => {
|
52
|
+
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`)
|
53
|
+
const data = await res.json();
|
54
|
+
const regex = /<img [^>]*class="wl-emoji"[^>]*>/;
|
55
|
+
await utils.getScript('!{url_for(theme.cdn.commentBarrage)}').then(() => {
|
56
|
+
initializeCommentBarrage(data.data.data
|
57
|
+
.map(item => ({
|
58
|
+
nick: item.nick,
|
59
|
+
mailId: item.avatar,
|
60
|
+
content: item.comment.replace(regex, ''),
|
61
|
+
id: item.objectId
|
62
|
+
})))
|
54
63
|
})
|
55
|
-
|
56
|
-
const data = await response.json();
|
57
|
-
await utils.getScript('!{url_for(theme.cdn.commentBarrage)}')
|
58
|
-
initializeCommentBarrage(data.data.map(item => ({
|
59
|
-
nick: item.nick,
|
60
|
-
mailId: item.avatar,
|
61
|
-
content: item.comment,
|
62
|
-
id: item.objectId
|
63
|
-
})))
|
64
|
-
} catch (error) {
|
65
|
-
console.error("An error occurred while fetching comments: ", error)
|
66
|
-
}
|
64
|
+
}).catch(error => console.error("An error occurred while fetching comments: ", error))
|
67
65
|
}
|
@@ -47,9 +47,8 @@ script.
|
|
47
47
|
}
|
48
48
|
|
49
49
|
const getComment = async (asideList) => {
|
50
|
-
|
51
|
-
|
52
|
-
const res = await fetch(`!{server}/api/v2/stats/latest_comments?${searchParams}`, {method: 'GET'})
|
50
|
+
const searchParams = new URLSearchParams({'site_name': "!{site}", 'limit': '6'})
|
51
|
+
await fetch(`!{server}/api/v2/stats/latest_comments?${searchParams}`, {method: 'GET'}).then(async res => {
|
53
52
|
const result = await res.json()
|
54
53
|
const avatarConfig = await getSetting()
|
55
54
|
const {mirror, params, default: defaults} = avatarConfig.frontend_conf.gravatar
|
@@ -65,11 +64,11 @@ script.
|
|
65
64
|
}))
|
66
65
|
utils.saveToLocal.set('artalk-newest-comments', artalk, !{theme.comment.newest_comment.storage})
|
67
66
|
generateHtml(artalk, asideList)
|
68
|
-
}
|
69
|
-
console.error(
|
67
|
+
}).catch(error => {
|
68
|
+
console.error(error);
|
70
69
|
asideList.textContent = "!{_p('newest_comment.error')}"
|
71
|
-
}
|
72
|
-
}
|
70
|
+
})
|
71
|
+
}
|
73
72
|
|
74
73
|
const newestCommentInit = (asideList) => {
|
75
74
|
const data = utils.saveToLocal.get('artalk-newest-comments')
|
@@ -1,10 +1,10 @@
|
|
1
|
-
if theme.console_plus && theme.comment.newest_comment.enable
|
1
|
+
if theme.comment.use && theme.console_plus && theme.comment.newest_comment.enable
|
2
2
|
case theme.comment.use[0]
|
3
3
|
when 'Twikoo'
|
4
|
-
!=partial('includes/widgets/third-party/news-comment/twikoo',{}, {cache: true})
|
4
|
+
!=partial('includes/widgets/third-party/news-comment/twikoo', {}, {cache: true})
|
5
5
|
when 'Waline'
|
6
|
-
!=partial('includes/widgets/third-party/news-comment/waline',{}, {cache: true})
|
6
|
+
!=partial('includes/widgets/third-party/news-comment/waline', {}, {cache: true})
|
7
7
|
when 'Valine'
|
8
|
-
!=partial('includes/widgets/third-party/news-comment/valine',{}, {cache: true})
|
8
|
+
!=partial('includes/widgets/third-party/news-comment/valine', {}, {cache: true})
|
9
9
|
when 'Artalk'
|
10
|
-
!=partial('includes/widgets/third-party/news-comment/artalk',{}, {cache: true})
|
10
|
+
!=partial('includes/widgets/third-party/news-comment/artalk', {}, {cache: true})
|
@@ -5,7 +5,10 @@ script.
|
|
5
5
|
|
6
6
|
const replacements = [
|
7
7
|
{regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '[!{_p("console.newest_comment.image")}]'},
|
8
|
-
{
|
8
|
+
{
|
9
|
+
regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,
|
10
|
+
replacement: '[!{_p("console.newest_comment.link")}]'
|
11
|
+
},
|
9
12
|
{regex: /```[\s\S]*?```/g, replacement: '[!{_p("console.newest_comment.code")}]'},
|
10
13
|
{regex: /<[^>]+>/g, replacement: ""}
|
11
14
|
];
|
@@ -26,17 +29,16 @@ script.
|
|
26
29
|
}
|
27
30
|
|
28
31
|
const getComment = async () => {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
"
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
const res = await fetch('!{theme.valine.serverURLs}/1.1/classes/Comment?limit=8&order=-createdAt', settings)
|
32
|
+
const settings = {
|
33
|
+
"method": "GET",
|
34
|
+
"headers": {
|
35
|
+
"X-LC-Id": '!{theme.valine.appId}',
|
36
|
+
"X-LC-Key": '!{theme.valine.appKey}',
|
37
|
+
"Content-Type": "application/json"
|
38
|
+
},
|
39
|
+
}
|
40
|
+
if (typeof md5 === "undefined") await utils.getScript('!{url_for(theme.cdn.blueimp_md5)}')
|
41
|
+
await fetch('!{theme.valine.serverURLs}/1.1/classes/Comment?limit=8&order=-createdAt', settings).then(async res => {
|
40
42
|
const result = await res.json()
|
41
43
|
window.res = result
|
42
44
|
const valineArray = result.results.map(e => {
|
@@ -50,10 +52,10 @@ script.
|
|
50
52
|
})
|
51
53
|
utils.saveToLocal.set('valine-newest-comment', valineArray, !{theme.comment.newest_comment.storage})
|
52
54
|
generateHtml(valineArray)
|
53
|
-
}
|
54
|
-
console.error(
|
55
|
+
}).catch(error => {
|
56
|
+
console.error(error);
|
55
57
|
$asideList.textContent = "!{_p('newest_comment.error')}"
|
56
|
-
}
|
58
|
+
})
|
57
59
|
}
|
58
60
|
|
59
61
|
const generateHtml = array => {
|
@@ -70,9 +72,9 @@ script.
|
|
70
72
|
</div>
|
71
73
|
</div>
|
72
74
|
`).join('') : "!{_p('newest_comment.zero')}"
|
73
|
-
window.lazyLoadInstance
|
74
|
-
window.pjax
|
75
|
-
sco
|
75
|
+
window.lazyLoadInstance?.update()
|
76
|
+
window.pjax?.refresh()
|
77
|
+
sco?.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
|
76
78
|
}
|
77
79
|
|
78
80
|
newestCommentInit()
|
@@ -5,7 +5,10 @@ script.
|
|
5
5
|
|
6
6
|
const replacements = [
|
7
7
|
{regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '[!{_p("console.newest_comment.image")}]'},
|
8
|
-
{
|
8
|
+
{
|
9
|
+
regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,
|
10
|
+
replacement: '[!{_p("console.newest_comment.link")}]'
|
11
|
+
},
|
9
12
|
{regex: /<pre><code>.*?<\/pre>/gi, replacement: '[!{_p("console.newest_comment.code")}]'},
|
10
13
|
{regex: /<[^>]+>/g, replacement: ""}
|
11
14
|
];
|
@@ -26,8 +29,7 @@ script.
|
|
26
29
|
}
|
27
30
|
|
28
31
|
const getComment = async () => {
|
29
|
-
|
30
|
-
const res = await fetch('!{theme.waline.envId}/api/comment?type=recent&count=8', {method: 'GET'})
|
32
|
+
await fetch('!{theme.waline.envId}/api/comment?type=recent&count=8', {method: 'GET'}).then(async res => {
|
31
33
|
const result = await res.json()
|
32
34
|
const walineArray = result.data.map(e => {
|
33
35
|
return {
|
@@ -40,10 +42,10 @@ script.
|
|
40
42
|
})
|
41
43
|
utils.saveToLocal.set('waline-newest-comment', walineArray, !{theme.comment.newest_comment.storage})
|
42
44
|
generateHtml(walineArray)
|
43
|
-
}
|
44
|
-
console.error(
|
45
|
+
}).catch(error => {
|
46
|
+
console.error(error)
|
45
47
|
$asideList.textContent = "!{_p('newest_comment.error')}"
|
46
|
-
}
|
48
|
+
})
|
47
49
|
}
|
48
50
|
|
49
51
|
const generateHtml = array => {
|
@@ -60,9 +62,9 @@ script.
|
|
60
62
|
</div>
|
61
63
|
</div>
|
62
64
|
`).join('') : "!{_p('newest_comment.zero')}"
|
63
|
-
window.lazyLoadInstance
|
64
|
-
window.pjax
|
65
|
-
sco
|
65
|
+
window.lazyLoadInstance?.update()
|
66
|
+
window.pjax?.refresh()
|
67
|
+
sco?.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
|
66
68
|
}
|
67
69
|
|
68
70
|
newestCommentInit()
|
@@ -1,17 +1,7 @@
|
|
1
1
|
script.
|
2
|
-
let pjaxSelectors = [
|
3
|
-
'title',
|
4
|
-
'#body-wrap',
|
5
|
-
'#site-config',
|
6
|
-
'meta[name="description"]',
|
7
|
-
'#js-pjax',
|
8
|
-
'meta[property^="og:"]',
|
9
|
-
'#config-diff'
|
10
|
-
]
|
11
|
-
|
12
2
|
const pjax = new Pjax({
|
13
3
|
elements: 'a:not([target="_blank"])',
|
14
|
-
selectors:
|
4
|
+
selectors: ['title','#body-wrap','#site-config','meta[name="description"]','.js-pjax','meta[property^="og:"]','#config-diff'],
|
15
5
|
cacheBust: false,
|
16
6
|
analytics: false,
|
17
7
|
scrollRestoration: false
|
package/layout/page.pug
CHANGED
package/layout/post.pug
CHANGED
package/package.json
CHANGED
package/plugins.yml
CHANGED
@@ -15,14 +15,15 @@ twikoo:
|
|
15
15
|
file: dist/twikoo.all.min.js
|
16
16
|
version: 1.6.32
|
17
17
|
waline_js:
|
18
|
-
name: 'waline'
|
18
|
+
name: '@waline/client'
|
19
19
|
file: dist/waline.js
|
20
20
|
other_name: waline
|
21
21
|
version: 3.1.3
|
22
22
|
waline_css:
|
23
|
-
name: 'waline'
|
23
|
+
name: '@waline/client'
|
24
24
|
file: dist/waline.css
|
25
25
|
version: 3.1.3
|
26
|
+
other_name: waline
|
26
27
|
valine:
|
27
28
|
name: valine
|
28
29
|
file: dist/Valine.min.js
|
@@ -95,12 +96,12 @@ medium_zoom:
|
|
95
96
|
fancyapps_ui:
|
96
97
|
name: '@fancyapps/ui'
|
97
98
|
file: dist/fancybox/fancybox.umd.js
|
98
|
-
version: 5.0.
|
99
|
+
version: 5.0.36
|
99
100
|
other_name: fancyapps-ui
|
100
101
|
fancyapps_css:
|
101
102
|
name: '@fancyapps/ui'
|
102
103
|
file: dist/fancybox/fancybox.css
|
103
|
-
version: 5.0.
|
104
|
+
version: 5.0.36
|
104
105
|
other_name: fancyapps-ui
|
105
106
|
mermaid_js:
|
106
107
|
name: mermaid
|
@@ -19,7 +19,7 @@ hexo.extend.filter.register('after_post_render', function (data) {
|
|
19
19
|
data.excerpt = data.title
|
20
20
|
data.toc = !!(config.aside.toc.page && data.toc !== false && data.aside);
|
21
21
|
}
|
22
|
-
data.comment = !!(config.comment.
|
22
|
+
data.comment = !!(config.comment.use && data.comment !== false);
|
23
23
|
return data;
|
24
24
|
});
|
25
25
|
|
package/source/css/index.styl
CHANGED
@@ -1,15 +1,12 @@
|
|
1
|
-
/**
|
2
|
-
* Comment Barrage
|
3
|
-
* author: @efu
|
4
|
-
* website: efu.me
|
5
|
-
* copyright: MIT
|
6
|
-
* date: 2024-04-12
|
7
|
-
* update: 2024-04-12
|
8
|
-
* @param array
|
9
|
-
*/
|
10
1
|
function initializeCommentBarrage(array) {
|
11
|
-
if (array ===
|
12
|
-
|
2
|
+
if (array === []) return;
|
3
|
+
let existingBarrage = window.currentBarrage;
|
4
|
+
|
5
|
+
if (existingBarrage) {
|
6
|
+
existingBarrage.destroy();
|
7
|
+
}
|
8
|
+
|
9
|
+
let barrage = class {
|
13
10
|
constructor() {
|
14
11
|
this.config = {
|
15
12
|
barrageTimer: [],
|
@@ -36,7 +33,7 @@ function initializeCommentBarrage(array) {
|
|
36
33
|
if (!content) return false;
|
37
34
|
const element = document.createElement("div");
|
38
35
|
element.className = "comment-barrage-item";
|
39
|
-
element.innerHTML = `<div class="barrageHead"><a class="barrageTitle" href="javascript:sco.scrollTo('post-comment')">${GLOBAL_CONFIG.lang.barrage.title}</a><div class="barrageNick">${comment.nick}</div><img class="barrageAvatar" src="${GLOBAL_CONFIG.comment.avatar}/avatar/${comment.mailMd5}"/><a class="comment-barrage-close" href="javascript:sco.switchCommentBarrage();"><i class="solitude st-close-fill"></i></a></div><a class="barrageContent" href="${comment.id ? `javascript:sco.scrollTo(\'${comment.id}\')` : 'javascript:sco.scrollTo(\'post-comment\')'
|
36
|
+
element.innerHTML = `<div class="barrageHead"><a class="barrageTitle" href="javascript:sco.scrollTo('post-comment')">${GLOBAL_CONFIG.lang.barrage.title}</a><div class="barrageNick">${comment.nick}</div><img class="barrageAvatar" src="${GLOBAL_CONFIG.comment.avatar}/avatar/${comment.mailMd5}"/><a class="comment-barrage-close" href="javascript:sco.switchCommentBarrage();"><i class="solitude st-close-fill"></i></a></div><a class="barrageContent" href="${comment.id ? `javascript:sco.scrollTo(\'${comment.id}\')` : 'javascript:sco.scrollTo(\'post-comment\')'}">${content}</a>`;
|
40
37
|
this.config.dom.appendChild(element);
|
41
38
|
this.config.barrageTimer.push(element);
|
42
39
|
return true;
|
@@ -74,5 +71,14 @@ function initializeCommentBarrage(array) {
|
|
74
71
|
this.config.dom.addEventListener('mouseover', () => this.hoverOnCommentBarrage = true);
|
75
72
|
this.config.dom.addEventListener('mouseout', () => this.hoverOnCommentBarrage = false);
|
76
73
|
}
|
77
|
-
|
74
|
+
|
75
|
+
destroy() {
|
76
|
+
clearInterval(this.commentInterval);
|
77
|
+
this.config.dom.removeEventListener('mouseover', () => this.hoverOnCommentBarrage = true)
|
78
|
+
this.config.dom.removeEventListener('mouseout', () => this.hoverOnCommentBarrage = false)
|
79
|
+
this.config.dom.innerHTML = ""
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
window.currentBarrage = new barrage();
|
78
84
|
}
|
package/source/js/right_menu.js
CHANGED
@@ -130,11 +130,11 @@ window.oncontextmenu = (ele) => {
|
|
130
130
|
if (selectTextNow && window.getSelection()) {
|
131
131
|
display = true;
|
132
132
|
rm.menuItems.copy.style.display = 'block';
|
133
|
-
rm.menuItems.comment.style.display = 'block';
|
133
|
+
GLOBAL_CONFIG.comment && (rm.menuItems.comment.style.display = 'block');
|
134
134
|
rm.menuItems.search.style.display = 'block';
|
135
135
|
} else {
|
136
136
|
rm.menuItems.copy.style.display = 'none';
|
137
|
-
rm.menuItems.comment.style.display = 'none';
|
137
|
+
GLOBAL_CONFIG.comment && (rm.menuItems.comment.style.display = 'none');
|
138
138
|
rm.menuItems.search.style.display = 'none';
|
139
139
|
}
|
140
140
|
|
@@ -220,7 +220,7 @@ window.oncontextmenu = (ele) => {
|
|
220
220
|
})
|
221
221
|
|
222
222
|
rm.menuItems.paste.addEventListener('click', () => rm.pasteText() && rm.hideRightMenu())
|
223
|
-
rm.menuItems.comment.addEventListener('click', () => rm.hideRightMenu() || sco.toTalk(selectTextNow))
|
223
|
+
GLOBAL_CONFIG.comment && rm.menuItems.comment.addEventListener('click', () => rm.hideRightMenu() || sco.toTalk(selectTextNow))
|
224
224
|
rm.menuItems.new.addEventListener('click', () => window.open(rm.domhref) && rm.hideRightMenu())
|
225
225
|
rm.menuItems.downloadImg.addEventListener('click', () => rm.downloadImage() && rm.hideRightMenu())
|
226
226
|
rm.menuItems.copyImg.addEventListener('click', () => rm.copyImage() && rm.hideRightMenu())
|