hexo-theme-stellar 1.26.7 → 1.27.0

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 (150) hide show
  1. package/_config.yml +134 -94
  2. package/_data/icons.yml +8 -1
  3. package/_data/widgets.yml +19 -7
  4. package/languages/en.yml +4 -2
  5. package/languages/zh-CN.yml +3 -1
  6. package/languages/zh-TW.yml +4 -2
  7. package/layout/404.ejs +1 -1
  8. package/layout/_partial/{plugins/comments → comments}/artalk/script.ejs +2 -2
  9. package/layout/_partial/{plugins/comments/utterances → comments/giscus}/layout.ejs +5 -2
  10. package/layout/_partial/{plugins/comments → comments}/giscus/script.ejs +1 -4
  11. package/layout/_partial/{plugins/comments → comments}/layout.ejs +1 -1
  12. package/layout/_partial/{plugins/comments → comments}/twikoo/script.ejs +1 -1
  13. package/layout/_partial/comments/waline/script.ejs +43 -0
  14. package/layout/_partial/head.ejs +0 -1
  15. package/layout/_partial/main/article/article_footer.ejs +1 -1
  16. package/layout/_partial/main/footer.ejs +1 -1
  17. package/layout/_partial/main/navbar/article_banner.ejs +81 -17
  18. package/layout/_partial/main/navbar/ghinfo.ejs +1 -1
  19. package/layout/_partial/main/post_list/post_card.ejs +1 -1
  20. package/layout/_partial/menubtn.ejs +6 -3
  21. package/layout/_partial/scripts/defines.ejs +31 -0
  22. package/layout/_partial/scripts/services.ejs +29 -0
  23. package/layout/_partial/scripts/sidebar.ejs +25 -0
  24. package/layout/_partial/scripts/utils.ejs +158 -0
  25. package/layout/_partial/scripts.ejs +32 -0
  26. package/layout/_partial/sidebar/{index.ejs → index_leftbar.ejs} +22 -20
  27. package/layout/_partial/sidebar/index_rightbar.ejs +84 -0
  28. package/layout/_partial/sidebar/logo.ejs +1 -1
  29. package/layout/_partial/widgets/author.ejs +37 -0
  30. package/layout/_partial/widgets/components/edit.ejs +24 -0
  31. package/layout/_partial/widgets/ghissues.ejs +1 -1
  32. package/layout/_partial/widgets/ghrepo.ejs +2 -2
  33. package/layout/_partial/widgets/ghuser.ejs +2 -2
  34. package/layout/_partial/widgets/markdown.ejs +1 -1
  35. package/layout/_partial/widgets/recent.ejs +1 -5
  36. package/layout/_partial/widgets/related.ejs +1 -1
  37. package/layout/_partial/widgets/timeline.ejs +1 -1
  38. package/layout/_partial/widgets/toc.ejs +32 -85
  39. package/layout/_partial/widgets/tree.ejs +71 -0
  40. package/layout/_plugins/copycode.ejs +13 -0
  41. package/layout/_plugins/fancybox.ejs +32 -0
  42. package/layout/_plugins/heti.ejs +21 -0
  43. package/layout/_plugins/index.ejs +24 -0
  44. package/layout/_plugins/lazyload.ejs +21 -0
  45. package/layout/{_partial/plugins/parser/mathjax/script.ejs → _plugins/mathjax.ejs} +1 -1
  46. package/layout/_plugins/mermaid.ejs +29 -0
  47. package/layout/_plugins/preload.ejs +9 -0
  48. package/layout/_plugins/scrollreveal.ejs +15 -0
  49. package/layout/_plugins/search/local_search.ejs +8 -0
  50. package/layout/_plugins/swiper.ejs +26 -0
  51. package/layout/_plugins/tianli_gpt.ejs +11 -0
  52. package/layout/archive.ejs +9 -2
  53. package/layout/layout.ejs +9 -6
  54. package/layout/page.ejs +2 -10
  55. package/package.json +1 -1
  56. package/scripts/events/lib/doc_tree.js +8 -8
  57. package/scripts/events/lib/topic_tree.js +3 -0
  58. package/scripts/generators/author.js +1 -1
  59. package/scripts/helpers/parse_config.js +6 -5
  60. package/scripts/tags/lib/albums.js +2 -2
  61. package/scripts/tags/lib/button.js +1 -1
  62. package/scripts/tags/lib/emoji.js +1 -1
  63. package/scripts/tags/lib/friends.js +1 -1
  64. package/scripts/tags/lib/icon.js +10 -5
  65. package/scripts/tags/lib/link.js +2 -2
  66. package/scripts/tags/lib/md.js +1 -1
  67. package/scripts/tags/lib/posters.js +2 -2
  68. package/scripts/tags/lib/sites.js +1 -1
  69. package/scripts/tags/lib/timeline.js +2 -2
  70. package/source/css/_common/button.styl +8 -2
  71. package/source/css/_common/device.styl +39 -12
  72. package/source/css/_custom.styl +15 -16
  73. package/source/css/_defines/const.styl +1 -1
  74. package/source/css/_defines/func.styl +14 -4
  75. package/source/css/_defines/theme.styl +38 -27
  76. package/source/css/_layout/layout.styl +61 -26
  77. package/source/css/_layout/list.styl +1 -1
  78. package/source/css/_layout/main.styl +1 -4
  79. package/source/css/_layout/md.styl +16 -2
  80. package/source/css/_layout/pages/archives.styl +4 -0
  81. package/source/css/_layout/partial/article-banner.styl +14 -15
  82. package/source/css/_layout/partial/article-footer.styl +0 -5
  83. package/source/css/_layout/partial/footer.styl +8 -6
  84. package/source/css/_layout/partial/related.styl +4 -0
  85. package/source/css/_layout/sidebar/footer.styl +3 -1
  86. package/source/css/_layout/sidebar/logo.styl +3 -1
  87. package/source/css/_layout/sidebar/nav-area.styl +1 -1
  88. package/source/css/_layout/sidebar/sidebar.styl +23 -16
  89. package/source/css/_layout/tag-plugins/banner.styl +1 -8
  90. package/source/css/_layout/tag-plugins/common.styl +10 -5
  91. package/source/css/_layout/tag-plugins/icon.styl +6 -0
  92. package/source/css/_layout/tag-plugins/image.styl +1 -1
  93. package/source/css/_layout/tag-plugins/quot.styl +1 -1
  94. package/source/css/_layout/tag-plugins/timeline.styl +26 -27
  95. package/source/css/_layout/widgets/ghrepo.styl +1 -1
  96. package/source/css/_layout/widgets/ghuser.styl +9 -5
  97. package/source/css/_layout/widgets/list.styl +4 -2
  98. package/source/css/_layout/widgets/related.styl +0 -1
  99. package/source/css/_layout/widgets/timeline.styl +27 -21
  100. package/source/css/_layout/widgets/toc.styl +182 -0
  101. package/source/css/_layout/widgets/tree.styl +0 -0
  102. package/source/css/_layout/widgets/widgets.styl +26 -7
  103. package/source/css/_plugins/comments/twikoo.styl +6 -6
  104. package/source/css/_plugins/comments/waline.styl +13 -10
  105. package/source/css/_plugins/index.styl +2 -0
  106. package/source/css/_plugins/katex.styl +5 -0
  107. package/source/css/_plugins/mermaid.styl +49 -59
  108. package/source/css/_plugins/tianli_gpt.styl +208 -151
  109. package/source/js/main.js +48 -251
  110. package/source/js/plugins/copycode.js +24 -28
  111. package/source/js/search/local-search.js +32 -0
  112. package/source/js/services/fcircle.js +36 -0
  113. package/source/js/services/friends.js +27 -0
  114. package/source/js/services/ghinfo.js +33 -0
  115. package/source/js/services/mdrender.js +10 -0
  116. package/source/js/services/memos.js +73 -0
  117. package/source/js/services/siteinfo.js +38 -0
  118. package/source/js/services/sites.js +30 -0
  119. package/source/js/services/timeline.js +106 -0
  120. package/source/js/services/weibo.js +60 -0
  121. package/layout/_partial/main/navbar/article_top_area.ejs +0 -35
  122. package/layout/_partial/main/navbar/author_banner.ejs +0 -29
  123. package/layout/_partial/plugins/ai/tianli_gpt.ejs +0 -9
  124. package/layout/_partial/plugins/comments/waline/script.ejs +0 -39
  125. package/layout/_partial/plugins/parser/head.ejs +0 -3
  126. package/layout/_partial/plugins/parser/katex/head.ejs +0 -3
  127. package/layout/_partial/plugins/parser/katex/script.ejs +0 -4
  128. package/layout/_partial/plugins/parser/mermaid/script.ejs +0 -29
  129. package/layout/_partial/plugins/parser/script.ejs +0 -9
  130. package/layout/_partial/scripts/index.ejs +0 -176
  131. package/source/css/_layout/widgets/toc_blog.styl +0 -3
  132. package/source/css/_layout/widgets/toc_common.styl +0 -92
  133. package/source/css/_layout/widgets/toc_wiki.styl +0 -62
  134. package/source/js/plugins/fcircle.js +0 -92
  135. package/source/js/plugins/friends.js +0 -84
  136. package/source/js/plugins/ghinfo.js +0 -85
  137. package/source/js/plugins/linkcard.js +0 -48
  138. package/source/js/plugins/marked.js +0 -50
  139. package/source/js/plugins/memos.js +0 -132
  140. package/source/js/plugins/sites.js +0 -87
  141. package/source/js/plugins/timeline.js +0 -162
  142. package/source/js/plugins/weibo.js +0 -116
  143. /package/layout/_partial/{plugins/comments → comments}/artalk/layout.ejs +0 -0
  144. /package/layout/_partial/{plugins/comments → comments}/beaudar/layout.ejs +0 -0
  145. /package/layout/_partial/{plugins/comments → comments}/beaudar/script.ejs +0 -0
  146. /package/layout/_partial/{plugins/comments → comments}/script.ejs +0 -0
  147. /package/layout/_partial/{plugins/comments → comments}/twikoo/layout.ejs +0 -0
  148. /package/layout/_partial/{plugins/comments/giscus → comments/utterances}/layout.ejs +0 -0
  149. /package/layout/_partial/{plugins/comments → comments}/utterances/script.ejs +0 -0
  150. /package/layout/_partial/{plugins/comments → comments}/waline/layout.ejs +0 -0
