Skip to content

Commit 99c8675

Browse files
authored
change the calendar logic #2 from Spark0618/Spark0618-wp
change calandar logic
2 parents 070224c + 8d1355c commit 99c8675

File tree

7 files changed

+71
-137
lines changed

7 files changed

+71
-137
lines changed

.github/workflows/push_wp.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Update schedule on push
1+
name: Update calendar on push
22

33
on:
44
push:
@@ -23,14 +23,14 @@ jobs:
2323
env:
2424
COMMITTER_NAME: ${{ github.actor }}
2525
COMMIT_URL: ${{ github.event.head_commit.url }}
26-
COMMIT_FILES: ${{ toJson(github.event.commits.*.modified) }}
26+
COMMIT_FILES: ${{ github.event.commits.*.added }}
2727
run: |
28-
python scripts/update_schedule_on_push.py
28+
python scripts/update_calendar_on_push.py
2929
3030
- name: Commit & Push
3131
run: |
3232
git config user.name "github-actions[bot]"
3333
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
34-
git add docs/data/schedule.json
35-
git commit -m "Update schedule from push" || echo "No changes"
34+
git add docs/data/calendar.json
35+
git commit -m "Update calendar from push" || echo "No changes"
3636
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} HEAD:main

.github/workflows/schedule.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

