hexo-theme-volantis 4.2.0 → 5.0.0-alpha.112

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 (302) hide show
  1. package/README.md +7 -5
  2. package/_config.yml +651 -234
  3. package/languages/en.yml +7 -0
  4. package/languages/zh-CN.yml +13 -2
  5. package/languages/zh-TW.yml +7 -0
  6. package/layout/404.ejs +1 -2
  7. package/layout/_meta/author.ejs +4 -4
  8. package/layout/_meta/category.ejs +11 -8
  9. package/layout/_meta/counter.ejs +51 -2
  10. package/layout/_meta/date.ejs +1 -1
  11. package/layout/_meta/music.ejs +1 -1
  12. package/layout/_meta/share.ejs +1 -1
  13. package/layout/_meta/tags.ejs +3 -0
  14. package/layout/_meta/thumbnail.ejs +3 -1
  15. package/layout/_meta/updated.ejs +1 -1
  16. package/layout/_meta/{valinecount.ejs → walinecount.ejs} +16 -15
  17. package/layout/{_cover → _partial/_cover}/blank.ejs +0 -0
  18. package/layout/{_cover → _partial/_cover}/dock.ejs +1 -1
  19. package/layout/{_cover → _partial/_cover}/featured.ejs +1 -1
  20. package/layout/{_cover → _partial/_cover}/focus.ejs +1 -1
  21. package/layout/_partial/_cover/layout.ejs +8 -0
  22. package/layout/{_cover → _partial/_cover}/search.ejs +2 -2
  23. package/layout/_partial/archive.ejs +2 -2
  24. package/layout/_partial/article.ejs +21 -13
  25. package/layout/_partial/categories.ejs +1 -1
  26. package/layout/_partial/cover.ejs +10 -30
  27. package/layout/_partial/footer.ejs +19 -11
  28. package/layout/_partial/head.ejs +70 -110
  29. package/layout/_partial/header.ejs +17 -11
  30. package/layout/_partial/meta.ejs +18 -4
  31. package/layout/_partial/post.ejs +35 -9
  32. package/layout/_partial/scripts/_ctrl/cdnCtrl.ejs +126 -0
  33. package/layout/_partial/scripts/{coverCtrl.ejs → _ctrl/coverCtrl.ejs} +22 -26
  34. package/layout/_partial/scripts/_ctrl.ejs +2 -0
  35. package/layout/_partial/scripts/content-visibility-scroll-fix.ejs +88 -0
  36. package/layout/_partial/scripts/global.ejs +423 -0
  37. package/layout/_partial/scripts/index.ejs +89 -73
  38. package/layout/_partial/scripts/toc.ejs +98 -68
  39. package/layout/_partial/side.ejs +4 -1
  40. package/layout/_plugins/_page_plugins/artitalk/index.ejs +15 -0
  41. package/layout/_plugins/_page_plugins/bbtalk/index.ejs +10 -0
  42. package/layout/_plugins/_page_plugins/fcircle/index.ejs +12 -0
  43. package/layout/_plugins/_page_plugins/gitter/index.ejs +14 -0
  44. package/layout/_plugins/_page_plugins/indent/index.ejs +16 -0
  45. package/layout/_plugins/_page_plugins/index.ejs +27 -0
  46. package/layout/_plugins/_page_plugins/katex/index.ejs +13 -0
  47. package/layout/{_third-party/math/mathjax/script.ejs → _plugins/_page_plugins/mathjax/index.ejs} +2 -2
  48. package/layout/_plugins/_page_plugins/snackbar/index.ejs +55 -0
  49. package/layout/{_partial/scripts/counter.ejs → _plugins/analytics/LCCounter.ejs} +0 -0
  50. package/layout/_plugins/analytics/script.ejs +74 -0
  51. package/layout/{_third-party → _plugins}/aplayer/layout.ejs +0 -0
  52. package/layout/_plugins/aplayer/script.ejs +74 -0
  53. package/layout/_plugins/chat/gitter/script.ejs +17 -0
  54. package/layout/_plugins/chat/index.ejs +1 -0
  55. package/layout/_plugins/chat/tidio/script.ejs +1 -0
  56. package/layout/_plugins/comments/artalk/script.ejs +59 -0
  57. package/layout/_plugins/comments/beaudar/script.ejs +61 -0
  58. package/layout/_plugins/comments/discuss/script.ejs +30 -0
  59. package/layout/_plugins/comments/disqus/script.ejs +98 -0
  60. package/layout/_plugins/comments/disqusjs/script.ejs +35 -0
  61. package/layout/_plugins/comments/giscus/script.ejs +47 -0
  62. package/layout/_plugins/comments/gitalk/script.ejs +24 -0
  63. package/layout/_plugins/comments/hashover/script.ejs +5 -0
  64. package/layout/{_third-party → _plugins}/comments/index.ejs +10 -3
  65. package/layout/_plugins/comments/isso/script.ejs +27 -0
  66. package/layout/_plugins/comments/livere/script.ejs +15 -0
  67. package/layout/_plugins/comments/twikoo/script.ejs +40 -0
  68. package/layout/_plugins/comments/utterances/script.ejs +43 -0
  69. package/layout/_plugins/comments/vssue/script.ejs +37 -0
  70. package/layout/_plugins/comments/waline/script.ejs +62 -0
  71. package/layout/_plugins/comments/z-custom/script.ejs +1 -0
  72. package/layout/_plugins/darkmode/script.ejs +114 -0
  73. package/layout/_plugins/end-of-support/script.ejs +62 -0
  74. package/layout/_plugins/github-api/script.ejs +27 -0
  75. package/layout/_plugins/highlight/highlightjs/script.ejs +26 -0
  76. package/layout/_plugins/highlight/prismjs/script.ejs +25 -0
  77. package/layout/_plugins/highlight/script.ejs +1 -0
  78. package/layout/{_third-party → _plugins}/lazyload/script.ejs +1 -1
  79. package/layout/_plugins/nodewaves/script.ejs +12 -0
  80. package/layout/_plugins/parallax/script.ejs +74 -0
  81. package/layout/{_third-party → _plugins}/pjax/animate.ejs +31 -26
  82. package/layout/_plugins/pjax/index.ejs +73 -0
  83. package/layout/_plugins/pjax/pdata.ejs +56 -0
  84. package/layout/_plugins/preload/script.ejs +14 -0
  85. package/layout/_plugins/rightmenu/layout.ejs +119 -0
  86. package/layout/_plugins/rightmenus/layout.ejs +137 -0
  87. package/layout/_plugins/scrollreveal/script.ejs +25 -0
  88. package/layout/_plugins/search/script.ejs +50 -0
  89. package/layout/{_third-party → _plugins}/share/layout.ejs +0 -0
  90. package/layout/_plugins/swiper/script.ejs +37 -0
  91. package/layout/_pre.ejs +2 -2
  92. package/layout/_widget/_pre.ejs +5 -0
  93. package/layout/_widget/blogger.ejs +1 -1
  94. package/layout/_widget/category.ejs +2 -2
  95. package/layout/_widget/copyright.ejs +1 -1
  96. package/layout/_widget/grid.ejs +3 -3
  97. package/layout/_widget/lastupdate.ejs +27 -0
  98. package/layout/_widget/list.ejs +2 -2
  99. package/layout/_widget/load.ejs +18 -0
  100. package/layout/_widget/music.ejs +3 -2
  101. package/layout/_widget/page.ejs +1 -1
  102. package/layout/_widget/qrcode.ejs +1 -1
  103. package/layout/_widget/related_posts.ejs +1 -1
  104. package/layout/_widget/tagcloud.ejs +1 -1
  105. package/layout/_widget/text.ejs +1 -1
  106. package/layout/_widget/toc.ejs +6 -2
  107. package/layout/_widget/webinfo.ejs +13 -76
  108. package/layout/archive.ejs +4 -4
  109. package/layout/category.ejs +9 -4
  110. package/layout/docs.ejs +1 -1
  111. package/layout/friends.ejs +6 -25
  112. package/layout/index.ejs +1 -1
  113. package/layout/layout.ejs +40 -24
  114. package/layout/list.ejs +1 -1
  115. package/layout/page.ejs +1 -1
  116. package/layout/post.ejs +1 -1
  117. package/layout/tag.ejs +8 -3
  118. package/package.json +6 -2
  119. package/scripts/events/index.js +13 -0
  120. package/scripts/events/lib/check-configuration.js +43 -0
  121. package/scripts/events/lib/check-environment.js +74 -0
  122. package/scripts/events/lib/config.js +35 -10
  123. package/scripts/events/lib/render-stylus.js +78 -0
  124. package/scripts/events/lib/stellar-tag-utils.js +76 -0
  125. package/scripts/filters/content-visibility.js +25 -0
  126. package/scripts/{render → filters}/img.js +1 -1
  127. package/scripts/filters/replace.js +15 -0
  128. package/scripts/{z-lazyload/lib/process.js → filters/z-lazyload.js} +18 -15
  129. package/scripts/helpers/custom-files.js +165 -0
  130. package/scripts/helpers/first-style.js +19 -0
  131. package/scripts/helpers/head/autoCanonical.js +15 -0
  132. package/scripts/helpers/head/generate_preload_fontfamily.js +22 -0
  133. package/scripts/helpers/head/generate_seo.js +24 -0
  134. package/scripts/helpers/head/generate_title__keywords__description.js +101 -0
  135. package/scripts/{related_posts/index.js → helpers/related-posts.js} +9 -9
  136. package/scripts/helpers/revisioned.js +158 -0
  137. package/scripts/helpers/structured-data/index.js +2 -0
  138. package/scripts/helpers/structured-data/lib/blogposting.js +77 -0
  139. package/scripts/helpers/structured-data/lib/breadcrumblist.js +152 -0
  140. package/scripts/helpers/structured-data/lib/config.js +31 -0
  141. package/scripts/helpers/structured-data/lib/index.js +30 -0
  142. package/scripts/helpers/structured-data/lib/organization.js +15 -0
  143. package/scripts/helpers/structured-data/lib/person.js +16 -0
  144. package/scripts/helpers/structured-data/lib/website.js +42 -0
  145. package/scripts/tags/btn.js +31 -26
  146. package/scripts/tags/btns.js +18 -13
  147. package/scripts/tags/checkbox.js +32 -22
  148. package/scripts/tags/contributors.js +100 -0
  149. package/scripts/tags/dropmenu.js +50 -35
  150. package/scripts/tags/fancybox.js +44 -10
  151. package/scripts/tags/folding.js +14 -9
  152. package/scripts/tags/frame.js +8 -3
  153. package/scripts/tags/friends.js +99 -0
  154. package/scripts/tags/ghcard.js +11 -6
  155. package/scripts/tags/image.js +18 -6
  156. package/scripts/tags/link.js +15 -10
  157. package/scripts/tags/md.js +59 -0
  158. package/scripts/tags/media.js +32 -8
  159. package/scripts/tags/note.js +41 -8
  160. package/scripts/tags/site.js +87 -51
  161. package/scripts/tags/span.js +16 -6
  162. package/scripts/tags/swiper.js +38 -0
  163. package/scripts/tags/table.js +1 -1
  164. package/scripts/tags/tabs.js +33 -3
  165. package/scripts/tags/timeline.js +9 -4
  166. package/source/css/Readme.md +28 -0
  167. package/source/css/_defines/AutoPrefixCSS.styl +347 -0
  168. package/source/css/_defines/Readme.md +3 -0
  169. package/source/css/_defines/color.styl +41 -1
  170. package/source/css/_defines/effect.styl +0 -13
  171. package/source/css/_defines/fonts.styl +17 -18
  172. package/source/css/_defines/func.styl +12 -30
  173. package/source/css/_first/base_first.styl +118 -0
  174. package/source/css/_first/{cover.styl → cover_first.styl} +113 -87
  175. package/source/css/_first/dark_first.styl +76 -0
  176. package/source/css/_first/fontfamily_first.styl +17 -0
  177. package/source/css/_first/{navbar.styl → navbar_first.styl} +4 -10
  178. package/source/css/_first/search_first.styl +12 -0
  179. package/source/css/{_base/index.styl → _style/_base/base.styl} +9 -93
  180. package/source/css/_style/_base/fontfamily_async.styl +8 -0
  181. package/source/css/{_layout → _style/_layout}/archive.styl +0 -0
  182. package/source/css/{_layout → _style/_layout}/article.styl +3 -30
  183. package/source/css/{_layout → _style/_layout}/footer.styl +0 -0
  184. package/source/css/_style/_layout/friends-simpleuser.styl +23 -0
  185. package/source/css/_style/_layout/friends-traditional.styl +81 -0
  186. package/source/css/{_layout → _style/_layout}/img.styl +0 -0
  187. package/source/css/_style/_layout/loading.styl +14 -0
  188. package/source/css/{_layout → _style/_layout}/main.styl +20 -7
  189. package/source/css/{_layout → _style/_layout}/md.styl +0 -0
  190. package/source/css/{_layout → _style/_layout}/pagination.styl +1 -1
  191. package/source/css/{_layout → _style/_layout}/posts.styl +2 -0
  192. package/source/css/{_first → _style/_layout}/search.styl +0 -103
  193. package/source/css/{_layout → _style/_layout}/sidebar.styl +23 -3
  194. package/source/css/{_layout → _style/_layout}/snackbar.styl +2 -1
  195. package/source/css/{_layout → _style/_layout}/toc.styl +3 -3
  196. package/source/css/{_layout → _style/_layout}/video.styl +0 -0
  197. package/source/css/_style/_plugins/_dark/dark_async.styl +41 -0
  198. package/source/css/_style/_plugins/_dark/dark_plugins.styl +136 -0
  199. package/source/css/_style/_plugins/_highlight/highlightjs/clipboard.styl +36 -0
  200. package/source/css/_style/_plugins/_highlight/highlightjs/color.styl +96 -0
  201. package/source/css/_style/_plugins/_highlight/highlightjs/index.styl +102 -0
  202. package/source/css/_style/_plugins/_highlight/highlightjs/language.styl +63 -0
  203. package/source/css/_style/_plugins/_highlight/index.styl +1 -0
  204. package/source/css/_style/_plugins/_highlight/prismjs/clipboard.styl +33 -0
  205. package/source/css/_style/_plugins/_highlight/prismjs/index.styl +8 -0
  206. package/source/css/_style/_plugins/_highlight/prismjs/language.styl +63 -0
  207. package/source/css/_style/_plugins/_rightmenu/reading.styl +56 -0
  208. package/source/css/{_plugins → _style/_plugins/_rightmenu}/rightmenu.styl +22 -2
  209. package/source/css/{_plugins → _style/_plugins}/aplayer.styl +11 -0
  210. package/source/css/{_plugins → _style/_plugins}/cursor.styl +49 -19
  211. package/source/css/_style/_plugins/fontcolor.styl +84 -0
  212. package/source/css/{_plugins → _style/_plugins}/gitalk.styl +0 -0
  213. package/source/css/_style/_plugins/index.styl +24 -0
  214. package/source/css/{_plugins → _style/_plugins}/mathjax.styl +0 -0
  215. package/source/css/_style/_plugins/message.styl +14 -0
  216. package/source/css/{_plugins → _style/_plugins}/pjaxanimate.styl +0 -0
  217. package/source/css/_style/_tag-plugins/Readme.md +6 -0
  218. package/source/css/{_tag-plugins → _style/_tag-plugins}/btns.styl +0 -0
  219. package/source/css/{_tag-plugins → _style/_tag-plugins}/checkbox.styl +0 -0
  220. package/source/css/{_tag-plugins → _style/_tag-plugins}/dropmenu.styl +0 -0
  221. package/source/css/{_plugins → _style/_tag-plugins}/fancybox.styl +8 -9
  222. package/source/css/{_tag-plugins → _style/_tag-plugins}/folding.styl +0 -0
  223. package/source/css/{_tag-plugins → _style/_tag-plugins}/frame.styl +0 -0
  224. package/source/css/_style/_tag-plugins/friends.styl +72 -0
  225. package/source/css/{_tag-plugins → _style/_tag-plugins}/ghcard.styl +0 -0
  226. package/source/css/{_tag-plugins → _style/_tag-plugins}/image.styl +0 -0
  227. package/source/css/{_tag-plugins → _style/_tag-plugins}/link.styl +0 -0
  228. package/source/css/{_tag-plugins → _style/_tag-plugins}/media.styl +0 -0
  229. package/source/css/{_tag-plugins → _style/_tag-plugins}/note.styl +0 -0
  230. package/source/css/_style/_tag-plugins/sites.styl +87 -0
  231. package/source/css/{_tag-plugins → _style/_tag-plugins}/span.styl +0 -0
  232. package/source/css/_style/_tag-plugins/swiper.styl +44 -0
  233. package/source/css/{_tag-plugins → _style/_tag-plugins}/table.styl +0 -0
  234. package/source/css/{_tag-plugins → _style/_tag-plugins}/tabs.styl +0 -0
  235. package/source/css/_style/_tag-plugins/tag.json +35 -0
  236. package/source/css/_style/_tag-plugins/text.styl +31 -0
  237. package/source/css/{_tag-plugins → _style/_tag-plugins}/timeline.styl +0 -0
  238. package/source/css/_style/index.styl +8 -0
  239. package/source/css/first.styl +17 -6
  240. package/source/css/style.styl +9 -7
  241. package/source/js/app.js +1128 -359
  242. package/source/js/plugins/aplayer.js +186 -0
  243. package/source/js/plugins/parallax.js +191 -0
  244. package/source/js/plugins/rightMenu.js +577 -0
  245. package/source/js/plugins/rightMenus.js +616 -0
  246. package/source/js/plugins/tags/contributors.js +92 -0
  247. package/source/js/plugins/tags/friends.js +93 -0
  248. package/source/js/plugins/tags/sites.js +96 -0
  249. package/source/js/search/hexo.js +180 -378
  250. package/layout/_partial/rightmenu.ejs +0 -204
  251. package/layout/_partial/scripts/cover.ejs +0 -45
  252. package/layout/_partial/scripts/darkmode.ejs +0 -96
  253. package/layout/_partial/scripts/import.ejs +0 -3
  254. package/layout/_partial/scripts/loadfunction.ejs +0 -72
  255. package/layout/_partial/scripts/search.ejs +0 -62
  256. package/layout/_partial/snackbar.ejs +0 -22
  257. package/layout/_third-party/analytics/script.ejs +0 -24
  258. package/layout/_third-party/aplayer/script.ejs +0 -24
  259. package/layout/_third-party/clipboard/script.ejs +0 -53
  260. package/layout/_third-party/comments/disqus/layout.ejs +0 -5
  261. package/layout/_third-party/comments/disqus/script.ejs +0 -93
  262. package/layout/_third-party/comments/gitalk/layout.ejs +0 -1
  263. package/layout/_third-party/comments/gitalk/script.ejs +0 -29
  264. package/layout/_third-party/comments/hashover/layout.ejs +0 -2
  265. package/layout/_third-party/comments/hashover/script.ejs +0 -1
  266. package/layout/_third-party/comments/isso/layout.ejs +0 -1
  267. package/layout/_third-party/comments/isso/script.ejs +0 -1
  268. package/layout/_third-party/comments/livere/layout.ejs +0 -3
  269. package/layout/_third-party/comments/livere/script.ejs +0 -10
  270. package/layout/_third-party/comments/minivaline/layout.ejs +0 -3
  271. package/layout/_third-party/comments/minivaline/script.ejs +0 -29
  272. package/layout/_third-party/comments/twikoo/layout.ejs +0 -3
  273. package/layout/_third-party/comments/twikoo/script.ejs +0 -17
  274. package/layout/_third-party/comments/valine/layout.ejs +0 -3
  275. package/layout/_third-party/comments/valine/script.ejs +0 -75
  276. package/layout/_third-party/comments/vssue/layout.ejs +0 -1
  277. package/layout/_third-party/comments/vssue/script.ejs +0 -22
  278. package/layout/_third-party/fancybox/script.ejs +0 -50
  279. package/layout/_third-party/issues/script.ejs +0 -15
  280. package/layout/_third-party/pjax/index.ejs +0 -143
  281. package/layout/_third-party/pjax/pdata.ejs +0 -47
  282. package/layout/_third-party/scrollreveal/script.ejs +0 -15
  283. package/layout/artitalk.ejs +0 -48
  284. package/scripts/tags/issues.js +0 -41
  285. package/scripts/z-lazyload/index.js +0 -4
  286. package/source/css/_highlight/index.styl +0 -316
  287. package/source/css/_layout/friends.styl +0 -79
  288. package/source/css/_plugins/clipboard.styl +0 -37
  289. package/source/css/_plugins/dark.styl +0 -149
  290. package/source/css/_plugins/darkmode.styl +0 -9
  291. package/source/css/_plugins/index.styl +0 -16
  292. package/source/css/_plugins/valine.styl +0 -173
  293. package/source/css/_tag-plugins/simpleuser.styl +0 -21
  294. package/source/css/_tag-plugins/site-card.styl +0 -70
  295. package/source/js/aplayer.js +0 -161
  296. package/source/js/issues.js +0 -186
  297. package/source/js/search/algolia.js +0 -348
  298. package/source/js/search/azure.js +0 -359
  299. package/source/js/search/baidu.js +0 -342
  300. package/source/js/search/google.js +0 -343
  301. package/source/js/twikoo.js +0 -13
  302. package/source/js/valine.js +0 -5265
