jekyll-zeta 0.7.1 → 0.7.2

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: 92e9c3d10127af0ab175e41aa41643467f0a73eac8027ae0f350f06c2ebd67ba
4
+ data.tar.gz: 3e9fa286e582ad2ed5acbc0a3d7c40baa51a34211789626c208a04afa3ba3b80
5
5
  SHA512:
6
- metadata.gz: 9b22c45cd8bb3e0611f4db3faab73b7297379bdc575c48838e51a0a587d25bb758c06b42b27b84fbeadd328d0033c2094e9cefacb765b68037c97b2c4997d22a
7
- data.tar.gz: f8a182e18e976e2f9b08d00cf954cf8e5fa0a3451f92b876d595911e46fdfab37f562266764f0a6857d359fe18d67a99d3dc25eda4b472204429a3d159510227
6
+ metadata.gz: 860c508e7587807af43753eba3de599a51ef42acca73128c0460aa988260b34eb3c1a0b0e2d2fc3a13e73f9c301bd2c3e3b80292a670b5d366fe15e6948bd618
7
+ data.tar.gz: 9ca90a4536c7c716eb5b43349106475d14d34678cd6bf6db757cfdf3f4d2eb9c7c3864f968b0f95b987eb9fb498a000c481e4217ca16e3af0c7d081d1bed34fd
@@ -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,237 @@
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(d2=>{
38
+ updateCell({...d2[0],...d2[1]});
39
+ })
40
+ })
41
+
42
+ function getIndex(ymd){
43
+ return DayCount - Math.floor((endStamp - new Date(ymd).getTime())/ (24 * 3600000)) -1
16
44
  }
17
- arrDatePost.push({title,url})
45
+
46
+ function idx2Ymd(idx){
47
+ let t = new Date(endStamp - ( (DayCount - 1) - idx) * 3600000 * 24)
48
+ let m = t.getMonth() + 1
49
+ let d = t.getDate()
50
+ return `${t.getFullYear()}-${m< 10 ? '0' + m : m }-${d<10 ? '0'+d:d}`
18
51
  }
19
-
20
- });
21
-
22
52
 
23
- var Father = document.getElementById("heatmap");
53
+ function updateCell(data){
54
+ if(!data)return
55
+
56
+ let daysEle = document.getElementById(dayEleId)
57
+ let dayCells = daysEle.childNodes
58
+
59
+ let Map = {}
60
+
61
+ for (const key in data) {
62
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
63
+ const element = data[key];
64
+ if(Array.isArray(element)){
65
+ element.forEach(e=>{
66
+ if(e.date && e.title && e.url){
67
+ let arr = Map[e.date]
68
+ if (!arr) {
69
+ arr = []
70
+ Map[e.date] = arr
71
+ }
72
+ arr.push(e)
73
+ }
74
+ })
75
+ }
76
+ }
77
+ }
24
78
 
25
- const Frag = document.createDocumentFragment();
26
79
 
27
- const monthEle = document.createElement("div");
28
- monthEle.className = "heatmap-month";
29
- Frag.appendChild(monthEle);
30
- const monthStr = _MonthStr.split(" ");
31
80
 
32
- var dateEnd = new Date();
81
+ let ymdArr = []
33
82
 
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
83
+ for (const dateKeyYmd in Map) {
84
+ if (Object.prototype.hasOwnProperty.call(Map, dateKeyYmd)) {
85
+ ymdArr.push(dateKeyYmd)
86
+ }
87
+ }
88
+
89
+
90
+ var G_idxOfDay = DayCount - 1;
91
+
92
+ function shuffle(array) {
93
+ let currentIndex = array.length;
94
+
95
+ // While there remain elements to shuffle...
96
+ while (currentIndex != 0) {
97
+
98
+ // Pick a remaining element...
99
+ let randomIndex = Math.floor(Math.random() * currentIndex);
100
+ currentIndex--;
101
+
102
+ // And swap it with the current element.
103
+ [array[currentIndex], array[randomIndex]] = [
104
+ array[randomIndex], array[currentIndex]];
105
+ }
106
+ }
107
+
108
+ const SEQ = new Array(DayCount)
109
+ let tmp = DayCount
110
+ while (tmp -- > 0) {
111
+ SEQ[tmp] = tmp
112
+ }
113
+
114
+ shuffle(SEQ)
115
+
116
+ function update1Day(){
117
+ if (G_idxOfDay < 0) {
118
+ return
119
+ }
120
+ const idxOfDay = SEQ[G_idxOfDay --];
121
+
122
+ let dateKeyYmd = idx2Ymd(idxOfDay )
123
+
124
+
125
+ let arrPostInOneDay = Map[dateKeyYmd];
126
+ // debug
127
+ arrPostInOneDay = arrPostInOneDay
128
+
129
+
130
+ const dayCell = dayCells[idxOfDay]
131
+ const nobg = parseInt(dateKeyYmd.substring(5,7))%2 == 1? 'hm-check-no-b' : 'hm-check-no-a';
132
+ dayCell.classList = `heatmap-day-cell ${!arrPostInOneDay ? nobg :arrPostInOneDay.length > 1 ? 'hm-check2' : 'hm-check' }`
133
+
134
+
135
+ if ((arrPostInOneDay && arrPostInOneDay.length > 0 )) {
136
+
137
+
138
+ let isDirectly = arrPostInOneDay.length == 1
139
+ let tip = document.createElement("div");
140
+
141
+ if (isDirectly) {
142
+ let lnk = document.createElement('a');
143
+ lnk.href = arrPostInOneDay[0].url
144
+ dayCell.appendChild(lnk)
46
145
  }
146
+
147
+ tip.className = "hm-tip";
148
+ let desc = ''
149
+ arrPostInOneDay.forEach(element => {
150
+
151
+ let lnk = document.createElement('a');
152
+ lnk.className = 'hm-tiplink'
153
+ lnk.href = element.url
154
+ tip.appendChild(lnk)
155
+
156
+ let t = document.createElement('span')
157
+ t.className = 'hm-date'
158
+ t.innerText = dateKeyYmd.substring(5);
159
+ lnk.appendChild(t);
160
+
161
+
162
+ let t2 = document.createElement('span')
163
+ t2.className = 'hm-title'
164
+ t2.innerText = element.title
165
+ lnk.appendChild(t2);
166
+
167
+ });
168
+ dayCell.appendChild(tip);
169
+
170
+ }
171
+
172
+ }
173
+
174
+
175
+ function updateMultiDays(){
176
+ let day = 6;
177
+ while (day -- ) {
178
+ update1Day();
179
+ }
180
+
181
+ if (G_idxOfDay >= 0) {
182
+ requestAnimationFrame(updateMultiDays)
47
183
  }
184
+
48
185
  }
186
+
187
+ setTimeout(() => {
188
+ requestAnimationFrame(updateMultiDays)
189
+ }, 200);
190
+
191
+ return
192
+
193
+
194
+
195
+
196
+
49
197
  }
50
198
 
51
- dateEnd = new Date(chooseddate)
52
- console.log(chooseddate,dateEnd,typeof chooseddate)
199
+
53
200
 
54
- }else{
55
- dateEnd = new Date()
56
- }
201
+ function getYearData(year){
202
+ return fetch(`${jsonUrlBase}/${year}.json`)
203
+ .then(r => r.json())
204
+ .catch(e=>{
205
+ return null
206
+ })
57
207
 
58
- {% endcomment %}
208
+ }
59
209
 
60
- var nowM = dateEnd.getMonth();
61
- var nowWeek = dateEnd.getDay();
62
- var endStamp = dateEnd.getTime()
63
210
 
64
- for (var i = 0; i < monthStr.length; i++) {
65
- var m = document.createElement("span");
211
+
212
+
213
+ }()
214
+
215
+
216
+
217
+ ;(function initMap(){
218
+
219
+ let Father = document.getElementById("heatmap");
220
+
221
+ const Frag = document.createDocumentFragment();
222
+
223
+ const monthEle = document.createElement("div");
224
+ monthEle.className = "heatmap-month";
225
+ Frag.appendChild(monthEle);
226
+ const monthStr = _MonthStr.split(" ");
227
+
228
+
229
+ let nowM = dateEnd.getMonth();
230
+ let nowWeek = dateEnd.getDay();
231
+
232
+
233
+ for (let i = 0; i < monthStr.length ; i++) {
234
+ let m = document.createElement("span");
66
235
  m.className = "heatmap-month-cell";
67
236
  m.innerHTML = `${monthStr[(i + nowM + 1) % 12]}`;
68
237
  monthEle.appendChild(m);
@@ -72,8 +241,8 @@ const weekEle = document.createElement("div");
72
241
  weekEle.className = "heatmap-week";
73
242
  const WeekStr = _showWeek.split(" ");
74
243
 
75
- for (var i = 0; i < WeekStr.length; i++) {
76
- var m = document.createElement("div");
244
+ for (let i = 0; i < WeekStr.length; i++) {
245
+ let m = document.createElement("div");
77
246
  m.className = "heatmap-week-cell";
78
247
  m.innerHTML = `<span>${WeekStr[i]}</span>`;
79
248
  weekEle.appendChild(m);
@@ -84,11 +253,10 @@ Frag.appendChild(weekEle);
84
253
  const dayEle = document.createElement("div");
85
254
 
86
255
  dayEle.className = "heatmap-day";
256
+ dayEle.id = dayEleId;
87
257
 
88
- const ColumnsCount = 53;
89
- const RowCount = 7;
90
258
 
91
- var firstDateDayDiff = (ColumnsCount - 1) * RowCount + nowWeek;
259
+ let firstDateDayDiff = (ColumnsCount - 1) * RowCount + nowWeek;
92
260
 
93
261
 
94
262
  console.log(nowWeek, firstDateDayDiff);
@@ -98,55 +266,22 @@ for (let c = 0; c < ColumnsCount; c++) {
98
266
  if (r > nowWeek && c == ColumnsCount - 1) {
99
267
  break
100
268
  }
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
269
 
111
- if (arrPostInOneDay ) {
112
- var isDirectly = arrPostInOneDay.length == 1
113
- var tip = document.createElement("div");
270
+ let m = document.createElement("span");
271
+ m.classList = `heatmap-day-cell hm-check-nodata`
272
+ dayEle.appendChild(m);
273
+ }
274
+ }
275
+
114
276
 
115
- if (isDirectly) {
116
- var lnk = document.createElement('a');
117
- lnk.href = arrPostInOneDay[0].url
118
- m.appendChild(lnk)
119
- }
277
+ Frag.appendChild(dayEle);
278
+ Father.append(Frag);
279
+ })()
120
280
 
121
- tip.className = "hm-tip";
122
- var desc = ''
123
- arrPostInOneDay.forEach(element => {
124
281
 
125
- var lnk = document.createElement('a');
126
- lnk.className = 'hm-tiplink'
127
- lnk.href = element.url
128
- tip.appendChild(lnk)
129
282
 
130
- var t = document.createElement('span')
131
- t.className = 'hm-date'
132
- t.innerText = dateStr.substring(5);
133
- lnk.appendChild(t);
134
283
 
135
-
136
- var t2 = document.createElement('span')
137
- t2.className = 'hm-title'
138
- t2.innerText = element.title
139
- lnk.appendChild(t2);
140
284
 
141
- });
142
- m.appendChild(tip);
143
-
144
- }
145
- dayEle.appendChild(m);
146
- }
147
- }
285
+ }();
148
286
 
149
287
 
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.2
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