hexo-theme-stellar 1.9.0 → 1.11.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 (69) hide show
  1. package/_config.yml +60 -52
  2. package/_data/widgets.yml +46 -0
  3. package/languages/en.yml +0 -6
  4. package/languages/zh-CN.yml +0 -6
  5. package/languages/zh-TW.yml +0 -6
  6. package/layout/404.ejs +1 -1
  7. package/layout/_partial/main/footer.ejs +6 -17
  8. package/layout/_partial/main/header/index.ejs +1 -1
  9. package/layout/_partial/main/navbar/list_post.ejs +2 -2
  10. package/layout/_partial/plugins/comments/valine/script.ejs +1 -1
  11. package/layout/_partial/scripts/index.ejs +5 -3
  12. package/layout/_partial/sidebar/index.ejs +9 -7
  13. package/layout/_partial/sidebar/logo.ejs +1 -1
  14. package/layout/_partial/sidebar/widgets/ghrepo.ejs +53 -0
  15. package/layout/_partial/sidebar/widgets/ghuser.ejs +53 -0
  16. package/layout/_partial/sidebar/widgets/toc.ejs +1 -1
  17. package/layout/post.ejs +1 -1
  18. package/layout/wiki.ejs +1 -1
  19. package/package.json +1 -1
  20. package/scripts/events/lib/config.js +26 -10
  21. package/scripts/tags/about.js +12 -13
  22. package/scripts/tags/folders.js +55 -0
  23. package/scripts/tags/friends.js +2 -3
  24. package/scripts/tags/ghcard.js +2 -2
  25. package/scripts/tags/lib/users.js +1 -2
  26. package/scripts/tags/sites.js +2 -3
  27. package/scripts/tags/timeline.js +32 -25
  28. package/source/css/_common/base.styl +5 -9
  29. package/source/css/_common/button.styl +1 -1
  30. package/source/css/_common/device.styl +2 -2
  31. package/source/css/_common/highlight.styl +4 -3
  32. package/source/css/_common/html.styl +2 -0
  33. package/source/css/_common/loading.styl +5 -0
  34. package/source/css/_common/pre.styl +6 -0
  35. package/source/css/_custom.styl +36 -23
  36. package/source/css/_defines/const.styl +1 -0
  37. package/source/css/_defines/theme.styl +13 -13
  38. package/source/css/_layout/layout.styl +2 -2
  39. package/source/css/_layout/main.styl +2 -2
  40. package/source/css/_layout/md.styl +36 -2
  41. package/source/css/_layout/partial/footer.styl +3 -7
  42. package/source/css/_layout/partial/navbar.styl +1 -1
  43. package/source/css/_layout/partial/paginator.styl +4 -0
  44. package/source/css/_layout/partial/related.styl +2 -0
  45. package/source/css/_layout/sidebar/ghrepo.styl +30 -0
  46. package/source/css/_layout/sidebar/ghuser.styl +80 -0
  47. package/source/css/_layout/sidebar/sidebar.styl +2 -3
  48. package/source/css/_layout/tag-plugins/about.styl +14 -16
  49. package/source/css/_layout/tag-plugins/common.styl +1 -1
  50. package/source/css/_layout/tag-plugins/folders.styl +62 -0
  51. package/source/css/_layout/tag-plugins/friends.styl +3 -6
  52. package/source/css/_layout/tag-plugins/inline-labels.styl +1 -0
  53. package/source/css/_layout/tag-plugins/link.styl +2 -1
  54. package/source/css/_layout/tag-plugins/note.styl +8 -0
  55. package/source/css/_layout/tag-plugins/poetry.styl +1 -1
  56. package/source/css/_layout/tag-plugins/quot.styl +7 -6
  57. package/source/css/_layout/tag-plugins/sites.styl +2 -6
  58. package/source/css/_layout/tag-plugins/tabs.styl +5 -0
  59. package/source/css/_layout/tag-plugins/timeline.styl +108 -6
  60. package/source/css/_layout/tag-plugins/toc.styl +1 -1
  61. package/source/css/_plugins/comments/twikoo.styl +2 -2
  62. package/source/css/_plugins/comments/waline.styl +1 -1
  63. package/source/js/main.js +13 -15
  64. package/source/js/plugins/friends.js +1 -2
  65. package/source/js/plugins/ghinfo.js +73 -0
  66. package/source/js/plugins/sites.js +1 -1
  67. package/source/js/plugins/timeline.js +144 -0
  68. package/layout/_partial/sidebar/widgets/repo_info.ejs +0 -72
  69. package/source/css/_layout/sidebar/repo_info.styl +0 -28
