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
@@ -69,7 +69,7 @@ const sitesjs = {
69
69
  }
70
70
 
71
71
  $(function () {
72
- const els = document.getElementsByClassName('sitesjs-wrap');
72
+ const els = document.getElementsByClassName('stellar-sites-api');
73
73
  for (var i = 0; i < els.length; i++) {
74
74
  const el = els[i];
75
75
  const api = el.getAttribute('api');
@@ -0,0 +1,144 @@
1
+ const StellarTimeline = {
2
+ reactions: {
3
+ '+1': '๐Ÿ‘',
4
+ '-1': '๐Ÿ‘Ž',
5
+ 'laugh': '๐Ÿ˜€',
6
+ 'hooray': '๐ŸŽ‰',
7
+ 'confused': '๐Ÿ˜•',
8
+ 'heart': 'โค๏ธ',
9
+ 'rocket': '๐Ÿš€',
10
+ 'eyes': '๐Ÿ‘€'
11
+ },
12
+ requestAPI: (url, callback, timeout) => {
13
+ let retryTimes = 5;
14
+ function request() {
15
+ return new Promise((resolve, reject) => {
16
+ let status = 0; // 0 ็ญ‰ๅพ… 1 ๅฎŒๆˆ 2 ่ถ…ๆ—ถ
17
+ let timer = setTimeout(() => {
18
+ if (status === 0) {
19
+ status = 2;
20
+ timer = null;
21
+ reject('่ฏทๆฑ‚่ถ…ๆ—ถ');
22
+ if (retryTimes == 0) {
23
+ timeout();
24
+ }
25
+ }
26
+ }, 5000);
27
+ fetch(url).then(function(response) {
28
+ if (status !== 2) {
29
+ clearTimeout(timer);
30
+ resolve(response);
31
+ timer = null;
32
+ status = 1;
33
+ }
34
+ if (response.ok) {
35
+ return response.json();
36
+ }
37
+ throw new Error('Network response was not ok.');
38
+ }).then(function(data) {
39
+ retryTimes = 0;
40
+ callback(data);
41
+ }).catch(function(error) {
42
+ if (retryTimes > 0) {
43
+ retryTimes -= 1;
44
+ setTimeout(() => {
45
+ request();
46
+ }, 5000);
47
+ } else {
48
+ timeout();
49
+ }
50
+ });
51
+ });
52
+ }
53
+ request();
54
+ },
55
+ layoutDiv: (cfg) => {
56
+ const el = $(cfg.el)[0];
57
+ $(el).append('<div class="loading-wrap"><svg class="loading" style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2709"><path d="M832 512c0-176-144-320-320-320V128c211.2 0 384 172.8 384 384h-64zM192 512c0 176 144 320 320 320v64C300.8 896 128 723.2 128 512h64z" p-id="2710"></path></svg><p></p></div>');
58
+ StellarTimeline.requestAPI(cfg.api, function(data) {
59
+ $(el).find('.loading-wrap').remove();
60
+ const user = el.getAttribute('user');
61
+ const arr = data.content || data;
62
+ arr.forEach((item, i) => {
63
+ if (item.user && item.user.login && user && user.length > 0) {
64
+ if (!user.includes(item.user.login)) {
65
+ return;
66
+ }
67
+ }
68
+ var cell = '<div class="timenode" index="' + i + '">';
69
+ cell += '<div class="header">';
70
+ if (!user && item.user) {
71
+ cell += '<a class="user-info" href="' + item.user.html_url + '" target="_blank" rel="external nofollow noopener noreferrer">';
72
+ cell += '<img src="' + item.user.avatar_url + '">';
73
+ cell += '<span>' + item.user.login + '</span>';
74
+ cell += '</a>';
75
+ }
76
+ let date = new Date(item.created_at);
77
+ cell += '<p>' + date.toString().replace(/\sGMT([^.]*)/i, "") + '</p>';
78
+ cell += '</div>';
79
+ cell += '<div class="body">';
80
+ cell += '<p class="title">';
81
+ cell += '<a href="' + item.html_url + '" target="_blank" rel="external nofollow noopener noreferrer">';
82
+ cell += item.title || item.name || item.tag_name;
83
+ cell += '</a>';
84
+ cell += '</p>';
85
+
86
+ cell += marked.parse(item.body);
87
+ cell += '<div class="footer">';
88
+ cell += '<div class="flex left">';
89
+ if (item.labels) {
90
+ item.labels.forEach((label, i) => {
91
+ cell += '<div class="item label ' + label.name + '" style="background:#' + label.color + '18;border-color:#' + label.color + '36">';
92
+ cell += '<span>' + label.name + '</span>';
93
+ cell += '</div>';
94
+ });
95
+ } else if (item.zipball_url) {
96
+ cell += '<a class="item download" href="' + item.zipball_url + '" target="_blank" rel="external nofollow noopener noreferrer">';
97
+ cell += '<span>๐Ÿ“ฆ ' + item.tag_name + '.zip</span>';
98
+ cell += '</a>';
99
+ }
100
+ cell += '</div>';
101
+ cell += '<div class="flex right">';
102
+ if (item.reactions && item.reactions.total_count > 0) {
103
+ for (let key of Object.keys(StellarTimeline.reactions)) {
104
+ let num = item.reactions[key];
105
+ if (num > 0) {
106
+ cell += '<div class="item reaction ' + key + '">';
107
+ cell += '<span>' + StellarTimeline.reactions[key] + ' ' + item.reactions[key] + '</span>';
108
+ cell += '</div>';
109
+ }
110
+ }
111
+ }
112
+ if (item.comments != null) {
113
+ cell += '<a class="item comments last" href="' + item.html_url + '#issuecomment-new" target="_blank" rel="external nofollow noopener noreferrer">';
114
+ 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>';
115
+ cell += '</a>';
116
+ }
117
+
118
+ cell += '</div>';
119
+ cell += '</div>';
120
+ cell += '</div>';
121
+ cell += '</div>';
122
+ $(el).append(cell);
123
+ });
124
+ }, function() {
125
+ $(el).find('.loading-wrap svg').remove();
126
+ $(el).find('.loading-wrap p').text('ๅŠ ่ฝฝๅคฑ่ดฅ๏ผŒ่ฏท็จๅŽ้‡่ฏ•ใ€‚');
127
+ });
128
+ },
129
+ }
130
+
131
+ $(function () {
132
+ const els = document.getElementsByClassName('stellar-timeline-api');
133
+ for (var i = 0; i < els.length; i++) {
134
+ const el = els[i];
135
+ const api = el.getAttribute('api');
136
+ if (api == null) {
137
+ continue;
138
+ }
139
+ var obj = new Object();
140
+ obj.el = el;
141
+ obj.api = api;
142
+ StellarTimeline.layoutDiv(obj);
143
+ }
144
+ });
@@ -1,72 +0,0 @@
1
- <%
2
- function layoutDiv() {
3
- var el = '';
4
- var repo;
5
- var branch = 'main';
6
- if (page.layout === 'wiki' && page.wiki) {
7
- let proj = theme.wiki.projects[page.wiki];
8
- if (proj && proj.repo) {
9
- repo = proj.repo;
10
- if (proj.branch != undefined) {
11
- branch = proj.branch;
12
- }
13
- }
14
- } else {
15
- // ๅ…ถๅฎƒ็š„ๅฆ‚ๆžœๆœ‰่ฎพ็ฝฎ repo ไนŸๅฏไปฅ
16
- repo = page.repo;
17
- }
18
- if (repo == undefined) {
19
- return el;
20
- }
21
- // ๅธƒๅฑ€
22
- el += '<div class="widget-wrap" id="repo-info">';
23
- // header
24
- el += '<div class="widget-header cap dis-select">';
25
- el += '<span class="name">' + __("meta.repo_info") + '</span>';
26
- el += '</div>';
27
- // body
28
- el += '<div class="widget-body fs14">';
29
- el += '<div class="items">';
30
- var items = [];
31
- // GitHub
32
- items.push({
33
- icon: '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1rem" height="1rem" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>',
34
- text: 'GitHub',
35
- href: 'https://github.com/' + repo
36
- });
37
- // Releases
38
- items.push({
39
- icon: '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1rem" height="1rem" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path fill-rule="evenodd" d="M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"></path></svg>',
40
- text: 'Releases',
41
- href: 'https://github.com/' + repo + '/releases'
42
- });
43
- // Download
44
- items.push({
45
- icon: '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1rem" height="1rem" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path fill-rule="evenodd" d="M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"></path></svg>',
46
- text: 'Download',
47
- href: 'https://github.com/' + repo + '/archive/refs/heads/' + branch + '.zip'
48
- });
49
- // Issues
50
- items.push({
51
- icon: '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1rem" height="1rem" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path d="M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path><path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z"></path></svg>',
52
- text: 'Issues',
53
- href: 'https://github.com/' + repo + '/issues'
54
- });
55
- items.forEach((item, i) => {
56
- el += '<div class="line"></div>';
57
- el += '<a class="item-link"';
58
- el += ' title="' + item.href + '"';
59
- el += ' href="' + url_for(item.href) + '"';
60
- el += ' target="_blank" rel="external nofollow noopener noreferrer"';
61
- el += '>';
62
- el += item.icon;
63
- el += '<span>' + item.text + '</span>';
64
- el += '</a>';
65
- });
66
- el += '</div>';
67
- el += '</div>';
68
- el += '</div>';
69
- return el;
70
- }
71
- %>
72
- <%- layoutDiv() %>
@@ -1,28 +0,0 @@
1
- .widget-wrap#repo-info
2
- .widget-body
3
- >.items
4
- margin: 4px 0
5
- border: 1px solid var(--block-border)
6
- border-radius: $border-block
7
- background: var(--block)
8
- overflow: hidden
9
- .line
10
- margin: 0
11
- height: 1px
12
- background: var(--block-border)
13
- &+.line,&:first-child,&:last-child
14
- display: none
15
- a.item-link
16
- color: var(--text-p2)
17
- font-weight: 500
18
- display: flex
19
- align-items: center
20
- padding: 0.5rem .5rem
21
- font-size: $fs-13
22
- justify-content: space-between
23
- flex-direction: row-reverse
24
- svg
25
- width: 1em
26
- height: 1em
27
- a:hover
28
- background: var(--block-hover)