-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
129 lines (107 loc) · 3.78 KB
/
index.js
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
const express = require('express');
const app = express();
const timetable = require('./app/timetable');
const ical = require('ical-generator');
const events = require('./app/events');
const alternate_table = require('./app/alternate_table');
const PORT = process.env.PORT || 3000
app.get('/', function (req, res) {
res.sendFile(__dirname + '/index.html');
});
app.get('/Achard-Grundschule-6-C.json', function (req, res) {
const json = timetable.timetable('Achard-Grundschule-6-C.json');
res.send(json);
});
app.get('/Achard-Grundschule-6-C.ical', function (req, res) {
const json = timetable.timetable('Achard-Grundschule-6-C.json');
const cal = ical({
domain: 'emkay',
prodId: { company: 'emkay.org', product: 'timetable-ical' },
name: 'Timetable iCal',
timezone: 'Europe/Berlin'
});
// iterate over the 5 days ( 0 = Monday ... 4 = Friday )
for (var i = 0; i < 5; i++) {
cal.events(events.weekday(json, i));
}
cal.serve(res);
});
app.get('/Merian-Schule-9-1.json', function (req, res) {
const json = timetable.timetable('Merian-Schule-9-1.json');
res.send(json);
});
app.get('/Merian-Schule-9-1.ical', function (req, res) {
const json = timetable.timetable('Merian-Schule-9-1.json');
const cal = ical({
domain: 'emkay',
prodId: { company: 'emkay.org', product: 'timetable-ical' },
name: 'Timetable iCal',
timezone: 'Europe/Berlin'
});
// iterate over the 5 days ( 0 = Monday ... 4 = Friday )
for (var i = 0; i < 5; i++) {
cal.events(events.weekday(json, i));
}
cal.serve(res);
});
app.get('/Siemens-Gymnasium-9-C-Woche-A.json', function (req, res) {
const json = timetable.timetable('Siemens-Gymnasium-9-C-Woche-A.json');
res.send(json);
});
app.get('/Siemens-Gymnasium-9-C-Woche-A.ical', function (req, res) {
const json = timetable.timetable('Siemens-Gymnasium-9-C-Woche-A.json');
const cal = ical({
domain: 'emkay',
prodId: { company: 'emkay.org', product: 'timetable-ical' },
name: 'Timetable iCal',
timezone: 'Europe/Berlin'
});
// iterate over the 5 days ( 0 = Monday ... 4 = Friday )
for (var i = 0; i < 5; i++) {
cal.events(events.weekday(json, i));
}
cal.serve(res);
});
app.get('/Siemens-Gymnasium-9-C-Woche-B.json', function (req, res) {
const json = timetable.timetable('Siemens-Gymnasium-9-C-Woche-B.json');
res.send(json);
});
app.get('/Siemens-Gymnasium-9-C-Woche-B.ical', function (req, res) {
const json = timetable.timetable('Siemens-Gymnasium-9-C-Woche-B.json');
const cal = ical({
domain: 'emkay',
prodId: { company: 'emkay.org', product: 'timetable-ical' },
name: 'Timetable iCal',
timezone: 'Europe/Berlin'
});
// iterate over the 5 days ( 0 = Monday ... 4 = Friday )
for (var i = 0; i < 5; i++) {
cal.events(events.weekday(json, i));
}
cal.serve(res);
});
app.get('/Siemens-Gymnasium-9-C.json', function (req, res) {
const week_A = timetable.timetable('Siemens-Gymnasium-9-C-Woche-A.json');
const week_B = timetable.timetable('Siemens-Gymnasium-9-C-Woche-B.json');
const json = alternate_table.alternate(new Date(), week_B, week_A);
res.send(json);
});
app.get('/Siemens-Gymnasium-9-C.ical', function (req, res) {
const week_A = timetable.timetable('Siemens-Gymnasium-9-C-Woche-A.json');
const week_B = timetable.timetable('Siemens-Gymnasium-9-C-Woche-B.json');
const json = alternate_table.alternate(new Date(), week_B, week_A);
const cal = ical({
domain: 'emkay',
prodId: { company: 'emkay.org', product: 'timetable-ical' },
name: 'Timetable iCal',
timezone: 'Europe/Berlin'
});
// iterate over the 5 days ( 0 = Monday ... 4 = Friday )
for (var i = 0; i < 5; i++) {
cal.events(events.weekday(json, i));
}
cal.serve(res);
});
app.listen(PORT, function () {
console.log(`emkay-ical-app is listening on port ${PORT}!`);
});