@@ -0,0 +1,80 @@
1
+ .widget-wrap#github-user
2
+ .widget-header+.widget-body
3
+ margin: 0.75rem 0
4
+ .widget-wrap#github-user .widget-body
5
+ text-align: center
6
+ background: var(--card)
7
+ border-radius: $border-card
8
+ padding: 1rem
9
+
10
+ .widget-wrap#github-user .widget-body .avatar
11
+ display: block
12
+ border-radius: 100%
13
+ margin: 1rem auto 1.25rem auto
14
+ max-width: 75%
15
+ overflow: hidden
16
+ img
17
+ display: block
18
+ @media screen and (max-width: $device-tablet)
19
+ max-width: 50%
20
+
21
+ .widget-wrap#github-user .widget-body .username
22
+ font-weight: 900
23
+ font-size: $fs-h2
24
+ color: var(--text-p0)
25
+ margin: 0.5rem 0
26
+
27
+ .widget-wrap#github-user .widget-body .bio
28
+ font-size: $fs-13
29
+ margin: 0.5rem 0
30
+
31
+ .widget-wrap#github-user .widget-body .follow
32
+ font-weight: 500
33
+ border-radius: 64px
34
+ padding: 0.5rem 1rem
35
+ background: $color-theme
36
+ color: var(--card)
37
+ font-size: 1rem
38
+ align-self: stretch
39
+ text-align: center
40
+ line-height: 1.5
41
+ display: flex
42
+ align-items: center
43
+ justify-content: center
44
+ trans1: background
45
+ svg
46
+ margin-right: 6px
47
+ &:hover
48
+ background: $color-hover
49
+
50
+
51
+
52
+ .widget-wrap#github-user .widget-body .buttons
53
+ margin: 1rem 0
54
+ align-self: stretch
55
+ display: grid
56
+ grid-gap: 2px
57
+ grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 2px)
58
+
59
+ .widget-wrap#github-user .widget-body .btn
60
+ display: flex
61
+ flex-direction: column
62
+ align-items: center
63
+ color: inherit
64
+ border: 1px solid transparent
65
+ border-radius: 4px
66
+ padding: 0.25rem 0
67
+ trans1: background
68
+ &:hover
69
+ background: var(--block)
70
+
71
+
72
+ .widget-wrap#github-user .widget-body .buttons .btn .title
73
+ font-size: 1rem
74
+ font-weight: 700
75
+
76
+
77
+ .widget-wrap#github-user .widget-body .buttons .btn .desc
78
+ font-size: $fs-12
79
+ color: var(--text-p3)
80
+ font-weight: 500
@@ -6,14 +6,14 @@
6
6
  padding: var(--gap-l)
7
7
  padding-top: "calc(2 * %s)" % var(--gap-l)
8
8
  height: "calc(100vh - 3 * %s)" % var(--gap-l)
9
- @media screen and (max-width: $device-tablet)
9
+ @media screen and (max-width: $device-mobile-max)
10
10
  padding-top: "calc(1 * %s)" % var(--gap-l)
11
11
  height: "calc(100% - 2 * %s)" % var(--gap-l)
12
12
 
13
13
  .l_left[layout=wiki]
14
14
  padding-bottom: 0
