restructure calendars.json
This commit is contained in:
parent
3901a5d894
commit
0e7e3e7804
|
@ -1,32 +1,36 @@
|
|||
{
|
||||
"linkGroups": [
|
||||
"mergedCalendars": [
|
||||
{
|
||||
"name": "Group 1",
|
||||
"links": [
|
||||
"id": "uniqueId1",
|
||||
"calendars": [
|
||||
{
|
||||
"linkGroupName": "Group 1",
|
||||
"url": "https://example.com/calendar1.ics",
|
||||
"prefix": "Calendar 1",
|
||||
"overrideSummary": false
|
||||
"override": false
|
||||
},
|
||||
{
|
||||
"linkGroupName": "Group 1",
|
||||
"url": "https://example.com/calendar2.ics",
|
||||
"prefix": "Calendar 2",
|
||||
"overrideSummary": true
|
||||
"override": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Group 2",
|
||||
"links": [
|
||||
"id": "uniqueId2",
|
||||
"calendars": [
|
||||
{
|
||||
"linkGroupName": "Group 2",
|
||||
"url": "https://example.com/calendar3.ics",
|
||||
"prefix": "Calendar 3",
|
||||
"overrideSummary": false
|
||||
"override": false
|
||||
},
|
||||
{
|
||||
"linkGroupName": "Group 2",
|
||||
"url": "https://example.com/calendar4.ics",
|
||||
"prefix": "Calendar 4",
|
||||
"overrideSummary": true
|
||||
"override": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
12
server.js
12
server.js
|
@ -16,6 +16,11 @@ if (!fs.existsSync(MERGED_CALENDARS_DIR)) {
|
|||
fs.mkdirSync(MERGED_CALENDARS_DIR);
|
||||
}
|
||||
|
||||
app.get('/script.js', (req, res) => {
|
||||
res.setHeader('Content-Type', 'application/javascript');
|
||||
res.sendFile('script.js', { root: '.' });
|
||||
});
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile('index.html', { root: '.' });
|
||||
});
|
||||
|
@ -73,7 +78,6 @@ app.post('/merge', async (req, res) => {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
// Save merged calendar to file with unique identifier
|
||||
const filename = `${calendarId}.ics`;
|
||||
let icalString = `BEGIN:VCALENDAR
|
||||
|
@ -84,7 +88,7 @@ METHOD:PUBLISH
|
|||
mergedCal.forEach((event) => {
|
||||
icalString += `BEGIN:VEVENT
|
||||
DTSTART;VALUE=DATE:${event.start.toISOString().split('T')[0].replace(/-/g, '')}
|
||||
DTEND;VALUE=DATE:${event.end.toISOString().split('T')[0].replace(/-/g, '')}
|
||||
DTEND;VALUE=DATE:${ event.end.toISOString().split('T')[0].replace(/-/g, '')}
|
||||
SUMMARY:${event.summary}
|
||||
END:VEVENT
|
||||
`;
|
||||
|
@ -191,7 +195,7 @@ END:VEVENT
|
|||
// Store the merged calendar URL in a file
|
||||
fs.writeFileSync(`${MERGED_CALENDARS_DIR}/${filename}`, icalString);
|
||||
|
||||
console.log(`Merged calendar updated: ${mergedCalendarUrl}`);
|
||||
console.log(`Merged calendar updated: ${mergedCalendar.id}`);
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
|
@ -200,7 +204,7 @@ END:VEVENT
|
|||
}
|
||||
|
||||
// Schedule a cron job to update the merged calendar every hour
|
||||
cron.schedule('*/3 * * * *', () => {
|
||||
cron.schedule('1 * * * *', () => {
|
||||
console.log('Updating merged calendar...');
|
||||
updateMergedCalendars();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue