1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-05 09:56:22 +00:00

Improve theme/format inheritance (interim).

This commit is contained in:
hacksalot 2016-01-05 09:28:40 -05:00
parent d205e882f6
commit 2819faeb6f
3 changed files with 24 additions and 4 deletions

View File

@ -181,15 +181,26 @@ Definition of the FRESHTheme class.
return fmt && (fmt.ext === 'css'); return fmt && (fmt.ext === 'css');
})) }))
// For each CSS file, get its corresponding HTML file // For each CSS file, get its corresponding HTML file. It's possible that
// a theme can have a CSS file but *no* HTML file, as when a theme author
// creates a pure CSS override of an existing theme.
.forEach(function( cssf ) { .forEach(function( cssf ) {
var idx = _.findIndex(fmts, function( fmt ) { var idx = _.findIndex(fmts, function( fmt ) {
return fmt && fmt.pre === cssf.pre && fmt.ext === 'html'; return fmt && fmt.pre === cssf.pre && fmt.ext === 'html';
}); });
cssf.action = null; cssf.action = null;
if( idx > -1) {
fmts[ idx ].css = cssf.data; fmts[ idx ].css = cssf.data;
fmts[ idx ].cssPath = cssf.path; fmts[ idx ].cssPath = cssf.path;
}
else {
if( that.inherits ) {
// Found a CSS file without an HTML file in a theme that inherits
// from another theme. This is the override CSS file.
that.overrides = { file: cssf.path, data: cssf.data };
}
}
}); });
// Remove CSS files from the formats array // Remove CSS files from the formats array

View File

@ -215,9 +215,17 @@ Generic template helper definitions for HackMyResume / FluentCV.
via <style></style> tag. via <style></style> tag.
*/ */
styleSheet: function( file, options ) { styleSheet: function( file, options ) {
return ( this.opts.css === 'link') ? var styles = ( this.opts.css === 'link') ?
'<link href="' + file + '" rel="stylesheet" type="text/css">' : '<link href="' + file + '" rel="stylesheet" type="text/css">' :
'<style>' + this.cssInfo.data + '</style>'; '<style>' + this.cssInfo.data + '</style>';
if( this.opts.themeObj.inherits &&
this.opts.themeObj.inherits.html &&
this.format === 'html' ) {
styles += (this.opts.css === 'link') ?
'<link href="' + this.opts.themeObj.overrides.path + '" rel="stylesheet" type="text/css">' :
'<style>' + this.opts.themeObj.overrides.data + '</style>';
}
return styles;
}, },
/** /**

View File

@ -45,6 +45,7 @@ Definition of the HandlebarsGenerator class.
RAW: json, RAW: json,
filt: opts.filters, filt: opts.filters,
cssInfo: cssInfo, cssInfo: cssInfo,
format: format,
opts: opts, opts: opts,
headFragment: opts.headFragment || '' headFragment: opts.headFragment || ''
}); });