15
15
  height: "calc(100vh - 2 * %s)" % var(--gap-l)
16
- @media screen and (max-width: $device-tablet)
16
+ @media screen and (max-width: $device-mobile-max)
17
17
  height: "calc(100% - 1 * %s)" % var(--gap-l)
18
18
  .widgets >:last-child
19
19
  margin-bottom: 6rem
@@ -75,7 +75,6 @@
75
75
  font-weight: 900
76
76
  color: inherit
77
77
  line-height: 1.2
78
- font-family: $ff-logo
79
78
  display: block
80
79
  position: relative
81
80
  .main
@@ -1,12 +1,12 @@
1
1
  .tag-plugin.about
2
2
  background: var(--block)
3
- border-radius: $border-block
3
+ border-radius: $border-card
4
4
  padding: 2rem
5
5
  .about-header
6
6
  display flex
7
- flex-direction: row-reverse
8
- justify-content: space-between
7
+ justify-content: center
9
8
  flex-wrap: wrap
9
+ margin: 1.5rem 0 3rem
10
10
  img
11
11
  object-fit: contain
12
12
  >img
@@ -28,28 +28,26 @@
28
28
  >p
29
29
  line-height: 1.5
30
30
  .tag-plugin.navbar:last-child
31
+ text-align: center
31
32
  nav.cap
32
33
  margin-top: 1rem
34
+ background: var(--card)
35
+ box-shadow: $boxshadow-button
33
36
  a
34
- margin: 0
35
- color: $color-link
36
- background: var(--block-hover)
37
- &.active
38
- background: none
37
+ color: var(--text-p2)
39
38
  &:hover
40
- color: $color-hover
41
- background: var(--block-border)
42
- a+a
43
- margin-left: .5rem
39
+ background: var(--block)
40
+ &.active
41
+ background: var(--block)
42
+ box-shadow: none
43
+ color: var(--text-p1)
44
44
  .about-header+.about-body
45
45
  margin-top: 1.5rem
46
46
 
47
47
  @media screen and (max-width: $device-mobile)
48
48
  .tag-plugin.about
49
- padding: 1rem
49
+ padding: 1.5rem 1rem
50
50
  .about-header
51
- flex-direction: column
52
- .avatar
53
- margin: 1rem auto
51
+ margin: 2.5rem 0 3rem
54
52
  p
55
53
  width 100%
@@ -81,7 +81,7 @@ if hexo-config('style.darkmode') == 'auto'
81
81
  .tag-plugin[color='light']
82
82
  --theme-border: white
83
83
  --theme-bg: #ddd
84
- color: var(--site-bg) !important
84
+ color: var(--card) !important
85
85
 
86
86
  .tag-plugin[color='dark']
87
87
  --theme-border: black
@@ -0,0 +1,62 @@
1
+ .tag-plugin.folders
2
+ display: block
3
+ margin: 1rem 0
4
+ border-radius: $border-block
5
+ font-size: $fs-14
6
+ border: 1px solid var(--theme-border)
7
+ overflow: hidden
8
+ .folder
9
+ display: block
10
+ font-size: $fs-14
11
+ background: var(--block)
12
+ &:last-child summary
13
+ border-bottom: none
14
+ summary
15
+ display: block
16
+ cursor: pointer
17
+ color: var(--text-p2)
18
+ font-weight: 500
19
+ position: relative
20
+ line-height: 1.2
21
+ outline: none
22
+ padding: 0.75rem 1rem
23
+ border-bottom: 1px solid var(--theme-border)
24
+ &:last-child
25
+ border-bottom: none
26
+ >
27
+ p,h1,h2,h3,h4,h5,h6
28
+ display: inline
29
+ border-bottom: none !important
30
+ &:hover
31
+ color: var(--text-p0)
32
+ background: var(--block-hover)
33
+ &:after
34
+ position: absolute
35
+ content: '+'
36
+ text-align: center
37
+ top: 50%
38
+ transform: translateY(-50%)
39
+ right: 1rem
40
+
41
+
42
+ .tag-plugin.folders details[open]
43
+ background: none
44
+ &:last-child
45
+ summary
46
+ border-bottom: 1px solid var(--theme-border)
47
+ .body
48
+ border-bottom: none
49
+ >summary
50
+ color: var(--text-p1)
51
+ background: var(--block-hover)
52
+ &:hover:after
53
+ content: '-'
54
+
55
+ >div.body
56
+ padding: 1rem
57
+ border-bottom: 1px solid var(--theme-border)
58
+ font-size: $fs-15
59
+ >:first-child
60
+ margin-top: 0
61
+ >:last-child
62
+ margin-bottom: 0
@@ -15,12 +15,9 @@
15
15
  align-items: stretch
16
16
  &+.group-header
17
17
  margin-top: 2rem
18
- .friendsjs-wrap
18
+ .stellar-friends-api
19
19
  display: block
20
- .loading-wrap
21
- min-height: 50px
22
- margin: 2rem 0
23
- text-align: center
20
+
24
21
 
25
22
  .users-wrap .user-card
26
23
  flex-shrink: 1
@@ -33,7 +30,7 @@
33
30
  width: 16.66%
34
31
  @media screen and (max-width: 820px)
35
32
  width: 20%
36
- @media screen and (max-width: $device-tablet)
33
+ @media screen and (max-width: $device-mobile-max)
37
34
  width: 16.66%
38
35
  @media screen and (max-width: $device-mobile)
39
36
  width: 25%
@@ -3,6 +3,7 @@
3
3
  text-decoration: none
4
4
  border-bottom: 2px solid $color-hover
5
5
  emp
6
+ width: fit-content
6
7
  text-decoration: none
7
8
  border-bottom: 4px dotted $color-hover
8
9
  wavy
@@ -3,7 +3,7 @@
3
3
  margin: 1em auto
4
4
  display: flex
5
5
  justify-content: center
6
- @media screen and (max-width: $device-mobile-375)
6
+ @media screen and (max-width: $device-mobile-425)
7
7
  width: 100%
8
8
 
9
9
  .md .link-card
@@ -32,6 +32,7 @@
32
32
  flex-direction: column
33
33
  align-items: stretch
34
34
  width: 400px
35
+ text-align: justify
35
36
 
36
37
  .md .link-card
37
38
  line-height: 1.2
@@ -44,5 +44,13 @@
44
44
  >.tabs
45
45
  margin-top: .5rem
46
46
 
47
+ .md .tag-plugin.note[child=iframe]
48
+ overflow: hidden
49
+ padding: 0
50
+ >.body
51
+ margin: 0
52
+ iframe
53
+ margin: 0
54
+
47
55
  .md .tag-plugin .tag-plugin.note
48
56
  --gap-p: 1rem
@@ -47,4 +47,4 @@
47
47
  top: 6px
48
48
  bottom: 6px
49
49
  border-radius: 4px
50
- background: $color-highlight
50
+ background: $color-accent
@@ -41,13 +41,13 @@ article.md.content
41
41
  &:before
42
42
  top: 8px
43
43
  left: 0
44
- border-top: 6px solid $color-highlight
45
- border-left: 6px solid $color-highlight
44
+ border-top: 6px solid $color-accent
45
+ border-left: 6px solid $color-accent
46
46
  &:after
47
47
  right: 0
48
48
  bottom: 0
49
- border-right: 6px solid $color-highlight
50
- border-bottom: 6px solid $color-highlight
49
+ border-right: 6px solid $color-accent
50
+ border-bottom: 6px solid $color-accent
51
51
  article.md.content h1.quot[type=text]
52
52
  &:before,&:after
53
53
  width: 12px
@@ -59,9 +59,10 @@ article.md.content h1.quot[type=text]
59
59
  .icon
60
60
  height: 1.5em