@@ -1,342 +0,0 @@
1
- var SearchService = "";
2
-
3
- (function($) {
4
- /**
5
- * A super class of common logics for all search services
6
- * @param options : (object)
7
- */
8
- SearchService = function(options) {
9
- var self = this;
10
-
11
- self.config = $.extend({
12
- per_page: 10,
13
- selectors: {
14
- body: "body",
15
- form: ".u-search-form",
16
- input: ".u-search-input",
17
- container: "#u-search",
18
- modal: "#u-search .modal",
19
- modal_body: "#u-search .modal-body",
20
- modal_footer: "#u-search .modal-footer",
21
- modal_overlay: "#u-search .modal-overlay",
22
- modal_results: "#u-search .modal-results",
23
- modal_metadata: "#u-search .modal-metadata",
24
- modal_error: "#u-search .modal-error",
25
- modal_loading_bar: "#u-search .modal-loading-bar",
26
- modal_ajax_content: "#u-search .modal-ajax-content",
27
- modal_logo: '#u-search .modal-footer .logo',
28
- btn_close: "#u-search .btn-close",
29
- btn_next: "#u-search .btn-next",
30
- btn_prev: "#u-search .btn-prev"
31
- },
32
- brands: {
33
- 'hexo': {logo: '', url: ''},
34
- 'google': {logo: 'google.svg', url: 'https://cse.google.com'},
35
- 'algolia': {logo: 'algolia.svg', url: 'https://www.algolia.com'},
36
- 'baidu': {logo: 'baidu.svg', url: 'http://zn.baidu.com/cse/home/index'},
37
- 'azure': {logo: 'azure.svg', url: 'https://azure.microsoft.com/en-us/services/search/'}
38
- },
39
- imagePath: "https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@master/img/logo/"
40
- }, options);
41
-
42
- self.dom = {};
43
- self.percentLoaded = 0;
44
- self.open = false;
45
- self.queryText = "";
46
- self.nav = {
47
- next: -1,
48
- prev: -1,
49
- total: 0,
50
- current: 1
51
- };
52
-
53
- self.parseSelectors = function() {
54
- for (var key in self.config.selectors) {
55
- self.dom[key] = $(self.config.selectors[key]);
56
- }
57
- };
58
-
59
- self.beforeQuery = function() {
60
- if (!self.open) {
61
- self.dom.container.fadeIn();
62
- // self.dom.body.addClass('modal-active');
63
- // 上面的是去除了文章的滚动条,我觉得没必要
64
- }
65
- self.dom.input.each(function(index,elem) {
66
- $(elem).val(self.queryText);
67
- });
68
- document.activeElement.blur();
69
- self.dom.modal_error.hide();
70
- self.dom.modal_ajax_content.removeClass('loaded');
71
- self.startLoading();
72
- };
73
-
74
- self.afterQuery = function() {
75
- self.dom.modal_body.scrollTop(0);
76
- self.dom.modal_ajax_content.addClass('loaded');
77
- self.stopLoading();
78
- };
79
-
80
- /**
81
- * Perform a complete serach operation including UI updates and query
82
- * @param startIndex {int} start index or page number
83
- */
84
- self.search = function(startIndex, callback) {
85
- self.beforeQuery();
86
- if (self.search instanceof Function) {
87
- self.query(self.queryText, startIndex, function() {
88
- self.afterQuery();
89
- });
90
- }
91
- else {
92
- console.log("query() does not exist.");
93
- self.onQueryError(self.queryText, '');
94
- self.afterQuery();
95
- }
96
- };
97
-
98
- /**
99
- * Query error handler
100
- * @param queryText: (string)
101
- * @param status: (string)
102
- */
103
- self.onQueryError = function(queryText, status) {
104
- var errMsg = "";
105
- if (status === "success") errMsg = "No result found for \"" +queryText+ "\".";
106
- else if (status === "timeout") errMsg = "Unfortunate timeout.";
107
- else errMsg = "Mysterious failure.";
108
- self.dom.modal_results.html("");
109
- self.dom.modal_error.html(errMsg);
110
- self.dom.modal_error.show();
111
- };
112
-
113
- self.nextPage = function() {
114
- if (self.nav.next !== -1) {
115
- self.search(self.nav.next);
116
- }
117
- };
118
-
119
- self.prevPage = function() {
120
- if (self.nav.prev !== -1) {
121
- self.search(self.nav.prev);
122
- }
123
- };
124
-
125
- self.getUrlRelativePath = function (url) {
126
- var arrUrl = url.split("//");
127
- var start = arrUrl[1].indexOf("/");
128
- var relUrl = arrUrl[1].substring(start);
129
- if (relUrl.indexOf("?") != -1) {
130
- relUrl = relUrl.split("?")[0];
131
- }
132
- return relUrl;
133
- }
134
-
135
- /**
136
- * Generate html for one result
137
- * @param url : (string) url
138
- * @param title : (string) title
139
- * @param digest : (string) digest
140
- */
141
- self.buildResult = function (url, title, digest) {
142
- var result = self.getUrlRelativePath(url);
143
- var html = "";
144
- html = "<li>";
145
- html += "<a class='result' href='" + result + "'>";
146
- html += "<span class='title'>" + title + "</span>";
147
- if (digest !== "") html += "<span class='digest'>" + digest + "</span>";
148
- html += "</a>";
149
- html += "</li>";
150
- return html;
151
- };
152
-
153
- /**
154
- * Close the modal, resume body scrolling
155
- * no param
156
- */
157
- self.close = function() {
158
- self.open = false;
159
- self.dom.container.fadeOut();
160
- self.dom.body.removeClass('modal-active');
161
- };
162
-
163
- /**
164
- * Searchform submit event handler
165
- * @param queryText : (string) the query text
166
- */
167
- self.onSubmit = function(event) {
168
- event.preventDefault();
169
- self.queryText = $(this).find('.u-search-input').val();
170
- if (self.queryText) {
171
- self.search(1);
172
- }
173
- };
174
-
175
- /**
176
- * Start loading bar animation
177
- * no param
178
- */
179
- self.startLoading = function() {
180
- self.dom.modal_loading_bar.show();
181
- self.loadingTimer = setInterval(function() {
182
- self.percentLoaded = Math.min(self.percentLoaded+5,95);
183
- self.dom.modal_loading_bar.css('width', self.percentLoaded+'%');
184
- }, 100);
185
- };
186
-
187
- /**
188
- * Stop loading bar animation
189
- * no param
190
- */
191
- self.stopLoading = function() {
192
- clearInterval(self.loadingTimer);
193
- self.dom.modal_loading_bar.css('width', '100%');
194
- self.dom.modal_loading_bar.fadeOut();
195
- setTimeout(function() {
196
- self.percentLoaded = 0;
197
- self.dom.modal_loading_bar.css('width', '0%');
198
- }, 300);
199
- };
200
-
201
- /**
202
- * Add service branding
203
- * @param service {String} service name
204
- */
205
- self.addLogo = function(service) {
206
- var html = "";
207
- if (self.config.brands[service] && self.config.brands[service].logo) {
208
- html += "<a href='" +self.config.brands[service].url+ "' class='" +service+ "'>";
209
- html += '<img src="' +self.config.imagePath+self.config.brands[service].logo+ '" />';
210
- html += "</a>";
211
- self.dom.modal_logo.html(html);
212
- }
213
- };
214
-
215
- self.destroy = function() {
216
- self.dom.form.each(function(index,elem) {
217
- $(elem).off('submit');
218
- });
219
- self.dom.modal_overlay.off('click');
220
- self.dom.btn_close.off('click');
221
- self.dom.btn_next.off('click');
222
- self.dom.btn_prev.off('click');
223
- self.dom.container.remove();
224
- };
225
-
226
- /**
227
- * Load template and register event handlers
228
- * no param
229
- */
230
- self.init = function() {
231
- $('body').append(template);
232
- self.parseSelectors();
233
- self.dom.modal_footer.show();
234
- self.dom.form.each(function(index,elem) {
235
- $(elem).on('submit', self.onSubmit);
236
- });
237
- self.dom.modal_overlay.on('click', self.close);
238
- self.dom.btn_close.on('click', self.close);
239
- self.dom.btn_next.on('click', self.nextPage);
240
- self.dom.btn_prev.on('click', self.prevPage);
241
- };
242
-
243
- self.init();
244
- };
245
-
246
- var template = '<div id="u-search"><div class="modal"> <header class="modal-header" class="clearfix"><form id="u-search-modal-form" class="u-search-form" name="uSearchModalForm"> <input type="text" id="u-search-modal-input" class="u-search-input" /> <button type="submit" id="u-search-modal-btn-submit" class="u-search-btn-submit"> <span class="fas fa-search"></span> </button></form> <a class="btn-close"> <span class="fas fa-times"></span> </a><div class="modal-loading"><div class="modal-loading-bar"></div></div> </header> <main class="modal-body"><ul class="modal-results modal-ajax-content"></ul> </main> <footer class="modal-footer clearfix"><div class="modal-metadata modal-ajax-content"> <strong class="range"></strong> of <strong class="total"></strong></div><div class="modal-error"></div> <div class="logo"></div> <a class="nav btn-next modal-ajax-content"> <span class="text">NEXT</span> <span class="fal fa-chevron-right"></span> </a> <a class="nav btn-prev modal-ajax-content"> <span class="fal fa-chevron-left"></span> <span class="text">PREV</span> </a> </footer></div><div class="modal-overlay"></div></div>';
247
- })(jQuery);
248
-
249
- var BaiduSearch;
250
- (function($) {
251
- 'use strict';
252
-
253
- /**
254
- * TODO
255
- * Search by Baidu Search API
256
- * @param options : (object)
257
- */
258
- BaiduSearch = function(options) {
259
- SearchService.apply(this, arguments);
260
- var self = this;
261
- var endpoint = "";
262
- self.addLogo('baidu');
263
-
264
- /**
265
- * Generate result list html
266
- * @param data : (array) result items
267
- */
268
- self.buildResultList = function(data, queryText) {
269
- var results = [],
270
- html = "";
271
- $.each(data, function(index, post) {
272
- if (self.contentSearch(post, queryText))
273
- html += self.buildResult(post.linkUrl, post.title, post.abstract);
274
- });
275
- html += "<script>try{pjax.refresh(document.querySelector('#u-search'));document.addEventListener('pjax:send',function(){$('#u-search').fadeOut(500);$('body').removeClass('modal-active')});}catch(e){$('#u-search').fadeOut(500);}</script>";
276
- return html;
277
- };
278
-
279
- /**
280
- * Generate metadata after a successful query
281
- * @param data : (object) the raw google custom search response data
282
- */
283
- self.buildMetadata = function(data) {
284
-
285
- };
286
-
287
- self.loadScript = function() {
288
- self.dom.input.each(function(index,elem) {
289
- $(elem).attr('disabled', true);
290
- });
291
- var script = "<script src='http://zhannei.baidu.com/api/customsearch/apiaccept?sid=" +self.config.apiId+ "&v=2.0&callback=customSearch.initBaidu' type='text/javascript' charset='utf-8'></script>";
292
- self.dom.body.append(script);
293
- };
294
-
295
- self.initBaidu = function() {
296
- self.cse = new BCse.Search(self.config.apiId);
297
- //self.cse.setPageNum(self.config.per_page);
298
- self.dom.input.each(function(index,elem) {
299
- $(elem).attr('disabled', false);
300
- });
301
- };
302
-
303
- /**
304
- * Get search results
305
- * @param queryText {String}
306
- * @param page {Integer}
307
- * @param callback {Function}
308
- */
309
- self.query = function(queryText, page, callback) {
310
- self.cse.getResult(queryText, function(data) {
311
- console.log("Searching: " + queryText);
312
- self.cse.getError(function(data) {
313
- console.log(data);
314
- });
315
- if (data.length > 0) {
316
- self.buildResultList(data, queryText);
317
- self.cse.getSearchInfo(queryText, function(data) {
318
- console.log(data);
319
- self.buildMetadata(data);
320
- });
321
- }
322
- else {
323
- self.nav.total = 0;
324
- self.nav.next = -1;
325
- self.nav.prev = -1;
326
- self.dom.modal_metadata.hide();
327
- self.dom.btn_next.hide();
328
- self.dom.btn_prev.hide();
329
- self.onQueryError(queryText, "success");
330
- }
331
- if (callback instanceof Function) {
332
- callback();
333
- }
334
- });
335
- };
336
-
337
- self.loadScript();
338
-
339
- return self;
340
- };
341
-
342
- })(jQuery);
@@ -1,343 +0,0 @@
1
- var SearchService = "";
2
-
3
- (function($) {
4
- /**
5
- * A super class of common logics for all search services
6
- * @param options : (object)
7
- */
8
- SearchService = function(options) {
9
- var self = this;
10
-
11
- self.config = $.extend({
12
- per_page: 10,
13
- selectors: {
14
- body: "body",
15
- form: ".u-search-form",
16
- input: ".u-search-input",
17
- container: "#u-search",
18
- modal: "#u-search .modal",
19
- modal_body: "#u-search .modal-body",
20
- modal_footer: "#u-search .modal-footer",
21
- modal_overlay: "#u-search .modal-overlay",
22
- modal_results: "#u-search .modal-results",
23
- modal_metadata: "#u-search .modal-metadata",
24
- modal_error: "#u-search .modal-error",
25
- modal_loading_bar: "#u-search .modal-loading-bar",
26
- modal_ajax_content: "#u-search .modal-ajax-content",
27
- modal_logo: '#u-search .modal-footer .logo',
28
- btn_close: "#u-search .btn-close",
29
- btn_next: "#u-search .btn-next",
30
- btn_prev: "#u-search .btn-prev"
31
- },
32
- brands: {
33
- 'hexo': {logo: '', url: ''},
34
- 'google': {logo: 'google.svg', url: 'https://cse.google.com'},
35
- 'algolia': {logo: 'algolia.svg', url: 'https://www.algolia.com'},
36
- 'baidu': {logo: 'baidu.svg', url: 'http://zn.baidu.com/cse/home/index'},
37
- 'azure': {logo: 'azure.svg', url: 'https://azure.microsoft.com/en-us/services/search/'}
38
- },
39
- imagePath: "https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@master/img/logo/"
40
- }, options);
41
-
42
- self.dom = {};
43
- self.percentLoaded = 0;
44
- self.open = false;
45
- self.queryText = "";
46
- self.nav = {
47
- next: -1,
48
- prev: -1,
49
- total: 0,
50
- current: 1
51
- };
52
-
53
- self.parseSelectors = function() {
54
- for (var key in self.config.selectors) {
55
- self.dom[key] = $(self.config.selectors[key]);
56
- }
57
- };
58
-
59
- self.beforeQuery = function() {
60
- if (!self.open) {
61
- self.dom.container.fadeIn();
62
- // self.dom.body.addClass('modal-active');
63
- // 上面的是去除了文章的滚动条,我觉得没必要
64
- }
65
- self.dom.input.each(function(index,elem) {
66
- $(elem).val(self.queryText);
67
- });
68
- document.activeElement.blur();
69
- self.dom.modal_error.hide();
70
- self.dom.modal_ajax_content.removeClass('loaded');
71
- self.startLoading();
72
- };
73
-
74
- self.afterQuery = function() {
75
- self.dom.modal_body.scrollTop(0);
76
- self.dom.modal_ajax_content.addClass('loaded');
77
- self.stopLoading();
78
- };
79
-
80
- /**
81
- * Perform a complete serach operation including UI updates and query
82
- * @param startIndex {int} start index or page number
83
- */
84
- self.search = function(startIndex, callback) {
85
- self.beforeQuery();
86
- if (self.search instanceof Function) {
87
- self.query(self.queryText, startIndex, function() {
88
- self.afterQuery();
89
- });
90
- }
91
- else {
92
- console.log("query() does not exist.");
93
- self.onQueryError(self.queryText, '');
94
- self.afterQuery();
95
- }
96
- };
97
-
98
- /**
99
- * Query error handler
100
- * @param queryText: (string)
101
- * @param status: (string)
102
- */
103
- self.onQueryError = function(queryText, status) {
104
- var errMsg = "";
105
- if (status === "success") errMsg = "No result found for \"" +queryText+ "\".";
106
- else if (status === "timeout") errMsg = "Unfortunate timeout.";
107
- else errMsg = "Mysterious failure.";
108
- self.dom.modal_results.html("");
109
- self.dom.modal_error.html(errMsg);
110
- self.dom.modal_error.show();
111
- };
112
-
113
- self.nextPage = function() {
114
- if (self.nav.next !== -1) {
115
- self.search(self.nav.next);
116
- }
117
- };
118
-
119
- self.prevPage = function() {
120
- if (self.nav.prev !== -1) {
121
- self.search(self.nav.prev);
122
- }
123
- };
124
-
125
- self.getUrlRelativePath = function (url) {
126
- var arrUrl = url.split("//");
127
- var start = arrUrl[1].indexOf("/");
128
- var relUrl = arrUrl[1].substring(start);
129
- if (relUrl.indexOf("?") != -1) {
130
- relUrl = relUrl.split("?")[0];
131
- }
132
- return relUrl;
133
- }
134
-
135
- /**
136
- * Generate html for one result
137
- * @param url : (string) url
138
- * @param title : (string) title
139
- * @param digest : (string) digest
140
- */
141
- self.buildResult = function (url, title, digest) {
142
- var result = self.getUrlRelativePath(url);
143
- var html = "";
144
- html = "<li>";
145
- html += "<a class='result' href='" + result + "'>";
146
- html += "<span class='title'>" + title + "</span>";
147
- if (digest !== "") html += "<span class='digest'>" + digest + "</span>";
148
- html += "</a>";
149
- html += "</li>";
150
- return html;
151
- };
152
-
153
- /**
154
- * Close the modal, resume body scrolling
155
- * no param
156
- */
157
- self.close = function() {
158
- self.open = false;
159
- self.dom.container.fadeOut();
160
- self.dom.body.removeClass('modal-active');
161
- };
162
-
163
- /**
164
- * Searchform submit event handler
165
- * @param queryText : (string) the query text
166
- */
167
- self.onSubmit = function(event) {
168
- event.preventDefault();
169
- self.queryText = $(this).find('.u-search-input').val();
170
- if (self.queryText) {
171
- self.search(1);
172
- }
173
- };
174
-
175
- /**
176
- * Start loading bar animation
177
- * no param
178
- */
179
- self.startLoading = function() {
180
- self.dom.modal_loading_bar.show();
181
- self.loadingTimer = setInterval(function() {
182
- self.percentLoaded = Math.min(self.percentLoaded+5,95);
183
- self.dom.modal_loading_bar.css('width', self.percentLoaded+'%');
184
- }, 100);
185
- };
186
-
187
- /**
188
- * Stop loading bar animation
189
- * no param
190
- */
191
- self.stopLoading = function() {
192
- clearInterval(self.loadingTimer);
193
- self.dom.modal_loading_bar.css('width', '100%');
194
- self.dom.modal_loading_bar.fadeOut();
195
- setTimeout(function() {
196
- self.percentLoaded = 0;
197
- self.dom.modal_loading_bar.css('width', '0%');
198
- }, 300);
199
- };
200
-
201
- /**
202
- * Add service branding
203
- * @param service {String} service name
204
- */
205
- self.addLogo = function(service) {
206
- var html = "";
207
- if (self.config.brands[service] && self.config.brands[service].logo) {
208
- html += "<a href='" +self.config.brands[service].url+ "' class='" +service+ "'>";
209
- html += '<img src="' +self.config.imagePath+self.config.brands[service].logo+ '" />';
210
- html += "</a>";
211
- self.dom.modal_logo.html(html);
212
- }
213
- };
214
-
215
- self.destroy = function() {
216
- self.dom.form.each(function(index,elem) {
217
- $(elem).off('submit');
218
- });
219
- self.dom.modal_overlay.off('click');
220
- self.dom.btn_close.off('click');
221
- self.dom.btn_next.off('click');
222
- self.dom.btn_prev.off('click');
223
- self.dom.container.remove();
224
- };
225
-
226
- /**
227
- * Load template and register event handlers
228
- * no param
229
- */
230
- self.init = function() {
231
- $('body').append(template);
232
- self.parseSelectors();
233
- self.dom.modal_footer.show();
234
- self.dom.form.each(function(index,elem) {
235
- $(elem).on('submit', self.onSubmit);
236
- });
237
- self.dom.modal_overlay.on('click', self.close);
238
- self.dom.btn_close.on('click', self.close);
239
- self.dom.btn_next.on('click', self.nextPage);
240
- self.dom.btn_prev.on('click', self.prevPage);
241
- };
242
-
243
- self.init();
244
- };
245
-
246
- var template = '<div id="u-search"><div class="modal"> <header class="modal-header" class="clearfix"><form id="u-search-modal-form" class="u-search-form" name="uSearchModalForm"> <input type="text" id="u-search-modal-input" class="u-search-input" /> <button type="submit" id="u-search-modal-btn-submit" class="u-search-btn-submit"> <span class="fas fa-search"></span> </button></form> <a class="btn-close"> <span class="fas fa-times"></span> </a><div class="modal-loading"><div class="modal-loading-bar"></div></div> </header> <main class="modal-body"><ul class="modal-results modal-ajax-content"></ul> </main> <footer class="modal-footer clearfix"><div class="modal-metadata modal-ajax-content"> <strong class="range"></strong> of <strong class="total"></strong></div><div class="modal-error"></div> <div class="logo"></div> <a class="nav btn-next modal-ajax-content"> <span class="text">NEXT</span> <span class="fal fa-chevron-right"></span> </a> <a class="nav btn-prev modal-ajax-content"> <span class="fal fa-chevron-left"></span> <span class="text">PREV</span> </a> </footer></div><div class="modal-overlay"></div></div>';
247
- })(jQuery);
248
-
249
- var GoogleCustomSearch = "";
250
- (function($) {
251
- 'use strict';
252
-
253
- /**
254
- * Search by Google Custom Search Engine JSON API
255
- * @param options : (object)
256
- */
257
- GoogleCustomSearch = function(options) {
258
- SearchService.apply(this, arguments);
259
- var self = this;
260
- var endpoint = "https://www.googleapis.com/customsearch/v1";
261
- self.addLogo('google');
262
-
263
- /**
264
- * Generate result list html
265
- * @param data : (array) result items
266
- */
267
- self.buildResultList = function(data) {
268
- var html = "";
269
- $.each(data, function(index, row) {
270
- var url = row.link;
271
- var title = row.title;
272
- var digest = (row.htmlSnippet || "").replace('<br>','');
273
- html += self.buildResult(url, title, digest);
274
- });
275
- html += "<script>try{pjax.refresh(document.querySelector('#u-search'));document.addEventListener('pjax:send',function(){$('#u-search').fadeOut(500);$('body').removeClass('modal-active')});}catch(e){$('#u-search').fadeOut(500);}</script>";
276
- return html;
277
- };
278
-
279
- /**
280
- * Generate metadata after a successful query
281
- * @param data : (object) the raw google custom search response data
282
- */
283
- self.buildMetadata = function(data) {
284
- if (data.queries && data.queries.request && data.queries.request[0].totalResults !== '0') {
285
- self.nav.current = data.queries.request[0].startIndex;
286
- self.nav.currentCount = data.queries.request[0].count;
287
- self.nav.total = parseInt(data.queries.request[0].totalResults);
288
- self.dom.modal_metadata.children('.total').html(self.nav.total);
289
- self.dom.modal_metadata.children('.range').html(self.nav.current + "-" + (self.nav.current+self.nav.currentCount-1));
290
- self.dom.modal_metadata.show();
291
- }
292
- else {
293
- self.dom.modal_metadata.hide();
294
- }
295
- if (data.queries && data.queries.nextPage) {
296
- self.nav.next = data.queries.nextPage[0].startIndex;
297
- self.dom.btn_next.show();
298
- }
299
- else {
300
- self.nav.next = -1;
301
- self.dom.btn_next.hide();
302
- }
303
- if (data.queries && data.queries.previousPage) {
304
- self.nav.prev = data.queries.previousPage[0].startIndex;
305
- self.dom.btn_prev.show();
306
- }
307
- else {
308
- self.nav.prev = -1;
309
- self.dom.btn_prev.hide();
310
- }
311
- };
312
-
313
- /**
314
- * Send a GET request
315
- * @param queryText : (string) the query text
316
- * @param startIndex : (int) the index of first item (start from 1)
317
- * @param callback : (function)
318
- */
319
- self.query = function(queryText, startIndex, callback) {
320
- $.get(endpoint, {
321
- key: self.config.apiKey,
322
- cx: self.config.engineId,
323
- q: queryText,
324
- start: startIndex,
325
- num: self.config.per_page
326
- }, function(data, status) {
327
- if (status === 'success' && data.items && data.items.length > 0) {
328
- var results = self.buildResultList(data.items);
329
- self.dom.modal_results.html(results);
330
- }
331
- else {
332
- self.onQueryError(queryText, status);
333
- }
334
- self.buildMetadata(data);
335
- if (callback) {
336
- callback();
337
- }
338
- });
339
- };
340
-
341
- return self;
342
- };
343
- })(jQuery);