hexo-theme-solitude 1.10.6 → 1.11.1

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 (43) hide show
  1. package/.github/FUNDING.yml +3 -3
  2. package/_config.yml +28 -0
  3. package/languages/default.yml +5 -0
  4. package/languages/en.yml +5 -0
  5. package/languages/zh-CN.yml +5 -0
  6. package/languages/zh-TW.yml +5 -0
  7. package/layout/includes/console.pug +5 -1
  8. package/layout/includes/head/config.pug +5 -0
  9. package/layout/includes/inject/head.pug +12 -1
  10. package/layout/includes/page/recentcomment.pug +16 -0
  11. package/layout/includes/page/says.pug +4 -0
  12. package/layout/includes/widgets/page/about/other.pug +47 -20
  13. package/layout/includes/widgets/page/banner.pug +2 -2
  14. package/layout/includes/widgets/page/message/artalk.pug +45 -0
  15. package/layout/includes/widgets/page/message/js.pug +5 -1
  16. package/layout/includes/widgets/page/message/twikoo.pug +19 -16
  17. package/layout/includes/widgets/page/message/valine.pug +12 -3
  18. package/layout/includes/widgets/page/message/waline.pug +42 -0
  19. package/layout/includes/widgets/page/recentcomment/artalk.pug +78 -0
  20. package/layout/includes/widgets/page/recentcomment/twikoo.pug +83 -0
  21. package/layout/includes/widgets/page/recentcomment/valine.pug +79 -0
  22. package/layout/includes/widgets/page/recentcomment/waline.pug +72 -0
  23. package/layout/includes/widgets/third-party/comments/artalk.pug +1 -1
  24. package/layout/includes/widgets/third-party/news-comment/valine.pug +19 -17
  25. package/layout/includes/widgets/third-party/news-comment/waline.pug +3 -3
  26. package/layout/page.pug +2 -0
  27. package/package.json +1 -1
  28. package/plugins.yml +3 -3
  29. package/scripts/event/merge_config.js +7 -0
  30. package/source/css/_comments/comment.styl +1 -1
  31. package/source/css/_comments/valine.styl +1 -0
  32. package/source/css/_global/index.styl +9 -1
  33. package/source/css/_layout/console.styl +11 -0
  34. package/source/css/_layout/footer.styl +4 -1
  35. package/source/css/_layout/other.styl +2 -1
  36. package/source/css/_page/_about/skills.styl +1 -1
  37. package/source/css/_page/_about/statistic.styl +1 -1
  38. package/source/css/_page/_home/home-top.styl +3 -0
  39. package/source/css/_page/index.styl +3 -0
  40. package/source/css/_page/other.styl +1 -6
  41. package/source/css/_page/recentcomment.styl +85 -0
  42. package/source/css/_page/says.styl +5 -13
  43. package/source/js/main.js +36 -5
@@ -1,7 +1,7 @@
1
1
  # These are supported funding model platforms
2
2
 
3
- github: [efuo] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
- patreon: # Replace with a single Patreon username
3
+ github: [everfu] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ patreon: everfu # Replace with a single Patreon username
5
5
  open_collective: # Replace with a single Open Collective username
6
6
  ko_fi: # Replace with a single Ko-fi username
7
7
  tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
@@ -10,4 +10,4 @@ liberapay: # Replace with a single Liberapay username
10
10
  issuehunt: # Replace with a single IssueHunt username
11
11
  otechie: # Replace with a single Otechie username
12
12
  lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13
- custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13
+ custom: ['https://afdian.net/a/everfu', 'https://s3.qjqq.cn/47/66374315ebd08.webp!color', 'https://s3.qjqq.cn/47/663742bac8e52.webp!color'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
package/_config.yml CHANGED
@@ -515,6 +515,21 @@ says:
515
515
  # Talk short text only shows the first n
516
516
  strip: 30
517
517
 
518
+ # 最近评论
519
+ # recent comments
520
+ # 前置要求:需配置最近评论页面和评论,否则显示为空
521
+ # Pre-requirements: recent comments page needs to be configured and commented, otherwise it will be displayed as empty
522
+ recent_comments:
523
+ enable: false
524
+ # 评论数
525
+ # Number of comments
526
+ limit: 50 # ⚠️waline 仅支持最大50条评论 / ⚠️waline only supports a maximum of 50 comments
527
+ # 缓存时间
528
+ # Cache time
529
+ cache: 0.2 # 1 = 1天 / 1 = 1 day
530
+ console: true # 控制台按钮 / console button
531
+ page: /recentcomments/ # 最近评论页面 / recent comments page
532
+
518
533
  # 留言板
519
534
  # message board
520
535
  # 前置要求:需配置留言板页面
@@ -525,6 +540,7 @@ envelope:
525
540
  speed: 20 # 播放速度
526
541
  hover: true # 鼠标悬停暂停
527
542
  loop: true # 循环播放
543
+ page: /message/ # 留言板页面 / message board page
528
544
 
529
545
  # -------------------------
530
546
  # meeting-api,用于界面中的音乐胶囊和音乐馆页,可自定义api,不会请勿动。
@@ -893,6 +909,18 @@ right_menu:
893
909
  # class:
894
910
  # icon: st-afdian-line
895
911
 
912
+ # 哀悼模式,网页黑白
913
+ # Mourning mode, web page black and white
914
+ memorial:
915
+ enable: false
916
+ # 日期, (M-D)
917
+ # Date, (M-D)
918
+ # eg: 7-8, 9-18, 12-13 ...
919
+ date:
920
+ - "7-8" #七八卢沟桥事变
921
+ - "9-18" #九一八事变/建军节
922
+ - "12-13" #南京国家公祭日
923
+
896
924
  # CDN
897
925
  # Don't modify the following settings unless you know how they work
898
926
  # 非必要请不要修改
@@ -3,6 +3,7 @@ star: Behold, those who found delight in this piece also perused
3
3
  random: Random
4
4
  upload: 'datetime: '
5
5
  totalk: You don't need to delete blank lines, just type in your comments.
6
+ loading: Loading...
6
7
 
7
8
  theme:
8
9
  dark: Dark
@@ -92,6 +93,8 @@ aside:
92
93
  toc: Table of contents
93
94
  tagmore: View all
94
95
  avatar: Avatar
96
+ hello: Long time no see,
97
+ back: Welcome back again,
95
98
  sticker: Mood sticker
96
99
  newpost: New posts
97
100
  card:
@@ -109,10 +112,12 @@ console:
109
112
  switch_keyboard: Keyboard operation
110
113
  switch_music: Music switch
111
114
  archive_unit: Posts
115
+ recent_comment_more: Recent comments
112
116
  newest_comment:
113
117
  image: Image
114
118
  link: Link
115
119
  code: Code
120
+ emoji: Emoji
116
121
 
117
122
  sidebar:
118
123
  function: Function
package/languages/en.yml CHANGED
@@ -3,6 +3,7 @@ star: Behold, those who found delight in this piece also perused
3
3
  random: Random
4
4
  upload: 'datetime: '
5
5
  totalk: You don't need to delete blank lines, just type in your comments.
6
+ loading: Loading...
6
7
 
7
8
  theme:
8
9
  dark: Dark
@@ -92,6 +93,8 @@ aside:
92
93
  toc: Table of contents
93
94
  tagmore: View all
94
95
  avatar: Avatar
96
+ hello: Long time no see,
97
+ back: Welcome back again,
95
98
  sticker: Mood sticker
96
99
  newpost: New posts
97
100
  card:
@@ -109,10 +112,12 @@ console:
109
112
  switch_keyboard: Keyboard operation
110
113
  switch_music: Music switch
111
114
  archive_unit: Posts
115
+ recent_comment_more: Recent comments
112
116
  newest_comment:
113
117
  image: Image
114
118
  link: Link
115
119
  code: Code
120
+ emoji: Emoji
116
121
 
117
122
  sidebar:
118
123
  function: Function
@@ -3,6 +3,7 @@ star: 喜欢这篇的人也看了
3
3
  random: 随便逛逛
4
4
  upload: 发布时间:
5
5
  totalk: 无需删除空行,直接输入评论即可
6
+ loading: 加载中...
6
7
 
7
8
  # Language: 简体中文
8
9
  theme:
@@ -94,6 +95,8 @@ aside:
94
95
  toc: 文章目录
95
96
  tagmore: 查看全部
96
97
  avatar: 头像
98
+ hello: 好久不见,
99
+ back: 欢迎再次回来,
97
100
  sticker: 心情贴纸
98
101
  newpost: 最近发布
99
102
  card:
@@ -111,10 +114,12 @@ console:
111
114
  switch_keyboard: 键盘快捷键
112
115
  switch_music: 音乐开关
113
116
  archive_unit: 篇
117
+ recent_comment_more: 最近评论
114
118
  newest_comment:
115
119
  image: 图片
116
120
  link: 链接
117
121
  code: 代码
122
+ emoji: 表情
118
123
 
119
124
  sidebar:
120
125
  function: 功能
@@ -3,6 +3,7 @@ star: 喜歡這篇的人也看了
3
3
  random: 随便逛逛
4
4
  upload: 發佈時間:
5
5
  totalk: 無需刪除空行,直接輸入評論即可
6
+ loading: 加載中...
6
7
 
7
8
  # Language: 繁體中文 (台灣)
8
9
  theme:
@@ -94,6 +95,8 @@ aside:
94
95
  toc: 文章目錄
95
96
  tagmore: 查看全部
96
97
  avatar: 头像
98
+ hello: 好久不見,
99
+ back: 歡迎再次回來,
97
100
  sticker: 心情贴纸
98
101
  newpost: 最近发布
99
102
  card:
@@ -111,10 +114,12 @@ console:
111
114
  switch_keyboard: 鍵盤快捷鍵
112
115
  switch_music: 音樂開關
113
116
  archive_unit: 篇
117
+ recent_comment_more: 最近評論
114
118
  newest_comment:
115
119
  image: 圖片
116
120
  link: 連結
117
121
  code: 代碼
122
+ emoji: 表情
118
123
 
119
124
  sidebar:
120
125
  function: 功能
@@ -8,7 +8,11 @@ div#console
8
8
  div.console-card#card-newest-comments(onclick="sco.hideConsole()")
9
9
  div.card-content
10
10
  div.author-content-item-tips= _p('console.comment_tip')
11
- div.author-content-item-title= _p('console.comment_title')
11
+ div.author-content-item-title
12
+ | #{_p('console.comment_title')}
13
+ if theme.recent_comments.enable && theme.recent_comments.console
14
+ a.recent-comment-more(href=url_for(theme.recent_comments.page) title=_p('console.recent_comment_more'))
15
+ i.solitude.st-right-btn-fill
12
16
  div.aside-list
13
17
 
14
18
  div.console-card-group-right
@@ -23,6 +23,7 @@
23
23
  }
