jekyll-zeta 0.7.1 → 0.7.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 919077f0e2679d399ca69e89c32b77b4564f1b2f8e81b20b31eb681f5f59d5b0
4
- data.tar.gz: 32ccee6ae73513ba00f818f1b3d47b5eb7eec2060eff0ab53e0fc0730075a4ad
3
+ metadata.gz: 355269c9bb3e0eb724d648b8841875bc45026fa10b6173a17236940fb225e2d0
4
+ data.tar.gz: 7960a7083bb100e9cb89c4517fa8a26a15f864f8d243a23291b36096034b0a17
5
5
  SHA512:
6
- metadata.gz: 9b22c45cd8bb3e0611f4db3faab73b7297379bdc575c48838e51a0a587d25bb758c06b42b27b84fbeadd328d0033c2094e9cefacb765b68037c97b2c4997d22a
7
- data.tar.gz: f8a182e18e976e2f9b08d00cf954cf8e5fa0a3451f92b876d595911e46fdfab37f562266764f0a6857d359fe18d67a99d3dc25eda4b472204429a3d159510227
6
+ metadata.gz: faa4c3db616777ece4b3b80097f0ea0bddf5d32d9157bb813d6f0f48ebc82db47f7ca651aa60fa4ee6766dde31ef6d730b37f010f646c5f4fbfe05f6a79750cd
7
+ data.tar.gz: e17428da2bb51de98dd6547c2cc1ff4b283d1dad835f784412f6dbb687136c102f0dbff78a46874d95dae0099958ad7c670da42758d1300db1184c16465a29cd
@@ -4,29 +4,6 @@
4
4
  {%- assign posts = site.posts -%}
5
5
  {%- endif -%}
6
6
 
7
- {%- assign jsstr='' -%}
8
- {%- for post in posts limit: include.limit -%}
9
-
10
-
11
-
12
- {%- capture url -%}
13
- {{ post.url | relative_url }}
14
- {%- endcapture -%}
15
-
16
- {%- capture postdate -%}
17
- {{ post.date | date: '%Y-%m-%d' }}
18
- {%- endcapture -%}
19
-
20
-
21
- {%- capture posttitlex -%}
22
- {{ post.title | replace: '"'," "}}
23
- {%- endcapture -%}
24
-
25
-
26
- {%- capture jsstr -%}
27
- {{ jsstr | append: url | append:"\x01" | append: posttitlex | append:"\x01" | append: postdate | append:"\n" }}
28
- {%- endcapture -%}
29
- {%- endfor -%}
30
7
  <div>
31
8
  <span class="heatmap-title">{{ heatMapTitle | site.theme_config.heatMapTitle }}</span>
32
9
  <div class='heatmap' id="heatmap">
@@ -36,7 +13,7 @@
36
13
  </div>
37
14
  <script >
38
15
  (function(){
39
- var _GALLPOSTSTR = "{{jsstr}}";
16
+
40
17
  {%- assign MothStr = site.theme_config.heatMapMonth -%}
41
18
  {%- assign HeatMapShowWeek = site.theme_config.heatMapShowWeek -%}
42
19
 
@@ -46,6 +23,8 @@
46
23
  var _HeatMapType = "{{ HeatMapType | default:'1' }}"
47
24
  var _MonthStr = '{{ MothnStr | default: "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" }}'
48
25
  var _showWeek = '{{ HeatMapShowWeek | default: "Mon Wed Fri" }}';
26
+
27
+ var _allyearurl = '{{ "assets/dyn/allyear.json" | relative_url }}';
49
28
  {% include heatmap.js %}
50
29
  })()
51
30
  </script>
