jekyll-text-theme 1.4.3 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -6
  3. data/_data/locale.yml +21 -3
  4. data/_data/variables.yml +31 -0
  5. data/_includes/{blog → components}/article-data.html +4 -2
  6. data/_includes/{info → components}/follow-me.html +1 -1
  7. data/_includes/{blog → components}/footer.html +1 -1
  8. data/_includes/components/header.html +42 -0
  9. data/_includes/{blog → components}/license.html +0 -0
  10. data/_includes/{blog → components}/tags.html +5 -6
  11. data/_includes/icon/clear.svg +3 -0
  12. data/_includes/icon/link.svg +1 -0
  13. data/_includes/icon/omit.svg +1 -0
  14. data/_includes/icon/search.svg +3 -0
  15. data/_includes/icon/{mail.svg → social/mail.svg} +0 -0
  16. data/_includes/scripts/all.html +244 -0
  17. data/_includes/scripts/common.html +30 -0
  18. data/_includes/scripts/data.html +27 -0
  19. data/_includes/scripts/home.html +26 -0
  20. data/_includes/scripts/page-post.html +32 -0
  21. data/_includes/scripts/post.html +183 -0
  22. data/_includes/scripts/utils.html +180 -0
  23. data/_includes/snippets/get-lang.html +2 -2
  24. data/_includes/snippets/get-sources.html +5 -0
  25. data/_includes/utils/chart.html +17 -0
  26. data/_includes/utils/comment-disqus.html +0 -3
  27. data/_includes/utils/comment-gitalk.html +15 -12
  28. data/_includes/utils/google-analytics.html +6 -8
  29. data/_includes/utils/mathjax.html +10 -4
  30. data/_includes/utils/mermaid.html +5 -4
  31. data/_layouts/all.html +10 -131
  32. data/_layouts/base.html +38 -0
  33. data/_layouts/error-404.html +1 -1
  34. data/_layouts/home.html +81 -68
  35. data/_layouts/page.html +3 -3
  36. data/_layouts/post.html +32 -172
  37. data/_sass/animate/_fade-in-down.scss +10 -0
  38. data/_sass/animate/_fade-in.scss +8 -0
  39. data/_sass/colors/{_colors.chocolate.scss → _chocolate.scss} +9 -3
  40. data/_sass/colors/{_colors.dark.scss → _dark.scss} +10 -3
  41. data/_sass/colors/{_colors.default.scss → _default.scss} +10 -4
  42. data/_sass/colors/{_colors.forest.scss → _forest.scss} +9 -3
  43. data/_sass/colors/{_colors.ocean.scss → _ocean.scss} +9 -3
  44. data/_sass/colors/{_colors.orange.scss → _orange.scss} +9 -3
  45. data/_sass/common/_classes.scss +15 -0
  46. data/_sass/{settings → common}/_highlighting.scss +0 -12
  47. data/_sass/common/_reset.scss +171 -0
  48. data/_sass/common/_variables.scss +64 -0
  49. data/_sass/common/classes/_animation.scss +4 -0
  50. data/_sass/common/classes/_clearfix.scss +7 -0
  51. data/_sass/{mixins → common/classes}/_flex.scss +0 -0
  52. data/_sass/common/classes/_link.scss +161 -0
  53. data/_sass/common/classes/_media.scss +18 -0
  54. data/_sass/common/classes/_shadow.scss +14 -0
  55. data/_sass/common/classes/_shape.scss +19 -0
  56. data/_sass/common/classes/_space.scss +40 -0
  57. data/_sass/common/classes/_split-line.scss +24 -0
  58. data/_sass/common/classes/_transform.scss +4 -0
  59. data/_sass/common/classes/_transition.scss +4 -0
  60. data/_sass/common/classes/_user-select.scss +6 -0
  61. data/_sass/common/components/_button.scss +72 -0
  62. data/_sass/components/_article.content.extra.scss +41 -0
  63. data/_sass/components/_article.content.scss +127 -69
  64. data/_sass/components/_article.data.scss +11 -11
  65. data/_sass/components/_follow-me.scss +27 -34
  66. data/_sass/components/_footer.scss +4 -4
  67. data/_sass/components/_header.scss +35 -22
  68. data/_sass/components/_license.scss +7 -7
  69. data/_sass/components/_main.scss +23 -0
  70. data/_sass/components/_pagination.scss +12 -0
  71. data/_sass/components/_tags.scss +30 -15
  72. data/_sass/components/_toc.scss +32 -19
  73. data/_sass/layout/_all.scss +82 -0
  74. data/_sass/layout/_default.scss +19 -0
  75. data/_sass/{blog/_page.error-404.scss → layout/_error-404.scss} +1 -1
  76. data/_sass/layout/_home.scss +61 -0
  77. data/_sass/layout/_post.scss +80 -0
  78. data/assets/css/blog.scss +29 -34
  79. data/assets/images/logo/logo.svg +1 -1
  80. metadata +56 -38
  81. data/_includes/blog/header.html +0 -56
  82. data/_layouts/blog-base.html +0 -36
  83. data/_layouts/blog-default.html +0 -7
  84. data/_sass/base/_animate.scss +0 -19
  85. data/_sass/base/_base.scss +0 -83
  86. data/_sass/base/_image&icon.scss +0 -23
  87. data/_sass/base/_links.scss +0 -73
  88. data/_sass/base/_text.scss +0 -56
  89. data/_sass/blog/_layout.base.scss +0 -3
  90. data/_sass/blog/_layout.default.scss +0 -21
  91. data/_sass/blog/_layout.post.scss +0 -68
  92. data/_sass/blog/_page.all.scss +0 -35
  93. data/_sass/blog/_page.index.scss +0 -50
  94. data/_sass/components/_wrapper.scss +0 -29
  95. data/_sass/mixins/_link.scss +0 -67
  96. data/_sass/mixins/_media.scss +0 -12
  97. data/_sass/mixins/_prefix.scss +0 -14
  98. data/_sass/mixins/_shape.scss +0 -19
  99. data/_sass/settings/_base.scss +0 -12
  100. data/_sass/settings/_colors.scss +0 -9
  101. data/_sass/settings/_font.scss +0 -32
