mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Create events.js
This commit is contained in:
parent
5d4a85488e
commit
87b32a2831
34
website/workers/events.js
Normal file
34
website/workers/events.js
Normal file
@ -0,0 +1,34 @@
|
||||
addEventListener('fetch', event => {
|
||||
event.respondWith(handleRequest(event.request))
|
||||
})
|
||||
|
||||
async function handleRequest(request) {
|
||||
let raw = await fetch('https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/README.md');
|
||||
let text = await raw.text();
|
||||
let lines = text.split('\n');
|
||||
let skip = true;
|
||||
let events = [];
|
||||
for (let idx in lines) {
|
||||
let line = lines[idx];
|
||||
if (skip) {
|
||||
if (line.includes('Upcoming Events')) {
|
||||
skip = false;
|
||||
}
|
||||
} else {
|
||||
if (!line) { continue; };
|
||||
line = line.split('](');
|
||||
var tail = line[1].split(') ');
|
||||
events.push({
|
||||
'signup_link': tail[0],
|
||||
'event_name': line[0].replace('* [', ''),
|
||||
'event_date': tail[1].slice(0, -1).replace('on ', '')
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let response = new Response(JSON.stringify({
|
||||
'events': events
|
||||
}));
|
||||
response.headers.set('Content-Type', 'application/json');
|
||||
return response;
|
||||
}
|
Loading…
Reference in New Issue
Block a user