-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathJakefile
59 lines (48 loc) · 1.29 KB
/
Jakefile
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
fs = require('fs');
bcnjs2013 = require('./contents/2013');
bcnjs2014 = require('./contents/2014');
desc('Monthly talks');
task('copy', [], function () {
console.info('Copying for next month');
var
found = false,
next_event = {};
bcnjs2014.forEach(function (event) {
var event_date = new Date(event.date);
if (event_date >= new Date() && !found) {
next_event = event;
found = true;
}
});
fs.writeFile('./contents/_index/events.json', JSON.stringify(next_event.talks), function (err) {
console.info('Done. Next event: ' + new Date(next_event.date).toDateString());
complete();
});
}, true);
task('archive', [], function () {
console.info('Archiving history');
var
history = [];
bcnjs2014.forEach(function (event) {
var event_date = new Date(event.date);
if (event.talks) {
if (event_date <= new Date()) {
event.talks.reverse();
history.push(event);
}
}
});
history.sort(function(a, b) {
return new Date(b.date) - new Date(a.date);
});
fs.writeFile('./contents/_history/events.json', JSON.stringify(history), function (err) {
console.info('Done');
complete();
});
}, true);
task('clear', [], function () {
console.info('Cleaning for next month');
fs.writeFile('./contents/_index/events.json', '[{},{}]', function (err) {
complete();
});
}, true);