@@ -1,92 +0,0 @@
1
-
2
- .toc-item
3
- margin-top: 2px
4
- .toc-child
5
- margin-top: 2px
6
- .widget-wrapper.toc .widget-body
7
- margin-top: 0
8
- ul ul, ul ol
9
- padding-left: 0
10
- ol ul, ol ol
11
- padding-left: 0
12
-
13
- .toc
14
- padding: 0
15
- margin: 0
16
- padding-left: 0.25rem
17
- .toc-item .toc-link
18
- padding: 0.5rem
19
- font-weight: 500
20
- font-size: $fs-13
21
- color: var(--text-p1)
22
- .toc-child .toc-item .toc-link
23
- padding: 0.25rem 0.5rem 0.25rem 1.3rem
24
- font-weight: 400
25
- color: var(--text-p2)
26
- .toc-child .toc-child .toc-item .toc-link
27
- padding-left: 2.1rem
28
- font-size: $fs-12
29
- color: var(--text-p3)
30
- .toc-child .toc-child .toc-child .toc-item .toc-link
31
- padding-left: 2.9rem
32
-
33
-
34
- .widget-wrapper.toc .toc-item
35
- color: var(--text-p2)
36
- font-size: $fs-12
37
- padding: 0
38
- list-style: none
39
- &.active
40
- background: var(--alpha50)
41
- border-left-color: @color
42
- .toc-child .toc-item
43
- padding: 0
44
- .widget-wrapper.toc a.toc-link
45
- color: inherit
46
- display: block
47
- line-height: 1.2
48
- border-radius: $border-bar
49
- position: relative
50
- trans1 background
51
- &:before
52
- content: ''
53
- position: absolute
54
- left: -6px
55
- top: 'calc(50% - %s)' % 6px
56
- bottom: 'calc(50% - %s)' % 6px
57
- width: 2px
58
- border-radius: 2px
59
- background: var(--text)
60
- visibility: hidden
61
- &.active
62
- background: var(--alpha50)
63
- &:before
64
- visibility: visible
65
- &:hover
66
- background: var(--alpha100)
67
-
68
-
69
- // 始终折叠
70
- .widget-wrapper.toc[collapse='true']
71
- .toc-item a.toc-link+ol
72
- display: none
73
- // 激活上级目录时显示子目录
74
- .toc a.toc-link.active+ol
75
- display: block
76
-
77
- // 自动折叠
78
- .widget-wrapper.toc[collapse='auto']
79
- .toc-item a.toc-link+ol
80
- display: none
81
- // 激活上级目录时显示子目录
82
- .toc a.toc-link.active+ol
83
- display: block
84
- // 鼠标放上去时显示子目录
85
- &:hover a.toc-link+ol
86
- display: block
87
-
88
- // 子目录激活时显示
89
- .widget-wrapper.toc[collapse='true'] ol:has(> .toc-item a.active)
90
- display: block
91
- .widget-wrapper.toc[collapse='auto'] ol:has(> .toc-item a.active)
92
- display: block
@@ -1,62 +0,0 @@
1
- .doc-tree+.doc-tree
2
- margin-top: 2px
3
-
4
- .widget-wrapper.toc.multi
5
- // .widget-header
6
- // color: $color-theme
7
- // filter: brightness(75%)
8
- .widget-body+.widget-header
9
- margin-top: 28px
10
-
11
- // 其它分页链接
12
- .widget-wrapper.toc.multi .doc-tree
13
- border-radius: $border-bar
14
- overflow: hidden
15
- a.doc-tree-link
16
- color: var(--text-p1)
17
- padding: 0 16px
18
- display: flex
19
- min-height: 32px
20
- justify-content: space-between
21
- align-items: center
22
- font-size: $fs-14
23
- position: relative
24
- trans1 background
25
- .toc-text
26
- txt-ellipsis()
27
- svg,img
28
- flex-shrink: 0
29
- width: 1em
30
- height: 1em
31
- transform: scale(1.2)
32
- &:after
33
- position: absolute
34
- right: .5rem
35
- &:only-child
36
- &.active
37
- background: var(--alpha50)
38
- &:hover
39
- background: var(--alpha100)
40
- &:hover
41
- background: var(--alpha100)
42
-
43
-
44
- // 当前分页链接
45
- .widget-wrapper.toc.multi .doc-tree.active
46
- a.doc-tree-link
47
- background: var(--alpha100)
48
- font-weight: 500
49
- &:hover:after
50
- content: none
51
- >.toc
52
- padding: 4px 10px
53
- border: 1px solid var(--alpha50)
54
- background: var(--alpha20)
55
- border-bottom-left-radius: $border-bar
56
- border-bottom-right-radius: $border-bar
57
- a.toc-link:before
58
- left: -7px
59
- width: 4px
60
- background: var(--text-p2)
61
- a.toc-link:hover
62
- background: var(--alpha100)
@@ -1,92 +0,0 @@
1
- const FCircle = {
2
- requestAPI: (url, callback, timeout) => {
3
- let retryTimes = 5;
4
- function request() {
5
- return new Promise((resolve, reject) => {
6
- let status = 0; // 0 等待 1 完成 2 超时
7
- let timer = setTimeout(() => {
8
- if (status === 0) {
9
- status = 2;
10
- timer = null;
11
- reject('请求超时');
12
- if (retryTimes == 0) {
13
- timeout();
14
- }
15
- }
16
- }, 5000);
17
- fetch(url).then(function(response) {
18
- if (status !== 2) {
19
- clearTimeout(timer);
20
- resolve(response);
21
- timer = null;
22
- status = 1;
23
- }
24
- if (response.ok) {
25
- return response.json();
26
- }
27
- throw new Error('Network response was not ok.');
28
- }).then(function(data) {
29
- retryTimes = 0;
30
- callback(data);
31
- }).catch(function(error) {
32
- if (retryTimes > 0) {
33
- retryTimes -= 1;
34
- setTimeout(() => {
35
- request();
36
- }, 5000);
37
- } else {
38
- timeout();
39
- }
40
- });
41
- });
42
- }
43
- request();
44
- },
45
- layoutDiv: (cfg) => {
46
- const el = $(cfg.el)[0];
47
- $(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" stroke-opacity=".3" d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="1.3s" values="60;0"/></path><path stroke-dasharray="15" stroke-dashoffset="15" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"/><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></g></svg></div>');
48
- FCircle.requestAPI(cfg.api, function(data) {
49
- $(el).find('.loading-wrap').remove();
50
- const arr = data.article_data || [];
51
- const limit = el.getAttribute('limit');
52
- arr.forEach((item, i) => {
53
- if (limit && i >= limit) {
54
- return;
55
- }
56
- var cell = '<div class="timenode" index="' + i + '">';
57
- cell += '<div class="header">';
58
- cell += '<div class="user-info">';
59
- cell += '<img src="' + (item.avatar || cfg.avatar) + '" onerror="javascript:this.src=\'' + cfg.avatar + '\';">';
60
- cell += '<span>' + item.author + '</span>';
61
- cell += '</div>';
62
- cell += '<p>' + item.created + '</p>';
63
- cell += '</div>';
64
- cell += '<a class="body" href="' + item.link + '" target="_blank" rel="external nofollow noopener noreferrer">';
65
- cell += item.title;
66
- cell += '</a>';
67
- cell += '</div>';
68
- $(el).append(cell);
69
- });
70
- }, function() {
71
- $(el).find('.loading-wrap svg').remove();
72
- $(el).find('.loading-wrap').append('<svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" d="M12 3L21 20H3L12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.5s" values="60;0"/></path><path stroke-dasharray="6" stroke-dashoffset="6" d="M12 10V14"><animate fill="freeze" attributeName="stroke-dashoffset" begin="0.6s" dur="0.2s" values="6;0"/></path></g><circle cx="12" cy="17" r="1" fill="currentColor" fill-opacity="0"><animate fill="freeze" attributeName="fill-opacity" begin="0.8s" dur="0.4s" values="0;1"/></circle></svg>');
73
- $(el).find('.loading-wrap').addClass('error');
74
- });
75
- },
76
- }
77
-
78
- $(function () {
79
- const els = document.getElementsByClassName('stellar-fcircle-api');
80
- for (var i = 0; i < els.length; i++) {
81
- const el = els[i];
82
- const api = el.getAttribute('api');
83
- if (api == null) {
84
- continue;
85
- }
86
- var cfg = new Object();
87
- cfg.el = el;
88
- cfg.api = api;
89
- cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/avatar/round/3442075.svg';
90
- FCircle.layoutDiv(cfg);
91
- }
92
- });
@@ -1,84 +0,0 @@
1
- const friendsjs = {
2
- requestAPI: (url, callback, timeout) => {
3
- let retryTimes = 5;
4
- function request() {
5
- return new Promise((resolve, reject) => {
6
- let status = 0; // 0 等待 1 完成 2 超时
7
- let timer = setTimeout(() => {
8
- if (status === 0) {
9
- status = 2;
10
- timer = null;
11
- reject('请求超时');
12
- if (retryTimes == 0) {
13
- timeout();
14
- }
15
- }
16
- }, 5000);
17
- fetch(url).then(function(response) {
18
- if (status !== 2) {
19
- clearTimeout(timer);
20
- resolve(response);
21
- timer = null;
22
- status = 1;
23
- }
24
- if (response.ok) {
25
- return response.json();
26
- }
27
- throw new Error('Network response was not ok.');
28
- }).then(function(data) {
29
- retryTimes = 0;
30
- callback(data);
31
- }).catch(function(error) {
32
- if (retryTimes > 0) {
33
- retryTimes -= 1;
34
- setTimeout(() => {
35
- request();
36
- }, 5000);
37
- } else {
38
- timeout();
39
- }
40
- });
41
- });
42
- }
43
- request();
44
- },
45
- layout: (cfg) => {
46
- const el = $(cfg.el)[0];
47
- $(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" stroke-opacity=".3" d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="1.3s" values="60;0"/></path><path stroke-dasharray="15" stroke-dashoffset="15" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"/><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></g></svg></div>');
48
- friendsjs.requestAPI(cfg.api, function(data) {
49
- $(el).find('.loading-wrap').remove();
50
- for (let item of (data.content || data)) {
51
- var cell = `<div class="grid-cell user-card">`;
52
- cell += `<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="${item.html_url || item.url}">`;;
53
- cell += `<img src="${item.avatar_url || item.avatar || item.icon || cfg.avatar}" onerror="javascript:this.removeAttribute(\'data-src\');this.src=\'${cfg.avatar}\';"/>`;
54
- cell += `<div class="name image-meta">`;
55
- cell += `<span class="image-caption">${item.title || item.login}</span>`;
56
- cell += `</div>`;
57
- cell += `</a>`;
58
- cell += `</div>`;
59
- $(el).find('.grid-box').append(cell);
60
- }
61
- }, function() {
62
- $(el).find('.loading-wrap svg').remove();
63
- $(el).find('.loading-wrap').append('<svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" d="M12 3L21 20H3L12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.5s" values="60;0"/></path><path stroke-dasharray="6" stroke-dashoffset="6" d="M12 10V14"><animate fill="freeze" attributeName="stroke-dashoffset" begin="0.6s" dur="0.2s" values="6;0"/></path></g><circle cx="12" cy="17" r="1" fill="currentColor" fill-opacity="0"><animate fill="freeze" attributeName="fill-opacity" begin="0.8s" dur="0.4s" values="0;1"/></circle></svg>');
64
- $(el).find('.loading-wrap').addClass('error');
65
- });
66
- },
67
- }
68
-
69
- $(function () {
70
- const els = document.getElementsByClassName('stellar-friends-api');
71
- for (var i = 0; i < els.length; i++) {
72
- const el = els[i];
73
- const api = el.getAttribute('api');
74
- if (api == null) {
75
- continue;
76
- }
77
- var cfg = new Object();
78
- cfg.el = el;
79
- cfg.api = api;
80
- cfg.class = el.getAttribute('class');
81
- cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/avatar/round/3442075.svg';
82
- friendsjs.layout(cfg);
83
- }
84
- });
@@ -1,85 +0,0 @@
1
- const GitHubInfo = {
2
- requestAPI: (url, callback, timeout) => {
3
- let retryTimes = 5;
4
- function request() {
5
- return new Promise((resolve, reject) => {
6
- let status = 0; // 0 等待 1 完成 2 超时
7
- let timer = setTimeout(() => {
8
- if (status === 0) {
9
- status = 2;
10
- timer = null;
11
- reject('请求超时');
12
- if (retryTimes == 0) {
13
- timeout();
14
- }
15
- }
16
- }, 5000);
17
- fetch(url).then(function(response) {
18
- if (status !== 2) {
19
- clearTimeout(timer);
20
- resolve(response);
21
- timer = null;
22
- status = 1;
23
- }
24
- if (response.ok) {
25
- return response.json();
26
- }
27
- throw new Error('Network response was not ok.');
28
- }).then(function(data) {
29
- retryTimes = 0;
30
- callback(data);
31
- }).catch(function(error) {
32
- if (retryTimes > 0) {
33
- retryTimes -= 1;
34
- setTimeout(() => {
35
- request();
36
- }, 5000);
37
- } else {
38
- timeout();
39
- }
40
- });
41
- });
42
- }
43
- request();
44
- },
45
- layout: (cfg) => {
46
- const el = $(cfg.el)[0];
47
- function fill(data) {
48
- for (let key of Object.keys(data)) {
49
- $(el).find("[type=text]#" + key).text(data[key]);
50
- $(el).find("[type=link]#" + key).attr("href", data[key]);
51
- $(el).find("[type=img]#" + key).attr("src", data[key]);
52
- }
53
- }
54
- GitHubInfo.requestAPI(cfg.api, function(data) {
55
- const idx = el.getAttribute('index');
56
- if (idx != undefined) {
57
- const arr = data.content || data;
58
- if (arr && arr.length > idx) {
59
- let obj = arr[idx];
60
- obj['latest-tag-name'] = obj['name'];
61
- fill(arr[idx]);
62
- }
63
- } else {
64
- fill(data);
65
- }
66
- }, function() {
67
- });
68
- },
69
- }
70
-
71
- $(function () {
72
- const els = document.getElementsByClassName('stellar-ghinfo-api');
73
- for (var i = 0; i < els.length; i++) {
74
- const el = els[i];
75
- const api = el.getAttribute('api');
76
- if (api == null) {
77
- continue;
78
- }
79
- var cfg = new Object();
80
- cfg.el = el;
81
- cfg.api = api;
82
- cfg.class = el.getAttribute('class');
83
- GitHubInfo.layout(cfg);
84
- }
85
- });
@@ -1,48 +0,0 @@
1
- // 本插件由CardLink定制而成,原项目源码: https://github.com/Lete114/CardLink
2
-
3
- function renderer(el, obj) {
4
- var autofill = [];
5
- const autofillStr = el.getAttribute('autofill');
6
- if (autofillStr) {
7
- autofill = autofillStr.split(',');
8
- }
9
- if (obj.title && obj.title.length > 0 && autofill.includes('title')) {
10
- el.querySelector('.title').innerHTML = obj.title;
11
- el.title = obj.title;
12
- }
13
- if (obj.icon && obj.icon.length > 0 && autofill.includes('icon')) {
14
- el.querySelector('.img').style = 'background-image: url("' + obj.icon + '");';
15
- el.querySelector('.img').setAttribute('data-bg', obj.icon);
16
- }
17
- let desc = el.querySelector('.desc');
18
- if (desc && obj.desc && obj.desc.length > 0 && autofill.includes('desc')) {
19
- desc.innerHTML = obj.desc;
20
- }
21
- }
22
-
23
- /**
24
- * Create card links
25
- * @param {NodeList} nodes A collection of nodes or a collection of arrays,
26
- * if it is an array then the array must always contain node element
27
- */
28
- function setCardLink(nodes) {
29
- // If the `nodes` do not contain a `forEach` method, then the default `a[cardlink]` is used
30
- nodes = 'forEach' in (nodes || {}) ? nodes : document.querySelectorAll('a[cardlink]')
31
- nodes.forEach((el) => {
32
- // If it is not a tag element then it is not processed
33
- if (el.nodeType !== 1) return;
34
- el.removeAttribute('cardlink');
35
- const api = el.getAttribute('api');
36
- if (api == null) return;
37
- fetch(api).then(function(response) {
38
- if (response.ok) {
39
- return response.json();
40
- }
41
- throw new Error('Network response was not ok.');
42
- }).then(function(data) {
43
- renderer(el, data);
44
- }).catch(function(error) {
45
- console.error(error);
46
- });
47
- })
48
- }
@@ -1,50 +0,0 @@
1
- const loadMarkdown = (cfg) => {
2
- if (!window.fetch) {
3
- cfg.el.innerHTML =
4
- '<div style="font-size: 24px"><p>Your browser outdated. Please use the latest version of Chrome or Firefox!</p><p>您的浏览器版本过低,请使用最新版的 Chrome 或 Firefox 浏览器!</p></div>';
5
- } else {
6
- cfg.el.innerHTML =
7
- '<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" stroke-opacity=".3" d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="1.3s" values="60;0"/></path><path stroke-dasharray="15" stroke-dashoffset="15" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"/><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></g></svg></div>';
8
- fetch(cfg.src, { method: "GET" })
9
- .then((resp) => {
10
- return Promise.all([
11
- resp.ok,
12
- resp.status,
13
- resp.text(),
14
- resp.headers,
15
- ]);
16
- })
17
- .then(([ok, status, data, headers]) => {
18
- if (ok) {
19
- return {
20
- ok,
21
- status,
22
- data,
23
- headers,
24
- };
25
- } else {
26
- throw new Error(JSON.stringify(json.error));
27
- }
28
- })
29
- .then((resp) => {
30
- let data = marked.parse(resp.data);
31
- cfg.el.innerHTML = data;
32
- })
33
- .catch((error) => {
34
- console.error(error);
35
- cfg.el.innerHTML =
36
- '<div class="loading-wrap error"><svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" d="M12 3L21 20H3L12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.5s" values="60;0"/></path><path stroke-dasharray="6" stroke-dashoffset="6" d="M12 10V14"><animate fill="freeze" attributeName="stroke-dashoffset" begin="0.6s" dur="0.2s" values="6;0"/></path></g><circle cx="12" cy="17" r="1" fill="currentColor" fill-opacity="0"><animate fill="freeze" attributeName="fill-opacity" begin="0.8s" dur="0.4s" values="0;1"/></circle></svg></div>';
37
- });
38
- };
39
- };
40
-
41
- $(function () {
42
- const els = document.getElementsByClassName('stellar-marked-api');
43
- for (var i = 0; i < els.length; i++) {
44
- var cfg = new Object();
45
- const el = els[i];
46
- cfg.src = `${el.getAttribute('src')}?t=${new Date().getTime()}`;
47
- cfg.el = el;
48
- loadMarkdown(cfg);
49
- }
50
- });
@@ -1,132 +0,0 @@
1
- const MemosJS = {
2
- requestAPI: (url, callback, timeout) => {
3
- let retryTimes = 5;
4
- function request() {
5
- return new Promise((resolve, reject) => {
6
- let status = 0; // 0 等待 1 完成 2 超时
7
- let timer = setTimeout(() => {
8
- if (status === 0) {
9
- status = 2;
10
- timer = null;
11
- reject('请求超时');
12
- if (retryTimes == 0) {
13
- timeout();
14
- }
15
- }
16
- }, 5000);
17
- fetch(url).then(function(response) {
18
- if (status !== 2) {
19
- clearTimeout(timer);
20
- resolve(response);
21
- timer = null;
22
- status = 1;
23
- }
24
- if (response.ok) {
25
- return response.json();
26
- }
27
- throw new Error('Network response was not ok.');
28
- }).then(function(data) {
29
- retryTimes = 0;
30
- callback(data);
31
- }).catch(function(error) {
32
- if (retryTimes > 0) {
33
- retryTimes -= 1;
34
- setTimeout(() => {
35
- request();
36
- }, 5000);
37
- } else {
38
- timeout();
39
- }
40
- });
41
- });
42
- }
43
- request();
44
- },
45
- layoutDiv: (cfg) => {
46
- const el = $(cfg.el)[0];
47
- $(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" stroke-opacity=".3" d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="1.3s" values="60;0"/></path><path stroke-dasharray="15" stroke-dashoffset="15" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"/><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></g></svg></div>');
48
- MemosJS.requestAPI(cfg.api, function(data) {
49
- $(el).find('.loading-wrap').remove();
50
- var users = [];
51
- const filter = el.getAttribute('user');
52
- if (filter && filter.length > 0) {
53
- users = filter.split(",");
54
- }
55
- var hide = [];
56
- const hideStr = el.getAttribute('hide');
57
- if (hideStr && hideStr.length > 0) {
58
- hide = hideStr.split(",");
59
- }
60
- data.forEach((item, i) => {
61
- if (cfg.limit && i >= cfg.limit) {
62
- return;
63
- }
64
- if (item.user && item.user.login && users.length > 0) {
65
- if (!users.includes(item.user.login)) {
66
- return;
67
- }
68
- }
69
- let date = new Date(item.createdTs * 1000)
70
- var cell = '<div class="timenode" index="' + i + '">';
71
- cell += '<div class="header">';
72
- if (!users.length && !hide.includes('user')) {
73
- cell += '<div class="user-info">';
74
- if (cfg.avatar?.length > 0) {
75
- cell += `<img src="${cfg.avatar}">`;
76
- }
77
- cell += '<span>' + item.creatorName + '</span>';
78
- cell += '</div>';
79
- }
80
- cell += '<p>' + date.toLocaleString() + '</p>';
81
- cell += '</div>';
82
- cell += '<div class="body">';
83
- cell += marked.parse(item.content || '');
84
- var imgs = [];
85
- for (let res of item.resourceList) {
86
- if (res.type?.includes('image/')) {
87
- imgs.push(res);
88
- }
89
- }
90
- if (imgs.length > 0) {
91
- cell += '<div class="tag-plugin image">';
92
- for (let img of imgs) {
93
- if (img.externalLink?.length > 0) {
94
- cell += `<div class="image-bg"><img src="${img.externalLink}" data-fancybox="memos"></div>`;
95
- } else {
96
- cell += `<div class="image-bg"><img src="https://${cfg.host}/o/r/${img.id}" data-fancybox="memos"></div>`;
97
- }
98
- }
99
- cell += '</div>';
100
- }
101
- cell += '</div>';
102
- cell += '</div>';
103
- $(el).append(cell);
104
- });
105
- }, function() {
106
- $(el).find('.loading-wrap svg').remove();
107
- $(el).find('.loading-wrap').append('<svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" d="M12 3L21 20H3L12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.5s" values="60;0"/></path><path stroke-dasharray="6" stroke-dashoffset="6" d="M12 10V14"><animate fill="freeze" attributeName="stroke-dashoffset" begin="0.6s" dur="0.2s" values="6;0"/></path></g><circle cx="12" cy="17" r="1" fill="currentColor" fill-opacity="0"><animate fill="freeze" attributeName="fill-opacity" begin="0.8s" dur="0.4s" values="0;1"/></circle></svg>');
108
- $(el).find('.loading-wrap').addClass('error');
109
- });
110
- },
111
- }
112
-
113
- $(function () {
114
- const els = document.getElementsByClassName('stellar-memos-api');
115
- for (var i = 0; i < els.length; i++) {
116
- const el = els[i];
117
- const api = el.getAttribute('api');
118
- if (api == null) {
119
- continue;
120
- }
121
- var cfg = new Object();
122
- cfg.el = el;
123
- cfg.api = api;
124
- cfg.limit = el.getAttribute('limit');
125
- cfg.host = api.replace(/https:\/\/(.*?)\/(.*)/i, '$1');
126
- cfg.avatar = el.getAttribute('avatar');
127
- if (!cfg.avatar) {
128
- cfg.avatar = 'https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/avatar/round/3442075.svg';
129
- }
130
- MemosJS.layoutDiv(cfg);
131
- }
132
- });