24
24
 
25
25
  const sayhello2 = theme.aside?.card?.sayhello2?.map(item => `"${item}"`) || [];
26
+ const [hello_prefix, hello_back] = [_p('aside.hello'), _p('aside.back')];
26
27
 
27
28
  let comment = false
28
29
 
@@ -149,6 +150,10 @@ script.
149
150
  goodnight: '!{theme.aside.card.sayhello.goodnight}',
150
151
  },
151
152
  sayhello2: [!{sayhello2}],
153
+ sayhello3: {
154
+ prefix: '!{hello_prefix}',
155
+ back: '!{hello_back}',
156
+ },
152
157
  },
153
158
  covercolor: {
154
159
  enable: !{theme.post.covercolor.enable}
@@ -27,12 +27,23 @@ include ../head/pwa.pug
27
27
 
28
28
  script.
29
29
  console.log(
30
- "%c Program: Hexo %c Theme: Solitude %c Version: v1.10.6",
30
+ "%c Program: Hexo %c Theme: Solitude %c Version: v1.11.1",
31
31
  "border-radius:5px 0 0 5px;padding: 5px 10px;color:white;background:#ff3842;",
32
32
  "padding: 5px 10px;color:white;background:#3e9f50;",
33
33
  "padding: 5px 10px;color:white;background:#0084ff;border-radius:0 5px 5px 0",
34
34
  )
35
35
 
36
+ if theme.memorial.enable
37
+ script.
38
+ let mdate = "!{theme.memorial.date}";
39
+ mdate = (mdate.split(","));
40
+ let ndate = new Date();
41
+ for (let i of mdate) {
42
+ if (i == (ndate.getMonth()+1) + "-" + (ndate.getDate())) {
43
+ document.documentElement.classList.add('memorial');
44
+ }
45
+ }
46
+
36
47
  if theme.extends.head
37
48
  each item in theme.extends.head
38
49
  != item
@@ -0,0 +1,16 @@
1
+ - const { enable, limit, cache } = theme.recent_comments
2
+ - const {use, avatar} = theme.comment
3
+
4
+ include ../widgets/page/banner
5
+
6
+ if enable && use
7
+ #comments-page
8
+ case use[0]
9
+ when 'Twikoo'
10
+ include ../widgets/page/recentcomment/twikoo
11
+ when 'Valine'
12
+ include ../widgets/page/recentcomment/valine
13
+ when 'Waline'
14
+ include ../widgets/page/recentcomment/waline
15
+ when 'Artalk'
16
+ include ../widgets/page/recentcomment/artalk
@@ -40,6 +40,10 @@ if theme.says.enable
40
40
  .bber-info-time
41
41
  i.solitude.st-calendar-todo-fill
42
42
  time.datetime(datetime=moment(item.date).format())
43
+ if item.location
44
+ .bber-info-location
45
+ i.solitude.st-map-pin-fill
46
+ | #{item.location}
43
47
  if item.link
44
48
  a.bber-content-link(href=url_for(item.link) target="_blank")
45
49
  i.solitude.st-link-m-line
@@ -10,26 +10,53 @@
10
10
  #statistic
11
11
  .post-tips
12
12
  = _p('about.other.tj.post_tip')
13
- a(href="https://v6.51.la/") 51la网站统计
14
-
15
- script.
16
- fetch("#{tj.url}")
17
- .then(res => res.text())
18
- .then(data => {
19
- const title = ["最近活跃", "今日人数", "今日访问", "昨日人数", "昨日访问", "本月访问", "总访问量"];
20
- let num = data.match(/(<\/span><span>).*?(\/span><\/p>)/g);
21
- num = num.map(el => {
22
- let val = el.replace(/(<\/span><span>)/g, "");
23
- return val.replace(/(<\/span><\/p>)/g, "");
24
- });
25
- const s = document.getElementById("statistic");
26
- let html = '';
27
- for (let i = 0; i < num.length; i++) {
28
- if (i === 0 || i === num.length - 1) continue;
29
- html += `<div><span>${title[i]}</span><span id="${title[i]}">${num[i]}</span></div>`;
30
- }
31
- s.innerHTML = html;
32
- });
13
+ case tj.provider
14
+ when '51la'
15
+ a(href="https://v6.51.la/") 51la网站统计
16
+ when 'baidu'
17
+ a(href="https://tongji.baidu.com/") 百度统计
18
+ if tj.button
19
+ .banner-button-group
20
+ a.banner-button(href=url_for(tj.button_link))
21
+ i.solitude.st-right-btn-fill
22
+ span.banner-button-text= tj.button_text
23
+
24
+ case tj.provider
25
+ when '51la'
26
+ script.
27
+ fetch("#{tj.url}")
28
+ .then(res => res.text())
29
+ .then(data => {
30
+ const title = ["最近活跃", "今日人数", "今日访问", "昨日人数", "昨日访问", "本月访问", "总访问量"];
31
+ let num = data.match(/(<\/span><span>).*?(\/span><\/p>)/g);
32
+ num = num.map(el => {
33
+ let val = el.replace(/(<\/span><span>)/g, "");
34
+ return val.replace(/(<\/span><\/p>)/g, "");
35
+ });
36
+ const s = document.getElementById("statistic");
37
+ let html = '';
38
+ for (let i = 0; i < num.length; i++) {
39
+ if (i === 0 || i === num.length - 1) continue;
40
+ html += `<div><span>${title[i]}</span><span id="${title[i]}">${num[i]}</span></div>`;
41
+ }
42
+ s.innerHTML = html;
43
+ });
44
+ when 'baidu'
45
+ script.
46
+ fetch("#{tj.url}")
47
+ .then(res => res.json())
48
+ .then(data => {
49
+ const title = {"today_uv": "今日人数", "today_pv": "今日访问", "yesterday_uv": "昨日人数", "yesterday_pv": "昨日访问", "last_month_pv": "最近月访问", "last_year_pv": "最近年访问"};
50
+
51
+ let s = document.getElementById("statistic");
52
+
53
+ for (let key in data) {
54
+ if (data.hasOwnProperty(key) && title[key]) {
55
+ s.innerHTML += `<div><span>${title[key]}</span><span id="${key}">${data[key]}</span></div>`;
56
+ }
57
+ }
58
+ });
59
+
33
60
 
34
61
  if oneself
35
62
  style.
@@ -1,7 +1,7 @@
1
1
  .author-content.author-content-item.single.sharePage(style=`background: url(${page.cover}) no-repeat center; background-size: cover;`)
2
2
  .card-content
3
- .author-content-item-tips= page.title
4
- span.author-content-item-title= page.desc
3
+ .author-content-item-tips= page.desc
4
+ span.author-content-item-title= page.title
5
5
  .content-bottom
6
6
  if page.leftend
7
7
  .tips= page.leftend
@@ -0,0 +1,45 @@
1
+ - const { server, site, option } = theme.artalk
2
+
3
+ script(pjax).
4
+ (async () => {
5
+ const emojiReg = /<img [^>]+ atk-emoticon="[^"]+">/g
6
+ if (typeof EasyDanmaku === "undefined") await utils.getScript('!{url_for(theme.cdn.envelope_js)}')
7
+ const envel = new EasyDanmaku({
8
+ page: '!{theme.envelope.page}',
9
+ el: '#barrage',
10
+ line: !{line},
11
+ speed: !{speed},
12
+ hover: !{hover},
13
+ loop: !{loop},
14
+ })
15
+ const data = utils.saveToLocal.get('enevlope')
16
+ if (data) {
17
+ envel.batchSend(data, true)
18
+ return
19
+ }
20
+
21
+ const searchParams = new URLSearchParams({'site_name': "!{site}", 'limit': '100'})
22
+ await fetch(`!{server}/api/v2/stats/latest_comments?${searchParams}`, {method: 'GET'}).then(async res => res.json())
23
+ .then(async data => {
24
+ let ls = []
25
+ for (const i of data.data) {
26
+ ls.push({
27
+ content: i.nick + ': ' + formatDanmaku(i.content),
28
+ avatar: '!{avatar}' + '/avatar/' + i.email_encrypted,
29
+ url: i.page_key + '#atk-comment-' + i.id,
30
+ })
31
+ }
32
+ envel.batchSend(ls, true)
33
+ utils.saveToLocal.set('enevlope', ls, .02)
34
+ }).catch(error => {
35
+ console.error("An error occurred while fetching comments: ", error)
36
+ })
37
+
38
+ function formatDanmaku(str) {
39
+ str = str.replace(emojiReg, '[!{__("console.newest_comment.emoji")}]')
40
+ str = str.replace(/!\[.*?\]\((.*?)\)/g, '[!{__("console.newest_comment.image")}]')
41
+ str = str.replace(/\[.*?\]\((.*?)\)/g, '[!{__("console.newest_comment.link")}]')
42
+ str = str.replace(/```.*?```/g, '[!{__("console.newest_comment.code")}]')
43
+ return str
44
+ }
45
+ })()
@@ -5,4 +5,8 @@ if use
5
5
  when "Valine"
6
6
  include ./valine
7
7
  when "Twikoo"
8
- include ./twikoo
8
+ include ./twikoo
9
+ when "Waline"
10
+ include ./waline
11
+ when "Artalk"
12
+ include ./artalk
@@ -2,38 +2,41 @@
2
2
 
3
3
  script(pjax).
4
4
  (async () => {
5
- if(typeof EasyDanmaku === "undefined") await utils.getScript('!{url_for(theme.cdn.envelope_js)}')
5
+ const emojiReg = /<img class="tk-owo-emotion" [^>]+>/g
6
+ if (typeof EasyDanmaku === "undefined") await utils.getScript('!{url_for(theme.cdn.envelope_js)}')
6
7
  const Danmaku = new EasyDanmaku({
7
- page: '/message/',
8
- el: '#barrage',
9
- line: !{line},
10
- speed: !{speed},
8
+ page: '!{theme.envelope.page}',
9
+ el: '#barrage',
10
+ line: !{line},
11
+ speed: !{speed},
11
12
  hover: !{hover},
12
13
  loop: !{loop},
13
14
  })
14
15
  const data = utils.saveToLocal.get('enevlope')
15
- if(data){
16
- Danmaku.batchSend(data,true)
16
+ if (data) {
17
+ Danmaku.batchSend(data, true)
17
18
  return
18
19
  }
19
20
  let ls = []
20
21
  fetch('!{envId}/', {
21
22
  method: "POST",
22
23
  body: JSON.stringify({
23
- "event": "GET_RECENT_COMMENTS",
24
- "includeReply": false,
25
- "pageSize": 100
24
+ "event": "GET_RECENT_COMMENTS",
25
+ "includeReply": false,
26
+ "pageSize": 100
26
27
  }),
27
- headers: { 'Content-Type': 'application/json' }
28
- }).then(res => res.json()).then(({ data }) => {
29
- data.forEach(i => {
30
- if (i.avatar == undefined) i.avatar = '!{avatar}/avatar/d615d5793929e8c7d70eab5f00f7f5f1?d=mp'
31
- ls.push({ avatar: i.avatar, content: i.nick + '' + formatDanmaku(i.comment), url: i.url + '#' + i.id })
32
- });
28
+ headers: {'Content-Type': 'application/json'}
29
+ }).then(res => res.json()).then(({data}) => {
30
+ for (const i of data) {
31
+ if (i.avatar === undefined) i.avatar = '!{avatar}/avatar/d615d5793929e8c7d70eab5f00f7f5f1?d=mp'
32
+ ls.push({avatar: i.avatar, content: i.nick + ': ' + formatDanmaku(i.comment), url: i.url + '#' + i.id})
33
+ }
33
34
  Danmaku.batchSend(ls, true);
34
35
  utils.saveToLocal.set('envelope', ls, 0.02)
35
36
  });
37
+
36
38
  function formatDanmaku(str) {
39
+ str = str.replace(emojiReg, '!{__("console.newest_comment.emoji")}')
37
40
  str = str.replace(/<\/*br>|[\s\uFEFF\xA0]+/g, '');
38
41
  str = str.replace(/<img.*?>/g, '[!{__("console.newest_comment.image")}]');
39
42
  str = str.replace(/<a.*?>.*?<\/a>/g, '[!{__("console.newest_comment.link")}]');
@@ -2,9 +2,10 @@
2
2
 
3
3
  script(pjax).
4
4
  (async () => {
5
+ const emojiReg = /:[a-z0-9_\u4e00-\u9fa5]+:/g
5
6
  if(typeof EasyDanmaku === "undefined") await utils.getScript('!{url_for(theme.cdn.envelope_js)}')
6
7
  const envel = new EasyDanmaku({
7
- page: '/message/',
8
+ page: '!{theme.envelope.page}',
8
9
  el: '#barrage',
9
10
  line: !{line},
10
11
  speed: !{speed},
@@ -35,9 +36,9 @@ script(pjax).
35
36
  const data = await res.json()
36
37
  const init = () =>
37
38
  data.results.map(item => ({
38
- content: item.comment,
39
+ content: item.nick + ': ' + formatDanmaku(item.comment),
39
40
  avatar: '!{avatar}/avatar/'+md5(item.mail),
40
- url: item.url,
41
+ url: item.url
41
42
  }))
42
43
  if (typeof md5 === "undefined") await utils.getScript('!{url_for(theme.cdn.blueimp_md5)}')
43
44
  envel.batchSend(init(),true)
@@ -45,4 +46,12 @@ script(pjax).
45
46
  } catch (error) {
46
47
  console.error("An error occurred while fetching comments: ", error)
47
48
  }
49
+
50
+ function formatDanmaku(str) {
51
+ str = str.replace(emojiReg, '[!{__("console.newest_comment.emoji")}]')
52
+ str = str.replace(/!\[.*?\]\((.*?)\)/g, '[!{__("console.newest_comment.image")}]')
53
+ str = str.replace(/\[.*?\]\((.*?)\)/g, '[!{__("console.newest_comment.link")}]')
54
+ str = str.replace(/```.*?```/g, '[!{__("console.newest_comment.code")}]')
55
+ return str
56
+ }
48
57
  })()
@@ -0,0 +1,42 @@
1
+ script(pjax).
2
+ (async () => {
3
+ const emojiReg = /<img [^>]+ class="wl-emoji">/g
4
+ if(typeof EasyDanmaku === "undefined") await utils.getScript('!{url_for(theme.cdn.envelope_js)}')
5
+ const envel = new EasyDanmaku({
6
+ page: '!{theme.envelope.page}',
7
+ el: '#barrage',
8
+ line: !{line},
9
+ speed: !{speed},
10
+ hover: !{hover},
11
+ loop: !{loop},
12
+ })
13
+ const data = utils.saveToLocal.get('enevlope')
14
+ if(data){
15
+ envel.batchSend(data,true)
16
+ return
17
+ }
18
+ await fetch('!{theme.waline.envId}/api/comment?type=recent&count=50', {method: 'GET'}).then(async res => res.json())
19
+ .then(async data => {
20
+ let ls = []
21
+ for (const i of data.data) {
22
+ ls.push({
23
+ content: i.nick + ': ' + formatContent(i.comment),
24
+ avatar: i.avatar,
25
+ url: i.url
26
+ })
27
+ }
28
+ envel.batchSend(ls,true)
29
+ utils.saveToLocal.set('enevlope',ls,.02)
30
+ }).catch(error => {
31
+ console.error("An error occurred while fetching comments: ", error)
32
+ })
33
+
34
+ function formatContent(content) {
35
+ content = content.replace(emojiReg, '[!{__("console.newest_comment.emoji")}]')
36
+ content = content.replace(/<img.*?>/g, '[!{__("console.newest_comment.image")}]');
37
+ content = content.replace(/<a.*?>.*?<\/a>/g, '[!{__("console.newest_comment.link")}]');
38
+ content = content.replace(/<pre.*?>.*?<\/pre>/g, '[!{__("console.newest_comment.code")}]');
39
+ content = content.replace(/<.*?>/g, '');
40
+ return content
41
+ }
42
+ })()
@@ -0,0 +1,78 @@
1
+ - const { server, site, option } = theme.artalk
2
+
3
+ script(pjax).
4
+ (async () => {
5
+ document.querySelector('#comments-page').textContent = `#{__("loading")}`
6
+ const emojiReg = /<img [^>]+ atk-emoticon="[^"]+">/g
7
+ let cache = utils.saveToLocal.get('artalk-recent-comments')
8
+ if (cache) {
9
+ setHtml(document.querySelector('#comments-page'), cache)
10
+ return
11
+ }
12
+ let ls = []
13
+ const searchParams = new URLSearchParams({'site_name': "!{site}", 'limit': '!{limit}'})
14
+ await fetch(`!{server}/api/v2/stats/latest_comments?${searchParams}`, {method: 'GET'}).then(async res => res.json())
15
+ .then(async data => {
16
+ for (const i of data.data) {
17
+ if (checkEmoji(i.content)) continue
18
+ let title = ''
19
+ if (i.page_key) {
20
+ await fetch(i.page_key).then(res => res.text()).then(html => {
21
+ const parser = new DOMParser()
22
+ const doc = parser.parseFromString(html, 'text/html')
23
+ title = doc.querySelector('title').innerText
24
+ }).catch(() => {
25
+ title = i.page_key
26
+ })
27
+ }
28
+ if (title.indexOf('|') > 0) {
29
+ title = title.split('|')[0]
30
+ }
31
+ ls.push({
32
+ title: title,
33
+ url: i.page_key + '#atk-comment-' + i.id,
34
+ nick: i.nick,
35
+ avatar: '!{avatar}' + '/avatar/' + i.email_encrypted,
36
+ time: i.date,
37
+ content: formatContent(i.content)
38
+ })
39
+ }
40
+ setHtml(document.querySelector('#comments-page'), ls)
41
+ utils.saveToLocal.set('artalk-recent-comments', ls, !{cache})
42
+ })
43
+
44
+ function setHtml(el, data) {
45
+ el.innerHTML = data.map(i => `
46
+ <div class="comment-card" title="${i.title}" onclick="pjax.loadUrl('${i.url}')">
47
+ <div class="comment-info">
48
+ <img src="${i.avatar}" class="nolazyload" alt="${i.nick}">
49
+ <div>
50
+ <span class="comment-user">${i.nick}</span>
51
+ </div>
52
+ <time class="comment-time" datetime="${i.time}"></time>
53
+ </div>
54
+ <div class="comment-content">${i.content}</div>
55
+ <div class="comment-title">
56
+ <i class="solitude st-chat-fill"></i>
57
+ ${i.title}</div>
58
+ </div>
59
+ `).join('')
60
+ if (typeof sco !== 'undefined') sco.changeTimeFormat(document.querySelectorAll('.comment-time'))
61
+ else {
62
+ document.addEventListener('pjax:complete', () => sco.changeTimeFormat(document.querySelectorAll('.comment-time')))
63
+ document.addEventListener('DOMContentLoaded', () => sco.changeTimeFormat(document.querySelectorAll('.comment-time')))
64
+ }
65
+ }
66
+
67
+ function checkEmoji(content) {
68
+ return emojiReg.test(content)
69
+ }
70
+
71
+ function formatContent(content) {
72
+ content = content.replace(emojiReg, '[!{__("console.newest_comment.emoji")}]')
73
+ content = content.replace(/!\[.*?\]\((.*?)\)/g, '[!{__("console.newest_comment.image")}]')
74
+ content = content.replace(/\[.*?\]\((.*?)\)/g, '[!{__("console.newest_comment.link")}]')
75
+ content = content.replace(/```.*?```/g, '[!{__("console.newest_comment.code")}]')
76
+ return content
77
+ }
78
+ })()