docs/assets/js/calendar.js

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ document.addEventListener('DOMContentLoaded', function() {
55
initialView: 'dayGridMonth',
66
validRange: function(nowDate) {
77
let endDate = new Date();
8-
endDate.setDate(endDate.getDate() + 6);
8+
endDate.setDate(endDate.getDate() + 7);
99
return {
1010
start: '2025-09-01',
1111
end: endDate
12-
}; // 可预览未来6天的事件
12+
}; // 可预览未来7天的事件
1313
},
1414
headerToolbar: {
1515
left: 'prev,next today',
1616
center: 'title',
1717
right: 'dayGridMonth'
1818
},
19-
events: './data/schedule.json', // 加载 WP JSON 数据
19+
events: './data/calendar.json', // 加载 WP JSON 数据
2020
eventContent: function(arg) {
2121
// 自定义事件显示样式
2222
let color = '#fff'; // 默认白色
@@ -29,44 +29,50 @@ document.addEventListener('DOMContentLoaded', function() {
2929
return { html: `<div style="color:${color}; font-weight:bold">${arg.event.title + " " + type}</div>` };
3030
},
3131
eventDidMount: function(info) {
32-
// 根据状态修改整个事件块样式
33-
let status = info.event.extendedProps.status;
34-
let color, textColor;
35-
if(!info.event.extendedProps.desc) {
36-
if (status === 'done') {
37-
// color = '#4CAF50';
38-
color = '#4ecd7cff'; // 亮绿色
39-
textColor = '#fff';
40-
} else if (status === 'pending') {
41-
const tomorrow = new Date();
42-
tomorrow.setHours(0, 0, 0, 0);
43-
tomorrow.setDate(tomorrow.getDate() + 1);
44-
if (info.event.start < tomorrow) {
45-
color = '#dc2626'; // 暗红
46-
textColor = '#fff';
47-
} else {
48-
color = '#9ca3af'; // 灰色
49-
textColor = '#fff';
50-
}
51-
} else {
52-
color = '#9ca3af'; // 灰色
53-
textColor = '#fff';
54-
}
55-
} else {
56-
// 如果有 type 字段,表示是节假日或特殊事件
57-
color = '#fbbf24'; // 黄色
58-
textColor = '#000';
59-
}
60-
let title = info.event.extendedProps.desc ? info.event.extendedProps.desc : (info.event.url ? info.event.url : "wp");
61-
// 鼠标悬浮显示完整标题
62-
info.el.title = title;
63-
info.el.style.backgroundColor = color;
64-
info.el.style.borderColor = color;
65-
info.el.style.color = textColor;
66-
info.el.style.borderRadius = '4px';
67-
info.el.style.fontWeight = 'bold';
68-
info.el.style.padding = '2px 4px';
69-
info.el.style.cursor = 'pointer'; // 提示可点击
32+
let status = info.event.extendedProps.status;
33+
let color, textColor;
34+
35+
// 从 url 中提取方向
36+
let url = info.event.url || "";
37+
let direction = url.split("/")[0].toLowerCase(); // web/misc/pwn/...
38+
39+
// 定义方向对应的颜色
40+
const directionColors = {
41+
web: '#3498db', // 蓝
42+
misc: '#9b59b6', // 紫
43+
pwn: '#e74c3c', // 红
44+
reverse:'#27ae60', // 绿
45+
crypto: '#34495e', // 深灰蓝
46+
ai: '#e67e22' // 橙
47+
};
48+
49+
if(!info.event.extendedProps.desc) {
50+
if (directionColors[direction]) {
51+
// 如果有方向,就按方向颜色
52+
color = directionColors[direction];
53+
// 让文字颜色自动根据背景深浅决定
54+
textColor = (direction === 'crypto') ? '#000' : '#fff';
55+
} else {
56+
// 默认灰
57+
color = '#9ca3af';
58+
textColor = '#fff';
59+
}
60+
} else {
61+
// 有 desc = 特殊事件
62+
color = '#f1c40f'; // 亮黄色(特殊事件)
63+
textColor = '#fff';
64+
}
65+
66+
let title = info.event.extendedProps.desc ? info.event.extendedProps.desc : (info.event.url ? info.event.url : "wp");
67+
// 鼠标悬浮显示完整标题
68+
info.el.title = title;
69+
info.el.style.backgroundColor = color;
70+
info.el.style.borderColor = color;
71+
info.el.style.color = textColor;
72+
info.el.style.borderRadius = '4px';
73+
info.el.style.fontWeight = 'bold';
74+
info.el.style.padding = '2px 4px';
75+
info.el.style.cursor = 'pointer';
7076
},
7177
// 点击事件跳转
7278
eventClick: function(info) {

docs/data/calendar.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
{"date": "2025-09-21","title": "Born","desc": "项目成立","status": "done","url": ""},
3+
{"date": "2025-09-21","title": "Spark","desc": "","status": "done","url": "web/unfinish"}
4+
]

docs/data/schedule.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

scripts/generate_schedule.py

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json, os, datetime, ast
22

3-
schedule_file = 'docs/data/schedule.json'
3+
schedule_file = 'docs/data/calendar.json'
44
today = datetime.date.today().isoformat()
55

66
# 取环境变量
@@ -39,19 +39,21 @@ def to_mkdocs_url(path):
3939
events = []
4040

4141
# 先找当天该人的 pending 事件
42-
pending_index = None
43-
for idx, ev in enumerate(events):
44-
if ev.get('date') == today and ev.get('title') == committer and ev.get('status') == 'pending':
45-
pending_index = idx
46-
break
42+
# pending_index = None
43+
# for idx, ev in enumerate(events):
44+
# if ev.get('date') == today and ev.get('title') == committer and ev.get('status') == 'pending':
45+
# pending_index = idx
46+
# break
4747

48-
if pending_index is not None and urls:
49-
# 用第一条 md 文件更新现有事件
50-
events[pending_index]['status'] = 'done'
51-
events[pending_index]['url'] = urls[0]
52-
used = 1
53-
else:
54-
used = 0
48+
# if pending_index is not None and urls:
49+
# # 用第一条 md 文件更新现有事件
50+
# events[pending_index]['status'] = 'done'
51+
# events[pending_index]['url'] = urls[0]
52+
# used = 1
53+
# else:
54+
# used = 0
55+
56+
used = 0
5557

5658
# 对剩余的 md 文件新增事件
5759
for url in urls[used:]:

0 commit comments

Comments
 (0)