-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
189 lines (166 loc) · 8.72 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Linux Kernel Patch Statistic among Universities</title>
<script src="https://s4.zstatic.net/ajax/libs/react/18.2.0/umd/react.development.min.js" integrity="sha384-2Lh7Q+QSdCvoe0sllT5jFErR9aFIWJHFufzuseDyLsJn9a5m2YqQHhCz0NpGNFIB" crossorigin="anonymous"></script>
<script src="https://s4.zstatic.net/ajax/libs/react-dom/18.2.0/umd/react-dom.development.min.js" integrity="sha384-UQ4ATYmjYZlBA1kyQlDkeJj4TdyVKTmKtUnyVEDVKvPr7GOISK9tfDyxTIvpDFhc" crossorigin="anonymous"></script>
<script src="https://s4.zstatic.net/ajax/libs/babel-standalone/7.22.17/babel.min.js" integrity="sha384-E9gF5bp/9ap5fWKPvScT2xn3qYLXBVuViOUYO1AritUY8zlH3ISflL2d7NvJfg/s" crossorigin="anonymous"></script>
<script src="https://s4.zstatic.net/ajax/libs/dayjs/1.11.9/dayjs.min.js" integrity="sha384-ok2ureoh4h8/yzfhscH9aGBd1IrWT0jPFG7JF7dbo+uFAQCn3jc6nY1AYH5y6hhv" crossorigin="anonymous"></script>
<script src="https://s4.zstatic.net/ajax/libs/antd/5.9.0/antd.min.js" integrity="sha384-PYHnf42vhdyuGieCUjW1qCt8qpvsUnbRGdHnKnNhdxj0g5P+fljo+JmM4NYV0FDD" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://s4.zstatic.net/ajax/libs/antd/5.9.0/reset.min.css" integrity="sha384-iqyoCPXvqh7OcpFMoeqEPDFuAYAXgbIzXw++z0KY2NBDjkvq0siOCcRIKwu892Ca" crossorigin="anonymous">
</head>
<body>
<div id="root"></div>
<style>
#root {
padding: 16px;
}
.cell-country {
display: inline-block;
}
.cell-country img {
height: 1em;
margin-right: 8px;
}
.form {
margin-bottom: 16px;
}
</style>
<script type="text/babel">
const ESCAPE_MAP = {
"Taiwan, Province of China": "Taiwan, Province of China",
}
function escapeSpecialRegion(region) {
return ESCAPE_MAP[region] || region
}
function isNeedEscape(region) {
return ESCAPE_MAP[region] !== undefined
}
function GithubIcon(props) {
return (
<svg
{...props}
xmlns="http://www.w3.org/2000/svg" width="1.2em" height="1.2em" viewBox="0 0 24 24"><path fill="black" d="M12 2A10 10 0 0 0 2 12c0 4.42 2.87 8.17 6.84 9.5c.5.08.66-.23.66-.5v-1.69c-2.77.6-3.36-1.34-3.36-1.34c-.46-1.16-1.11-1.47-1.11-1.47c-.91-.62.07-.6.07-.6c1 .07 1.53 1.03 1.53 1.03c.87 1.52 2.34 1.07 2.91.83c.09-.65.35-1.09.63-1.34c-2.22-.25-4.55-1.11-4.55-4.92c0-1.11.38-2 1.03-2.71c-.1-.25-.45-1.29.1-2.64c0 0 .84-.27 2.75 1.02c.79-.22 1.65-.33 2.5-.33s1.71.11 2.5.33c1.91-1.29 2.75-1.02 2.75-1.02c.55 1.35.2 2.39.1 2.64c.65.71 1.03 1.6 1.03 2.71c0 3.82-2.34 4.66-4.57 4.91c.36.31.69.92.69 1.85V21c0 .27.16.59.67.5C19.14 20.16 22 16.42 22 12A10 10 0 0 0 12 2"/>
</svg>
)
}
function App() {
const [data, setData] = React.useState([]);
const [loading, setLoading] = React.useState(false);
const [meta, setMeta] = React.useState(undefined); // [update, repo, branch, commit]
const [chinaOnly, setChinaOnly] = React.useState(false);
const columns = [
{
key: 'rank',
title: 'Rank',
dataIndex: 'rank'
},
{
key: "name",
title: "Name",
dataIndex: "name",
render: (text, record) => <a href={`detail/${record.id}.html`} target="_blank">{record.name}</a>
},
{
key: 'domain',
title: 'Domain(s)',
dataIndex: 'domain',
render: (text, record) => <div>
{record.domains.map(u => <div key={u}>{u}</div>)}
</div>
},
{
key: "country",
title: "Country / Region",
render: (text, record) => <div className="cell-country">
{record.university?.alpha_two_code && !isNeedEscape(record.university?.country) && <img
alt={record.university.alpha_two_code}
src={`http://purecatamphetamine.github.io/country-flag-icons/3x2/${record.university.alpha_two_code}.svg`} />}
{escapeSpecialRegion(record.university?.country || "Unknown")}
</div>
},
{
key: 'count',
title: 'Patch Count',
dataIndex: 'count'
},
{
key: 'lines',
title: 'Line Count',
dataIndex: 'lines'
}
]
const expandedRowRender = (record) => {
const columns = [
{title: 'Author', dataIndex: 'name', key: 'author'},
{title: 'Email', dataIndex: 'email', key: 'email'},
{title: 'Patch Count', dataIndex: 'count', key: 'count'},
];
const secondExpandedRowRender = (items) => {
const columns = [
{title: 'Summary', dataIndex: 'summary', key: 'summary', render: (text, record) => <a href={"https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=" + record.commit} target="_blank">{text}</a>},
{title: 'Date', dataIndex: 'date', key: 'date', render: (text) => dayjs(text).format('YYYY-MM-DD')},
{title: 'Files', dataIndex: 'files', key: 'files', },
{title: 'Lines', dataIndex: 'lines', key: 'lines', }
]
return <antd.Table columns={columns} dataSource={items.commits} pagination={false} rowKey="commit" />;
}
return <antd.Table columns={columns} dataSource={record.authors} pagination={false} rowKey="email" expandable={{
expandedRowRender: secondExpandedRowRender
}} />;
}
React.useEffect(() => {
setLoading(true);
fetch('result.json')
.then(d => d.json())
.then(d => {
setData(d.data)
setMeta(d.meta)
})
.finally(() => {
setLoading(false)
})
}, [])
const displayData = React.useMemo(() => {
if (chinaOnly) {
return data.filter(d =>
d.university?.alpha_two_code === 'CN' || d.domains?.join("").includes('.cn')
)
}
return data
}, [chinaOnly, data])
return (
<antd.Spin spinning={loading}>
<div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between' }}>
<h1>Linux Kernel Patch Statistic among Universities</h1>
<a href="https://github.com/hust-open-atom-club/linux-edu-rank">
<GithubIcon style={{ transform: 'scale(1.5)', marginRight: '1em' }} />
</a>
</div>
<div>
{
meta && <antd.Descriptions>
<antd.Descriptions.Item label="Last update">{meta.update ? dayjs(meta.update).format("YYYY-MM-DD HH:mm") : "N/A"}</antd.Descriptions.Item>
<antd.Descriptions.Item label="Repo">{meta.repo}</antd.Descriptions.Item>
<antd.Descriptions.Item label="Branch">{meta.branch}</antd.Descriptions.Item>
<antd.Descriptions.Item label="Commit">{meta.commit}</antd.Descriptions.Item>
</antd.Descriptions>
}
</div>
<div className="form">
<antd.Checkbox checked={chinaOnly} onChange={(e) => {
setChinaOnly(e.target.checked)
}}>Only show universities in China's mainland</antd.Checkbox>
</div>
<antd.Table dataSource={displayData} columns={columns} pagination={false} expandable={{expandedRowRender}} rowKey="id">
</antd.Table>
</antd.Spin>
)
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);
</script>
</body>
</html>