mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-24 01:10:11 +00:00
feat: introduce two skill-related helpers
This commit is contained in:
parent
38a073b09a
commit
c08c5f0fa3
10
dist/helpers/block-helpers.js
vendored
10
dist/helpers/block-helpers.js
vendored
@ -43,6 +43,16 @@ Block helper definitions for HackMyResume / FluentCV.
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
ifHasSkill: function(rez, skill, options) {
|
||||||
|
var ret, skUp;
|
||||||
|
skUp = skill.toUpperCase();
|
||||||
|
ret = _.some(rez.skills.list, function(sk) {
|
||||||
|
return (skUp.toUpperCase() === sk.name.toUpperCase()) && sk.years;
|
||||||
|
}, this);
|
||||||
|
if (ret) {
|
||||||
|
return options.fn(this);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Emit the enclosed content if the resume has the named
|
Emit the enclosed content if the resume has the named
|
||||||
|
19
dist/helpers/generic-helpers.js
vendored
19
dist/helpers/generic-helpers.js
vendored
@ -6,7 +6,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var FS, FluentDate, GenericHelpers, H2W, HMSTATUS, LO, MD, PATH, XML, _, _fromTo, _reportError, moment, printf, skillLevelToIndex, unused;
|
var FS, FluentDate, GenericHelpers, H2W, HMSTATUS, LO, MD, PATH, XML, _, _fromTo, _reportError, _skillLevelToIndex, moment, printf, unused;
|
||||||
|
|
||||||
MD = require('marked');
|
MD = require('marked');
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
|||||||
*/
|
*/
|
||||||
skillColor: function(lvl) {
|
skillColor: function(lvl) {
|
||||||
var idx, skillColors;
|
var idx, skillColors;
|
||||||
idx = skillLevelToIndex(lvl);
|
idx = _skillLevelToIndex(lvl);
|
||||||
skillColors = (this.theme && this.theme.palette && this.theme.palette.skillLevels) || ['#FFFFFF', '#5CB85C', '#F1C40F', '#428BCA', '#C00000'];
|
skillColors = (this.theme && this.theme.palette && this.theme.palette.skillLevels) || ['#FFFFFF', '#5CB85C', '#F1C40F', '#428BCA', '#C00000'];
|
||||||
return skillColors[idx];
|
return skillColors[idx];
|
||||||
},
|
},
|
||||||
@ -402,7 +402,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
|||||||
*/
|
*/
|
||||||
skillHeight: function(lvl) {
|
skillHeight: function(lvl) {
|
||||||
var idx;
|
var idx;
|
||||||
idx = skillLevelToIndex(lvl);
|
idx = _skillLevelToIndex(lvl);
|
||||||
return ['38.25', '30', '16', '8', '0'][idx];
|
return ['38.25', '30', '16', '8', '0'][idx];
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -541,6 +541,17 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
|||||||
ret = PAD(stringOrArray, stringOrArray.length + Math.abs(padAmount), null, padAmount < 0 ? PAD.LEFT : PAD.RIGHT);
|
ret = PAD(stringOrArray, stringOrArray.length + Math.abs(padAmount), null, padAmount < 0 ? PAD.LEFT : PAD.RIGHT);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
},
|
||||||
|
skillYears: function(skill, rez) {
|
||||||
|
var sk;
|
||||||
|
sk = _.find(rez.skills.list, function(sk) {
|
||||||
|
return sk.name.toUpperCase() === skill.toUpperCase();
|
||||||
|
});
|
||||||
|
if (sk) {
|
||||||
|
return sk.years;
|
||||||
|
} else {
|
||||||
|
return '?';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -599,7 +610,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
|||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
skillLevelToIndex = function(lvl) {
|
_skillLevelToIndex = function(lvl) {
|
||||||
var idx, intVal;
|
var idx, intVal;
|
||||||
idx = 0;
|
idx = 0;
|
||||||
if (String.is(lvl)) {
|
if (String.is(lvl)) {
|
||||||
|
@ -38,6 +38,14 @@ BlockHelpers = module.exports =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ifHasSkill: ( rez, skill, options ) ->
|
||||||
|
skUp = skill.toUpperCase()
|
||||||
|
ret = _.some rez.skills.list, (sk) ->
|
||||||
|
(skUp.toUpperCase() == sk.name.toUpperCase()) and sk.years
|
||||||
|
, @
|
||||||
|
options.fn @ if ret
|
||||||
|
|
||||||
|
|
||||||
###*
|
###*
|
||||||
Emit the enclosed content if the resume has the named
|
Emit the enclosed content if the resume has the named
|
||||||
property or subproperty.
|
property or subproperty.
|
||||||
|
@ -329,6 +329,7 @@ GenericHelpers = module.exports =
|
|||||||
# If not provided by the user, stitle should default to sname. ps.
|
# If not provided by the user, stitle should default to sname. ps.
|
||||||
# Handlebars silently passes in the options object to the last param,
|
# Handlebars silently passes in the options object to the last param,
|
||||||
# where in Underscore stitle will be null/undefined, so we check both.
|
# where in Underscore stitle will be null/undefined, so we check both.
|
||||||
|
# TODO: not actually sure that's true, given that we _.wrap these functions
|
||||||
stitle = (stitle && String.is(stitle) && stitle) || sname
|
stitle = (stitle && String.is(stitle) && stitle) || sname
|
||||||
|
|
||||||
# If there's a section title override, use it.
|
# If there's a section title override, use it.
|
||||||
@ -342,7 +343,7 @@ GenericHelpers = module.exports =
|
|||||||
wpml: ( txt, inline ) ->
|
wpml: ( txt, inline ) ->
|
||||||
return '' if !txt
|
return '' if !txt
|
||||||
inline = (inline && !inline.hash) || false
|
inline = (inline && !inline.hash) || false
|
||||||
txt = XML(txt.trim())
|
txt = XML txt.trim()
|
||||||
txt = if inline then MD(txt).replace(/^\s*<p>|<\/p>\s*$/gi, '') else MD(txt)
|
txt = if inline then MD(txt).replace(/^\s*<p>|<\/p>\s*$/gi, '') else MD(txt)
|
||||||
txt = H2W( txt )
|
txt = H2W( txt )
|
||||||
return txt
|
return txt
|
||||||
@ -376,7 +377,7 @@ GenericHelpers = module.exports =
|
|||||||
'#FFFFAA').
|
'#FFFFAA').
|
||||||
###
|
###
|
||||||
skillColor: ( lvl ) ->
|
skillColor: ( lvl ) ->
|
||||||
idx = skillLevelToIndex lvl
|
idx = _skillLevelToIndex lvl
|
||||||
skillColors = (this.theme && this.theme.palette &&
|
skillColors = (this.theme && this.theme.palette &&
|
||||||
this.theme.palette.skillLevels) ||
|
this.theme.palette.skillLevels) ||
|
||||||
[ '#FFFFFF', '#5CB85C', '#F1C40F', '#428BCA', '#C00000' ]
|
[ '#FFFFFF', '#5CB85C', '#F1C40F', '#428BCA', '#C00000' ]
|
||||||
@ -389,7 +390,7 @@ GenericHelpers = module.exports =
|
|||||||
@method lastWord
|
@method lastWord
|
||||||
###
|
###
|
||||||
skillHeight: ( lvl ) ->
|
skillHeight: ( lvl ) ->
|
||||||
idx = skillLevelToIndex lvl
|
idx = _skillLevelToIndex lvl
|
||||||
['38.25', '30', '16', '8', '0'][idx]
|
['38.25', '30', '16', '8', '0'][idx]
|
||||||
|
|
||||||
|
|
||||||
@ -505,6 +506,11 @@ GenericHelpers = module.exports =
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
skillYears: ( skill, rez ) ->
|
||||||
|
sk = _.find rez.skills.list, (sk) -> sk.name.toUpperCase() == skill.toUpperCase()
|
||||||
|
if sk then sk.years else '?'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###*
|
###*
|
||||||
Report an error to the outside world without throwing an exception. Currently
|
Report an error to the outside world without throwing an exception. Currently
|
||||||
@ -562,7 +568,7 @@ _fromTo = ( dateA, dateB, fmt, sep, fallback ) ->
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
skillLevelToIndex = ( lvl ) ->
|
_skillLevelToIndex = ( lvl ) ->
|
||||||
idx = 0
|
idx = 0
|
||||||
if String.is( lvl )
|
if String.is( lvl )
|
||||||
lvl = lvl.trim().toLowerCase()
|
lvl = lvl.trim().toLowerCase()
|
||||||
|
Loading…
Reference in New Issue
Block a user