61
61
  display: inline-block
62
- color: $color-highlight
62
+ color: $color-accent
63
63
  border-radius: 0
64
64
  &.prefix
65
+ margin-left: -0.5rem
65
66
  margin-right: .5rem
66
67
  &.suffix
67
68
  margin-left: .5rem
@@ -70,7 +71,7 @@ article.md.content h1.quot[type=text]
70
71
  .md span.tag-plugin.quot
71
72
  font-weight: 500
72
73
  &:before,&:after
73
- color: $color-highlight
74
+ color: $color-accent
74
75
  font-weight: 900
75
76
  &:before
76
77
  content: "「"
@@ -11,12 +11,8 @@
11
11
  width: 100%
12
12
  &+.group-header
13
13
  margin-top: 2rem
14
- .sitesjs-wrap
14
+ .stellar-sites-api
15
15
  display: block
16
- .loading-wrap
17
- min-height: 50px
18
- margin: 2rem 0
19
- text-align: center
20
16
 
21
17
  .sites-wrap .group-body
22
18
  display: grid
@@ -26,7 +22,7 @@
26
22
  grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 1rem)
27
23
  @media screen and (max-width: 900px)
28
24
  grid-template-columns: repeat(auto-fill, "calc((100% - 1 * %s) / 2)" % 1rem)
29
- @media screen and (max-width: $device-tablet)
25
+ @media screen and (max-width: $device-mobile-max)
30
26
  grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 1rem)
31
27
  @media screen and (max-width: $device-mobile)
32
28
  grid-template-columns: repeat(auto-fill, "calc((100% - 1 * %s) / 2)" % 1rem)
@@ -79,3 +79,8 @@
79
79
  display: none
80
80
  &.active
81
81
  display: block
82
+
83
+ .md.indent .tag-plugin.tabs .tab-content p:not([class])
84
+ text-indent: 'calc(%s * 2)' % $fs-p
85
+ a
86
+ text-indent: 0
@@ -1,6 +1,9 @@
1
- .tag-plugin.timeline
1
+ .md .tag-plugin.folding .body:has(.timeline)
2
+ background: var(--site-bg)
3
+
4
+ .md .tag-plugin.timeline
2
5
  position: relative
3
- margin: 1rem 0
6
+ margin-top: 0
4
7
  padding-left: 16px
5
8
  &:before
6
9
  content: ''
@@ -12,6 +15,10 @@
12
15
  border-radius: 8px
13
16
  top: .5rem
14
17
  bottom: 0
18
+ &:has(.loading-wrap)
19
+ padding-left: 0
20
+ &:before
21
+ display: none
15
22
 
16
23
  .tag-plugin.timeline .timenode
17
24
  position: relative
@@ -28,23 +35,48 @@
28
35
  &:hover .header
29
36
  p
30
37
  color: var(--text-p1)
38
+ .user-info
39
+ background: $color-theme
40
+ span
41
+ color: var(--card)
31
42
  &:before
32
43
  background: $color-theme
33
44
  height: 16px
34
45
  top: 'calc(50% - 0.5 * %s)' % @height
35
46
  transform: scale(1)
36
47
 
37
- .tag-plugin.timeline .header
48
+ .tag-plugin.timeline .timenode .header
38
49
  display: flex
39
50
  align-items: center
40
51
  position: relative
52
+ margin: 0.25rem 0
53
+ .user-info
54
+ display: flex
55
+ align-items: center
56
+ font-size: $fs-12
57
+ font-weight: 500
58
+ color: var(--text-p1)
59
+ margin-right: 4px
60
+ line-height: 1
61
+ border-radius: 16px
62
+ padding-right: 6px
63
+ trans2 color background
64
+ img
65
+ background: white
66
+ height: 16px
67
+ border-radius: 16px
68
+ display: inline
69
+ margin: 0 4px 0 0
70
+ object-fit: contain
71
+ &:hover
72
+ background: $color-hover
41
73
  p
