-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
160 lines (140 loc) · 5.74 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
var fs = require("fs");
var Handlebars = require("handlebars");
var URL = require("url");
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];
var nets = ["500px", "8tracks", "airbnb", "alliance", "amazon", "amplement", "android", "angellist", "apple", "appnet", "baidu", "bandcamp", "battlenet", "beam", "bebee", "bebo", "behance", "blizzard", "blogger", "buffer", "chrome", "coderwall", "curse", "dailymotion", "deezer", "delicious", "deviantart", "diablo", "digg", "discord", "disqus", "douban", "draugiem", "dribbble", "drupal", "ebay", "ello", "endomondo", "envato", "etsy", "facebook", "feedburner", "filmweb", "firefox", "flattr", "flickr", "formulr", "forrst", "foursquare", "friendfeed", "github", "goodreads", "google", "googlegroups", "googlephotos", "googleplus", "googlescholar", "grooveshark", "hackerrank", "hearthstone", "hellocoton", "hereos", "hitbox", "horde", "houzz", "icq", "identica", "imdb", "instagram", "issuu", "istock", "itunes", "keybase", "lanyrd", "lastfm", "line", "linkedin", "livejournal", "lyft", "macos", "mail", "medium", "meetup", "mixcloud", "modelmayhem", "mumble", "myspace", "newsvine", "nintendo", "npm", "odnoklassniki", "openid", "opera", "outlook", "overwatch", "pandora", "patreon", "paypal", "periscope", "persona", "pinterest", "play", "player", "playstation", "pocket", "qq", "quora", "raidcall", "ravelry", "reddit", "renren", "researchgate", "residentadvisor", "reverbnation", "rss", "sharethis", "skype", "slideshare", "smugmug", "snapchat", "songkick", "soundcloud", "spotify", "stackexchange", "stackoverflow", "starcraft", "stayfriends", "steam", "storehouse", "strava", "streamjar", "stumbleupon", "swarm", "teamspeak", "teamviewer", "technorati", "telegram", "tripadvisor", "tripit", "triplej", "tumblr", "twitch", "twitter", "uber", "ventrilo", "viadeo", "viber", "viewbug", "vimeo", "vine", "vkontakte", "warcraft", "wechat", "weibo", "whatsapp", "wikipedia", "windows", "wordpress", "wykop", "xbox", "xing", "yahoo", "yammer", "yandex", "yelp", "younow", "youtube", "zapier", "zerply", "zomato", "zynga", "spreadshirt", "trello", "gamejolt", "tunein", "bloglovin", "gamewisp", "messenger"];
module.exports = {
render: render
};
function render(resume) {
var css = fs.readFileSync(__dirname + "/style.css", "utf-8");
var template = fs.readFileSync(__dirname + "/resume.hbs", "utf-8");
return Handlebars.compile(template)({
css: css,
resume: resume
});
}
/* HANDLEBARS HELPERS */
Handlebars.registerHelper('paragraphSplit', function(plaintext) {
var output = '';
var lines = plaintext instanceof Array ? plaintext.join('').split(/\r\n|\r|\n/g) : plaintext.split(/\r\n|\r|\n/g);
var i = 0;
while (i < lines.length) {
if (lines[i]) {
output += '<p>' + lines[i] + '</p>';
}
i += 1;
}
return new Handlebars.SafeString(output);
});
Handlebars.registerHelper('toLower', function(str) {
if (str && typeof str === 'string') {
return str.toLowerCase();
}
});
Handlebars.registerHelper('santify', function(url, network) {
// first parse the url to see if can match to socion icons.
var str = URL.parse(url).hostname.toLowerCase();
var parts = str.split('.');
str = (parts.length == 2) ? parts[0] : parts[1];
// Check for googleplus, may have to add others ...
if (parts[0]=='plus' && parts[1] =='google') {
return parts[1]+parts[0];
}
for (var i = 0; i < nets.length; i++) {
if (nets[i].indexOf(str) > -1) {
return nets[i];
}
}
// url didn't parse to known icon, go with network without spaces or dash
if (network && typeof network === 'string') {
return network.split(' ').join('').split('-').join('').toLowerCase();
} else {
return "rss";
}
});
Handlebars.registerHelper('decodeURI', function(str) {
if (str && typeof str === 'string') {
return decodeURIComponent(str);
}
});
Handlebars.registerHelper('spaceToDash', function(str) {
if (str && typeof str === 'string') {
return str.replace(/\s/g, '-').toLowerCase();
}
});
Handlebars.registerHelper('theYear', function() {
return new Date().getFullYear();
});
Handlebars.registerHelper('prettifyDate', function(d) {
var date = Date.parse(d);
if (isNaN(date)) {
return d
} else {
var month = new Date(date).getMonth();
var year = new Date(date).getFullYear();
return months[month] + ' ' + year;
}
});
Handlebars.registerHelper('map', function(level) {
if (typeof level === 'undefined' || typeof level === null) {
return ""
} else {
level = level.toLowerCase();
switch (level) {
case "advanced":
case "professionial":
case "pro":
return "primary";
break;
case "basic":
case "novice":
case "student":
case "rookie":
case "amateur":
case "knowledgeable":
return "secondary";
break;
case "learning":
case "beginner":
case "dabbler":
return "info";
break;
case "average":
case "competent":
case "moderate":
case "intermediate":
case "proficient":
case "skillful":
case "junior":
case "jr":
case "jr.":
return "warning";
break;
case "experienced":
case "master":
case "working knowledge":
return "success";
break;
case "comfortable":
case "expert":
case "junor":
case "senior":
case "sr":
case "sr.":
case "architect":
return "alert";
break;
default:
return "";
}
}
});
/*
Handlebars.registerHelper('Y', function(date) {
return moment(date.toString(), ['YYYY-MM-DD']).format('YYYY');
});
Handlebars.registerHelper('DMY', function(date) {
return moment(date.toString(), ['YYYY-MM-DD']).format('D MMMM YYYY');
});
*/