hexo-theme-lnote 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +122 -122
- package/_config.yml +19 -19
- package/config/links.yml +63 -63
- package/config/svg.yml +33 -33
- package/index.d.ts +4 -0
- package/languages/de.yml +69 -69
- package/languages/en.yml +69 -69
- package/languages/eo.yml +69 -69
- package/languages/es.yml +69 -69
- package/languages/ja.yml +69 -69
- package/languages/ru.yml +69 -69
- package/languages/zh-CN.yml +69 -69
- package/languages/zh-HK.yml +69 -69
- package/languages/zh-TW.yml +69 -69
- package/layout/404.ejs +8 -8
- package/layout/_partials/archive-list.ejs +17 -17
- package/layout/_partials/category-chains.ejs +19 -19
- package/layout/_partials/category-list.ejs +62 -62
- package/layout/_partials/comments/changyan.ejs +11 -11
- package/layout/_partials/comments/cusdis.ejs +25 -25
- package/layout/_partials/comments/discuss.ejs +17 -17
- package/layout/_partials/comments/disqus.ejs +32 -32
- package/layout/_partials/comments/giscus.ejs +36 -36
- package/layout/_partials/comments/gitalk.ejs +19 -19
- package/layout/_partials/comments/livere.ejs +10 -10
- package/layout/_partials/comments/remark42.ejs +29 -29
- package/layout/_partials/comments/twikoo.ejs +25 -25
- package/layout/_partials/comments/utterances.ejs +27 -27
- package/layout/_partials/comments/valine.ejs +23 -23
- package/layout/_partials/comments/waline.ejs +24 -24
- package/layout/_partials/comments.ejs +8 -8
- package/layout/_partials/css.ejs +9 -9
- package/layout/_partials/footer/beian.ejs +33 -33
- package/layout/_partials/footer/statistics.ejs +39 -39
- package/layout/_partials/footer.ejs +7 -7
- package/layout/_partials/head.ejs +46 -46
- package/layout/_partials/header/banner.ejs +24 -24
- package/layout/_partials/header/navigation.ejs +56 -56
- package/layout/_partials/header.ejs +4 -4
- package/layout/_partials/markdown-plugins.ejs +24 -24
- package/layout/_partials/paginator.ejs +14 -14
- package/layout/_partials/plugins/CSR.ejs +4 -0
- package/layout/_partials/plugins/analytics.ejs +75 -75
- package/layout/_partials/plugins/anchorjs.ejs +39 -39
- package/layout/_partials/plugins/code-widget.ejs +7 -7
- package/layout/_partials/plugins/encrypt.ejs +18 -18
- package/layout/_partials/plugins/fancybox.ejs +11 -11
- package/layout/_partials/plugins/highlight.ejs +13 -13
- package/layout/_partials/plugins/math.ejs +51 -51
- package/layout/_partials/plugins/mermaid.ejs +4 -4
- package/layout/_partials/plugins/nprogress.ejs +7 -7
- package/layout/_partials/plugins/typed.ejs +20 -20
- package/layout/_partials/post/category-bar.ejs +18 -18
- package/layout/_partials/post/copyright.ejs +50 -50
- package/layout/_partials/post/css.ejs +3 -3
- package/layout/_partials/post/meta-bottom.ejs +16 -16
- package/layout/_partials/post/meta-top.ejs +27 -27
- package/layout/_partials/post/scripts.ejs +8 -7
- package/layout/_partials/post/sidebar-left.ejs +1 -1
- package/layout/_partials/post/sidebar-right.ejs +2 -2
- package/layout/_partials/post/toc.ejs +6 -6
- package/layout/_partials/scripts.ejs +10 -10
- package/layout/_partials/search.ejs +19 -19
- package/layout/about.ejs +22 -22
- package/layout/archive.ejs +10 -10
- package/layout/categories.ejs +20 -20
- package/layout/category.ejs +12 -12
- package/layout/index.ejs +61 -61
- package/layout/layout.ejs +60 -60
- package/layout/links.ejs +31 -31
- package/layout/page.ejs +15 -15
- package/layout/post.ejs +77 -77
- package/layout/tag.ejs +12 -12
- package/layout/tags.ejs +26 -26
- package/package.json +73 -70
- package/source/css/_functions/base.styl +8 -8
- package/source/css/_mixins/base.styl +23 -23
- package/source/css/_pages/_about/about.styl +32 -32
- package/source/css/_pages/_archive/archive.styl +32 -32
- package/source/css/_pages/_base/_widget/anchorjs.styl +8 -8
- package/source/css/_pages/_base/_widget/banner.styl +29 -29
- package/source/css/_pages/_base/_widget/board.styl +11 -11
- package/source/css/_pages/_base/_widget/code-widget.styl +37 -36
- package/source/css/_pages/_base/_widget/copyright.styl +91 -90
- package/source/css/_pages/_base/_widget/footer.styl +65 -65
- package/source/css/_pages/_base/_widget/footnote.styl +26 -25
- package/source/css/_pages/_base/_widget/header.styl +173 -173
- package/source/css/_pages/_base/_widget/modal.styl +100 -100
- package/source/css/_pages/_base/_widget/navlink.styl +15 -15
- package/source/css/_pages/_base/_widget/ngrogress.styl +12 -12
- package/source/css/_pages/_base/_widget/noscript.styl +13 -12
- package/source/css/_pages/_base/_widget/pagination.styl +23 -23
- package/source/css/_pages/_base/_widget/qrcode.styl +17 -17
- package/source/css/_pages/_base/_widget/scroll-btn.styl +48 -48
- package/source/css/_pages/_base/_widget/text.styl +20 -19
- package/source/css/_pages/_base/_widget/toc.styl +75 -75
- package/source/css/_pages/_base/base.styl +68 -68
- package/source/css/_pages/_base/color-schema.styl +75 -75
- package/source/css/_pages/_base/inline.styl +51 -51
- package/source/css/_pages/_base/keyframes.styl +31 -31
- package/source/css/_pages/_base/print.styl +39 -38
- package/source/css/_pages/_category/category-bar.styl +58 -58
- package/source/css/_pages/_category/category-chain.styl +6 -6
- package/source/css/_pages/_category/category-list.styl +62 -62
- package/source/css/_pages/_index/index.styl +75 -75
- package/source/css/_pages/_links/links.styl +80 -79
- package/source/css/_pages/_post/comment.styl +28 -27
- package/source/css/_pages/_post/highlight.styl +75 -75
- package/source/css/_pages/_post/markdown.styl +96 -96
- package/source/css/_pages/_post/post-page.styl +179 -179
- package/source/css/_pages/_post/post-plugin.styl +10 -0
- package/source/css/_pages/_post/post-tag.styl +43 -29
- package/source/css/_pages/_tag/tags.styl +9 -9
- package/source/css/_pages/pages.styl +8 -8
- package/source/css/_variables/base.styl +72 -72
- package/source/css/gitalk.css +546 -546
- package/source/css/main.styl +19 -19
- package/source/js/color-schema.js +279 -279
- package/source/js/events.js +72 -72
- package/source/js/img-lazyload.js +10 -10
- package/source/js/local-search.js +70 -70
- package/source/js/post/copying-code.js +34 -34
- package/source/js/post/enable.js +6 -6
- package/source/js/post/img-swipe-bf.js +47 -47
- package/source/js/post/img-swipe.js +81 -35
- package/source/js/post/mermaiding.js +9 -9
- package/source/js/post/play-imgs.js +58 -58
- package/source/js/post/toc.js +24 -24
- package/source/js/post/view-imgs.js +27 -27
- package/source/js/utils.js +245 -245
- package/source/xml/local-search.xml +45 -45
- package/templates/footer.ejs +12 -12
- package/templates/noun.vue +14 -17
- package/templates/utils/uri.ts +12 -0
- package/scripts/index.js +0 -1
- package/source/css/_pages/_tag/tag.styl +0 -9
package/source/js/utils.js
CHANGED
@@ -1,245 +1,245 @@
|
|
1
|
-
/* global LNote, CONFIG */
|
2
|
-
|
3
|
-
// window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
|
4
|
-
|
5
|
-
LNote.utils = {
|
6
|
-
|
7
|
-
listenScroll: function(callback) {
|
8
|
-
var dbc = new Debouncer(callback);
|
9
|
-
window.addEventListener('scroll', dbc, false);
|
10
|
-
dbc.handleEvent();
|
11
|
-
return dbc;
|
12
|
-
},
|
13
|
-
|
14
|
-
unlistenScroll: function(callback) {
|
15
|
-
window.removeEventListener('scroll', callback);
|
16
|
-
},
|
17
|
-
|
18
|
-
listenDOMLoaded(callback) {
|
19
|
-
if (document.readyState !== 'loading') {
|
20
|
-
callback();
|
21
|
-
} else {
|
22
|
-
document.addEventListener('DOMContentLoaded', function () {
|
23
|
-
callback();
|
24
|
-
});
|
25
|
-
}
|
26
|
-
},
|
27
|
-
|
28
|
-
scrollToElement: function(target, offset) {
|
29
|
-
var of = jQuery(target).offset();
|
30
|
-
if (of) {
|
31
|
-
jQuery('html,body').animate({
|
32
|
-
scrollTop: of.top + (offset || 0),
|
33
|
-
easing : 'swing'
|
34
|
-
});
|
35
|
-
}
|
36
|
-
},
|
37
|
-
|
38
|
-
elementVisible: function(element, offsetFactor) {
|
39
|
-
offsetFactor = offsetFactor && offsetFactor >= 0 ? offsetFactor : 0;
|
40
|
-
var rect = element.getBoundingClientRect();
|
41
|
-
const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
42
|
-
return (
|
43
|
-
(rect.top >= 0 && rect.top <= viewportHeight * (1 + offsetFactor) + rect.height / 2) ||
|
44
|
-
(rect.bottom >= 0 && rect.bottom <= viewportHeight * (1 + offsetFactor) + rect.height / 2)
|
45
|
-
);
|
46
|
-
},
|
47
|
-
|
48
|
-
waitElementVisible: function(selectorOrElement, callback, offsetFactor) {
|
49
|
-
var runningOnBrowser = typeof window !== 'undefined';
|
50
|
-
var isBot = (runningOnBrowser && !('onscroll' in window))
|
51
|
-
|| (typeof navigator !== 'undefined' && /(gle|ing|ro|msn)bot|crawl|spider|yand|duckgo/i.test(navigator.userAgent));
|
52
|
-
if (!runningOnBrowser || isBot) {
|
53
|
-
return;
|
54
|
-
}
|
55
|
-
|
56
|
-
offsetFactor = offsetFactor && offsetFactor >= 0 ? offsetFactor : 0;
|
57
|
-
|
58
|
-
function waitInViewport(element) {
|
59
|
-
LNote.utils.listenDOMLoaded(function() {
|
60
|
-
if (LNote.utils.elementVisible(element, offsetFactor)) {
|
61
|
-
callback();
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
if ('IntersectionObserver' in window) {
|
65
|
-
var io = new IntersectionObserver(function(entries, ob) {
|
66
|
-
if (entries[0].isIntersecting) {
|
67
|
-
callback();
|
68
|
-
ob.disconnect();
|
69
|
-
}
|
70
|
-
}, {
|
71
|
-
threshold : [0],
|
72
|
-
rootMargin: (window.innerHeight || document.documentElement.clientHeight) * offsetFactor + 'px'
|
73
|
-
});
|
74
|
-
io.observe(element);
|
75
|
-
} else {
|
76
|
-
var wrapper = LNote.utils.listenScroll(function() {
|
77
|
-
if (LNote.utils.elementVisible(element, offsetFactor)) {
|
78
|
-
LNote.utils.unlistenScroll(wrapper);
|
79
|
-
callback();
|
80
|
-
}
|
81
|
-
});
|
82
|
-
}
|
83
|
-
});
|
84
|
-
}
|
85
|
-
|
86
|
-
if (typeof selectorOrElement === 'string') {
|
87
|
-
this.waitElementLoaded(selectorOrElement, function(element) {
|
88
|
-
waitInViewport(element);
|
89
|
-
});
|
90
|
-
} else {
|
91
|
-
waitInViewport(selectorOrElement);
|
92
|
-
}
|
93
|
-
},
|
94
|
-
|
95
|
-
waitElementLoaded: function(selector, callback) {
|
96
|
-
var runningOnBrowser = typeof window !== 'undefined';
|
97
|
-
var isBot = (runningOnBrowser && !('onscroll' in window))
|
98
|
-
|| (typeof navigator !== 'undefined' && /(gle|ing|ro|msn)bot|crawl|spider|yand|duckgo/i.test(navigator.userAgent));
|
99
|
-
if (!runningOnBrowser || isBot) {
|
100
|
-
return;
|
101
|
-
}
|
102
|
-
|
103
|
-
if ('MutationObserver' in window) {
|
104
|
-
var mo = new MutationObserver(function(records, ob) {
|
105
|
-
var ele = document.querySelector(selector);
|
106
|
-
if (ele) {
|
107
|
-
callback(ele);
|
108
|
-
ob.disconnect();
|
109
|
-
}
|
110
|
-
});
|
111
|
-
mo.observe(document, { childList: true, subtree: true });
|
112
|
-
} else {
|
113
|
-
LNote.utils.listenDOMLoaded(function() {
|
114
|
-
var waitLoop = function() {
|
115
|
-
var ele = document.querySelector(selector);
|
116
|
-
if (ele) {
|
117
|
-
callback(ele);
|
118
|
-
} else {
|
119
|
-
setTimeout(waitLoop, 100);
|
120
|
-
}
|
121
|
-
};
|
122
|
-
waitLoop();
|
123
|
-
});
|
124
|
-
}
|
125
|
-
},
|
126
|
-
|
127
|
-
createScript: function(url, onload) {
|
128
|
-
var s = document.createElement('script');
|
129
|
-
s.setAttribute('src', url);
|
130
|
-
s.setAttribute('type', 'text/javascript');
|
131
|
-
s.setAttribute('charset', 'UTF-8');
|
132
|
-
s.async = false;
|
133
|
-
if (typeof onload === 'function') {
|
134
|
-
if (window.attachEvent) {
|
135
|
-
s.onreadystatechange = function() {
|
136
|
-
var e = s.readyState;
|
137
|
-
if (e === 'loaded' || e === 'complete') {
|
138
|
-
s.onreadystatechange = null;
|
139
|
-
onload();
|
140
|
-
}
|
141
|
-
};
|
142
|
-
} else {
|
143
|
-
s.onload = onload;
|
144
|
-
}
|
145
|
-
}
|
146
|
-
var ss = document.getElementsByTagName('script');
|
147
|
-
var e = ss.length > 0 ? ss[ss.length - 1] : document.head || document.documentElement;
|
148
|
-
e.parentNode.insertBefore(s, e.nextSibling);
|
149
|
-
},
|
150
|
-
|
151
|
-
createCssLink: function(url) {
|
152
|
-
var l = document.createElement('link');
|
153
|
-
l.setAttribute('rel', 'stylesheet');
|
154
|
-
l.setAttribute('type', 'text/css');
|
155
|
-
l.setAttribute('href', url);
|
156
|
-
var e = document.getElementsByTagName('link')[0]
|
157
|
-
|| document.getElementsByTagName('head')[0]
|
158
|
-
|| document.head || document.documentElement;
|
159
|
-
e.parentNode.insertBefore(l, e);
|
160
|
-
},
|
161
|
-
|
162
|
-
loadComments: function(selector, loadFunc) {
|
163
|
-
var ele = document.querySelector('#comments[lazyload]');
|
164
|
-
if (ele) {
|
165
|
-
var callback = function() {
|
166
|
-
loadFunc();
|
167
|
-
ele.removeAttribute('lazyload');
|
168
|
-
};
|
169
|
-
LNote.utils.waitElementVisible(selector, callback, 2);
|
170
|
-
} else {
|
171
|
-
loadFunc();
|
172
|
-
}
|
173
|
-
},
|
174
|
-
|
175
|
-
getBackgroundLightness(selectorOrElement) {
|
176
|
-
var ele = selectorOrElement;
|
177
|
-
if (typeof selectorOrElement === 'string') {
|
178
|
-
ele = document.querySelector(selectorOrElement);
|
179
|
-
}
|
180
|
-
var view = ele.ownerDocument.defaultView;
|
181
|
-
if (!view) {
|
182
|
-
view = window;
|
183
|
-
}
|
184
|
-
var rgbArr = view.getComputedStyle(ele).backgroundColor.replace(/rgba*\(/, '').replace(')', '').split(/,\s*/);
|
185
|
-
if (rgbArr.length < 3) {
|
186
|
-
return 0;
|
187
|
-
}
|
188
|
-
var colorCast = (0.213 * rgbArr[0]) + (0.715 * rgbArr[1]) + (0.072 * rgbArr[2]);
|
189
|
-
return colorCast === 0 || colorCast > 255 / 2 ? 1 : -1;
|
190
|
-
},
|
191
|
-
|
192
|
-
retry(handler, interval, times) {
|
193
|
-
if (times <= 0) {
|
194
|
-
return;
|
195
|
-
}
|
196
|
-
var next = function() {
|
197
|
-
if (--times >= 0 && !handler()) {
|
198
|
-
setTimeout(next, interval);
|
199
|
-
}
|
200
|
-
};
|
201
|
-
setTimeout(next, interval);
|
202
|
-
}
|
203
|
-
|
204
|
-
};
|
205
|
-
|
206
|
-
/**
|
207
|
-
* Handles debouncing of events via requestAnimationFrame
|
208
|
-
* @see http://www.html5rocks.com/en/tutorials/speed/animations/
|
209
|
-
* @param {Function} callback The callback to handle whichever event
|
210
|
-
*/
|
211
|
-
function Debouncer(callback) {
|
212
|
-
this.callback = callback;
|
213
|
-
this.ticking = false;
|
214
|
-
}
|
215
|
-
|
216
|
-
Debouncer.prototype = {
|
217
|
-
constructor: Debouncer,
|
218
|
-
|
219
|
-
/**
|
220
|
-
* dispatches the event to the supplied callback
|
221
|
-
* @private
|
222
|
-
*/
|
223
|
-
update: function() {
|
224
|
-
this.callback && this.callback();
|
225
|
-
this.ticking = false;
|
226
|
-
},
|
227
|
-
|
228
|
-
/**
|
229
|
-
* ensures events don't get stacked
|
230
|
-
* @private
|
231
|
-
*/
|
232
|
-
requestTick: function() {
|
233
|
-
if (!this.ticking) {
|
234
|
-
requestAnimationFrame(this.rafCallback || (this.rafCallback = this.update.bind(this)));
|
235
|
-
this.ticking = true;
|
236
|
-
}
|
237
|
-
},
|
238
|
-
|
239
|
-
/**
|
240
|
-
* Attach this as the event listeners
|
241
|
-
*/
|
242
|
-
handleEvent: function() {
|
243
|
-
this.requestTick();
|
244
|
-
}
|
245
|
-
};
|
1
|
+
/* global LNote, CONFIG */
|
2
|
+
|
3
|
+
// window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
|
4
|
+
|
5
|
+
LNote.utils = {
|
6
|
+
|
7
|
+
listenScroll: function(callback) {
|
8
|
+
var dbc = new Debouncer(callback);
|
9
|
+
window.addEventListener('scroll', dbc, false);
|
10
|
+
dbc.handleEvent();
|
11
|
+
return dbc;
|
12
|
+
},
|
13
|
+
|
14
|
+
unlistenScroll: function(callback) {
|
15
|
+
window.removeEventListener('scroll', callback);
|
16
|
+
},
|
17
|
+
|
18
|
+
listenDOMLoaded(callback) {
|
19
|
+
if (document.readyState !== 'loading') {
|
20
|
+
callback();
|
21
|
+
} else {
|
22
|
+
document.addEventListener('DOMContentLoaded', function () {
|
23
|
+
callback();
|
24
|
+
});
|
25
|
+
}
|
26
|
+
},
|
27
|
+
|
28
|
+
scrollToElement: function(target, offset) {
|
29
|
+
var of = jQuery(target).offset();
|
30
|
+
if (of) {
|
31
|
+
jQuery('html,body').animate({
|
32
|
+
scrollTop: of.top + (offset || 0),
|
33
|
+
easing : 'swing'
|
34
|
+
});
|
35
|
+
}
|
36
|
+
},
|
37
|
+
|
38
|
+
elementVisible: function(element, offsetFactor) {
|
39
|
+
offsetFactor = offsetFactor && offsetFactor >= 0 ? offsetFactor : 0;
|
40
|
+
var rect = element.getBoundingClientRect();
|
41
|
+
const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
42
|
+
return (
|
43
|
+
(rect.top >= 0 && rect.top <= viewportHeight * (1 + offsetFactor) + rect.height / 2) ||
|
44
|
+
(rect.bottom >= 0 && rect.bottom <= viewportHeight * (1 + offsetFactor) + rect.height / 2)
|
45
|
+
);
|
46
|
+
},
|
47
|
+
|
48
|
+
waitElementVisible: function(selectorOrElement, callback, offsetFactor) {
|
49
|
+
var runningOnBrowser = typeof window !== 'undefined';
|
50
|
+
var isBot = (runningOnBrowser && !('onscroll' in window))
|
51
|
+
|| (typeof navigator !== 'undefined' && /(gle|ing|ro|msn)bot|crawl|spider|yand|duckgo/i.test(navigator.userAgent));
|
52
|
+
if (!runningOnBrowser || isBot) {
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
|
56
|
+
offsetFactor = offsetFactor && offsetFactor >= 0 ? offsetFactor : 0;
|
57
|
+
|
58
|
+
function waitInViewport(element) {
|
59
|
+
LNote.utils.listenDOMLoaded(function() {
|
60
|
+
if (LNote.utils.elementVisible(element, offsetFactor)) {
|
61
|
+
callback();
|
62
|
+
return;
|
63
|
+
}
|
64
|
+
if ('IntersectionObserver' in window) {
|
65
|
+
var io = new IntersectionObserver(function(entries, ob) {
|
66
|
+
if (entries[0].isIntersecting) {
|
67
|
+
callback();
|
68
|
+
ob.disconnect();
|
69
|
+
}
|
70
|
+
}, {
|
71
|
+
threshold : [0],
|
72
|
+
rootMargin: (window.innerHeight || document.documentElement.clientHeight) * offsetFactor + 'px'
|
73
|
+
});
|
74
|
+
io.observe(element);
|
75
|
+
} else {
|
76
|
+
var wrapper = LNote.utils.listenScroll(function() {
|
77
|
+
if (LNote.utils.elementVisible(element, offsetFactor)) {
|
78
|
+
LNote.utils.unlistenScroll(wrapper);
|
79
|
+
callback();
|
80
|
+
}
|
81
|
+
});
|
82
|
+
}
|
83
|
+
});
|
84
|
+
}
|
85
|
+
|
86
|
+
if (typeof selectorOrElement === 'string') {
|
87
|
+
this.waitElementLoaded(selectorOrElement, function(element) {
|
88
|
+
waitInViewport(element);
|
89
|
+
});
|
90
|
+
} else {
|
91
|
+
waitInViewport(selectorOrElement);
|
92
|
+
}
|
93
|
+
},
|
94
|
+
|
95
|
+
waitElementLoaded: function(selector, callback) {
|
96
|
+
var runningOnBrowser = typeof window !== 'undefined';
|
97
|
+
var isBot = (runningOnBrowser && !('onscroll' in window))
|
98
|
+
|| (typeof navigator !== 'undefined' && /(gle|ing|ro|msn)bot|crawl|spider|yand|duckgo/i.test(navigator.userAgent));
|
99
|
+
if (!runningOnBrowser || isBot) {
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
|
103
|
+
if ('MutationObserver' in window) {
|
104
|
+
var mo = new MutationObserver(function(records, ob) {
|
105
|
+
var ele = document.querySelector(selector);
|
106
|
+
if (ele) {
|
107
|
+
callback(ele);
|
108
|
+
ob.disconnect();
|
109
|
+
}
|
110
|
+
});
|
111
|
+
mo.observe(document, { childList: true, subtree: true });
|
112
|
+
} else {
|
113
|
+
LNote.utils.listenDOMLoaded(function() {
|
114
|
+
var waitLoop = function() {
|
115
|
+
var ele = document.querySelector(selector);
|
116
|
+
if (ele) {
|
117
|
+
callback(ele);
|
118
|
+
} else {
|
119
|
+
setTimeout(waitLoop, 100);
|
120
|
+
}
|
121
|
+
};
|
122
|
+
waitLoop();
|
123
|
+
});
|
124
|
+
}
|
125
|
+
},
|
126
|
+
|
127
|
+
createScript: function(url, onload) {
|
128
|
+
var s = document.createElement('script');
|
129
|
+
s.setAttribute('src', url);
|
130
|
+
s.setAttribute('type', 'text/javascript');
|
131
|
+
s.setAttribute('charset', 'UTF-8');
|
132
|
+
s.async = false;
|
133
|
+
if (typeof onload === 'function') {
|
134
|
+
if (window.attachEvent) {
|
135
|
+
s.onreadystatechange = function() {
|
136
|
+
var e = s.readyState;
|
137
|
+
if (e === 'loaded' || e === 'complete') {
|
138
|
+
s.onreadystatechange = null;
|
139
|
+
onload();
|
140
|
+
}
|
141
|
+
};
|
142
|
+
} else {
|
143
|
+
s.onload = onload;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
var ss = document.getElementsByTagName('script');
|
147
|
+
var e = ss.length > 0 ? ss[ss.length - 1] : document.head || document.documentElement;
|
148
|
+
e.parentNode.insertBefore(s, e.nextSibling);
|
149
|
+
},
|
150
|
+
|
151
|
+
createCssLink: function(url) {
|
152
|
+
var l = document.createElement('link');
|
153
|
+
l.setAttribute('rel', 'stylesheet');
|
154
|
+
l.setAttribute('type', 'text/css');
|
155
|
+
l.setAttribute('href', url);
|
156
|
+
var e = document.getElementsByTagName('link')[0]
|
157
|
+
|| document.getElementsByTagName('head')[0]
|
158
|
+
|| document.head || document.documentElement;
|
159
|
+
e.parentNode.insertBefore(l, e);
|
160
|
+
},
|
161
|
+
|
162
|
+
loadComments: function(selector, loadFunc) {
|
163
|
+
var ele = document.querySelector('#comments[lazyload]');
|
164
|
+
if (ele) {
|
165
|
+
var callback = function() {
|
166
|
+
loadFunc();
|
167
|
+
ele.removeAttribute('lazyload');
|
168
|
+
};
|
169
|
+
LNote.utils.waitElementVisible(selector, callback, 2);
|
170
|
+
} else {
|
171
|
+
loadFunc();
|
172
|
+
}
|
173
|
+
},
|
174
|
+
|
175
|
+
getBackgroundLightness(selectorOrElement) {
|
176
|
+
var ele = selectorOrElement;
|
177
|
+
if (typeof selectorOrElement === 'string') {
|
178
|
+
ele = document.querySelector(selectorOrElement);
|
179
|
+
}
|
180
|
+
var view = ele.ownerDocument.defaultView;
|
181
|
+
if (!view) {
|
182
|
+
view = window;
|
183
|
+
}
|
184
|
+
var rgbArr = view.getComputedStyle(ele).backgroundColor.replace(/rgba*\(/, '').replace(')', '').split(/,\s*/);
|
185
|
+
if (rgbArr.length < 3) {
|
186
|
+
return 0;
|
187
|
+
}
|
188
|
+
var colorCast = (0.213 * rgbArr[0]) + (0.715 * rgbArr[1]) + (0.072 * rgbArr[2]);
|
189
|
+
return colorCast === 0 || colorCast > 255 / 2 ? 1 : -1;
|
190
|
+
},
|
191
|
+
|
192
|
+
retry(handler, interval, times) {
|
193
|
+
if (times <= 0) {
|
194
|
+
return;
|
195
|
+
}
|
196
|
+
var next = function() {
|
197
|
+
if (--times >= 0 && !handler()) {
|
198
|
+
setTimeout(next, interval);
|
199
|
+
}
|
200
|
+
};
|
201
|
+
setTimeout(next, interval);
|
202
|
+
}
|
203
|
+
|
204
|
+
};
|
205
|
+
|
206
|
+
/**
|
207
|
+
* Handles debouncing of events via requestAnimationFrame
|
208
|
+
* @see http://www.html5rocks.com/en/tutorials/speed/animations/
|
209
|
+
* @param {Function} callback The callback to handle whichever event
|
210
|
+
*/
|
211
|
+
function Debouncer(callback) {
|
212
|
+
this.callback = callback;
|
213
|
+
this.ticking = false;
|
214
|
+
}
|
215
|
+
|
216
|
+
Debouncer.prototype = {
|
217
|
+
constructor: Debouncer,
|
218
|
+
|
219
|
+
/**
|
220
|
+
* dispatches the event to the supplied callback
|
221
|
+
* @private
|
222
|
+
*/
|
223
|
+
update: function() {
|
224
|
+
this.callback && this.callback();
|
225
|
+
this.ticking = false;
|
226
|
+
},
|
227
|
+
|
228
|
+
/**
|
229
|
+
* ensures events don't get stacked
|
230
|
+
* @private
|
231
|
+
*/
|
232
|
+
requestTick: function() {
|
233
|
+
if (!this.ticking) {
|
234
|
+
requestAnimationFrame(this.rafCallback || (this.rafCallback = this.update.bind(this)));
|
235
|
+
this.ticking = true;
|
236
|
+
}
|
237
|
+
},
|
238
|
+
|
239
|
+
/**
|
240
|
+
* Attach this as the event listeners
|
241
|
+
*/
|
242
|
+
handleEvent: function() {
|
243
|
+
this.requestTick();
|
244
|
+
}
|
245
|
+
};
|
@@ -1,45 +1,45 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<search>
|
3
|
-
{% if posts %}
|
4
|
-
{% for post in posts.toArray() %}
|
5
|
-
{% if post.indexing == undefined or post.indexing %}
|
6
|
-
<entry>
|
7
|
-
<title>{{ post.title }}</title>
|
8
|
-
<link href="{{ [url, post.path] | urlJoin | uriencode }}"/>
|
9
|
-
<url>{{ [url, post.path] | urlJoin | uriencode }}</url>
|
10
|
-
{% if content %}
|
11
|
-
<content type="html"><![CDATA[{{ post.content | noControlChars | safe }}]]></content>
|
12
|
-
{% endif %}
|
13
|
-
{% if post.categories and post.categories.length>0 %}
|
14
|
-
<categories>
|
15
|
-
{% for cate in post.categories.toArray() %}
|
16
|
-
<category>{{ cate.name }}</category>
|
17
|
-
{% endfor %}
|
18
|
-
</categories>
|
19
|
-
{% endif %}
|
20
|
-
{% if post.tags and post.tags.length>0 %}
|
21
|
-
<tags>
|
22
|
-
{% for tag in post.tags.toArray() %}
|
23
|
-
<tag>{{ tag.name }}</tag>
|
24
|
-
{% endfor %}
|
25
|
-
</tags>
|
26
|
-
{% endif %}
|
27
|
-
</entry>
|
28
|
-
{% endif %}
|
29
|
-
{% endfor %}
|
30
|
-
{% endif %}
|
31
|
-
{% if pages %}
|
32
|
-
{% for page in pages.toArray() %}
|
33
|
-
{% if post.indexing == undefined or post.indexing %}
|
34
|
-
<entry>
|
35
|
-
<title>{{ page.title }}</title>
|
36
|
-
<link href="{{ [url, post.path] | urlJoin | uriencode }}"/>
|
37
|
-
<url>{{ [url, post.path] | urlJoin | uriencode }}</url>
|
38
|
-
{% if content %}
|
39
|
-
<content type="html"><![CDATA[{{ page.content | noControlChars | safe }}]]></content>
|
40
|
-
{% endif %}
|
41
|
-
</entry>
|
42
|
-
{% endif %}
|
43
|
-
{% endfor %}
|
44
|
-
{% endif %}
|
45
|
-
</search>
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<search>
|
3
|
+
{% if posts %}
|
4
|
+
{% for post in posts.toArray() %}
|
5
|
+
{% if post.indexing == undefined or post.indexing %}
|
6
|
+
<entry>
|
7
|
+
<title>{{ post.title }}</title>
|
8
|
+
<link href="{{ [url, post.path] | urlJoin | uriencode }}"/>
|
9
|
+
<url>{{ [url, post.path] | urlJoin | uriencode }}</url>
|
10
|
+
{% if content %}
|
11
|
+
<content type="html"><![CDATA[{{ post.content | noControlChars | safe }}]]></content>
|
12
|
+
{% endif %}
|
13
|
+
{% if post.categories and post.categories.length>0 %}
|
14
|
+
<categories>
|
15
|
+
{% for cate in post.categories.toArray() %}
|
16
|
+
<category>{{ cate.name }}</category>
|
17
|
+
{% endfor %}
|
18
|
+
</categories>
|
19
|
+
{% endif %}
|
20
|
+
{% if post.tags and post.tags.length>0 %}
|
21
|
+
<tags>
|
22
|
+
{% for tag in post.tags.toArray() %}
|
23
|
+
<tag>{{ tag.name }}</tag>
|
24
|
+
{% endfor %}
|
25
|
+
</tags>
|
26
|
+
{% endif %}
|
27
|
+
</entry>
|
28
|
+
{% endif %}
|
29
|
+
{% endfor %}
|
30
|
+
{% endif %}
|
31
|
+
{% if pages %}
|
32
|
+
{% for page in pages.toArray() %}
|
33
|
+
{% if post.indexing == undefined or post.indexing %}
|
34
|
+
<entry>
|
35
|
+
<title>{{ page.title }}</title>
|
36
|
+
<link href="{{ [url, post.path] | urlJoin | uriencode }}"/>
|
37
|
+
<url>{{ [url, post.path] | urlJoin | uriencode }}</url>
|
38
|
+
{% if content %}
|
39
|
+
<content type="html"><![CDATA[{{ page.content | noControlChars | safe }}]]></content>
|
40
|
+
{% endif %}
|
41
|
+
</entry>
|
42
|
+
{% endif %}
|
43
|
+
{% endfor %}
|
44
|
+
{% endif %}
|
45
|
+
</search>
|
package/templates/footer.ejs
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
<footer>
|
2
|
-
<div class="footer-inner">
|
3
|
-
<div class="footer-content">
|
4
|
-
<a href="<%= href %>" rel="nofollow noopener">
|
5
|
-
<%= name %>
|
6
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-heart-fill" viewBox="0 0 16 16">
|
7
|
-
<path fill-rule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"/>
|
8
|
-
</svg>
|
9
|
-
<%= version %>
|
10
|
-
</a>
|
11
|
-
</div>
|
12
|
-
</div>
|
1
|
+
<footer>
|
2
|
+
<div class="footer-inner">
|
3
|
+
<div class="footer-content">
|
4
|
+
<a href="<%= href %>" rel="nofollow noopener">
|
5
|
+
<%= name %>
|
6
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-heart-fill" viewBox="0 0 16 16">
|
7
|
+
<path fill-rule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"/>
|
8
|
+
</svg>
|
9
|
+
<%= version %>
|
10
|
+
</a>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
13
|
</footer>
|
package/templates/noun.vue
CHANGED
@@ -1,18 +1,15 @@
|
|
1
|
-
<template>
|
2
|
-
<button
|
3
|
-
data-bs-custom-class="lnote-popover" :data-bs-content="desc">
|
4
|
-
{{ text }}
|
5
|
-
<svg width="18" height="18"
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
const title: string | undefined = undefined
|
16
|
-
const desc = ''
|
17
|
-
const text = ''
|
1
|
+
<template>
|
2
|
+
<button type="button" class="btn btn-link lnote-popover-btn" data-bs-toggle="popover" data-bs-trigger="hover focus"
|
3
|
+
data-bs-placement="right" data-bs-custom-class="lnote-popover" :data-bs-title="title" :data-bs-content="desc">
|
4
|
+
{{ text }}
|
5
|
+
<svg width="18" height="18">
|
6
|
+
<use xlink:href="#question-circle-fill"></use>
|
7
|
+
</svg>
|
8
|
+
</button>
|
9
|
+
</template>
|
10
|
+
|
11
|
+
<script lang="ts" setup>
|
12
|
+
const title: string | undefined = undefined
|
13
|
+
const desc = ''
|
14
|
+
const text = ''
|
18
15
|
</script>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import fs from 'fs'
|
2
|
+
import path from 'path'
|
3
|
+
|
4
|
+
function runtimeProjectInfo() {
|
5
|
+
const projectPath = path.resolve(process.cwd(), 'package.json')
|
6
|
+
return JSON.parse(fs.readFileSync(projectPath, 'utf-8'))
|
7
|
+
}
|
8
|
+
|
9
|
+
export function uriFor(resUri: string) {
|
10
|
+
const { name } = runtimeProjectInfo()
|
11
|
+
return ['', name, resUri.replace(/^\//, '')].join('/')
|
12
|
+
}
|