42
- margin: .25rem 0
74
+ margin: 0
43
75
  font-size: $fs-12
44
- font-weight: 700
76
+ font-weight: 500
45
77
  color: var(--text-p3)
46
- font-family: $ff-code
47
78
  trans1 color
79
+ line-height: 1
48
80
  a
49
81
  color: inherit
50
82
  font-weight: inherit
@@ -68,9 +100,79 @@
68
100
  padding: 0.5rem 1rem
69
101
  margin-top: 4px
70
102
  box-shadow: $boxshadow-block
103
+ p
104
+ font-size: $fs-14
71
105
  &:empty
72
106
  display: none
73
107
  p,.highlight,ol,ul,.tag-plugin
74
108
  margin: .5rem 0
75
109
  .tag-plugin.copy
76
110
  width: 240px
111
+
112
+
113
+ .tag-plugin.timeline.stellar-timeline-api .body
114
+ max-height: convert(hexo-config('tag_plugins.timeline.max-height'))
115
+ overflow: scroll
116
+ p.title
117
+ font-size: 1rem
118
+ font-weight: 700
119
+ margin: 0
120
+ padding: 0.5rem 0 0.75rem
121
+ line-height: 1.25
122
+ border-bottom: 1px dashed var(--block-border)
123
+ a
124
+ color: inherit
125
+ &:hover
126
+ color: $color-hover
127
+ pre code
128
+ font-size: $fs-12
129
+
130
+ .tag-plugin.timeline.stellar-timeline-api .body .footer
131
+ padding: 0.5rem 0 1rem
132
+ margin-bottom: -0.5rem
133
+ user-select: none
134
+ font-weight: 500
135
+ display: flex
136
+ flex-wrap: wrap
137
+ justify-content: space-between
138
+ align-items: stretch
139
+ position: sticky
140
+ position: -webkit-sticky
141
+ bottom: -0.5rem
142
+ background: var(--card)
143
+ span
144
+ line-height: 1.8
145
+ &:empty
146
+ display: none
147
+ .flex
148
+ display: flex
149
+ flex-wrap: wrap
150
+ font-size: $fs-12
151
+ align-items: stretch
152
+
153
+ .tag-plugin.timeline.stellar-timeline-api .body .footer
154
+ .item
155
+ border-width: 1px
156
+ border-style: solid
157
+ margin: 2px
158
+ border-radius: 4px
159
+ padding: 0 0.5rem
160
+ display: flex
161
+ align-items: center
162
+ &:first-child
163
+ margin-left: 0
164
+ &:last-child
165
+ margin-right: 0
166
+ .reaction
167
+ border-color: var(--block)
168
+
169
+ .tag-plugin.timeline .body blockquote
170
+ padding: 0 0.5rem
171
+ box-shadow: none
172
+ border-left: 4px solid var(--block-border)
173
+ border-radius: 0
174
+ display: block
175
+ margin: 0.75rem 0
176
+ p
177
+ font-size: $fs-13
178
+ margin: 0.25rem
@@ -33,6 +33,6 @@ details.toc[open] >div.body
33
33
  margin-top: 0
34
34
 
35
35
 
36
- @media screen and (max-width: $device-tablet)
36
+ @media screen and (max-width: $device-mobile-max)
37
37
  .tag-plugin.toc[display=mobile]
38
38
  display: block !important
@@ -2,7 +2,7 @@
2
2
  --twikoo-lighttext: #ef794f;
3
3
  --twikoo-secondtext: #909094;
4
4
  --twikoo-emoji-background: #f8f8f8;
5
- --twikoo-theme: #409eff;
5
+ --twikoo-theme: $color-theme;
6
6
  margin-top: 1.5rem
7
7
 
8
8
  .tk-content
@@ -112,4 +112,4 @@ if hexo-config('style.darkmode') == 'auto'
112
112
  --twikoo-lighttext: #f2b94b;
