mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-05 01:56:21 +00:00
Aerate.
This commit is contained in:
parent
d894f62607
commit
7c0a9bcc02
@ -17,11 +17,15 @@ LO = require 'lodash'
|
||||
PATH = require 'path'
|
||||
printf = require 'printf'
|
||||
_ = require 'underscore'
|
||||
unused = require '../utils/string';
|
||||
unused = require '../utils/string'
|
||||
|
||||
|
||||
|
||||
###* Generic template helper function definitions. ###
|
||||
GenericHelpers = module.exports =
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Convert the input date to a specified format through Moment.js.
|
||||
If date is invalid, will return the time provided by the user,
|
||||
@ -35,6 +39,8 @@ GenericHelpers = module.exports =
|
||||
|
||||
datetime || (typeof fallback == 'string' ? fallback : (fallback == true ? 'Present' : null));
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Given a resume sub-object with a start/end date, format a representation of
|
||||
the date range.
|
||||
@ -44,12 +50,16 @@ GenericHelpers = module.exports =
|
||||
return '' if !obj
|
||||
_fromTo obj.start, obj.end, fmt, sep, fallback, options
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Format a from/to date range for display.
|
||||
@method toFrom
|
||||
###
|
||||
fromTo: () -> _fromTo.apply this, arguments
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Return a named color value as an RRGGBB string.
|
||||
@method toFrom
|
||||
@ -66,6 +76,8 @@ GenericHelpers = module.exports =
|
||||
return colorDefault
|
||||
ret
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Return true if the section is present on the resume and has at least one
|
||||
element.
|
||||
@ -84,6 +96,8 @@ GenericHelpers = module.exports =
|
||||
ret = options.fn @
|
||||
ret
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Emit the size of the specified named font.
|
||||
@param key {String} A named style from the "fonts" section of the theme's
|
||||
@ -133,6 +147,7 @@ GenericHelpers = module.exports =
|
||||
ret
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Emit the font face (such as 'Helvetica' or 'Calibri') associated with the
|
||||
provided key.
|
||||
@ -185,6 +200,8 @@ GenericHelpers = module.exports =
|
||||
|
||||
return ret;
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Emit a comma-delimited list of font names suitable associated with the
|
||||
provided key.
|
||||
@ -240,6 +257,8 @@ GenericHelpers = module.exports =
|
||||
|
||||
return ret;
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Capitalize the first letter of the word.
|
||||
@method section
|
||||
@ -248,6 +267,8 @@ GenericHelpers = module.exports =
|
||||
val = (val && val.trim()) || ''
|
||||
return if val then (val.charAt(0).toUpperCase() + val.slice(1)) else val
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Return true if the context has the property or subpropery.
|
||||
@method has
|
||||
@ -258,6 +279,8 @@ GenericHelpers = module.exports =
|
||||
return options.fn this
|
||||
return
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Generic template helper function to display a user-overridable section
|
||||
title for a FRESH resume theme. Use this in lieue of hard-coding section
|
||||
@ -291,6 +314,8 @@ GenericHelpers = module.exports =
|
||||
this.opts.stitles[ sname.toLowerCase().trim() ] ) ||
|
||||
stitle;
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Convert inline Markdown to inline WordProcessingML.
|
||||
@method wpml
|
||||
@ -304,6 +329,7 @@ GenericHelpers = module.exports =
|
||||
return txt
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Emit a conditional link.
|
||||
@method link
|
||||
@ -311,6 +337,8 @@ GenericHelpers = module.exports =
|
||||
link: ( text, url ) ->
|
||||
return if url && url.trim() then ('<a href="' + url + '">' + text + '</a>') else text
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Return the last word of the specified text.
|
||||
@method lastWord
|
||||
@ -318,6 +346,8 @@ GenericHelpers = module.exports =
|
||||
lastWord: ( txt ) ->
|
||||
return if txt && txt.trim() then _.last( txt.split(' ') ) else ''
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Convert a skill level to an RGB color triplet. TODO: refactor
|
||||
@method skillColor
|
||||
@ -333,6 +363,8 @@ GenericHelpers = module.exports =
|
||||
[ '#FFFFFF', '#5CB85C', '#F1C40F', '#428BCA', '#C00000' ]
|
||||
return skillColors[idx]
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Return an appropriate height. TODO: refactor
|
||||
@method lastWord
|
||||
@ -341,6 +373,8 @@ GenericHelpers = module.exports =
|
||||
idx = skillLevelToIndex lvl
|
||||
['38.25', '30', '16', '8', '0'][idx]
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Return all but the last word of the input text.
|
||||
@method initialWords
|
||||
@ -348,6 +382,8 @@ GenericHelpers = module.exports =
|
||||
initialWords: ( txt ) ->
|
||||
if txt && txt.trim() then _.initial( txt.split(' ') ).join(' ') else ''
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Trim the protocol (http or https) from a URL/
|
||||
@method trimURL
|
||||
@ -355,6 +391,8 @@ GenericHelpers = module.exports =
|
||||
trimURL: ( url ) ->
|
||||
if url && url.trim() then url.trim().replace(/^https?:\/\//i, '') else ''
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Convert text to lowercase.
|
||||
@method toLower
|
||||
@ -362,6 +400,8 @@ GenericHelpers = module.exports =
|
||||
toLower: ( txt ) ->
|
||||
if txt && txt.trim() then txt.toLowerCase() else ''
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Convert text to lowercase.
|
||||
@method toLower
|
||||
@ -369,6 +409,8 @@ GenericHelpers = module.exports =
|
||||
toUpper: ( txt ) ->
|
||||
if txt && txt.trim() then txt.toUpperCase() else ''
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Return true if either value is truthy.
|
||||
@method either
|
||||
@ -377,6 +419,8 @@ GenericHelpers = module.exports =
|
||||
if lhs || rhs
|
||||
return options.fn this
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Conditional stylesheet link. Creates a link to the specified stylesheet with
|
||||
<link> or embeds the styles inline with <style></style>, depending on the
|
||||
@ -413,6 +457,8 @@ GenericHelpers = module.exports =
|
||||
# it when Handlebars is the chosen engine, which is most of the time.
|
||||
ret
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Perform a generic comparison.
|
||||
See: http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates
|
||||
@ -445,6 +491,8 @@ relies on kludging the running verb into. opts.
|
||||
_reportError = ( code, params ) ->
|
||||
GenericHelpers.opts.errHandler.err( code, params )
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Format a from/to date range for display.
|
||||
###
|
||||
@ -487,6 +535,8 @@ _fromTo = ( dateA, dateB, fmt, sep, fallback ) ->
|
||||
return dateFrom || dateTo
|
||||
return ''
|
||||
|
||||
|
||||
|
||||
skillLevelToIndex = ( lvl ) ->
|
||||
idx = 0
|
||||
if String.is( lvl )
|
||||
@ -507,6 +557,7 @@ skillLevelToIndex = ( lvl ) ->
|
||||
idx
|
||||
|
||||
|
||||
|
||||
# Note [1] --------------------------------------------------------------------
|
||||
# Make sure it's precisely a string or array since some template engines jam
|
||||
# their options/context object into the last parameter and we are allowing the
|
||||
|
Loading…
Reference in New Issue
Block a user