-
Notifications
You must be signed in to change notification settings - Fork 6
/
basics.js
103 lines (92 loc) · 2.9 KB
/
basics.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
var config = require('./config'),
_ = require('underscore'),
gravatar = require('gravatar'),
urlMap = {
github: 'github.com',
twitter: 'twitter.com',
soundcloud: 'soundcloud.com',
pinterest: 'pinterest.com',
vimeo: 'vimeo.com',
behance: 'behance.net',
codepen: 'codepen.io',
foursquare: 'foursquare.com',
reddit: 'reddit.com',
spotify: 'open.spotify.com',
dribble: 'dribbble.com',
dribbble: 'dribbble.com',
facebook: 'facebook.com',
angellist: 'angel.co',
bitbucket: 'bitbucket.org',
exercism: 'exercism.io',
instagram: 'instagram.com',
googleplus: 'plus.google.com',
gratipay: 'gratipay.com',
hackernews: 'news.ycombinator.com',
lastfm: 'last.fm',
stackexchange: 'stackexchange.com',
stackoverflow: 'stackoverflow.com',
tumblr: 'tumblr.com',
youtube: 'youtube.com',
medium: 'medium.com',
blogger: 'blogspot.com',
meetup: 'meetup.com',
flickr: 'flickr.com',
telegram: 'telegram.me'
};
function getPictureFromEmail(email) {
return gravatar.url(email, config.gravatar, 'https');
}
function getUrlForPicture(resume) {
return (resume.basics.picture || getPictureFromEmail(resume.basics.email));
}
function getProfile(resume, network) {
var profiles = resume.basics.profiles;
return _.find(profiles, function(profile) {
return profile.network.toLowerCase() === network.toLowerCase();
});
}
function getUrlForProfile(resume, network) {
var url, username,
profile = getProfile(resume, network);
if (profile.url) {
return profile.url;
}
username = profile.username;
url = urlMap[network];
if (!username && !url) {
return;
}
//in case user forgets to append `@` at the start of username for medium accounts
if (network === 'medium' && !/^@.*/.test(username)) {
username = '@' + username;
}
switch(network) {
case 'skype':
return 'skype:' + username + '?call';
case 'reddit':
case 'spotify':
case 'lastfm':
case 'foursquare':
case 'youtube':
return '//' + url + '/user/' + username;
case 'hackernews':
return '//' + url + '/user?id=' + username;
case 'stackexchange':
case 'stackoverflow':
return '//' + url + '/users/' + username;
case 'tumblr':
case 'blogger':
return '//' + username + '.' + url;
case 'meetup':
return '//' + url + '/members/' + username;
case 'flickr':
return '//' + url + '/people/' + username;
default:
return '//' + url + '/' + username;
}
}
module.exports = {
getUrlForPicture: getUrlForPicture,
getProfile: getProfile,
getUrlForProfile: getUrlForProfile
};