jekyll-zeta 0.7.5.1 → 0.9.1

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.
data/_includes/heatmap.js CHANGED
@@ -1,307 +1,350 @@
1
- ;!function(){
2
-
3
- function date2ymd(t){
4
- let m = t.getMonth() + 1;
5
- let d = t.getDate()
6
- return `${t.getFullYear()}-${m< 10 ? '0' + m : m }-${d<10 ? '0'+d:d}`
7
- }
8
-
9
-
10
- const dateEnd = new Date();
11
- const endStamp = dateEnd.getTime()
12
- const dayEleId = Math.random().toString(16).substring(2);
13
- let arr = _allyearurl.split('/');
14
- arr.pop();
15
- const jsonUrlBase = arr.join('/')
16
-
17
-
18
- const ColumnsCount = 53;
19
- const RowCount = 7;
20
- const DayCount = (ColumnsCount - 1) * RowCount + dateEnd.getDay() + 1;
21
-
22
- !function fillData(){
23
- let year = '' + dateEnd.getFullYear()
24
- let preYear = '' + (year - 1)
25
- fetch(_allyearurl)
26
- .then(r => r.json())
27
- .then(d=>{
28
- let yearCfg = d ;
29
- let arr = []
30
- if (yearCfg[year]) {
31
- arr.push(getYearData(year ))
32
- }
33
-
34
- if (yearCfg[preYear]) {
35
- arr.push(getYearData(preYear ))
36
- }
37
- Promise.all(arr).then(alldata=>{
38
- let combineData = {};
39
- let d1 = alldata[0];
40
- let d2 = alldata[1];
41
-
42
- for (const key in d1) {
43
- if (Object.prototype.hasOwnProperty.call(d1, key)) {
44
- const element = d1[key];
45
- let keyNew = 'K1-' + key;
46
- combineData[keyNew] = element
47
- }
48
- }
49
-
50
- for (const key in d2) {
51
- if (Object.prototype.hasOwnProperty.call(d2, key)) {
52
- const element = d2[key];
53
- let keyNew = 'K2-' + key;
54
- combineData[keyNew] = element
55
- }
56
- }
57
-
58
-
59
- updateCell(combineData);
60
- })
61
- })
62
-
63
- function getIndex(ymd){
64
- return DayCount - Math.floor((endStamp - new Date(ymd).getTime())/ (24 * 3600000)) -1
65
- }
1
+ ;!(function () {
66
2
 
67
- function idx2Ymd(idx){
68
- let t = new Date(endStamp - ( (DayCount - 1) - idx) * 3600000 * 24)
69
- let m = t.getMonth() + 1
70
- let d = t.getDate()
71
- return `${t.getFullYear()}-${m< 10 ? '0' + m : m }-${d<10 ? '0'+d:d}`
3
+ var GDATA = window._G_DATA;
4
+ if (!GDATA) {
5
+ GDATA = {}
6
+ window._G_DATA = GDATA
72
7
  }
73
8
 
74
- function updateCell(data){
75
- if(!data)return
76
-
77
- console.log(data)
78
-
79
- let daysEle = document.getElementById(dayEleId)
80
- let dayCells = daysEle.childNodes
81
-
82
- let Map = {}
83
-
84
- for (const key in data) {
85
- if (Object.prototype.hasOwnProperty.call(data, key)) {
86
- const element = data[key];
87
- if(Array.isArray(element)){
88
- element.forEach(e=>{
89
- if(e.date && e.title && e.url){
90
- let arr = Map[e.date]
91
- if (!arr) {
92
- arr = []
93
- Map[e.date] = arr
94
- }
95
- arr.push(e)
96
- }
97
- })
98
- }
99
- }
100
- }
101
-
102
9
 
10
+ function date2ymd(t) {
11
+ let m = t.getMonth() + 1;
12
+ let d = t.getDate();
13
+ return `${t.getFullYear()}-${m < 10 ? "0" + m : m}-${d < 10 ? "0" + d : d}`;
14
+ }
103
15
 
104
- let ymdArr = []
16
+ const dateEnd =
17
+ endYear && endYear.length == 4 ? new Date(`${endYear}-12-31`) : new Date();
105
18
 
106
- for (const dateKeyYmd in Map) {
107
- if (Object.prototype.hasOwnProperty.call(Map, dateKeyYmd)) {
108
- ymdArr.push(dateKeyYmd)
109
- }
110
- }
19
+ const endStamp = dateEnd.getTime();
20
+ const dayEleId = Math.random().toString(16).substring(2);
21
+ let arr = _allyearurl.split("/");
22
+ arr.pop();
23
+ const jsonUrlBase = arr.join("/");
111
24
 
25
+ const ColumnsCount = 53;
26
+ const RowCount = 7;
27
+ const DayCount = (ColumnsCount - 1) * RowCount + dateEnd.getDay() + 1;
112
28
 
113
- var G_idxOfDay = DayCount - 1;
29
+ let queue = window._y_queue || []
30
+ window._y_queue = queue;
31
+
114
32
 
115
- function shuffle(array) {
116
- let currentIndex = array.length;
33
+ function getAllYearCfg(){
117
34
 
118
- // While there remain elements to shuffle...
119
- while (currentIndex != 0) {
120
35
 
121
- // Pick a remaining element...
122
- let randomIndex = Math.floor(Math.random() * currentIndex);
123
- currentIndex--;
124
-
125
- // And swap it with the current element.
126
- [array[currentIndex], array[randomIndex]] = [
127
- array[randomIndex], array[currentIndex]];
128
- }
36
+ if (GDATA['_allYear']) {
37
+ return GDATA['_allYear'];
129
38
  }
130
39
 
131
- const SEQ = new Array(DayCount)
132
- let tmp = DayCount
133
- while (tmp -- > 0) {
134
- SEQ[tmp] = tmp
40
+ if (window._isFetchAllYearData == 1) {
41
+ return new Promise(r=>{
42
+ queue.push(r);
43
+ })
135
44
  }
136
45
 
137
- shuffle(SEQ)
138
-
139
- function update1Day(){
140
- if (G_idxOfDay < 0) {
141
- return
142
- }
143
- const idxOfDay = SEQ[G_idxOfDay --];
144
-
145
- let dateKeyYmd = idx2Ymd(idxOfDay )
146
-
147
-
148
- let arrPostInOneDay = Map[dateKeyYmd];
149
- // debug
150
- arrPostInOneDay = arrPostInOneDay
151
-
152
-
153
- const dayCell = dayCells[idxOfDay]
154
- const nobg = parseInt(dateKeyYmd.substring(5,7))%2 == 1? 'hm-check-no-b' : 'hm-check-no-a';
155
- dayCell.classList = `heatmap-day-cell ${!arrPostInOneDay ? nobg :arrPostInOneDay.length > 1 ? 'hm-check2' : 'hm-check' }`
156
-
157
-
158
- if ((arrPostInOneDay && arrPostInOneDay.length > 0 )) {
159
-
160
-
161
- let isDirectly = arrPostInOneDay.length == 1
162
- let tip = document.createElement("div");
163
-
164
- if (isDirectly) {
165
- let lnk = document.createElement('a');
166
- lnk.href = arrPostInOneDay[0].url
167
- dayCell.appendChild(lnk)
46
+
47
+ window._isFetchAllYearData = 1;
48
+ return fetch(_allyearurl)
49
+ .then((r) => r.json())
50
+ .then(d => {
51
+ window._isFetchAllYearData = 0;
52
+ if (queue.length) {
53
+ queue.forEach(calback=>{calback(d)});
54
+ queue.length = 0;
55
+ }
56
+ GDATA['_allYear'] = d ;return d ;})
57
+ }
58
+ !(function fillData() {
59
+ let year = "" + dateEnd.getFullYear();
60
+ let preYear = "" + (year - 1);
61
+ getAllYearCfg()
62
+ .then((d) => {
63
+ let yearCfg = d;
64
+ let arr = [];
65
+ if (yearCfg[year]) {
66
+ arr.push(getYearData(year));
168
67
  }
169
68
 
170
- tip.className = "hm-tip";
171
- let desc = ''
172
- arrPostInOneDay.forEach(element => {
173
-
174
- let lnk = document.createElement('a');
175
- lnk.className = 'hm-tiplink'
176
- lnk.href = element.url
177
- tip.appendChild(lnk)
178
-
179
- let t = document.createElement('span')
180
- t.className = 'hm-date'
181
- t.innerText = dateKeyYmd.substring(5);
182
- lnk.appendChild(t);
69
+ if (yearCfg[preYear]) {
70
+ arr.push(getYearData(preYear));
71
+ }
72
+ Promise.all(arr).then((alldata) => {
73
+ let combineData = {};
74
+ let d1 = alldata[0];
75
+ let d2 = alldata[1];
76
+
77
+ for (const key in d1) {
78
+ if (Object.prototype.hasOwnProperty.call(d1, key)) {
79
+ const element = d1[key];
80
+ let keyNew = "K1-" + key;
81
+ combineData[keyNew] = element;
82
+ }
83
+ }
183
84
 
184
-
185
- let t2 = document.createElement('span')
186
- t2.className = 'hm-title'
187
- t2.innerText = element.title
188
- lnk.appendChild(t2);
85
+ for (const key in d2) {
86
+ if (Object.prototype.hasOwnProperty.call(d2, key)) {
87
+ const element = d2[key];
88
+ let keyNew = "K2-" + key;
89
+ combineData[keyNew] = element;
90
+ }
91
+ }
189
92
 
93
+ updateCell(combineData);
190
94
  });
191
- dayCell.appendChild(tip);
192
-
193
- }
194
-
95
+ });
96
+
97
+ function getIndex(ymd) {
98
+ return (
99
+ DayCount -
100
+ Math.floor((endStamp - new Date(ymd).getTime()) / (24 * 3600000)) -
101
+ 1
102
+ );
195
103
  }
196
104
 
197
-
198
- function updateMultiDays(){
199
- let day = heatMapLoadCount;
200
- while (day -- ) {
201
- update1Day();
202
- }
203
-
204
- if (G_idxOfDay >= 0) {
205
- requestAnimationFrame(updateMultiDays)
206
- }
207
-
105
+ function idx2Ymd(idx) {
106
+ let t = new Date(endStamp - (DayCount - 1 - idx) * 3600000 * 24);
107
+ let m = t.getMonth() + 1;
108
+ let d = t.getDate();
109
+ return `${t.getFullYear()}-${m < 10 ? "0" + m : m}-${
110
+ d < 10 ? "0" + d : d
111
+ }`;
208
112
  }
209
- requestAnimationFrame(updateMultiDays)
210
-
211
- return
212
-
213
-
214
-
215
-
216
113
 
217
- }
114
+ function updateCell(data) {
115
+ if (!data) return;
218
116
 
219
-
220
117
 
221
- function getYearData(year){
222
- return fetch(`${jsonUrlBase}/${year}.json`)
223
- .then(r => r.json())
224
- .catch(e=>{
225
- return null
226
- })
118
+ let daysEle = document.getElementById(dayEleId);
119
+ let dayCells = daysEle.childNodes;
227
120
 
228
- }
121
+ let Map = {};
229
122
 
123
+ for (const key in data) {
124
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
125
+ const element = data[key];
126
+ if (Array.isArray(element)) {
127
+ element.forEach((e) => {
128
+ if (e.date && e.title && e.url) {
129
+ let arr = Map[e.date];
130
+ if (!arr) {
131
+ arr = [];
132
+ Map[e.date] = arr;
133
+ }
134
+ arr.push(e);
135
+ }
136
+ });
137
+ }
138
+ }
139
+ }
230
140
 
141
+ let ymdArr = [];
231
142
 
232
-
233
- }()
143
+ for (const dateKeyYmd in Map) {
144
+ if (Object.prototype.hasOwnProperty.call(Map, dateKeyYmd)) {
145
+ ymdArr.push(dateKeyYmd);
146
+ }
147
+ }
234
148
 
149
+ var G_idxOfDay = DayCount - 1;
235
150
 
151
+ function shuffle(array) {
152
+ let currentIndex = array.length;
236
153
 
237
- ;(function initMap(){
154
+ // While there remain elements to shuffle...
155
+ while (currentIndex != 0) {
156
+ // Pick a remaining element...
157
+ let randomIndex = Math.floor(Math.random() * currentIndex);
158
+ currentIndex--;
238
159
 
239
- let Father = document.getElementById("heatmap");
160
+ // And swap it with the current element.
161
+ [array[currentIndex], array[randomIndex]] = [
162
+ array[randomIndex],
163
+ array[currentIndex],
164
+ ];
165
+ }
166
+ }
240
167
 
241
- const Frag = document.createDocumentFragment();
168
+ const SEQ = new Array(DayCount);
169
+ let tmp = DayCount;
170
+ while (tmp-- > 0) {
171
+ SEQ[tmp] = tmp;
172
+ }
242
173
 
243
- const monthEle = document.createElement("div");
244
- monthEle.className = "heatmap-month";
245
- Frag.appendChild(monthEle);
246
- const monthStr = _MonthStr.split(" ");
174
+ shuffle(SEQ);
247
175
 
176
+ function update1Day() {
177
+ if (G_idxOfDay < 0) {
178
+ return;
179
+ }
180
+ const idxOfDay = SEQ[G_idxOfDay--];
181
+ let dateKeyYmd = idx2Ymd(idxOfDay);
182
+ let arrPostInOneDay = Map[dateKeyYmd];
183
+ const dayCell = dayCells[idxOfDay];
184
+ const nobg =
185
+ parseInt(dateKeyYmd.substring(5, 7)) % 2 == 1
186
+ ? "hm-check-no-b"
187
+ : "hm-check-no-a";
188
+ dayCell.classList = `heatmap-day-cell ${
189
+ !arrPostInOneDay
190
+ ? nobg
191
+ : arrPostInOneDay.length > 1
192
+ ? "hm-check2"
193
+ : "hm-check"
194
+ }`;
195
+
196
+ if (arrPostInOneDay && arrPostInOneDay.length > 0) {
197
+ let isDirectly = arrPostInOneDay.length == 1;
198
+ let tip = document.createElement("div");
199
+
200
+ if (isDirectly) {
201
+ let lnk = document.createElement("a");
202
+ lnk.href = arrPostInOneDay[0].url;
203
+ dayCell.appendChild(lnk);
204
+ }
205
+
206
+ tip.className = "hm-tip";
207
+ let desc = "";
208
+ arrPostInOneDay.forEach((element) => {
209
+ let lnk = document.createElement("a");
210
+ lnk.className = "hm-tiplink";
211
+ lnk.href = element.url;
212
+ tip.appendChild(lnk);
213
+
214
+ let t = document.createElement("span");
215
+ t.className = "hm-date";
216
+ t.innerText = dateKeyYmd.substring(5);
217
+ lnk.appendChild(t);
218
+
219
+ let t2 = document.createElement("span");
220
+ t2.className = "hm-title";
221
+ t2.innerText = element.title;
222
+ lnk.appendChild(t2);
223
+ });
224
+ dayCell.appendChild(tip);
225
+ }
226
+ }
248
227
 
249
- let nowM = dateEnd.getMonth();
250
- let nowWeek = dateEnd.getDay();
228
+ function updateMultiDays() {
229
+ let day = heatMapLoadCount;
230
+ if (!day || day <= 0) {
231
+ day = 8;
232
+ }
233
+ while (day--) {
234
+ update1Day();
235
+ }
251
236
 
237
+ if (G_idxOfDay >= 0) {
238
+ requestAnimationFrame(updateMultiDays);
239
+ }
240
+ }
241
+ requestAnimationFrame(updateMultiDays);
252
242
 
253
- for (let i = 0; i < monthStr.length ; i++) {
254
- let m = document.createElement("span");
255
- m.className = "heatmap-month-cell";
256
- m.innerHTML = `${monthStr[(i + nowM + 1) % 12]}`;
257
- monthEle.appendChild(m);
258
- }
243
+ return;
244
+ }
259
245
 
260
- const weekEle = document.createElement("div");
261
- weekEle.className = "heatmap-week";
262
- const WeekStr = _showWeek.split(" ");
246
+ function getYearData(year) {
247
+ year = '' + year
263
248
 
264
- for (let i = 0; i < WeekStr.length; i++) {
265
- let m = document.createElement("div");
266
- m.className = "heatmap-week-cell";
267
- m.innerHTML = `<span>${WeekStr[i]}</span>`;
268
- weekEle.appendChild(m);
269
- }
249
+
250
+ if(GDATA[year]){
270
251
 
271
- Frag.appendChild(weekEle);
252
+ return GDATA[year]
253
+ }
272
254
 
273
- const dayEle = document.createElement("div");
255
+ let queueFlgKey = '_singleyearFlg' + year
256
+ let queueArrKey = '_singleyearQueue' + year
257
+ if (GDATA[queueFlgKey] == 1) {
258
+ // console.log('put in queue',year,Math.random())
259
+ let arrQueue = GDATA[queueArrKey]
260
+ if (!arrQueue) {
261
+ arrQueue = []
262
+ GDATA[queueArrKey] = arrQueue;
263
+ }
264
+
265
+ return new Promise(r=>{
266
+ arrQueue.push(r);
267
+ });
268
+ }
274
269
 
275
- dayEle.className = "heatmap-day";
276
- dayEle.id = dayEleId;
277
270
 
271
+ GDATA[queueFlgKey] = 1;
272
+ // console.log('RealQuery',year,Math.random())
273
+ return fetch(`${jsonUrlBase}/${year}.json`)
274
+ .then((r) => r.json())
275
+ .then(d=>{
276
+ GDATA[queueFlgKey] = 0 ;GDATA[year] = d;
277
+ let queue = GDATA[queueArrKey];
278
+ // console.log('queryFinish',year)
279
+ if(queue && queue.length){
280
+ queue.forEach(cb=>{
281
+ // console.log('queryFinishQueue',year,queue.length,Math.random());
282
+ cb(d);})
283
+ queue.length = 0;
284
+ GDATA[queueArrKey] = undefined
285
+ }
286
+
287
+ return d})
288
+ .catch((e) => {
289
+ return null;
290
+ });
291
+ }
292
+ })();
293
+ (function initMap() {
294
+ let Father = document.getElementById(heatmapid);
278
295
 
279
- let firstDateDayDiff = (ColumnsCount - 1) * RowCount + nowWeek;
296
+ const Frag = document.createDocumentFragment();
280
297
 
298
+ const monthEle = document.createElement("div");
299
+ monthEle.className = "heatmap-month";
300
+ Frag.appendChild(monthEle);
301
+ const monthStr = _MonthStr.split(" ");
281
302
 
282
- console.log(nowWeek, firstDateDayDiff);
303
+ let nowM = dateEnd.getMonth();
304
+ let nowWeek = dateEnd.getDay();
283
305
 
284
- for (let c = 0; c < ColumnsCount; c++) {
285
- for (let r = 0; r < RowCount; r++) {
286
- if (r > nowWeek && c == ColumnsCount - 1) {
287
- break
306
+ for (let i = 0; i < monthStr.length; i++) {
307
+ let m = document.createElement("span");
308
+ m.className = "heatmap-month-cell";
309
+ m.innerHTML = `${monthStr[(i + nowM + 1) % 12]}`;
310
+ monthEle.appendChild(m);
288
311
  }
289
312
 
290
- let m = document.createElement("span");
291
- m.classList = `heatmap-day-cell hm-check-nodata`
292
- dayEle.appendChild(m);
293
- }
294
- }
313
+ const weekEle = document.createElement("div");
314
+ weekEle.className = "heatmap-week";
315
+ const WeekStr = _showWeek.split(" ");
295
316
 
317
+ for (let i = 0; i < WeekStr.length; i++) {
318
+ let m = document.createElement("div");
319
+ m.className = "heatmap-week-cell";
320
+ m.innerHTML = `<span>${WeekStr[i]}</span>`;
321
+ weekEle.appendChild(m);
322
+ }
296
323
 
297
- Frag.appendChild(dayEle);
298
- Father.append(Frag);
299
- })()
324
+ Frag.appendChild(weekEle);
300
325
 
326
+ const dayEle = document.createElement("div");
301
327
 
328
+ dayEle.className = "heatmap-day";
329
+ dayEle.id = dayEleId;
302
330
 
331
+ let firstDateDayDiff = (ColumnsCount - 1) * RowCount + nowWeek;
303
332
 
333
+ // console.log(nowWeek, firstDateDayDiff);
304
334
 
305
- }();
335
+ for (let c = 0; c < ColumnsCount; c++) {
336
+ for (let r = 0; r < RowCount; r++) {
337
+ if (r > nowWeek && c == ColumnsCount - 1) {
338
+ break;
339
+ }
306
340
 
341
+ let m = document.createElement("span");
342
+ m.classList = `heatmap-day-cell hm-check-nodata`;
343
+ dayEle.appendChild(m);
344
+ }
345
+ }
307
346
 
347
+ Frag.appendChild(dayEle);
348
+ Father.append(Frag);
349
+ })();
350
+ })();
data/_includes/home.html CHANGED
@@ -1,13 +1,12 @@
1
-
2
-
3
-
4
- {%- include heatmap.html -%}
5
-
6
-
7
1
  {%- assign titlelen = page.title.size -%}
8
2
  {%- if titlelen > 0 -%}
9
3
  <h2>{{ page.title }}</h2>
10
4
  {%- endif -%}
5
+
6
+ {%- include heatmap.html -%}
7
+
8
+
9
+
11
10
  {%-assign nextPage = site.paginate_path | replace: ':num', '2' -%}
12
11
 
13
12
 
@@ -0,0 +1,39 @@
1
+ <div class="sidebar">
2
+ <div class="sidecontent">
3
+ {%- capture currentUrl -%}{{ page.url | relative_url}}{%- endcapture %}
4
+ <img src="{{'assets/image/avartar.png' | relative_url }}" class="avatar"/>
5
+
6
+
7
+ <nav>
8
+ <ul class="navul">
9
+ {%-for item in site.theme_config.menu %}
10
+
11
+ {%- if item.url -%}
12
+ {%- capture itemurl -%}{{ item.url | relative_url}}{%- endcapture -%}
13
+
14
+ {%- assign iscurrent= false %}
15
+ {%- if currentUrl == itemurl -%}
16
+ {%- assign iscurrent= true %}
17
+ {%- else -%}
18
+ {%- for subpath in item.subpath %}
19
+ {%- if currentUrl contains subpath %}
20
+ {%- assign iscurrent= true %}
21
+ {%- break %}
22
+ {%- endif %}
23
+ {%- endfor %}
24
+ {%- endif %}
25
+ <li class="{% if iscurrent == true -%}navli curNav{%-else -%}navli{%- endif -%}">
26
+
27
+ <a href="{{ itemurl }}" class="nav">{{ item.title }}</a>
28
+
29
+ {%- else -%}
30
+ {{ item.title }}
31
+ {%- endif -%}
32
+ </li>
33
+ {%-endfor-%}
34
+ </ul>
35
+ </nav>
36
+
37
+
38
+ </div>
39
+ </div>
@@ -0,0 +1,20 @@
1
+ <header>
2
+ {%- include navbar_left.html -%}
3
+ </header>
4
+ <section class="rightsidecontent">
5
+ <div class="w">
6
+
7
+ {{ content }}
8
+
9
+ {%- assign footnote = site.theme_config.show_footnote -%}
10
+ {%- if footnote == true -%}
11
+
12
+ <footer class="footer">
13
+ <p> Powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/vitock/jekyll-zeta">Jekyll-zeta</a>
14
+ </p>
15
+ </footer>
16
+ {%- endif -%}
17
+
18
+
19
+ </div>
20
+ </section>