@@ -0,0 +1,30 @@
1
+ <script>
2
+ (function () {
3
+ var root = document.body
4
+ function classnames(classes) {
5
+ var i, cur, _classes = '';
6
+ if (window.isString(classes)) {
7
+ _classes = classes;
8
+ } else if (window.isArray(classes)) {
9
+ for (i = 0; i < classes.length; i++) {
10
+ cur = classes[i];
11
+ if (window.isString(cur)) {
12
+ _classes = _classes.concat(_classes ? ' ' + cur : cur);
13
+ }
14
+ }
15
+ } else {
16
+ return '';
17
+ }
18
+ return _classes;
19
+ }
20
+ function addClass(dom, classname) {
21
+ dom.setAttribute('class', classnames([dom.getAttribute('class'), classname]));
22
+ }
23
+ if (window.hasEvent('touchstart')) {
24
+ addClass(root, 'is-touch');
25
+ document.addEventListener("touchstart", function(){}, false);
26
+ } else {
27
+ addClass(root, 'not-touch');
28
+ }
29
+ })();
30
+ </script>
@@ -0,0 +1,27 @@
1
+ {%- assign __locale = site.data.locale.ARTICLE_LIST_DATE_FORMAT -%}
2
+ {%- include snippets/locale-to-string.html -%}
3
+ {%- assign _format = __return -%}
4
+ {%- assign post_count = site.posts | size -%}
5
+ {%- if post_count < 1 -%}
6
+ {}
7
+ {%- else -%}
8
+ {
9
+ {%- for post in site.posts -%}
10
+ {%- assign currentdate = post.date | date: '%Y' -%}
11
+ {%- if currentdate != date -%}
12
+ {%- unless forloop.first -%}],{%- endunless -%}
13
+ "{{ currentdate }}":[{
14
+ {%- assign date = currentdate -%}
15
+ {%- else -%},{
16
+ {%- endif -%}
17
+ "key":"{{ forloop.index }}","title":"{{ post.title | url_encode }}","tags":[
18
+ {%- for tag in post.tags -%}
19
+ "{{ tag | url_encode }}" {%- unless forloop.last -%},{%- endunless -%}
20
+ {%- endfor -%}
21
+ {%- assign __path = post.url -%}
22
+ {%- include snippets/prepend-baseurl.html -%}
23
+ {%- assign _url = __return -%}
24
+ ],"url":"{{ _url }}","date":"{{ post.date | date: _format }}"}
25
+ {%- endfor -%}
26
+ ]}
27
+ {%- endif -%}
@@ -0,0 +1,26 @@
1
+ {%- if site.leancloud.app_id and site.leancloud.app_key and site.leancloud.app_class and jekyll.environment != "development" -%}
2
+ {%- include snippets/get-sources.html -%}
3
+ {%- assign _sources = __return -%}
4
+ <script>
5
+ window.Lazyload.js(['{{ _sources.jquery }}', '{{ _sources.leancloud_js_sdk }}'], function() {
6
+ AV.init({
7
+ appId: '{{ site.leancloud.app_id }}',
8
+ appKey: '{{ site.leancloud.app_key }}'
9
+ });
10
+ $(".article-view").each(function() {
11
+ var curId = this.id;
12
+ var query = new AV.Query('{{ site.leancloud.app_class }}');
13
+ query.equalTo('key', curId.substr(9));
14
+ query.first().then(function(result) {
15
+ if (result) {
16
+ $('#' + curId).text(result.attributes.views);
17
+ }
18
+ }, function(error) {
19
+ if (error) {
20
+ throw error;
21
+ }
22
+ });
23
+ });
24
+ });
25
+ </script>
26
+ {%- endif -%}
@@ -0,0 +1,32 @@
1
+ {%- include snippets/get-sources.html -%}
2
+ {%- assign _sources = __return -%}
3
+ <script>
4
+ (function() {
5
+ function scrollAnimateTo(destination, duration, callback) {
6
+ var $body = $('html, body'), bodyScrollTop = $body.scrollTop();
7
+ if(bodyScrollTop === destination) { return; }
8
+ $body.animate({ scrollTop: destination }, duration, callback);
9
+ }
10
+ window.scrollTopAnchor = function(anchor, callback) {
11
+ scrollAnimateTo($(anchor).offset().top, 400, function() {
12
+ window.history.replaceState(null, '', window.location.href.split('#')[0] + anchor);
13
+ callback && callback();
14
+ });
15
+ }
16
+ })();
17
+ window.Lazyload.js('{{ _sources.jquery }}', function() {
18
+ var $articleContent = $('.m-post, .m-page').find('.m-article-content'), $this;
19
+ $articleContent.children('.highlight').each(function() {
20
+ $this = $(this);
21
+ $this.attr('data-lang', $this.find('code').attr('data-lang'));
22
+ });
23
+
24
+ $articleContent.children('h1, h2, h3, h4, h5, h6').each(function() {
25
+ $this = $(this);
26
+ $this.append($('<a class="anchor" aria-hidden="true"></a>').html('{%- include icon/link.svg -%}'));
27
+ });
28
+ $articleContent.on('click', '.anchor', function() {
29
+ window.scrollTopAnchor('#' + $(this).parent().attr('id'));
30
+ });
31
+ });
32
+ </script>
@@ -0,0 +1,183 @@
1
+ {%- assign _toc_selectors = site.toc.selectors | default: site.data.variables.default.toc.selectors -%}
2
+ {%- include snippets/get-sources.html -%}
3
+ {%- assign _sources = __return -%}
4
+ <script>
5
+ window.Lazyload.js('{{ _sources.jquery }}', function() {
6
+ var $window = $(window);
7
+ var $pageStage = $('.js-page-stage');
8
+ var $pageMain = $('.js-main');
9
+ var $pageFooter = $('.js-page-footer');
10
+ var $articleContent = $('.js-article-content');
11
+ var $articleAside = $('.js-article-aside');
12
+ var $toc = $('.js-toc');
13
+ var $col2 = $('.js-col-2');
14
+ var hasTitle = $articleContent.find('{{ _toc_selectors }}').length > 0;
15
+ function asideSticky() {
16
+ return $col2.css('display') !== 'none' && $pageStage.hasClass('has-toc');
17
+ }
18
+ function setTocClass() {
19
+ if (hasTitle) {
20
+ !$pageStage.hasClass('has-toc') && $pageStage.addClass('has-toc');
21
+ }
22
+ }
23
+ function setAsideTOC() {
24
+ var asideTop, asideLeft, scrollBottom, asideBottomTop, lastScrollTop;
25
+ function init() {
26
+ var asideOffset = $articleAside.offset();
27
+ var footerOffset = $pageFooter.offset();
28
+ var mainOffset = $pageMain.offset();
29
+ asideTop = mainOffset.top;
30
+ asideHeight = $toc.outerHeight() + parseInt($articleAside.css('padding-top'), 10) + parseInt($articleAside.css('padding-bottom'), 10);
31
+ asideLeft = mainOffset.left + $pageMain.outerWidth() - $articleAside.outerWidth() - parseInt($pageMain.css('padding-right'), 10);
32
+ scrollBottom = footerOffset.top - asideHeight;
33
+ asideBottomTop = scrollBottom - mainOffset.top;
34
+ }
35
+ function setAside(force) {
36
+ force !== true && (force = false);
37
+ var scrollTop = $window.scrollTop();
38
+ if (scrollTop >= asideTop && scrollTop <= scrollBottom) {
39
+ (!force && lastScrollTop >= asideTop && lastScrollTop <= scrollBottom) ||
40
+ $articleAside.addClass('fixed').css({
41
+ left: asideLeft + 'px',
42
+ top: 0
43
+ });
44
+ } else if (scrollTop < asideTop) {
45
+ (!force && lastScrollTop < asideTop) ||
46
+ $articleAside.removeClass('fixed').css({
47
+ left: 0,
48
+ top: 0
49
+ });
50
+ } else {
51
+ (!force && lastScrollTop > scrollBottom) ||
52
+ $articleAside.removeClass('fixed').css({
53
+ left: 0,
54
+ top: asideBottomTop + 'px'
55
+ });
56
+ }
57
+ lastScrollTop = scrollTop;
58
+ }
59
+ asideSticky() && (init(), setAside());
60
+ $window.on('scroll', function() {
61
+ asideSticky() && setAside();
62
+ });
63
+ $window.on('resize', window.throttle(function() {
64
+ setTocClass();
65
+ asideSticky() && (init(), setAside(true));
66
+ }, 100));
67
+ setTimeout(init, 4000);
68
+ }
69
+ function toc() {
70
+ var $tocUl = $('<ul></ul>'), $tocLi, $headings = $articleContent.find('{{ _toc_selectors }}'), headingsTop = [],
71
+ scrolling, activeLast, activeCur, rendered = false;
72
+ function init() {
73
+ $headings.each(function() {
74
+ headingsTop.push(Math.floor($(this).offset().top));
75
+ });
76
+ }
77
+ function setActiveHeading(element, disabled) {
78
+ var scrollTop = $window.scrollTop(), i;
79
+ if (disabled || headingsTop.length < 1) { return; }
80
+ if (element) {
81
+ activeCur = element;
82
+ } else {
83
+ for (i = 0; i < headingsTop.length; i++) {
84
+ if (scrollTop >= headingsTop[i]) {
85
+ activeCur = $tocLi.eq(i);
86
+ } else {
87
+ activeCur || (activeCur = $tocLi.eq(i));
88
+ break;
89
+ }
90
+ }
91
+ }
92
+ activeLast && activeLast.removeClass('toc-active');
93
+ (activeLast = activeCur).addClass('toc-active');
94
+ }
95
+ function render() {
96
+ $toc.append($tocUl);
97
+ $headings.each(function() {
98
+ var $this = $(this);
99
+ $tocUl.append($('<li></li>').addClass('toc-' + $this.prop("tagName").toLowerCase())
100
+ .append($('<a></a>').text($this.text()).attr('href', '#' + $this.prop('id'))));
101
+ });
102
+ $tocLi = $tocUl.children('li');
103
+ $tocUl.on('click', 'a', function(e) {
104
+ e.preventDefault();
105
+ var $this = $(this);
106
+ scrolling = true;
107
+ setActiveHeading($this.parent());
108
+ window.scrollTopAnchor($this.attr('href'), function() {
109
+ scrolling = false;
110
+ });
111
+ });
112
+ rendered = true;
113
+ }
114
+ asideSticky() && (render(), $window.on('load', function() {
115
+ setTimeout(function() {
116
+ init();
117
+ setActiveHeading(null, scrolling);
118
+ }, 1000);
119
+ }));
120
+ $window.on('resize', window.throttle(function() {
121
+ if (asideSticky()) {
122
+ rendered || render();
123
+ init();
124
+ setActiveHeading(null, scrolling);
125
+ }
126
+ }));
127
+ $window.on('scroll', function() {
128
+ asideSticky() && setActiveHeading(null, scrolling);
129
+ });
130
+ }
131
+ setTocClass();
132
+ toc();
133
+ setTimeout(function() {
134
+ setAsideTOC();
135
+ }, 1000);
136
+ });
137
+
138
+ {%- if page.key and site.leancloud.app_id and site.leancloud.app_key and site.leancloud.app_class and jekyll.environment != "development" -%}
139
+ window.Lazyload.js(['{{ _sources.jquery }}', '{{ _sources.leancloud_js_sdk }}'], function() {
140
+ AV.init({
141
+ appId: '{{ site.leancloud.app_id }}',
142
+ appKey: '{{ site.leancloud.app_key }}'
143
+ });
144
+ var query = new AV.Query('{{ site.leancloud.app_class }}');
145
+ query.equalTo('key', '{{ page.key }}');
146
+ query.first().then(function(result) {
147
+ if (result) {
148
+ addOne(result)
149
+ } else {
150
+ var Blog = AV.Object.extend('{{ site.leancloud.app_class }}');
151
+ var blog = new Blog();
152
+ blog.set('title', '{{ page.title }}');
153
+ blog.set('key', '{{ page.key }}');
154
+ blog.set('views', 0);
155
+ blog.save().then(function(page) {
156
+ addOne(page)
157
+ }, function(error) {
158
+ if (error) {
159
+ throw error;
160
+ }
161
+ });
162
+ }
163
+
164
+ function addOne(page) {
165
+ page.increment('views', 1);
166
+ page.save(null, {
167
+ fetchWhenSave: true
168
+ }).then(function(page) {
169
+ $("#post-key-{{ page.key }}").text(page.attributes.views);
170
+ }, function(error) {
171
+ if (error) {
172
+ throw error;
173
+ }
174
+ });
175
+ }
176
+ }, function(error) {
177
+ if (error) {
178
+ throw error;
179
+ }
180
+ });
181
+ });
182
+ {%- endif -%}
183
+ </script>
@@ -0,0 +1,180 @@
1
+ <script>
2
+ window.isArray = function(val) {
3
+ return Object.prototype.toString.call(val) === '[object Array]';
4
+ };
5
+ window.isString = function(val) {
6
+ return typeof val === 'string';
7
+ };
8
+ window.Lazyload = (function(doc) {
9
+ var queue = {js: [], css: []}, sources = {js: {}, css: {}}, context = this;
10
+ var Set = (function() {
11
+ var add = function(item) {
12
+ var i, data = this._data;
13
+ for (i = 0; i < data.length; i++) {
14
+ if (data[i] === item) {
15
+ return;
16
+ }
17
+ }
18
+ this.size ++;
19
+ data.push(item);
20
+ return data;
21
+ }
22
+
23
+ var Set = function(data) {
24
+ this.size = 0;
25
+ this._data = [];
26
+ if (data.length > 0) {
27
+ for (i = 0; i < data.length; i++) {
28
+ add.call(this, data[i]);
29
+ }
30
+ }
31
+ }
32
+ Set.prototype.add = add;
33
+ Set.prototype.get = function(index) { return this._data[index]; };
34
+ Set.prototype.has = function(item) {
35
+ var i, data = this._data;
36
+ for (i = 0; i < data.length; i++) {
37
+ if (this.get(i) === item) {
38
+ return true;
39
+ }
40
+ }
41
+ return false;
42
+ };
43
+ Set.prototype.is = function(map) {
44
+ if (map._data.length !== this._data.length) { return false; }
45
+ var i, j, flag, tData = this._data, mData = map._data;
46
+ for (i = 0; i < tData.length; i++) {
47
+ for (flag = false, j = 0; j < mData.length; j++) {
48
+ if (tData[i] === mData[j]) {
49
+ flag = true;
50
+ break;
51
+ }
52
+ }
53
+ if (!flag) { return false; }
54
+ }
55
+ return true;
56
+ };
57
+ Set.prototype.values = function() {
58
+ return this._data;
59
+ };
60
+ return Set;
61
+ })();
62
+
63
+ var createNode = function(name, attrs) {
64
+ var node = doc.createElement(name), attr;
65
+ for (attr in attrs) {
66
+ if (attrs.hasOwnProperty(attr)) {
67
+ node.setAttribute(attr, attrs[attr]);
68
+ }
69
+ }
70
+ return node;
71
+ }
72
+ var end = function(type, url, urls) {
73
+ var s, q, qi, cbs, i, j, cur,
74
+ val, flag;
75
+ if (type === 'js' || type ==='css') {
76
+ s = sources[type], q = queue[type];
77
+ s[url] = true;
78
+ for (i = 0; i < q.length; i++) {
79
+ cur = q[i];
80
+ if (cur.urls.has(url)) {
81
+ qi = cur, val = qi.urls.values();
82
+ qi && (cbs = qi.callbacks);
83
+ for (flag = true, j = 0; j < val.length; j++) {
84
+ cur = val[j]
85
+ if (!s[cur]) {
86
+ flag = false;
87
+ }
88
+ }
89
+ if (flag && cbs && cbs.length > 0) {
90
+ for (j = 0; j < cbs.length; j++) {
91
+ cbs[j].call(context);
92
+ }
93
+ qi.load = true;
94
+ }
95
+ }
96
+ }
97
+ }
98
+ };
99
+ var load = function(type, urls, callback) {
100
+ var s, si, q, qi, node, i, cur, flag,
101
+ _urls = typeof urls === 'string' ? new Set([urls]) : new Set(urls), val, url;
102
+ if (type === 'js' || type ==='css') {
103
+ s = sources[type], q = queue[type];
104
+ for (i = 0; i < q.length; i++) {
105
+ cur = q[i];
106
+ if (_urls.is(cur.urls)) {
107
+ qi = cur;
108
+ break;
109
+ }
110
+ }
111
+ val = _urls.values();
112
+ if (qi) {
113
+ callback && (qi.load || qi.callbacks.push(callback));
114
+ callback && (qi.load && callback());
115
+ } else {
116
+ q.push({
117
+ urls: _urls,
118
+ callbacks: callback ? [callback] : [],
119
+ load: false
120
+ });
121
+ for (i = 0; i < val.length; i++) {
122
+ node = null, url = val[i];
123
+ if (s[url] === undefined) {
124
+ (type === 'js' ) && (node = createNode('script', { src: url }));
125
+ (type === 'css') && (node = createNode('link', { rel: 'stylesheet', href: url }));
126
+ if (node) {
127
+ node.onload = (function(type, url) {
128
+ return function() {
129
+ end(type, url);
130
+ }
131
+ })(type, url);
132
+ (doc.head || doc.body).appendChild(node);
133
+ s[url] = false;
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+ };
140
+ return {
141
+ js: function(url, callback) {
142
+ load('js', url, callback);
143
+ },
144
+ css: function(url, callback) {
145
+ load('css', url, callback);
146
+ }
147
+ };
148
+ })(this.document);
149
+
150
+ window.throttle = function(func, wait) {
151
+ var args, result, thisArg, timeoutId, lastCalled = 0;
152
+
153
+ function trailingCall() {
154
+ lastCalled = new Date;
155
+ timeoutId = null;
156
+ result = func.apply(thisArg, args);
157
+ }
158
+ return function() {
159
+ var now = new Date,
160
+ remaining = wait - (now - lastCalled);
161
+
162
+ args = arguments;
163
+ thisArg = this;
164
+
165
+ if (remaining <= 0) {
166
+ clearTimeout(timeoutId);
167
+ timeoutId = null;
168
+ lastCalled = now;
169
+ result = func.apply(thisArg, args);
170
+ } else if (!timeoutId) {
171
+ timeoutId = setTimeout(trailingCall, remaining);
172
+ }
173
+ return result;
174
+ };
175
+ };
176
+
177
+ window.hasEvent = function(event) {
178
+ return 'on'.concat(event) in window.document;
179
+ }
180
+ </script>