hexo-theme-solitude 1.7.12 → 1.7.14

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.
Files changed (36) hide show
  1. package/_config.yml +8 -4
  2. package/languages/en.yml +4 -0
  3. package/languages/zh-CN.yml +4 -0
  4. package/languages/zh-TW.yml +4 -0
  5. package/layout/includes/head/config.pug +40 -39
  6. package/layout/includes/inject/body.pug +8 -11
  7. package/layout/includes/inject/head.pug +9 -36
  8. package/layout/includes/widgets/aside/asideInfoCard.pug +3 -2
  9. package/layout/includes/widgets/home/{leonus.pug → carousel.pug} +1 -1
  10. package/layout/includes/widgets/home/categoryGroup.pug +1 -1
  11. package/layout/includes/widgets/nav/right.pug +4 -41
  12. package/layout/includes/widgets/post/postMeta.pug +6 -0
  13. package/layout/includes/widgets/third-party/comments/artalk.pug +50 -0
  14. package/layout/includes/widgets/third-party/comments/comment.pug +3 -1
  15. package/layout/includes/widgets/third-party/comments/twikoo.pug +31 -2
  16. package/layout/includes/widgets/third-party/comments/valine.pug +44 -12
  17. package/layout/includes/widgets/third-party/comments/waline.pug +41 -14
  18. package/layout/includes/widgets/third-party/news-comment/artalk.pug +98 -0
  19. package/layout/includes/widgets/third-party/news-comment/newest-comment.pug +3 -1
  20. package/layout/includes/widgets/third-party/news-comment/twikoo.pug +9 -7
  21. package/layout/includes/widgets/third-party/news-comment/valine.pug +5 -5
  22. package/layout/includes/widgets/third-party/news-comment/waline.pug +5 -5
  23. package/layout/index.pug +2 -2
  24. package/package.json +1 -1
  25. package/plugins.yml +8 -4
  26. package/scripts/event/cdn.js +2 -12
  27. package/source/css/_layout/aside.styl +30 -26
  28. package/source/css/_layout/header.styl +48 -48
  29. package/source/css/_page/_home/carousel.styl +5 -2
  30. package/source/css/_page/_home/home-top.styl +2 -0
  31. package/source/js/barrage_comment.js +78 -0
  32. package/source/js/main.js +46 -1
  33. package/source/js/third_party/efu_ai.min.js +1 -1
  34. package/source/js/commentBarrage/twikoo.js +0 -151
  35. package/source/js/commentBarrage/valine.js +0 -156
  36. package/source/js/commentBarrage/waline.js +0 -153
@@ -1,5 +1,5 @@
1
1
  /**
2
- * author: Efu AI
2
+ * author: Efu
3
3
  * email: o@efu.me
4
4
  * website: https://efu.me
5
5
  */
@@ -1,151 +0,0 @@
1
- function initializeCommentBarrage() {
2
- window.commentBarrageInitialized = !0;
3
- const e = {
4
- maxBarrage: 1,
5
- barrageTime: 8e3,
6
- twikooUrl: GLOBAL_CONFIG.comment.url,
7
- pageUrl: window.location.pathname,
8
- accessToken: GLOBAL_CONFIG.comment.accessToken,
9
- };
10
-
11
- class CommentBarrage {
12
- constructor(config) {
13
- this.config = {
14
- ...config,
15
- barrageTimer: [],
16
- barrageList: [],
17
- barrageIndex: 0,
18
- dom: document.querySelector(".comment-barrage")
19
- };
20
- this.commentInterval = null;
21
- this.hoverOnCommentBarrage = false;
22
- this.init();
23
- }
24
-
25
- async fetchComments() {
26
- try {
27
- const response = await fetch(this.config.twikooUrl, {
28
- method: "POST",
29
- headers: {
30
- "Content-Type": "application/json"
31
- },
32
- body: JSON.stringify({
33
- event: "COMMENT_GET",
34
- accessToken: this.config.accessToken,
35
- url: this.config.pageUrl
36
- })
37
- });
38
- if (!response.ok) {
39
- throw new Error("HTTP error! status: " + response.status);
40
- }
41
- const data = await response.json();
42
- return data.data;
43
- } catch (error) {
44
- console.error("An error occurred while fetching comments: ", error);
45
- }
46
- }
47
-
48
- commentLinkFilter(comments) {
49
- comments.sort((a, b) => a.created - b.created);
50
- let filteredComments = [];
51
- comments.forEach(comment => {
52
- filteredComments.push(...this.getCommentReplies(comment));
53
- });
54
- return filteredComments;
55
- }
56
-
57
- getCommentReplies(comment) {
58
- let comments = [comment];
59
- if (comment.replies) {
60
- comment.replies.forEach(reply => {
61
- comments.push(...this.getCommentReplies(reply));
62
- });
63
- }
64
- return comments;
65
- }
66
-
67
- processCommentContent(comment) {
68
- const strippedContent = comment.replace(/<blockquote\b[^>]*>[\s\S]*?<\/blockquote>/gi, "");
69
- const plainText = strippedContent.replace(/<[^>]*>/g, "").replace(/\n/g, " ");
70
- return plainText.trim() !== "" ? `<p>${plainText}</p>` : "";
71
- }
72
-
73
- popCommentBarrage(comment) {
74
- const commentContent = this.processCommentContent(comment.comment);
75
- if (!commentContent.trim()) {
76
- return false;
77
- }
78
- const commentBarrageItem = document.createElement("div");
79
- commentBarrageItem.className = "comment-barrage-item";
80
- commentBarrageItem.innerHTML = `
81
- <div class="barrageHead">
82
- <a class="barrageTitle" href="javascript:sco.scrollTo('post-comment')">${GLOBAL_CONFIG.lang.barrage.title}</a>
83
- <div class="barrageNick">${comment.nick}</div>
84
- <img class="barrageAvatar" src="${GLOBAL_CONFIG.comment.avatar}/avatar/${comment.mailMd5}"/>
85
- <a class="comment-barrage-close" href="javascript:sco.switchCommentBarrage();"><i class="solitude st-close-fill"></i></a>
86
- </div>
87
- <a class="barrageContent" href="javascript:sco.scrollTo('${comment.id}');">${commentContent}</a>
88
- `;
89
- this.config.barrageTimer.push(commentBarrageItem);
90
- this.config.dom.appendChild(commentBarrageItem);
91
- return true;
92
- }
93
-
94
- removeCommentBarrage(commentBarrageItem) {
95
- commentBarrageItem.className = "comment-barrage-item out";
96
- setTimeout(() => {
97
- this.config.dom.removeChild(commentBarrageItem);
98
- }, 1000);
99
- }
100
-
101
- async initCommentBarrage() {
102
- const commentBarrageSwitch = localStorage.getItem("commentBarrageSwitch");
103
- if (commentBarrageSwitch != null) {
104
- document.querySelector(".comment-barrage").style.display = "flex";
105
- document.querySelector("#consoleCommentBarrage").classList.add("on");
106
- } else {
107
- document.querySelector(".comment-barrage").style.display = "none";
108
- document.querySelector("#consoleCommentBarrage").classList.remove("on");
109
- }
110
- const comments = await this.fetchComments();
111
- this.config.barrageList = this.commentLinkFilter(comments);
112
- this.config.dom.innerHTML = "";
113
- clearInterval(this.commentInterval);
114
- this.commentInterval = null;
115
- const t = () => {
116
- if (this.config.barrageList.length && !this.hoverOnCommentBarrage) {
117
- if (!this.popCommentBarrage(this.config.barrageList[this.config.barrageIndex])) {
118
- this.config.barrageIndex += 1;
119
- this.config.barrageIndex %= this.config.barrageList.length;
120
- return t();
121
- }
122
- this.config.barrageIndex += 1;
123
- this.config.barrageIndex %= this.config.barrageList.length;
124
- }
125
- if (this.config.barrageTimer.length > (this.config.barrageList.length > this.config.maxBarrage ? this.config.maxBarrage : this.config.barrageList.length) && !this.hoverOnCommentBarrage) {
126
- this.removeCommentBarrage(this.config.barrageTimer.shift());
127
- }
128
- };
129
- setTimeout(() => {
130
- t();
131
- if (this.commentInterval) {
132
- clearInterval(this.commentInterval);
133
- }
134
- this.commentInterval = setInterval(t, this.config.barrageTime);
135
- }, 3000);
136
- }
137
-
138
- init() {
139
- this.initCommentBarrage();
140
- const commentBarrage = document.querySelector(".comment-barrage");
141
- commentBarrage.addEventListener('mouseover', () => {
142
- this.hoverOnCommentBarrage = true;
143
- });
144
- commentBarrage.addEventListener('mouseout', () => {
145
- this.hoverOnCommentBarrage = false;
146
- });
147
- }
148
- }
149
-
150
- new CommentBarrage(e);
151
- }
@@ -1,156 +0,0 @@
1
- function initializeCommentBarrage() {
2
- window.commentBarrageInitialized = !0;
3
- let config = {
4
- maxBarrage: 1,
5
- barrageTime: 8e3,
6
- valineUrl: GLOBAL_CONFIG.comment.url,
7
- pageUrl: window.location.pathname,
8
- }
9
- new class {
10
- commentInterval = null
11
-
12
- constructor(config) {
13
- this.config = {
14
- ...config,
15
- barrageTimer: [],
16
- barrageList: [],
17
- barrageIndex: 0,
18
- dom: document.querySelector(".comment-barrage")
19
- };
20
- this.commentInterval = null;
21
- this.hoverOnCommentBarrage = false;
22
- this.init();
23
- }
24
-
25
- async fetchComments() {
26
- const url = new URL(`${this.config.valineUrl}/1.1/classes/Comment`);
27
- const params = {
28
- url: this.config.pageUrl,
29
- order: '-createdAt'
30
- };
31
-
32
- for (const [key, value] of Object.entries(params)) {
33
- url.searchParams.append(key, value);
34
- }
35
-
36
- try {
37
- const response = await fetch(url, {
38
- method: "GET",
39
- headers: {
40
- "X-LC-Id": GLOBAL_CONFIG.comment.appId,
41
- "X-LC-Key": GLOBAL_CONFIG.comment.appKey,
42
- "Content-Type": "application/json"
43
- },
44
- });
45
-
46
- if (!response.ok) {
47
- throw new Error(`HTTP error! status: ${response.status}`);
48
- }
49
-
50
- const data = await response.json();
51
- return data.results.filter(item => item.url === this.config.pageUrl)
52
- } catch (error) {
53
- console.error("An error occurred while fetching comments: ", error);
54
- }
55
- }
56
-
57
- commentLinkFilter(comments) {
58
- return comments.flatMap(comment => this.getCommentReplies(comment));
59
- }
60
-
61
- getCommentReplies(comment) {
62
- window.comment = comment
63
- if (!comment.replies) {
64
- return [comment];
65
- }
66
- return [comment, ...comment.replies.flatMap(reply => this.getCommentReplies(reply))];
67
- }
68
-
69
- processCommentContent(comment) {
70
- const processed = comment.replace(/```[\s\S]*?```|<blockquote\b[^>]*>[\s\S]*?<\/blockquote>|<[^>]*>|\n|`([^`]{1,9})`:/g, "").trim();
71
- return processed ? `<p>${processed}</p>` : "";
72
- }
73
-
74
- createCommentBarrage(comment) {
75
- const content = this.processCommentContent(comment.comment).trim();
76
- if (!content) {
77
- return false;
78
- }
79
-
80
- const element = document.createElement("div");
81
- element.classList.add("comment-barrage-item");
82
- element.innerHTML = `
83
- <div class="barrageHead">
84
- <a class="barrageTitle" href="javascript:sco.scrollTo('post-comment')">${GLOBAL_CONFIG.lang.barrage.title}</a>
85
- <div class="barrageNick">${comment.nick}</div>
86
- <img class="barrageAvatar" src="${GLOBAL_CONFIG.comment.avatar}/avatar/${md5(comment.mail.toLowerCase())}"/>
87
- <a class="comment-barrage-close" href="javascript:sco.switchCommentBarrage();">
88
- <i class="solitude st-close-fill"></i>
89
- </a>
90
- </div>
91
- <a class="barrageContent" href="javascript:sco.scrollTo('${comment.objectId}');">${comment.comment}</a>
92
- `;
93
-
94
- this.config.dom.appendChild(element);
95
- this.config.barrageTimer.push(element);
96
-
97
- return true;
98
- }
99
-
100
- removeCommentBarrage(element) {
101
- element.className = "comment-barrage-item out";
102
- setTimeout(() => {
103
- this.config.dom.removeChild(element);
104
- }, 1000);
105
- }
106
-
107
- async initCommentBarrage() {
108
- const commentBarrage = document.querySelector(".comment-barrage");
109
- const menuCommentBarrageText = document.querySelector(".menu-commentBarrage-text");
110
- const consoleCommentBarrage = document.querySelector("#consoleCommentBarrage");
111
-
112
- if (localStorage.getItem("commentBarrageSwitch") != null) {
113
- commentBarrage.style.display = "flex";
114
- consoleCommentBarrage.classList.add("on");
115
- } else {
116
- commentBarrage.style.display = "none";
117
- consoleCommentBarrage.classList.remove("on");
118
- }
119
-
120
- const comments = await this.fetchComments();
121
- this.config.barrageList = this.commentLinkFilter(comments);
122
- this.config.dom.innerHTML = "";
123
- clearInterval(this.commentInterval);
124
- this.commentInterval = null;
125
-
126
- const createOrRemoveBarrage = () => {
127
- if (this.config.barrageList.length && !this.hoverOnCommentBarrage) {
128
- if (!this.createCommentBarrage(this.config.barrageList[this.config.barrageIndex])) {
129
- this.config.barrageIndex = (this.config.barrageIndex + 1) % this.config.barrageList.length;
130
- return createOrRemoveBarrage();
131
- }
132
- this.config.barrageIndex = (this.config.barrageIndex + 1) % this.config.barrageList.length;
133
- }
134
- if (this.config.barrageTimer.length > (this.config.barrageList.length > this.config.maxBarrage ? this.config.maxBarrage : this.config.barrageList.length) && !this.hoverOnCommentBarrage) {
135
- this.removeCommentBarrage(this.config.barrageTimer.shift());
136
- }
137
- };
138
-
139
- setTimeout(() => {
140
- createOrRemoveBarrage();
141
- if (this.commentInterval) {
142
- clearInterval(this.commentInterval);
143
- }
144
- this.commentInterval = setInterval(createOrRemoveBarrage, this.config.barrageTime);
145
- }, 3000);
146
- }
147
-
148
- async init() {
149
- await this.initCommentBarrage();
150
- const commentBarrage = document.querySelector(".comment-barrage");
151
- commentBarrage.addEventListener('mouseover', () => this.hoverOnCommentBarrage = true);
152
- commentBarrage.addEventListener('mouseout', () => this.hoverOnCommentBarrage = false);
153
- }
154
- }
155
- (config)
156
- }
@@ -1,153 +0,0 @@
1
- function initializeCommentBarrage() {
2
- window.commentBarrageInitialized = !0;
3
- let config = {
4
- maxBarrage: 1,
5
- barrageTime: 8e3,
6
- walineUrl: GLOBAL_CONFIG.comment.url,
7
- pageUrl: window.location.pathname,
8
- }
9
- new class {
10
- commentInterval = null
11
-
12
- constructor(config) {
13
- this.config = {
14
- ...config,
15
- barrageTimer: [],
16
- barrageList: [],
17
- barrageIndex: 0,
18
- dom: document.querySelector(".comment-barrage")
19
- };
20
- this.commentInterval = null;
21
- this.hoverOnCommentBarrage = false;
22
- this.init();
23
- }
24
-
25
- async fetchComments() {
26
- const url = new URL(`${this.config.walineUrl}/api/comment`);
27
- const params = {
28
- path: this.config.pageUrl,
29
- sortBy: 'insertedAt_asc'
30
- };
31
-
32
- for (const [key, value] of Object.entries(params)) {
33
- url.searchParams.append(key, value);
34
- }
35
-
36
- try {
37
- const response = await fetch(url, {
38
- method: "GET",
39
- headers: {
40
- "Content-Type": "application/json"
41
- },
42
- });
43
-
44
- if (!response.ok) {
45
- throw new Error(`HTTP error! status: ${response.status}`);
46
- }
47
-
48
- const data = await response.json();
49
- return data.data;
50
- } catch (error) {
51
- console.error("An error occurred while fetching comments: ", error);
52
- }
53
- }
54
-
55
- commentLinkFilter(comments) {
56
- return comments.data.flatMap(comment => this.getCommentReplies(comment));
57
- }
58
-
59
- getCommentReplies(comment) {
60
- if (!comment.replies) {
61
- return [comment];
62
- }
63
- return [comment, ...comment.replies.flatMap(reply => this.getCommentReplies(reply))];
64
- }
65
-
66
- processCommentContent(comment) {
67
- const processed = comment.replace(/<blockquote\b[^>]*>[\s\S]*?<\/blockquote>|<[^>]*>|\n/g, "").trim();
68
- return processed ? `<p>${processed}</p>` : "";
69
- }
70
-
71
- createCommentBarrage(comment) {
72
- const content = this.processCommentContent(comment.comment).trim();
73
- if (!content) {
74
- return false;
75
- }
76
-
77
- const element = document.createElement("div");
78
- element.classList.add("comment-barrage-item");
79
- element.innerHTML = `
80
- <div class="barrageHead">
81
- <a class="barrageTitle" href="javascript:sco.scrollTo('post-comment')">${GLOBAL_CONFIG.lang.barrage.title}</a>
82
- <div class="barrageNick">${comment.nick}</div>
83
- <img class="barrageAvatar" src="${GLOBAL_CONFIG.comment.avatar}/avatar/${comment.avatar}"/>
84
- <a class="comment-barrage-close" href="javascript:sco.switchCommentBarrage();">
85
- <i class="solitude st-close-fill"></i>
86
- </a>
87
- </div>
88
- <a class="barrageContent" href="javascript:sco.scrollTo('${comment.objectId}');">${comment.comment}</a>
89
- `;
90
-
91
- this.config.dom.appendChild(element);
92
- this.config.barrageTimer.push(element);
93
-
94
- return true;
95
- }
96
-
97
- removeCommentBarrage(element) {
98
- element.className = "comment-barrage-item out";
99
- setTimeout(() => {
100
- this.config.dom.removeChild(element);
101
- }, 1000);
102
- }
103
-
104
- async initCommentBarrage() {
105
- const commentBarrage = document.querySelector(".comment-barrage");
106
- const menuCommentBarrageText = document.querySelector(".menu-commentBarrage-text");
107
- const consoleCommentBarrage = document.querySelector("#consoleCommentBarrage");
108
-
109
- if (localStorage.getItem("commentBarrageSwitch") != null) {
110
- commentBarrage.style.display = "flex";
111
- consoleCommentBarrage.classList.add("on");
112
- } else {
113
- commentBarrage.style.display = "none";
114
- consoleCommentBarrage.classList.remove("on");
115
- }
116
-
117
- const comments = await this.fetchComments();
118
- this.config.barrageList = this.commentLinkFilter(comments);
119
- this.config.dom.innerHTML = "";
120
- clearInterval(this.commentInterval);
121
- this.commentInterval = null;
122
-
123
- const createOrRemoveBarrage = () => {
124
- if (this.config.barrageList.length && !this.hoverOnCommentBarrage) {
125
- if (!this.createCommentBarrage(this.config.barrageList[this.config.barrageIndex])) {
126
- this.config.barrageIndex = (this.config.barrageIndex + 1) % this.config.barrageList.length;
127
- return createOrRemoveBarrage();
128
- }
129
- this.config.barrageIndex = (this.config.barrageIndex + 1) % this.config.barrageList.length;
130
- }
131
- if (this.config.barrageTimer.length > (this.config.barrageList.length > this.config.maxBarrage ? this.config.maxBarrage : this.config.barrageList.length) && !this.hoverOnCommentBarrage) {
132
- this.removeCommentBarrage(this.config.barrageTimer.shift());
133
- }
134
- };
135
-
136
- setTimeout(() => {
137
- createOrRemoveBarrage();
138
- if (this.commentInterval) {
139
- clearInterval(this.commentInterval);
140
- }
141
- this.commentInterval = setInterval(createOrRemoveBarrage, this.config.barrageTime);
142
- }, 3000);
143
- }
144
-
145
- async init() {
146
- await this.initCommentBarrage();
147
- const commentBarrage = document.querySelector(".comment-barrage");
148
- commentBarrage.addEventListener('mouseover', () => this.hoverOnCommentBarrage = true);
149
- commentBarrage.addEventListener('mouseout', () => this.hoverOnCommentBarrage = false);
150
- }
151
- }
152
- (config)
153
- }