forked from michelle/hackberkeley
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroster.js
64 lines (57 loc) · 1.24 KB
/
roster.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
var fs = require('fs');
var _ = require('lodash');
var people = [
{
name: 'Brian Chu',
link: 'https://www.brianchu.com'
},
'Kevin Chen',
'Bob Zhou',
'Daylen Yang',
'Lily Nguyen',
'David Bui',
'Larry Xu',
'Alex Yang',
'Smitha Milli',
'Apollo Jain',
'Mitchell Karchemsky',
'Rodney Folz',
'Michelle Chang',
'Melanie Cebula',
'Stephanie Djidjev',
'Justin Comins',
'Dennis Zhao',
'Andy Wang',
'Ravi Tadinada',
'Nathan Mandi',
'Sumukh Sridhara',
'Sidd Karamcheti',
'Alan Li',
];
// set image filenames:
var extensions = ['.jpg', '.png'];
var imageRoot = './public/images/people/';
for (var i = 0; i < people.length; i++) {
var person = people[i];
// convert <string> to object with name: <string>
if (typeof person === 'string') {
person = people[i] = {
name: person
};
}
var imageFilename = person.name.toLowerCase().split(' ').join('-');
var ext = null;
for (var j = 0; j < extensions.length; j++) {
var e = extensions[j];
try {
fs.openSync(imageRoot + imageFilename + e, 'r')
ext = e;
break;
}
catch (err) {}
}
person.img = ext ? imageFilename + ext : 'default.png';
}
module.exports.getPeople = function() {
return _.shuffle(people);
};