forked from drpicox/barcelonajs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJakefile
86 lines (74 loc) · 2.05 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
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
fs = require('fs');
bcnjs2013 = require('./contents/2013');
bcnjs2014 = require('./contents/2014');
bcnjs2015 = require('./contents/2015');
desc('Monthly talks');
task('copy', [], function () {
console.info('Copying for next month');
var
found = false,
next_event = {};
bcnjs2015.forEach(function (event) {
var event_date = new Date(event.date);
if (event_date >= new Date() && !found) {
next_event = event;
found = true;
}
});
if (next_event.special) {
fs.writeFile('./contents/_index/events.json', JSON.stringify(next_event.special), function (err) {
console.info('Done. Next event: ' + new Date(next_event.date).toDateString());
complete();
});
} else {
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 = [];
bcnjs2013.forEach(function (event) {
var event_date = new Date(event.date);
if (event.talks && event.talks.length >= 0) {
if (event_date <= new Date()) {
event.talks.reverse();
history.push(event);
}
}
});
bcnjs2014.forEach(function (event) {
var event_date = new Date(event.date);
if (event.talks && event.talks.length >= 0) {
if (event_date <= new Date()) {
event.talks.reverse();
history.push(event);
}
}
});
bcnjs2015.forEach(function (event) {
var event_date = new Date(event.date);
if (event.talks && event.talks.length >= 0) {
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);