113
113
  --twikoo-secondtext: #a1a2b8;
114
114
  --twikoo-emoji-background: darken($dark-block, 1);
115
- --twikoo-theme: #409eff;
115
+ --twikoo-theme: #409eff;
@@ -5,7 +5,7 @@
5
5
  --waline-light-grey: #999;
6
6
  --waline-dark-grey: #666;
7
7
  /* 主题色 */
8
- --waline-theme-color: #3498db;
8
+ --waline-theme-color: $color-theme;
9
9
  --waline-active-color: #2ecc71;
10
10
  /* 布局颜色 */
11
11
  --waline-color: #444;
package/source/js/main.js CHANGED
@@ -213,21 +213,19 @@ if (stellar.plugins.lazyload) {
213
213
  });
214
214
  }
215
215
 
216
- // issuesjs
217
- if (stellar.plugins.sitesjs) {
218
- const issues_api = document.getElementById('sites-api');
219
- if (issues_api != undefined) {
220
- stellar.jQuery(() => {
221
- stellar.loadScript(stellar.plugins.sitesjs, { defer: true })
222
- })
223
- }
224
- }
225
- if (stellar.plugins.friendsjs) {
226
- const issues_api = document.getElementById('friends-api');
227
- if (issues_api != undefined) {
228
- stellar.jQuery(() => {
229
- stellar.loadScript(stellar.plugins.friendsjs, { defer: true })
230
- })
216
+ // stellar js
217
+ if (stellar.plugins.stellar) {
218
+ for (let key of Object.keys(stellar.plugins.stellar)) {
219
+ let js = stellar.plugins.stellar[key];
220
+ const els = document.getElementsByClassName('stellar-' + key + '-api');
221
+ if (els != undefined && els.length > 0) {
222
+ stellar.jQuery(() => {
223
+ stellar.loadScript(js, { defer: true });
224
+ if (key == 'timeline') {
225
+ stellar.loadScript(stellar.plugins.marked);
226
+ }
227
+ })
228
+ }
231
229
  }
232
230
  }
233
231
 
@@ -48,7 +48,6 @@ const friendsjs = {
48
48
  friendsjs.requestAPI(cfg.api, function(data) {
49
49
  $(el).find('.loading-wrap').remove();
50
50
  const arr = data.content || data;
51
- console.log(data);
52
51
  arr.forEach((item, i) => {
53
52
  var user = '<div class="user-card">';
54
53
  user += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer"';
@@ -67,7 +66,7 @@ const friendsjs = {
67
66
  }
68
67
 
69
68
  $(function () {
70
- const els = document.getElementsByClassName('friendsjs-wrap');
69
+ const els = document.getElementsByClassName('stellar-friends-api');
71
70
  for (var i = 0; i < els.length; i++) {
72
71
  const el = els[i];
73
72
  const api = el.getAttribute('api');
@@ -0,0 +1,73 @@
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
+ GitHubInfo.requestAPI(cfg.api, function(data) {
48
+ const arr = data.content || data;
49
+ for (let key of Object.keys(data)) {
50
+ $(el).find("[type=text]#" + key).text(data[key]);
51
+ $(el).find("[type=link]#" + key).attr("href", data[key]);
52
+ $(el).find("[type=img]#" + key).attr("src", data[key]);
53
+ }
54
+ }, function() {
55
+ });
56
+ },
57
+ }
58
+
59
+ $(function () {
60
+ const els = document.getElementsByClassName('stellar-ghinfo-api');
61
+ for (var i = 0; i < els.length; i++) {
62
+ const el = els[i];
63
+ const api = el.getAttribute('api');
64
+ if (api == null) {
65
+ continue;
66
+ }
67
+ var cfg = new Object();
68
+ cfg.el = el;
69
+ cfg.api = api;
70
+ cfg.class = el.getAttribute('class');
71
+ GitHubInfo.layout(cfg);
72
+ }
73
+ });