data/_includes/heatmap.js CHANGED
@@ -1,68 +1,257 @@
1
- ;(function(){
2
-
3
- var Map = {}
4
- var arr1 = _GALLPOSTSTR.split("\n")
5
- arr1.forEach(element => {
6
- var post = element.split('\x01')
7
-
8
- var url = post[0]
9
- var title = post[1]
10
- var date = post[2]
11
- if (date && title && url) {
12
- var arrDatePost = Map[date]
13
- if (!arrDatePost ) {
14
- arrDatePost = []
15
- Map[date] = arrDatePost;
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
16
65
  }
17
- arrDatePost.push({title,url})
66
+
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}`
18
72
  }
19
-
20
- });
21
-
22
73
 
23
- var Father = document.getElementById("heatmap");
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
+ }
24
101
 
25
- const Frag = document.createDocumentFragment();
26
102
 
27
- const monthEle = document.createElement("div");
28
- monthEle.className = "heatmap-month";
29
- Frag.appendChild(monthEle);
30
- const monthStr = _MonthStr.split(" ");
31
103
 
32
- var dateEnd = new Date();
104
+ let ymdArr = []
33
105
 
34
- {%- comment -%}
35
- if(_HeatMapType == '1'){
36
- dateEnd = new Date()
37
- }else if(_HeatMapType == '2'){
38
-
39
- let chooseddate = ''
40
- for (const key in Map) {
41
- if (Object.prototype.hasOwnProperty.call(Map, key)) {
42
- const element = Map[key];
43
- if(element){
44
- if(key && key > chooseddate){
45
- chooseddate = key
106
+ for (const dateKeyYmd in Map) {
107
+ if (Object.prototype.hasOwnProperty.call(Map, dateKeyYmd)) {
108
+ ymdArr.push(dateKeyYmd)
109
+ }
110
+ }
111
+
112
+
113
+ var G_idxOfDay = DayCount - 1;
114
+
115
+ function shuffle(array) {
116
+ let currentIndex = array.length;
117
+
118
+ // While there remain elements to shuffle...
119
+ while (currentIndex != 0) {
120
+
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
+ }
129
+ }
130
+
131
+ const SEQ = new Array(DayCount)
132
+ let tmp = DayCount
133
+ while (tmp -- > 0) {
134
+ SEQ[tmp] = tmp
135
+ }
136
+
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
168
  }
169
+
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);
183
+
184
+
185
+ let t2 = document.createElement('span')
186
+ t2.className = 'hm-title'
187
+ t2.innerText = element.title
188
+ lnk.appendChild(t2);
189
+
190
+ });
191
+ dayCell.appendChild(tip);
192
+
193
+ }
194
+
195
+ }
196
+
197
+
198
+ function updateMultiDays(){
199
+ let day = 13;
200
+ while (day -- ) {
201
+ update1Day();
47
202
  }
203
+
204
+ if (G_idxOfDay >= 0) {
205
+ requestAnimationFrame(updateMultiDays)
206
+ }
207
+
48
208
  }
209
+ requestAnimationFrame(updateMultiDays)
210
+
211
+ return
212
+
213
+
214
+
215
+
216
+
49
217
  }
50
218
 
51
- dateEnd = new Date(chooseddate)
52
- console.log(chooseddate,dateEnd,typeof chooseddate)
219
+
220
+
221
+ function getYearData(year){
222
+ return fetch(`${jsonUrlBase}/${year}.json`)
223
+ .then(r => r.json())
224
+ .catch(e=>{
225
+ return null
226
+ })
227
+
228
+ }
229
+
230
+
231
+
232
+
233
+ }()
234
+
53
235
 
54
- }else{
55
- dateEnd = new Date()
56
- }
57
236
 
58
- {% endcomment %}
237
+ ;(function initMap(){
59
238
 
60
- var nowM = dateEnd.getMonth();
61
- var nowWeek = dateEnd.getDay();
62
- var endStamp = dateEnd.getTime()
239
+ let Father = document.getElementById("heatmap");
63
240
 
64
- for (var i = 0; i < monthStr.length; i++) {
65
- var m = document.createElement("span");
241
+ const Frag = document.createDocumentFragment();
242
+
243
+ const monthEle = document.createElement("div");
244
+ monthEle.className = "heatmap-month";
245
+ Frag.appendChild(monthEle);
246
+ const monthStr = _MonthStr.split(" ");
247
+
248
+
249
+ let nowM = dateEnd.getMonth();
250
+ let nowWeek = dateEnd.getDay();
251
+
252
+
253
+ for (let i = 0; i < monthStr.length ; i++) {
254
+ let m = document.createElement("span");
66
255
  m.className = "heatmap-month-cell";
67
256
  m.innerHTML = `${monthStr[(i + nowM + 1) % 12]}`;
68
257
  monthEle.appendChild(m);
@@ -72,8 +261,8 @@ const weekEle = document.createElement("div");
72
261
  weekEle.className = "heatmap-week";
73
262
  const WeekStr = _showWeek.split(" ");
74
263
 
75
- for (var i = 0; i < WeekStr.length; i++) {
76
- var m = document.createElement("div");
264
+ for (let i = 0; i < WeekStr.length; i++) {
265
+ let m = document.createElement("div");
77
266
  m.className = "heatmap-week-cell";
78
267
  m.innerHTML = `<span>${WeekStr[i]}</span>`;
79
268
  weekEle.appendChild(m);
@@ -84,11 +273,10 @@ Frag.appendChild(weekEle);
84
273
  const dayEle = document.createElement("div");
85
274
 
86
275
  dayEle.className = "heatmap-day";
276
+ dayEle.id = dayEleId;
87
277
 
88
- const ColumnsCount = 53;
89
- const RowCount = 7;
90
278
 
91
- var firstDateDayDiff = (ColumnsCount - 1) * RowCount + nowWeek;
279
+ let firstDateDayDiff = (ColumnsCount - 1) * RowCount + nowWeek;
92
280
 
93
281
 
94
282
  console.log(nowWeek, firstDateDayDiff);
@@ -98,55 +286,22 @@ for (let c = 0; c < ColumnsCount; c++) {
98
286
  if (r > nowWeek && c == ColumnsCount - 1) {
99
287
  break
100
288
  }
101
- const i = c * RowCount + r ;
102
- const date = new Date(endStamp - (firstDateDayDiff - i) * 3600000 * 24);
103
- const month = date.getMonth() + 1
104
- let dateStr = `${date.getFullYear()}-${month < 10 ? '0' + month : month}-${date.getDate() < 10 ? '0' + date.getDate() : date.getDate() }`
105
-
106
- var m = document.createElement("span");
107
- const arrPostInOneDay = Map[dateStr]
108
- m.classList = `heatmap-day-cell ${!arrPostInOneDay ? 'hm-check-no':arrPostInOneDay.length > 1 ? 'hm-check2' : 'hm-check' }`
109
-
110
289
 
111
- if (arrPostInOneDay ) {
112
- var isDirectly = arrPostInOneDay.length == 1
113
- var tip = document.createElement("div");
290
+ let m = document.createElement("span");
291
+ m.classList = `heatmap-day-cell hm-check-nodata`
292
+ dayEle.appendChild(m);
293
+ }
294
+ }
295
+
114
296
 
115
- if (isDirectly) {
116
- var lnk = document.createElement('a');
117
- lnk.href = arrPostInOneDay[0].url
118
- m.appendChild(lnk)
119
- }
297
+ Frag.appendChild(dayEle);
298
+ Father.append(Frag);
299
+ })()
120
300
 
121
- tip.className = "hm-tip";
122
- var desc = ''
123
- arrPostInOneDay.forEach(element => {
124
301
 
125
- var lnk = document.createElement('a');
126
- lnk.className = 'hm-tiplink'
127
- lnk.href = element.url
128
- tip.appendChild(lnk)
129
302
 
130
- var t = document.createElement('span')
131
- t.className = 'hm-date'
132
- t.innerText = dateStr.substring(5);
133
- lnk.appendChild(t);
134
303
 
135
-
136
- var t2 = document.createElement('span')
137
- t2.className = 'hm-title'
138
- t2.innerText = element.title
139
- lnk.appendChild(t2);
140
304
 
141
- });
142
- m.appendChild(tip);
143
-
144
- }
145
- dayEle.appendChild(m);
146
- }
147
- }
305
+ }();
148
306
 
149
307
 
150
- Frag.appendChild(dayEle);
151
- Father.append(Frag);
152
- })()
@@ -3,4 +3,59 @@ layout: default
3
3
  ---
4
4
  <link rel="stylesheet" href="{{ "/assets/css/main.css" | relative_url }}" />
5
5
  <br/><br/><br/>
6
- {%- include heatmap.html -%}
6
+ {%- include heatmap.html -%}
7
+
8
+
9
+ {% comment %}
10
+ generate this page only once。
11
+ {% endcomment %}
12
+ {% assign ALLJSON = "{" %}
13
+
14
+ {% assign postsByYear = site.posts | group_by_exp: "post", "post.date | date: '%Y' " %}
15
+
16
+
17
+
18
+ {%- for post in postsByYear -%}
19
+ {%- capture kv %}
20
+ "{{ post.name }}":1
21
+ {%- unless forloop.last -%},
22
+ {%- endunless -%}
23
+ {%- endcapture -%}
24
+ {% assign ALLJSON = ALLJSON | append:kv %}
25
+
26
+
27
+ {% assign itemM = post.items | group_by_exp: "post", "post.date | date: '%m' " %}
28
+
29
+ {%- capture SingleYearJson -%}
30
+ {
31
+ "year":"{{post.name}}",
32
+ {%- for item0 in itemM %}
33
+ "{{item0.name }}":
34
+ [
35
+ {%- for item00 in item0.items -%}
36
+ {
37
+ "title":"{{ item00.title | replace: '"', ' '}}",
38
+ "url":"{{ item00.url | relative_url}}",
39
+ "date": "{{ item00.date | date:"%Y-%m-%d"}}"
40
+ }{%- unless forloop.last -%},{%- endunless -%}
41
+ {%- endfor -%}
42
+ ]
43
+ {%- unless forloop.last -%},{%- endunless -%}
44
+ {%- endfor -%}
45
+ }
46
+ {%- endcapture -%}
47
+
48
+ {%- capture FILENAME -%}
49
+ assets/dyn/{{post.name}}.json
50
+ {%- endcapture -%}
51
+
52
+ {{ SingleYearJson | write_file: FILENAME }}
53
+ {%- endfor -%}
54
+
55
+ {% assign ALLJSON = ALLJSON | append: " }" %}
56
+ {{ ALLJSON | write_file: "assets/dyn/allyear.json" }}
57
+
58
+
59
+
60
+ <br>
61
+ {{ content }}
@@ -9,8 +9,8 @@ $color-lightGrayBg: #F0f2f4;
9
9
  $heatFont:Georgia,"Nimbus Roman No9 L","Songti SC",STSong,"AR PL New Sung","AR PL SungtiL GB",NSimSun,SimSun,"TW\-Sung","WenQuanYi Bitmap Song","AR PL UMing CN","AR PL UMing HK","AR PL UMing TW","AR PL UMing TW MBE",sans-serif;
10
10
 
11
11
  $dbgBorder:none;//ssolid 1px red;
12
- $hmbloksizeW:12px;
13
- $hmbloksizeH:15.2px;
12
+ $hmbloksizeW:11px;
13
+ $hmbloksizeH:13px;
14
14
  $dayGap:1px;
15
15
  $hmdaywidth: $dayGap * 52 + $hmbloksizeW * 53;
16
16
  $hmmonthWidth:40px;
@@ -360,7 +360,7 @@ img{
360
360
  grid-column-end: 3;
361
361
 
362
362
  display: grid;
363
- grid-template-columns:repeat(12,1fr);
363
+ grid-template-columns: repeat(12,1fr);
364
364
 
365
365
  width: $hmdaywidth;
366
366
  border: $dbgBorder;
@@ -376,7 +376,6 @@ img{
376
376
  font-family: $heatFont;
377
377
  font-size: 0.8rem;
378
378
 
379
- border: $dbgBorder;
380
379
  height: 12px;
381
380
 
382
381
  padding: 0.2em 0;
@@ -393,8 +392,7 @@ img{
393
392
 
394
393
 
395
394
  grid-auto-flow: row;
396
-
397
- height: $hmbloksizeW * 7
395
+ height: $hmbloksizeH * 7 + $dayGap * 6;
398
396
  }
399
397
 
400
398
 
@@ -433,6 +431,11 @@ img{
433
431
  overflow:hidden;
434
432
  }
435
433
 
434
+
435
+ .hm-check-nodata{
436
+ background-color: #93d5dc;
437
+ }
438
+
436
439
  .hm-check{
437
440
  background-color: #40c463bb;
438
441
  position: relative;
@@ -444,8 +447,13 @@ img{
444
447
  position: relative;
445
448
  }
446
449
 
447
- .hm-check-no{
448
- background-color: #edebf0;
450
+ .hm-check-no-a{
451
+ background-color: #edebf0;;
452
+ }
453
+
454
+
455
+ .hm-check-no-b{
456
+ background-color: #edebf0aa;
449
457
  }
450
458
 
451
459
  .heatmap-day-cell:hover{
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-zeta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - vitock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-22 00:00:00.000000000 Z
11
+ date: 2024-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll