hexo-theme-stellar 1.10.0 → 1.12.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.
- package/_config.yml +39 -56
- package/_data/widgets.yml +70 -0
- package/languages/en.yml +0 -1
- package/languages/zh-CN.yml +4 -5
- package/languages/zh-TW.yml +4 -5
- package/layout/_partial/main/article/read_next.ejs +16 -17
- package/layout/_partial/main/navbar/breadcrumb.ejs +1 -1
- package/layout/_partial/main/navbar/list_post.ejs +2 -2
- package/layout/_partial/main/post_list/post_card.ejs +21 -15
- package/layout/_partial/main/post_list/wiki_card.ejs +1 -1
- package/layout/_partial/sidebar/header.ejs +2 -26
- package/layout/_partial/sidebar/index.ejs +6 -6
- package/layout/_partial/sidebar/logo.ejs +3 -3
- package/layout/_partial/sidebar/menu.ejs +27 -0
- package/layout/_partial/sidebar/widgets/ghissues.ejs +46 -0
- package/layout/_partial/sidebar/widgets/ghrepo.ejs +53 -0
- package/layout/_partial/sidebar/widgets/ghuser.ejs +9 -11
- package/layout/_partial/sidebar/widgets/markdown.ejs +1 -1
- package/layout/_partial/sidebar/widgets/recent.ejs +8 -11
- package/layout/_partial/sidebar/widgets/{wiki_more.ejs → related.ejs} +7 -7
- package/layout/_partial/sidebar/widgets/tagcloud.ejs +24 -0
- package/layout/_partial/sidebar/widgets/timeline.ejs +27 -0
- package/layout/_partial/sidebar/widgets/toc.ejs +2 -6
- package/layout/index.ejs +1 -1
- package/package.json +1 -1
- package/scripts/events/lib/config.js +26 -10
- package/scripts/events/lib/doc_tree.js +3 -0
- package/scripts/helpers/related_posts.js +11 -39
- package/scripts/tags/about.js +10 -7
- package/scripts/tags/{grid.js → border.js} +4 -4
- package/scripts/tags/folders.js +55 -0
- package/scripts/tags/link.js +11 -9
- package/scripts/tags/navbar.js +1 -1
- package/scripts/tags/sites.js +1 -1
- package/scripts/tags/split.js +51 -0
- package/scripts/tags/timeline.js +4 -2
- package/source/css/_common/base.styl +5 -2
- package/source/css/_common/blur.styl +3 -0
- package/source/css/_common/device.styl +2 -0
- package/source/css/_common/highlight.styl +1 -1
- package/source/css/_common/loading.styl +16 -3
- package/source/css/_common/title.styl +0 -13
- package/source/css/_custom.styl +23 -26
- package/source/css/_defines/theme.styl +12 -12
- package/source/css/_layout/list.styl +40 -9
- package/source/css/_layout/md.styl +2 -2
- package/source/css/_layout/partial/related.styl +62 -93
- package/source/css/_layout/sidebar/footer.styl +4 -2
- package/source/css/_layout/sidebar/ghrepo.styl +36 -0
- package/source/css/_layout/sidebar/ghuser.styl +19 -1
- package/source/css/_layout/sidebar/sidebar.styl +4 -91
- package/source/css/_layout/sidebar/toc_common.styl +5 -3
- package/source/css/_layout/sidebar/widgets.styl +104 -0
- package/source/css/_layout/tag-plugins/about.styl +21 -17
- package/source/css/_layout/tag-plugins/common.styl +36 -31
- package/source/css/_layout/tag-plugins/folders.styl +62 -0
- package/source/css/_layout/tag-plugins/link.styl +41 -27
- package/source/css/_layout/tag-plugins/navbar.styl +10 -4
- package/source/css/_layout/tag-plugins/poetry.styl +1 -1
- package/source/css/_layout/tag-plugins/quot.styl +8 -7
- package/source/css/_layout/tag-plugins/split.styl +28 -0
- package/source/css/_layout/tag-plugins/timeline.styl +69 -41
- package/source/css/_plugins/comments/twikoo.styl +12 -6
- package/source/css/_plugins/comments/valine.styl +4 -0
- package/source/css/_plugins/comments/waline.styl +2 -2
- package/source/js/main.js +14 -8
- package/source/js/plugins/friends.js +3 -2
- package/source/js/plugins/ghinfo.js +14 -2
- package/source/js/plugins/linkcard.js +124 -0
- package/source/js/plugins/sites.js +4 -3
- package/source/js/plugins/timeline.js +60 -33
- package/layout/_partial/sidebar/widgets/repo_info.ejs +0 -91
- package/source/css/_layout/sidebar/repo_info.styl +0 -31
|
@@ -20,13 +20,15 @@
|
|
|
20
20
|
&:before
|
|
21
21
|
display: none
|
|
22
22
|
|
|
23
|
-
.tag-plugin.timeline .timenode
|
|
23
|
+
.md .tag-plugin.timeline .timenode
|
|
24
24
|
position: relative
|
|
25
25
|
display: flex
|
|
26
26
|
flex-direction: column
|
|
27
27
|
align-items: flex-start
|
|
28
|
-
|
|
28
|
+
box-sizing: border-box
|
|
29
|
+
max-width: 100%
|
|
29
30
|
>.header, >.body
|
|
31
|
+
box-sizing: border-box
|
|
30
32
|
max-width: @max-width
|
|
31
33
|
&[highlight] .header:before
|
|
32
34
|
background: $color-theme
|
|
@@ -35,24 +37,50 @@
|
|
|
35
37
|
&:hover .header
|
|
36
38
|
p
|
|
37
39
|
color: var(--text-p1)
|
|
40
|
+
.user-info
|
|
41
|
+
background: $color-theme
|
|
42
|
+
span
|
|
43
|
+
color: var(--card)
|
|
38
44
|
&:before
|
|
39
45
|
background: $color-theme
|
|
40
46
|
height: 16px
|
|
41
47
|
top: 'calc(50% - 0.5 * %s)' % @height
|
|
42
48
|
transform: scale(1)
|
|
43
49
|
|
|
44
|
-
.tag-plugin.timeline .header
|
|
50
|
+
.tag-plugin.timeline .timenode .header
|
|
45
51
|
display: flex
|
|
46
52
|
align-items: center
|
|
47
53
|
position: relative
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
margin: 0.25rem 0
|
|
55
|
+
font-size: $fs-12
|
|
56
|
+
.user-info
|
|
57
|
+
display: flex
|
|
58
|
+
align-items: center
|
|
50
59
|
font-size: $fs-12
|
|
51
|
-
font-weight:
|
|
60
|
+
font-weight: 500
|
|
61
|
+
color: var(--text-p1)
|
|
62
|
+
margin-right: 4px
|
|
63
|
+
line-height: 1
|
|
64
|
+
border-radius: 16px
|
|
65
|
+
padding-right: 6px
|
|
66
|
+
trans2 color background
|
|
67
|
+
img
|
|
68
|
+
background: white
|
|
69
|
+
height: 16px
|
|
70
|
+
border-radius: 16px
|
|
71
|
+
display: inline
|
|
72
|
+
margin: 0 4px 0 0
|
|
73
|
+
object-fit: contain
|
|
74
|
+
&:hover
|
|
75
|
+
background: $color-hover
|
|
76
|
+
&,p
|
|
77
|
+
font-weight: 500
|
|
52
78
|
color: var(--text-p3)
|
|
53
|
-
font-family: $ff-code
|
|
54
79
|
trans1 color
|
|
55
|
-
|
|
80
|
+
line-height: 1
|
|
81
|
+
p
|
|
82
|
+
margin: 0 !important
|
|
83
|
+
font-size: $fs-12 !important
|
|
56
84
|
a
|
|
57
85
|
color: inherit
|
|
58
86
|
font-weight: inherit
|
|
@@ -76,6 +104,8 @@
|
|
|
76
104
|
padding: 0.5rem 1rem
|
|
77
105
|
margin-top: 4px
|
|
78
106
|
box-shadow: $boxshadow-block
|
|
107
|
+
p
|
|
108
|
+
font-size: $fs-14
|
|
79
109
|
&:empty
|
|
80
110
|
display: none
|
|
81
111
|
p,.highlight,ol,ul,.tag-plugin
|
|
@@ -87,21 +117,28 @@
|
|
|
87
117
|
.tag-plugin.timeline.stellar-timeline-api .body
|
|
88
118
|
max-height: convert(hexo-config('tag_plugins.timeline.max-height'))
|
|
89
119
|
overflow: scroll
|
|
90
|
-
p
|
|
91
|
-
font-size: $fs-14
|
|
92
120
|
p.title
|
|
93
121
|
font-size: 1rem
|
|
94
|
-
font-weight:
|
|
95
|
-
margin: 0
|
|
96
|
-
padding: 0.5rem 0 0.75rem
|
|
122
|
+
font-weight: 700
|
|
123
|
+
margin: 0.5rem 0 0.75rem
|
|
97
124
|
line-height: 1.25
|
|
98
|
-
|
|
125
|
+
a
|
|
126
|
+
color: inherit
|
|
127
|
+
&:hover
|
|
128
|
+
color: $color-hover
|
|
129
|
+
a
|
|
130
|
+
&:has(img):after
|
|
131
|
+
display: none
|
|
132
|
+
img
|
|
133
|
+
margin: 0 auto
|
|
134
|
+
img
|
|
135
|
+
margin: 0.5rem auto
|
|
99
136
|
pre code
|
|
100
137
|
font-size: $fs-12
|
|
101
138
|
|
|
102
139
|
.tag-plugin.timeline.stellar-timeline-api .body .footer
|
|
140
|
+
margin: 0 0 -0.5rem
|
|
103
141
|
padding: 0.5rem 0 1rem
|
|
104
|
-
margin-bottom: -0.5rem
|
|
105
142
|
user-select: none
|
|
106
143
|
font-weight: 500
|
|
107
144
|
display: flex
|
|
@@ -116,18 +153,13 @@
|
|
|
116
153
|
line-height: 1.8
|
|
117
154
|
&:empty
|
|
118
155
|
display: none
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
156
|
+
.flex
|
|
157
|
+
display: flex
|
|
158
|
+
flex-wrap: wrap
|
|
159
|
+
font-size: $fs-12
|
|
160
|
+
align-items: stretch
|
|
122
161
|
|
|
123
|
-
.tag-plugin.timeline.stellar-timeline-api .body .footer
|
|
124
|
-
display: flex
|
|
125
|
-
flex-wrap: wrap
|
|
126
|
-
font-size: $fs-12
|
|
127
|
-
align-items: stretch
|
|
128
|
-
.reaction
|
|
129
|
-
border-color: var(--block)
|
|
130
|
-
border-style: dashed
|
|
162
|
+
.tag-plugin.timeline.stellar-timeline-api .body .footer
|
|
131
163
|
.item
|
|
132
164
|
border-width: 1px
|
|
133
165
|
border-style: solid
|
|
@@ -136,24 +168,20 @@
|
|
|
136
168
|
padding: 0 0.5rem
|
|
137
169
|
display: flex
|
|
138
170
|
align-items: center
|
|
139
|
-
&.comments
|
|
140
|
-
border-width: 0
|
|
141
171
|
&:first-child
|
|
142
172
|
margin-left: 0
|
|
143
173
|
&:last-child
|
|
144
174
|
margin-right: 0
|
|
145
|
-
|
|
146
|
-
|
|
175
|
+
.reaction
|
|
176
|
+
border-color: var(--block)
|
|
147
177
|
|
|
148
|
-
.tag-plugin.timeline
|
|
149
|
-
border-radius: 4px
|
|
178
|
+
.tag-plugin.timeline .body blockquote
|
|
150
179
|
padding: 0 0.5rem
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
180
|
+
box-shadow: none
|
|
181
|
+
border-left: 4px solid var(--block-border)
|
|
182
|
+
border-radius: 0
|
|
183
|
+
display: block
|
|
184
|
+
margin: 0.75rem 0
|
|
185
|
+
p
|
|
186
|
+
font-size: $fs-13
|
|
187
|
+
margin: 0.25rem
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
--twikoo-lighttext: #ef794f;
|
|
3
3
|
--twikoo-secondtext: #909094;
|
|
4
4
|
--twikoo-emoji-background: #f8f8f8;
|
|
5
|
-
--twikoo-theme:
|
|
5
|
+
--twikoo-theme: $color-theme;
|
|
6
6
|
margin-top: 1.5rem
|
|
7
7
|
|
|
8
8
|
.tk-content
|
|
@@ -106,10 +106,16 @@
|
|
|
106
106
|
.tk-comments-no
|
|
107
107
|
color: var(--text-p1);
|
|
108
108
|
|
|
109
|
+
set_darkmode_comments()
|
|
110
|
+
.cmt-body.twikoo
|
|
111
|
+
--twikoo-lighttext: #f2b94b;
|
|
112
|
+
--twikoo-secondtext: #a1a2b8;
|
|
113
|
+
--twikoo-emoji-background: darken($dark-block, 1);
|
|
114
|
+
--twikoo-theme: #409eff;
|
|
115
|
+
|
|
109
116
|
if hexo-config('style.darkmode') == 'auto'
|
|
110
117
|
@media (prefers-color-scheme: dark)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
--twikoo-theme: #409eff;
|
|
118
|
+
set_darkmode_comments()
|
|
119
|
+
|
|
120
|
+
if hexo-config('style.darkmode') == 'always'
|
|
121
|
+
set_darkmode_comments()
|
|
@@ -49,12 +49,16 @@
|
|
|
49
49
|
if hexo-config('style.darkmode') == 'auto'
|
|
50
50
|
@media (prefers-color-scheme: dark)
|
|
51
51
|
box-shadow: none
|
|
52
|
+
if hexo-config('style.darkmode') == 'always'
|
|
53
|
+
box-shadow: none
|
|
52
54
|
&:active
|
|
53
55
|
background: linear-gradient(145deg, #eee, #fff)
|
|
54
56
|
box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.1), -0px -0px 0px rgba(255, 255, 255, 0.8), inset 2px 2px 4px rgba(0, 0, 0, 0.1), inset -2px -2px 4px rgba(255, 255, 255, 1), inset -8px -8px 16px rgba(255, 255, 255, 0.4)
|
|
55
57
|
if hexo-config('style.darkmode') == 'auto'
|
|
56
58
|
@media (prefers-color-scheme: dark)
|
|
57
59
|
box-shadow: none
|
|
60
|
+
if hexo-config('style.darkmode') == 'always'
|
|
61
|
+
box-shadow: none
|
|
58
62
|
.vedit
|
|
59
63
|
.vctrl span
|
|
60
64
|
padding: 0
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
--waline-light-grey: #999;
|
|
6
6
|
--waline-dark-grey: #666;
|
|
7
7
|
/* 主题色 */
|
|
8
|
-
--waline-theme-color:
|
|
9
|
-
--waline-active-color:
|
|
8
|
+
--waline-theme-color: $color-theme;
|
|
9
|
+
--waline-active-color: $color-hover;
|
|
10
10
|
/* 布局颜色 */
|
|
11
11
|
--waline-color: #444;
|
|
12
12
|
--waline-bgcolor: #fff;
|
package/source/js/main.js
CHANGED
|
@@ -217,14 +217,20 @@ if (stellar.plugins.lazyload) {
|
|
|
217
217
|
if (stellar.plugins.stellar) {
|
|
218
218
|
for (let key of Object.keys(stellar.plugins.stellar)) {
|
|
219
219
|
let js = stellar.plugins.stellar[key];
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
220
|
+
if (key == 'linkcard') {
|
|
221
|
+
stellar.loadScript(js, { defer: true }).then(function () {
|
|
222
|
+
setCardLink(document.querySelectorAll('a.link-card'));
|
|
223
|
+
});
|
|
224
|
+
} else {
|
|
225
|
+
const els = document.getElementsByClassName('stellar-' + key + '-api');
|
|
226
|
+
if (els != undefined && els.length > 0) {
|
|
227
|
+
stellar.jQuery(() => {
|
|
228
|
+
stellar.loadScript(js, { defer: true });
|
|
229
|
+
if (key == 'timeline') {
|
|
230
|
+
stellar.loadScript(stellar.plugins.marked);
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
}
|
|
228
234
|
}
|
|
229
235
|
}
|
|
230
236
|
}
|
|
@@ -44,7 +44,7 @@ const friendsjs = {
|
|
|
44
44
|
},
|
|
45
45
|
layout: (cfg) => {
|
|
46
46
|
const el = $(cfg.el)[0];
|
|
47
|
-
$(el).append('<div class="loading-wrap"><svg
|
|
47
|
+
$(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2rem" height="2rem" 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
48
|
friendsjs.requestAPI(cfg.api, function(data) {
|
|
49
49
|
$(el).find('.loading-wrap').remove();
|
|
50
50
|
const arr = data.content || data;
|
|
@@ -60,7 +60,8 @@ const friendsjs = {
|
|
|
60
60
|
});
|
|
61
61
|
}, function() {
|
|
62
62
|
$(el).find('.loading-wrap svg').remove();
|
|
63
|
-
$(el).find('.loading-wrap
|
|
63
|
+
$(el).find('.loading-wrap').append('<svg xmlns="http://www.w3.org/2000/svg" width="2rem" height="2rem" 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');
|
|
64
65
|
});
|
|
65
66
|
},
|
|
66
67
|
}
|
|
@@ -44,13 +44,25 @@ const GitHubInfo = {
|
|
|
44
44
|
},
|
|
45
45
|
layout: (cfg) => {
|
|
46
46
|
const el = $(cfg.el)[0];
|
|
47
|
-
|
|
48
|
-
const arr = data.content || data;
|
|
47
|
+
function fill(data) {
|
|
49
48
|
for (let key of Object.keys(data)) {
|
|
50
49
|
$(el).find("[type=text]#" + key).text(data[key]);
|
|
51
50
|
$(el).find("[type=link]#" + key).attr("href", data[key]);
|
|
52
51
|
$(el).find("[type=img]#" + key).attr("src", data[key]);
|
|
53
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
|
+
}
|
|
54
66
|
}, function() {
|
|
55
67
|
});
|
|
56
68
|
},
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// 本插件由CardLink定制而成,原项目源码: https://github.com/Lete114/CardLink
|
|
2
|
+
|
|
3
|
+
var cardLink = {};
|
|
4
|
+
cardLink.caches = {};
|
|
5
|
+
cardLink.server = 'https://api.allorigins.win/raw?url=';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Remove '/' and '/index.html'
|
|
9
|
+
* @param {String} params
|
|
10
|
+
* @returns { String }
|
|
11
|
+
*/
|
|
12
|
+
function indexHandler(params) {
|
|
13
|
+
let path = params.replace(/(\/index\.html|\/)*$/gi, '')
|
|
14
|
+
if (path.length === 0) path += '/'
|
|
15
|
+
return path
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Determine if it is a ['https://', 'http://', '//'] protocol
|
|
20
|
+
* @param {String} url Website url
|
|
21
|
+
* @returns {Boolean}
|
|
22
|
+
*/
|
|
23
|
+
function isHttp(url) {
|
|
24
|
+
return /^(https?:)?\/\//g.test(url)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function renderer(el, obj) {
|
|
28
|
+
if (obj.title && obj.title.length > 0) {
|
|
29
|
+
el.querySelector('.title').innerHTML = obj.title;
|
|
30
|
+
}
|
|
31
|
+
if (obj.icon && obj.icon.length > 0) {
|
|
32
|
+
el.querySelector('.img').style = 'background-image: url("' + obj.icon + '");';
|
|
33
|
+
}
|
|
34
|
+
let desc = el.querySelector('.desc');
|
|
35
|
+
if (desc && obj.desc && obj.desc.length > 0) {
|
|
36
|
+
desc.innerHTML = obj.desc;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get info
|
|
42
|
+
* @param {Element} el Element
|
|
43
|
+
* @param {String} html String type html
|
|
44
|
+
* @param {String} link Website address
|
|
45
|
+
*/
|
|
46
|
+
// eslint-disable-next-line max-statements
|
|
47
|
+
function getInfo(el, html, link) {
|
|
48
|
+
try {
|
|
49
|
+
let title, icon, desc
|
|
50
|
+
const doc = new DOMParser().parseFromString(html, 'text/html')
|
|
51
|
+
// If there is no title, no card link is generated
|
|
52
|
+
title = doc.querySelector('title')
|
|
53
|
+
if (title) {
|
|
54
|
+
title = title.textContent
|
|
55
|
+
|
|
56
|
+
// Get the src of the first img tag in the body tag
|
|
57
|
+
let tmp = doc.querySelector('head link[rel="apple-touch-icon"]')
|
|
58
|
+
if (!tmp) {
|
|
59
|
+
tmp = doc.querySelector('head link[rel="icon"]')
|
|
60
|
+
}
|
|
61
|
+
icon = tmp && tmp.getAttribute('href')
|
|
62
|
+
|
|
63
|
+
if (/^data:image/.test(icon)) icon = ''
|
|
64
|
+
|
|
65
|
+
// If there is no src then get the site icon
|
|
66
|
+
if (!icon) {
|
|
67
|
+
const links = [].slice.call(doc.querySelectorAll('link[rel][href]'))
|
|
68
|
+
icon = links.find((_el) => _el.rel.includes('icon'))
|
|
69
|
+
icon = icon && icon.getAttribute('href')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
desc = doc.querySelector('head meta[name="description"]')
|
|
73
|
+
|
|
74
|
+
if (desc) {
|
|
75
|
+
desc = desc.content;
|
|
76
|
+
}
|
|
77
|
+
// If `icon` is not the ['https://', 'http://', '//'] protocol, splice on the `origin` of the a tag
|
|
78
|
+
if (icon && !isHttp(icon)) icon = new URL(link).origin + icon
|
|
79
|
+
cardLink.caches[link] = { title, link, icon, desc }
|
|
80
|
+
|
|
81
|
+
renderer(el, cardLink.caches[link])
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
// eslint-disable-next-line no-console
|
|
85
|
+
console.warn('CardLink Error: Failed to parse', error)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function fetchPage(link, callback) {
|
|
90
|
+
fetch(link)
|
|
91
|
+
.then((result) => result.text())
|
|
92
|
+
.then(callback)
|
|
93
|
+
.catch((error) => {
|
|
94
|
+
const server = cardLink.server
|
|
95
|
+
// eslint-disable-next-line no-console
|
|
96
|
+
if (link.includes(server) || !server) return console.error('CardLink Error:', error)
|
|
97
|
+
fetchPage(server + link, callback)
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Create card links
|
|
103
|
+
* @param {NodeList} nodes A collection of nodes or a collection of arrays,
|
|
104
|
+
* if it is an array then the array must always contain node element
|
|
105
|
+
*/
|
|
106
|
+
function setCardLink(nodes) {
|
|
107
|
+
// If the `nodes` do not contain a `forEach` method, then the default `a[cardlink]` is used
|
|
108
|
+
nodes = 'forEach' in (nodes || {}) ? nodes : document.querySelectorAll('a[cardlink]')
|
|
109
|
+
nodes.forEach((el) => {
|
|
110
|
+
// If it is not a tag element then it is not processed
|
|
111
|
+
if (el.nodeType !== 1) return
|
|
112
|
+
el.removeAttribute('cardlink')
|
|
113
|
+
const link = el.href
|
|
114
|
+
|
|
115
|
+
const cache = cardLink.caches[link]
|
|
116
|
+
if (cache) return renderer(el, cache)
|
|
117
|
+
|
|
118
|
+
if (isHttp(link)) {
|
|
119
|
+
fetchPage(link, (html) => {
|
|
120
|
+
getInfo(el, html, link)
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
}
|
|
@@ -44,14 +44,14 @@ const sitesjs = {
|
|
|
44
44
|
},
|
|
45
45
|
layout: (cfg) => {
|
|
46
46
|
const el = $(cfg.el)[0];
|
|
47
|
-
$(el).append('<div class="loading-wrap"><svg
|
|
47
|
+
$(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2rem" height="2rem" 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
48
|
sitesjs.requestAPI(cfg.api, function(data) {
|
|
49
49
|
$(el).find('.loading-wrap').remove();
|
|
50
50
|
const arr = data.content;
|
|
51
51
|
arr.forEach((item, i) => {
|
|
52
52
|
var cell = '<div class="site-card">';
|
|
53
53
|
cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + item.url + '">';
|
|
54
|
-
cell += '<img src="' + (item.screenshot || ('https://
|
|
54
|
+
cell += '<img src="' + (item.screenshot || ('https://screenshot-api.xaoxuu.com/api?url=' + item.url + '&width=1280&height=720')) + '" onerror="javascript:this.src=\'' + cfg.screenshot + '\';"/>';
|
|
55
55
|
cell += '<div class="info">';
|
|
56
56
|
cell += '<img src="' + (item.avatar || cfg.avatar) + '" onerror="javascript:this.src=\'' + cfg.avatar + '\';"/>';
|
|
57
57
|
cell += '<span class="title">' + item.title + '</span>';
|
|
@@ -63,7 +63,8 @@ const sitesjs = {
|
|
|
63
63
|
});
|
|
64
64
|
}, function() {
|
|
65
65
|
$(el).find('.loading-wrap svg').remove();
|
|
66
|
-
$(el).find('.loading-wrap
|
|
66
|
+
$(el).find('.loading-wrap').append('<svg xmlns="http://www.w3.org/2000/svg" width="2rem" height="2rem" 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>');
|
|
67
|
+
$(el).find('.loading-wrap').addClass('error');
|
|
67
68
|
});
|
|
68
69
|
},
|
|
69
70
|
}
|
|
@@ -54,54 +54,81 @@ const StellarTimeline = {
|
|
|
54
54
|
},
|
|
55
55
|
layoutDiv: (cfg) => {
|
|
56
56
|
const el = $(cfg.el)[0];
|
|
57
|
-
$(el).append('<div class="loading-wrap"><svg
|
|
57
|
+
$(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2rem" height="2rem" 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>');
|
|
58
58
|
StellarTimeline.requestAPI(cfg.api, function(data) {
|
|
59
59
|
$(el).find('.loading-wrap').remove();
|
|
60
60
|
const arr = data.content || data;
|
|
61
|
+
var users = [];
|
|
62
|
+
const filter = el.getAttribute('user');
|
|
63
|
+
if (filter && filter.length > 0) {
|
|
64
|
+
users = filter.split(",");
|
|
65
|
+
}
|
|
61
66
|
arr.forEach((item, i) => {
|
|
62
|
-
if (item.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
cell +=
|
|
71
|
-
cell += '<
|
|
72
|
-
cell += '<
|
|
67
|
+
if (item.user && item.user.login && users.length > 0) {
|
|
68
|
+
if (!users.includes(item.user.login)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
var cell = '<div class="timenode" index="' + i + '">';
|
|
73
|
+
cell += '<div class="header">';
|
|
74
|
+
if (!users.length && item.user) {
|
|
75
|
+
cell += '<a class="user-info" href="' + item.user.html_url + '" target="_blank" rel="external nofollow noopener noreferrer">';
|
|
76
|
+
cell += '<img src="' + item.user.avatar_url + '">';
|
|
77
|
+
cell += '<span>' + item.user.login + '</span>';
|
|
78
|
+
cell += '</a>';
|
|
79
|
+
}
|
|
80
|
+
let date = new Date(item.created_at);
|
|
81
|
+
cell += '<p>' + date.toString().replace(/\sGMT([^.]*)/i, "") + '</p>';
|
|
82
|
+
cell += '</div>';
|
|
83
|
+
cell += '<div class="body">';
|
|
84
|
+
cell += '<p class="title">';
|
|
85
|
+
cell += '<a href="' + item.html_url + '" target="_blank" rel="external nofollow noopener noreferrer">';
|
|
86
|
+
cell += item.title || item.name || item.tag_name;
|
|
87
|
+
cell += '</a>';
|
|
88
|
+
cell += '</p>';
|
|
89
|
+
|
|
90
|
+
cell += marked.parse(item.body);
|
|
91
|
+
cell += '<div class="footer">';
|
|
92
|
+
cell += '<div class="flex left">';
|
|
93
|
+
if (item.labels) {
|
|
73
94
|
item.labels.forEach((label, i) => {
|
|
74
|
-
cell += '<div class="item label ' + label.name + '" style="background:#' + label.color + '
|
|
95
|
+
cell += '<div class="item label ' + label.name + '" style="background:#' + label.color + '18;border-color:#' + label.color + '36">';
|
|
75
96
|
cell += '<span>' + label.name + '</span>';
|
|
76
97
|
cell += '</div>';
|
|
77
98
|
});
|
|
78
|
-
|
|
79
|
-
cell += '<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
99
|
+
} else if (item.zipball_url) {
|
|
100
|
+
cell += '<a class="item download" href="' + item.zipball_url + '" target="_blank" rel="external nofollow noopener noreferrer">';
|
|
101
|
+
cell += '<span>📦 ' + item.tag_name + '.zip</span>';
|
|
102
|
+
cell += '</a>';
|
|
103
|
+
}
|
|
104
|
+
cell += '</div>';
|
|
105
|
+
cell += '<div class="flex right">';
|
|
106
|
+
if (item.reactions && item.reactions.total_count > 0) {
|
|
107
|
+
for (let key of Object.keys(StellarTimeline.reactions)) {
|
|
108
|
+
let num = item.reactions[key];
|
|
109
|
+
if (num > 0) {
|
|
110
|
+
cell += '<div class="item reaction ' + key + '">';
|
|
111
|
+
cell += '<span>' + StellarTimeline.reactions[key] + ' ' + item.reactions[key] + '</span>';
|
|
112
|
+
cell += '</div>';
|
|
89
113
|
}
|
|
90
114
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
cell += '<
|
|
115
|
+
}
|
|
116
|
+
if (item.comments != null) {
|
|
117
|
+
cell += '<a class="item comments last" href="' + item.html_url + '#issuecomment-new" target="_blank" rel="external nofollow noopener noreferrer">';
|
|
118
|
+
cell += '<span><svg t="1666270368054" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2528" width="200" height="200"><path d="M952 64H72C32.3 64 0 96.3 0 136v508c0 39.7 32.3 72 72 72h261l128 128c14 14 32.5 21.1 50.9 21.1s36.9-7 50.9-21.1l128-128h261c39.7 0 72-32.3 72-72V136c0.2-39.7-32.1-72-71.8-72zM222 462c-39.8 0-72-32.2-72-72s32.2-72 72-72 72 32.2 72 72-32.2 72-72 72z m290-7.7c-39.8 0-72-32.2-72-72s32.2-72 72-72 72 32.2 72 72c0 39.7-32.2 72-72 72z m290 8c-39.8 0-72-32.2-72-72s32.2-72 72-72 72 32.2 72 72c0 39.7-32.2 72-72 72z" p-id="2529"></path></svg> ' + (item.comments || 0) + '</span>';
|
|
94
119
|
cell += '</a>';
|
|
95
|
-
cell += '</div>';
|
|
96
|
-
cell += '</div>';
|
|
97
|
-
cell += '</div>';
|
|
98
|
-
cell += '</div>';
|
|
99
|
-
$(el).append(cell);
|
|
100
120
|
}
|
|
121
|
+
|
|
122
|
+
cell += '</div>';
|
|
123
|
+
cell += '</div>';
|
|
124
|
+
cell += '</div>';
|
|
125
|
+
cell += '</div>';
|
|
126
|
+
$(el).append(cell);
|
|
101
127
|
});
|
|
102
128
|
}, function() {
|
|
103
129
|
$(el).find('.loading-wrap svg').remove();
|
|
104
|
-
$(el).find('.loading-wrap
|
|
130
|
+
$(el).find('.loading-wrap').append('<svg xmlns="http://www.w3.org/2000/svg" width="2rem" height="2rem" 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>');
|
|
131
|
+
$(el).find('.loading-wrap').addClass('error');
|
|
105
132
|
});
|
|
106
133
|
},
|
|
107
134
|
}
|